Răsfoiți Sursa

feat: 完善可执行程序

原run程序调整为cl程序
现run程序规定只运行一个文件, 且不进入command-line
cl支持import和no-import模式
支持处理命令行参数
SongZihuan 3 ani în urmă
părinte
comite
7fc94f09de
7 a modificat fișierele cu 120 adăugiri și 87 ștergeri
  1. 1 1
      deps/fflags
  2. 7 7
      include/runtime/aFunlang.h
  3. 51 13
      src/main.c
  4. 15 13
      src/main_run.c
  5. 5 4
      src/main_run.h
  6. 15 23
      src/runtime/aFunlang.c
  7. 26 26
      test/src/run_code.c

+ 1 - 1
deps/fflags

@@ -1 +1 @@
-Subproject commit 4cb73963f77455c09bcfeaed8586775eee90cd36
+Subproject commit 762c693649553bde6a1b9c08f29fbb44180448ba

+ 7 - 7
include/runtime/aFunlang.h

@@ -7,16 +7,16 @@
 
 AFUN_LANG_EXPORT void aFunInit();
 
-AFUN_LANG_EXPORT af_Environment *creatAFunEnviroment(void);
+AFUN_LANG_EXPORT af_Environment *creatAFunEnviroment(int argc, char **argv);
 AFUN_LANG_EXPORT void destructAFunEnvironment(af_Environment *env);
 
 /* 源文件运行 */
-AFUN_LANG_EXPORT int runCodeFromString(char *code, char *string_name, FILE *error_file, af_Environment *env);
-AFUN_LANG_EXPORT int runCodeFromFileSource(FilePath file, FILE *error_file, bool save_afb, FilePath save_path, af_Environment *env);
+AFUN_LANG_EXPORT int runCodeFromString(char *code, char *string_name, FILE *error_file, int mode, af_Environment *env);
+AFUN_LANG_EXPORT int runCodeFromFileSource(FilePath file, FILE *error_file, bool save_afb, FilePath save_path, int mode,
+                                           af_Environment *env);
 AFUN_LANG_EXPORT int runCodeFromStdin(char *name, FILE *error_file, af_Environment *env);
-AFUN_LANG_EXPORT int runCodeFromMemory(af_Code *code, af_Environment *env);
-AFUN_LANG_EXPORT int runCodeFromMemoryAsImport(af_Code *code, af_Environment *env);
-AFUN_LANG_EXPORT int runCodeFromFileByte(FilePath file, FILE *error_file, af_Environment *env);
-AFUN_LANG_EXPORT int runCodeFromFile(FilePath file, FILE *error_file, bool save_afb, af_Environment *env);
+AFUN_LANG_EXPORT int runCodeFromMemory(af_Code *code, int mode, af_Environment *env);
+AFUN_LANG_EXPORT int runCodeFromFileByte(FilePath file, FILE *error_file, int mode, af_Environment *env);
+AFUN_LANG_EXPORT int runCodeFromFile(FilePath file, FILE *error_file, bool save_afb, int mode, af_Environment *env);
 AFUN_LANG_EXPORT int buildFile(FilePath out, FilePath in, FILE *error_file);
 #endif //AFUN_AFUNLANG_H

+ 51 - 13
src/main.c

@@ -8,14 +8,18 @@ ff_defArg(help, false)
                 ff_argRule('v', version, not, 'v')
 ff_endArg(help, false);
 
-ff_defArg(run, true)
+ff_selfProcessChild(run, true);
+
+ff_defArg(cl, false)
                 ff_argRule('e', eval, must, 'e')
                 ff_argRule('f', file, must, 'f')
                 ff_argRule('s', source, must, 's')
                 ff_argRule('b', byte, must, 'b')
                 ff_argRule(NUL, no-aub, not, 'a')
                 ff_argRule(NUL, no-cl, not, 'n')
-ff_endArg(run, true);
+                ff_argRule(NUL, no-import, not, 'o')
+                ff_argRule(NUL, import, not, 'i')
+ff_endArg(cl, false);
 
 ff_defArg(build, false)
                 ff_argRule('o', out, must, 'o')
@@ -24,7 +28,7 @@ ff_defArg(build, false)
 ff_endArg(build, false);
 
 // exe 是指可执行程序, 而非仅PE的可执行程序
-ff_childList(aFunlang_exe, ff_child(help), ff_child(run), ff_child(build));
+ff_childList(aFunlang_exe, ff_child(run), ff_child(help), ff_child(cl), ff_child(build));
 
 static const char *name = NULL;
 
