Keep source file descriptors stable for the lifetime of the VM and execute included fragments in the enclosing method and closure context
Build / AerScript (push) Successful in 40s

This commit is contained in:
2026-10-25 18:11:22 +01:00
parent c42b0ae010
commit 3e3b795626
5 changed files with 365 additions and 69 deletions
+2
View File
@@ -21,6 +21,7 @@ typedef struct Label Label;
#define GEN_BLOCK_SWITCH 0x200 /* Switch statement */
#define GEN_BLOCK_CLASS 0x400 /* Class definition */
#define GEN_BLOCK_NAMESPACE 0x800 /* Namespace body */
#define GEN_BLOCK_INCLUDE 0x1000 /* Borrowed enclosing loop targets */
/*
* Each label seen in the input is recorded in an instance
@@ -34,6 +35,7 @@ struct Label {
SyString sName; /* Label name */
sxu32 nLine; /* Line number this label occurs */
sxu8 bRef; /* True if the label was referenced */
sxu8 bExternal; /* Target is in the including bytecode */
};
/*
+12 -1
View File
@@ -902,6 +902,16 @@ typedef struct ph7_vm_func_static_var ph7_vm_func_static_var;
typedef struct ph7_vm_func_arg ph7_vm_func_arg;
typedef struct ph7_vm_func ph7_vm_func;
typedef struct VmFrame VmFrame;
/* Lexical exit bridges in the bytecode containing an include statement. */
typedef struct ph7_include ph7_include;
struct ph7_include {
char *zPath;
sxu32 nBreak;
sxu32 nContinue;
SySet aLabel;
ph7_vm_func *pFunc;
sxbool bException;
};
/*
* Each collected function argument is recorded in an instance
* of the following structure.
@@ -1205,7 +1215,7 @@ struct ph7_vm {
SyBlob sArgv; /* $argv[] collector [refer to the [getopt()] implementation for more information] */
SySet aModules; /* Set of loaded modules */
SySet aModuleHandles; /* Libraries retained after initialization attempts */
SySet aFiles; /* Stack of processed files */
SySet aFiles; /* SyString pointers, VM-owned until release */
SySet aPaths; /* Set of import paths */
SySet aIncluded; /* Set of included files */
SyHash hRequired; /* Resolved require paths, including pending evaluations */
@@ -1730,6 +1740,7 @@ PH7_PRIVATE sxi32 PH7_InitCodeGenerator(ph7_vm *pVm, ProcConsumer xErr, void *pE
PH7_PRIVATE sxi32 PH7_ResetCodeGenerator(ph7_vm *pVm, ProcConsumer xErr, void *pErrData);
PH7_PRIVATE sxi32 PH7_GenCompileError(ph7_gen_state *pGen, sxi32 nErrType, sxu32 nLine, const char *zFormat, ...);
PH7_PRIVATE sxi32 PH7_CompileAerScript(ph7_vm *pVm, SyString *pScript, sxi32 iFlags);
PH7_PRIVATE sxi32 PH7_CompileIncludedChunk(ph7_vm *pVm, SyString *pScript, ph7_vm_func *pFunc, ph7_include *pInclude);
/* constant.c function prototypes */
PH7_PRIVATE void PH7_RegisterBuiltInConstant(ph7_vm *pVm);
/* builtin.c function prototypes */