scriptvmtypes.h, scriptcompiletypes.h and scriptnode.h each crammed several unrelated struct definitions into one file, unlike the rest of dusk (see src/dusk/display or src/dusk/rpg/battle), which always gives a type its own file named after it, with other types reached by an explicit include or a forward declaration. - scriptvmtypes.h: scriptvmfunction_t moves into scriptvmfunction.h (next to the functions that already work with it), scriptvmname_t into scriptvmname.h, scriptvmhandler_t into scriptvmtable.h, and scriptvmimage_t gets a new scriptvmimage.h. scriptvmtypes.h keeps working as a thin re-include umbrella for the ~45 vm files that reach into several of these at once, the same role scripttypes.h already plays for the base types. - scriptcompiletypes.h: scriptlabel_t moves into scriptbuilderlabel.h, scriptloopcontext_t into scriptcompileloopcontext.h, scriptincluderesolver_t into scriptcompile.h, and the big scriptbuilder_t gets a new scriptbuilder.h. Breaking the resulting include cycle needed scriptbuilderlabel.h and scriptcompileloopcontext.h to forward-declare scriptbuilder_t/scriptlabel_t rather than pull in full definitions they only ever use by pointer, and scriptcompile.h to define scriptincluderesolver_t before including scriptcompiletypes.h instead of after. - scriptnode.h: scriptfuncnode_t (a function declaration, not a kind of expression/statement node) moves into a new scriptfuncnode.h. Also gives scriptbuilder_t and scriptlabel_t proper struct tags (previously anonymous, which doesn't allow forward declaration) to match the project's _s tag / _t typedef convention from the previous pass. Co-Authored-By: Claude Sonnet 5 <[email protected]>
37 lines
1.2 KiB
C
37 lines
1.2 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "core/scriptcore.h"
|
|
#include "core/scriptsource.h"
|
|
#include "parser/scriptnode.h"
|
|
|
|
typedef struct {
|
|
char name[SCRIPT_NAME_MAX];
|
|
scriptnode_t *defaultValue;
|
|
} scriptparam_t;
|
|
|
|
// Bits of a function's flags, see scriptfuncnode_t.
|
|
#define SCRIPT_FUNCNODE_FLAG_ASYNC (1 << 0)
|
|
#define SCRIPT_FUNCNODE_FLAG_INLINE (1 << 1) // declared with inline, which is made in place of every call it can be
|
|
#define SCRIPT_FUNCNODE_FLAG_NOINLINE (1 << 2) // declared with noinline, which is never made in place
|
|
#define SCRIPT_FUNCNODE_FLAG_ROOT (1 << 3)
|
|
#define SCRIPT_FUNCNODE_FLAG_SCRIPT (1 << 4) // the top level of a script, which is not a function that was written in it
|
|
|
|
typedef struct scriptfuncnode_s {
|
|
char name[SCRIPT_NAME_MAX];
|
|
scriptparam_t params[SCRIPT_PARAMS_MAX];
|
|
uint8_t paramCount;
|
|
scriptnode_t *body;
|
|
uint8_t flags; // SCRIPT_FUNCNODE_FLAG_*
|
|
uint16_t uses; // how many times its name is used in the script, a function that is used once is made in place
|
|
uint16_t line;
|
|
uint16_t column;
|
|
const scriptsource_t *source;
|
|
} scriptfuncnode_t;
|