diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-08-04 09:34:26 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-08-05 15:50:13 +0200 |
commit | d7d1bde7380bc17bd2621f341b5657b04f0fb118 (patch) | |
tree | 9fd6c7775bd7b37f0cf150bbc68dd4088750a20f | |
parent | e55965a3d170f60776ffa2d82b2711d9ea3a0211 (diff) |
compiler: add a flag denoting module functions
Introduce a further uc_function_t structure member indicating whether the
underlying function is a module constructor.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r-- | compiler.c | 4 | ||||
-rw-r--r-- | include/ucode/types.h | 2 |
2 files changed, 5 insertions, 1 deletions
@@ -3484,6 +3484,10 @@ uc_compile_from_source(uc_parse_config_t *config, uc_source_t *source, uc_progra uc_compiler_init(&compiler, name, source, 0, progptr, config && config->strict_declarations); + if (progptr == prog) { + compiler.function->module = true; + } + uc_compiler_parse_advance(&compiler); while (!uc_compiler_parse_match(&compiler, TK_EOF)) diff --git a/include/ucode/types.h b/include/ucode/types.h index 0b63501..64ae7cb 100644 --- a/include/ucode/types.h +++ b/include/ucode/types.h @@ -112,7 +112,7 @@ typedef struct uc_weakref { typedef struct uc_function { uc_weakref_t progref; - bool arrow, vararg, strict; + bool arrow, vararg, strict, module; size_t nargs; size_t nupvals; size_t srcidx; |