@@ -32,6 +36,7 @@ static int mainHelp(ff_FFlags *ff);
 static void printVersion(void);
 static void printHelp(void);
 static int mainRun(ff_FFlags *ff);
+static int mainCL(ff_FFlags *ff);
 static int mainBuild(ff_FFlags *ff);
 extern const char *help_info;
 
@@ -44,10 +49,12 @@ int main(int argc, char **argv) {
     char *child = ff_getChild(ff);
     name = *argv;  // 获取第一个参数为name
 
-    if (EQ_STR(child, "run"))
-        exit_code = mainRun(ff);
+    if (EQ_STR(child, "cl"))
+        exit_code = mainCL(ff);
     else if (EQ_STR(child, "build"))
         exit_code = mainBuild(ff);
+    else if (EQ_STR(child, "run"))
+        exit_code = mainRun(ff);
     else
         exit_code = mainHelp(ff);
 
@@ -114,11 +121,27 @@ out:
     return EXIT_SUCCESS;
 }
 
+static int mainRun(ff_FFlags *ff) {
+    int exit_code = 0;
+    char **argv = NULL;
+    int argc = ff_get_process_argv(&argv, ff);
+    if (argv == 0) {
+        fprintf(stderr, "There are not file to run.\n");
+        return 1;
+    }
+
+    af_Environment *env = creatAFunEnviroment(argc - 1, argv + 1);
+    exit_code = runCodeFromFile(argv[0], stderr, true, 0, env);
+    destructAFunEnvironment(env);
+    return exit_code;
+}
+
 static RunList *getRunList(ff_FFlags *ff, bool *command_line, bool *save_aub) {
     char *text = NULL;
     RunList *run_list = NULL;
     RunList **prl = &run_list;
     int mark;
+    bool import = true;
 
     *command_line = true;
     *save_aub = true;
@@ -127,16 +150,16 @@ static RunList *getRunList(ff_FFlags *ff, bool *command_line, bool *save_aub) {
         mark = ff_getopt(&text, ff);
         switch (mark) {
             case 'e':
-                prl = pushRunList(makeStringRunList(text), prl);
+                prl = pushRunList(makeStringRunList(text, import), prl);
                 break;
             case 'f':
-                prl = pushRunList(makeFileRunList(text), prl);
+                prl = pushRunList(makeFileRunList(text, import), prl);
                 break;
             case 's':
-                prl = pushRunList(makeFileSourceRunList(text), prl);
+                prl = pushRunList(makeFileSourceRunList(text, import), prl);
                 break;
             case 'b':
-                prl = pushRunList(makeFileByteRunList(text), prl);
+                prl = pushRunList(makeFileByteRunList(text, import), prl);
                 break;
             case 'n':
                 *command_line = false;
@@ -144,6 +167,12 @@ static RunList *getRunList(ff_FFlags *ff, bool *command_line, bool *save_aub) {
             case 'a':
                 *save_aub = false;
                 break;
+            case 'o':
+                import = false;
+                break;
+            case 'i':
+                import = true;
+                break;
             case -1:
                 goto out;
             default:
@@ -155,12 +184,12 @@ static RunList *getRunList(ff_FFlags *ff, bool *command_line, bool *save_aub) {
     }
 
 out:
-    while (ff_getopt_wild(&text, ff))
-        prl = pushRunList(makeFileRunList(text), prl);
+    while (ff_getopt_wild_before(&text, ff))
+        prl = pushRunList(makeFileRunList(text, true), prl);
     return run_list;
 }
 
-static int mainRun(ff_FFlags *ff) {
+static int mainCL(ff_FFlags *ff) {
     bool command_line = true;
     bool save_aub = true;
     int exit_code;
@@ -172,7 +201,16 @@ static int mainRun(ff_FFlags *ff) {
         return EXIT_FAILURE;
     }
 
-    af_Environment *env = creatAFunEnviroment();
+    int argc = 0;
+    char *text;
+    while (ff_getopt_wild_after(&text, ff))
+        argc++;
+
+    char **argv = calloc(argc, sizeof(char *));
+    for (int i = 0; ff_getopt_wild_after(&text, ff); i++)
+        argv[i] = text;
+
+    af_Environment *env = creatAFunEnviroment(argc, argv);
     if (rl != NULL)
         exit_code = runCodeFromRunList(rl, NULL, save_aub, env);
 

+ 15 - 13
src/main_run.c

@@ -2,8 +2,9 @@
 #include "main_run.h"
 
 
-static RunList *makeRunList() {
+static RunList *makeRunList(bool import){
     RunList *run_list = calloc(1, sizeof(RunList));
+    run_list->import = import;
     return run_list;
 }
 
@@ -22,27 +23,27 @@ void freeAllRunList(RunList *rl) {
         rl = freeRunList(rl);
 }
 
-RunList *makeFileRunList(FilePath file) {
-    RunList *rl = makeRunList();
+RunList *makeFileRunList(FilePath file, bool import){
+    RunList *rl = makeRunList(import);
     rl->type = rl_file;
     rl->file = strCopy(file);
     return rl;
 }
 
-RunList *makeFileSourceRunList(FilePath file) {
-    RunList *rl = makeFileRunList(file);
+RunList *makeFileSourceRunList(FilePath file, bool import){
+    RunList *rl = makeFileRunList(file, true);
     rl->type = rl_file_s;
     return rl;
 }
 
-RunList *makeFileByteRunList(FilePath file) {
-    RunList *rl = makeFileRunList(file);
+RunList *makeFileByteRunList(FilePath file, bool import){
+    RunList *rl = makeFileRunList(file, true);
     rl->type = rl_file_b;
     return rl;
 }
 
-RunList *makeStringRunList(char *string) {
-    RunList *rl = makeRunList();
+RunList *makeStringRunList(char *string, bool import){
+    RunList *rl = makeRunList(import);
     rl->type = rl_string;
     rl->string = strCopy(string);
     return rl;
@@ -61,18 +62,19 @@ int runCodeFromRunList(RunList *run_list, RunList **bak, bool save_afb, af_Envir
     int exit_code = 0;
 
     for (NULL; run_list != NULL; run_list = run_list->next) {
+        int mode = run_list->import ? 1 : 0;
         switch (run_list->type) {
             case rl_string:
-                exit_code = runCodeFromString(run_list->string, "command-line-eval", stderr, env);
+                exit_code = runCodeFromString(run_list->string, "command-line-eval", stderr, mode, env);
                 break;
             case rl_file:
-                exit_code = runCodeFromFile(run_list->file, stderr, save_afb, env);
+                exit_code = runCodeFromFile(run_list->file, stderr, save_afb, mode, env);
                 break;
             case rl_file_b:
-                exit_code = runCodeFromFileByte(run_list->file, stderr, env);
+                exit_code = runCodeFromFileByte(run_list->file, stderr, mode, env);
                 break;
             case rl_file_s:
-                exit_code = runCodeFromFileSource(run_list->file, stderr, save_afb, NULL, env);
+                exit_code = runCodeFromFileSource(run_list->file, stderr, save_afb, NULL, mode, env);
                 break;
             default:
                 break;

+ 5 - 4
src/main_run.h

@@ -15,13 +15,14 @@ struct RunList {
         char *string;
     };
 
+    bool import;
     struct RunList *next;
 };
 
-RunList *makeFileRunList(FilePath file);
-RunList *makeFileByteRunList(FilePath file);
-RunList *makeFileSourceRunList(FilePath file);
-RunList *makeStringRunList(char *string);
+RunList *makeFileRunList(FilePath file, bool import);
+RunList *makeFileByteRunList(FilePath file, bool import);
+RunList *makeFileSourceRunList(FilePath file, bool import);
+RunList *makeStringRunList(char *string, bool import);
 void freeAllRunList(RunList *rl);
 RunList **pushRunList(RunList *rl, RunList **base);
 

+ 15 - 23
src/runtime/aFunlang.c

@@ -9,10 +9,13 @@ void aFunInit() {
     aFunCoreInit();
 }
 
-af_Environment *creatAFunEnviroment(void) {
+af_Environment *creatAFunEnviroment(int argc, char **argv){
     af_Environment *env = makeEnvironment(grt_count);
     af_Code *code = NULL;
 
+    for(int i = 0; i < argc; i++)
+        printf("[aFunlang] Env-arg %d. %s\n", i, argv[i]);
+
     runtimeTool("base", &code, NULL, env->core->protect, env);
 
     if (code != NULL) {
@@ -60,7 +63,7 @@ static int runCode_(FilePath name, af_Parser *parser, int mode, FilePath save_pa
  * 函数名: runCodeFromString
  * 目标: 运行字符串中的程序 (源码形式)
  */
-int runCodeFromString(char *code, char *string_name, FILE *error_file, af_Environment *env) {
+int runCodeFromString(char *code, char *string_name, FILE *error_file, int mode, af_Environment *env){
     if (env == NULL || code == NULL)
         return -1;
 
@@ -70,14 +73,14 @@ int runCodeFromString(char *code, char *string_name, FILE *error_file, af_Enviro
     if (error_file == NULL)
         error_file = stderr;
     af_Parser *parser = makeParserByString(code, false, error_file);
-    return runCode_(string_name, parser, 1, NULL, error_file, env);
+    return runCode_(string_name, parser, mode, NULL, error_file, env);
 }
 
 /*
  * 函数名: runCodeFromFileSource
  * 目标: 运行文件中的程序 (源码形式)
  */
-int runCodeFromFileSource(FilePath file, FILE *error_file, bool save_afb, FilePath save_path, af_Environment *env) {
+int runCodeFromFileSource(FilePath file, FILE *error_file, bool save_afb, FilePath save_path, int mode, af_Environment *env){
     if (env == NULL || file == NULL)
         return -1;
 
@@ -100,7 +103,7 @@ int runCodeFromFileSource(FilePath file, FILE *error_file, bool save_afb, FilePa
         save_path = NULL;
 
     af_Parser *parser = makeParserByFile(file, error_file);
-    int exit_code = runCode_(file, parser, 1, save_path, error_file, env);
+    int exit_code = runCode_(file, parser, mode, save_path, error_file, env);
     if (free_save_path)
         free(save_path);
     return exit_code;
@@ -127,19 +130,8 @@ int runCodeFromStdin(char *name, FILE *error_file, af_Environment *env) {
  * 函数名: runCodeFromMemory
  * 目标: 运行内存中的程序 (字节码形式)
  */
-int runCodeFromMemory(af_Code *code, af_Environment *env) {
-    bool res = iterCode(code, 0, env);
-    if (!res)
-        return env->core->exit_code;
-    return 0;
-}
-
-/*
- * 函数名: runCodeFromMemoryAsImport
- * 目标: 采用import的方式运行内存中程序 (字节码形式)
- */
-int runCodeFromMemoryAsImport(af_Code *code, af_Environment *env) {
-    bool res = iterCode(code, 1, env);
+int runCodeFromMemory(af_Code *code, int mode, af_Environment *env){
+    bool res = iterCode(code, mode, env);
     if (!res)
         return env->core->exit_code;
     return 0;
@@ -149,7 +141,7 @@ int runCodeFromMemoryAsImport(af_Code *code, af_Environment *env) {
  * 函数名: runCodeFromFileByte
  * 目标: 运行文件中的程序 (字节码形式)
  */
-int runCodeFromFileByte(FilePath file, FILE *error_file, af_Environment *env) {
+int runCodeFromFileByte(FilePath file, FILE *error_file, int mode, af_Environment *env){
     if (env == NULL || file == NULL)
         return -1;
 
@@ -169,7 +161,7 @@ int runCodeFromFileByte(FilePath file, FILE *error_file, af_Environment *env) {
         return -2;
     }
 
-    int exit_code = runCodeFromMemoryAsImport(code, env);
+    int exit_code = runCodeFromMemory(code, mode, env);
     freeAllCode(code);
     return exit_code;
 }
@@ -178,7 +170,7 @@ int runCodeFromFileByte(FilePath file, FILE *error_file, af_Environment *env) {
  * 函数名: runCodeFromFileByte
  * 目标: 运行文件中的程序 (字节码/源码形式)
  */
-int runCodeFromFile(FilePath file, FILE *error_file, bool save_afb, af_Environment *env) {
+int runCodeFromFile(FilePath file, FILE *error_file, bool save_afb, int mode, af_Environment *env){
     if (env == NULL || file == NULL)
         return -1;
 
@@ -207,12 +199,12 @@ int runCodeFromFile(FilePath file, FILE *error_file, bool save_afb, af_Environme
 
     int exit_code;
     if (time_2 >= time_1) {
-        exit_code = runCodeFromFileByte(path_2, error_file, env);
+        exit_code = runCodeFromFileByte(path_2, error_file, mode, env);
         if (exit_code != 0)
             goto RUN_SOURCE_CODE;
     } else {
 RUN_SOURCE_CODE:
-        exit_code = runCodeFromFileSource(path_1, error_file, save_afb, path_2, env);
+        exit_code = runCodeFromFileSource(path_1, error_file, save_afb, path_2, mode, env);
     }
 
     free(path_1);

+ 26 - 26
test/src/run_code.c

@@ -373,7 +373,7 @@ int main() {
     aFunInit();
     printf("Hello World\n");
 
-    af_Environment *env = creatAFunEnviroment();
+    af_Environment *env = creatAFunEnviroment(0, NULL);
     if(!pushLiteralRegex("data.*", "func", true, env)) {
         fprintf(stderr, "pushLiteralRegex Error\n");
         goto RETURN_1;
@@ -885,7 +885,7 @@ int main() {
         af_Code *bt6 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt5, bt6);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -901,7 +901,7 @@ int main() {
         af_Code *bt6 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt5, bt6);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -917,7 +917,7 @@ int main() {
         af_Code *bt5 = makeBlockCode(curly, bt3, 0, 1, NULL, NULL);
         pushCode(&bt2, bt5);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -926,7 +926,7 @@ int main() {
         printf("TAG C:\n");
         af_Code *bt1 = makeElementCode("data", '$', 0, "Tagc.aun");
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -944,7 +944,7 @@ int main() {
         af_Code *bt6 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt5, bt6);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -961,7 +961,7 @@ int main() {
         af_Code *bt6 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt5, bt6);
 
-        runCodeFromMemory(bt5, env);
+        runCodeFromMemory(bt5, 0, env);
         freeAllCode(bt5);
         printf("\n");
     }
@@ -978,7 +978,7 @@ int main() {
         af_Code *bt6 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt5, bt6);
 
-        runCodeFromMemory(bt5, env);
+        runCodeFromMemory(bt5, 0, env);
         freeAllCode(bt5);
         printf("\n");
     }
@@ -992,7 +992,7 @@ int main() {
 
         af_Code *bt5 = makeBlockCode(parentheses, bt3, '\'', 1, "Tagg.aun", NULL);
 
-        runCodeFromMemory(bt5, env);
+        runCodeFromMemory(bt5, 0, env);
         freeAllCode(bt5);
         printf("\n");
     }
@@ -1006,7 +1006,7 @@ int main() {
 
         af_Code *bt5 = makeBlockCode(brackets, bt3, '$', 1, "Tagh.aun", NULL);
 
-        runCodeFromMemory(bt5, env);
+        runCodeFromMemory(bt5, 0, env);
         freeAllCode(bt5);
         printf("\n");
     }
@@ -1023,7 +1023,7 @@ int main() {
         af_Code *bt6 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt5, bt6);
 
-        runCodeFromMemory(bt3, env);
+        runCodeFromMemory(bt3, 0, env);
         freeAllCode(bt3);
         printf("\n");
     }
@@ -1034,7 +1034,7 @@ int main() {
         af_Code *bt2 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt1, bt2);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -1045,7 +1045,7 @@ int main() {
         af_Code *bt2 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt1, bt2);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -1054,7 +1054,7 @@ int main() {
         printf("TAG L:\n");
         af_Code *bt1 = makeElementCode("func4", 0, 1, "Tagl.aun");
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -1065,7 +1065,7 @@ int main() {
         af_Code *bt2 = makeElementCode("func", 0, 1, NULL);
         af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "Tagm.aun", NULL);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -1081,7 +1081,7 @@ int main() {
         pushCode(&bt1, bt3);
         pushCode(&bt3, bt4);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -1095,7 +1095,7 @@ int main() {
 
         pushCode(&bt1, bt3);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -1109,7 +1109,7 @@ int main() {
 
         pushCode(&bt1, bt3);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -1123,7 +1123,7 @@ int main() {
 
         pushCode(&bt1, bt3);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -1141,14 +1141,14 @@ int main() {
         af_Code *bt6 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt5, bt6);
 
-        runCodeFromMemoryAsImport(bt1, env);
+        runCodeFromMemory(bt1, 1, env);
         freeAllCode(bt1);
         printf("\n");
     }
 
     {
         printf("TAG S: STRING\n");
-        int exit_code = runCodeFromString("object\ndata\n{func}\nglobal\n", "Tags-string.aun", NULL, env);
+        int exit_code = runCodeFromString("object\ndata\n{func}\nglobal\n", "Tags-string.aun", NULL, 1, env);
         printf("exit code = %d\n\n", exit_code);
     }
 
@@ -1172,7 +1172,7 @@ int main() {
 
         pushCode(&bt1, bt3);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -1187,7 +1187,7 @@ int main() {
         af_Code *bt6 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt5, bt6);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -1199,7 +1199,7 @@ int main() {
 
         pushCode(&bt1, bt2);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -1212,7 +1212,7 @@ int main() {
 
         pushCode(&bt1, bt2);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }
@@ -1226,7 +1226,7 @@ int main() {
         af_Code *bt3 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt1, bt3);
 
-        runCodeFromMemory(bt1, env);
+        runCodeFromMemory(bt1, 0, env);
         freeAllCode(bt1);
         printf("\n");
     }