浏览代码

refactor: 修改文件后缀

.af -> .aun
.afb -> .aub
SongZihuan 3 年之前
父节点
当前提交
2289b997f2
共有 9 个文件被更改,包括 53 次插入53 次删除
  1. 2 2
      src/core/env.c
  2. 8 8
      src/runtime/aFunlang.c
  3. 0 0
      test/af/test1.aub
  4. 0 0
      test/af/test1.aun
  5. 0 0
      test/af/test2.aub
  6. 9 9
      test/export/main.c
  7. 4 4
      test/src/byte_code.c
  8. 27 27
      test/src/run_code.c
  9. 3 3
      test/src/syntactic.c

+ 2 - 2
src/core/env.c

@@ -215,7 +215,7 @@ static af_Activity *makeGcActivity(gc_DestructList *dl, gc_DestructList **pdl, a
     activity->var_list = makeVarSpaceList(getProtectVarSpace(env));
     activity->new_vs_count = 1;
 
-    activity->file = strCopy("aFun-gc.af.sys");
+    activity->file = strCopy("aFun-gc.aun.sys");
     activity->line = 0;
     activity->dl = dl;
     activity->pdl = pdl;
@@ -1248,7 +1248,7 @@ static af_ErrorBacktracking *makeErrorBacktracking(FileLine line, FilePath file,
     af_ErrorBacktracking *ebt = calloc(1, sizeof(af_ErrorBacktracking));
     ebt->line = line;
     if (file == NULL)
-        ebt->file = strCopy("unknown.af.sys");
+        ebt->file = strCopy("unknown.aun.sys");
     else
         ebt->file = strCopy(file);
     if (note != NULL)

+ 8 - 8
src/runtime/aFunlang.c

@@ -61,7 +61,7 @@ int runCodeFromString(char *code, char *string_name, FILE *error_file, af_Enviro
         return -1;
 
     if (string_name == NULL)
-        string_name = "string-code.af";
+        string_name = "string-code.aun";
 
     if (error_file == NULL)
         error_file = stderr;
@@ -78,14 +78,14 @@ int runCodeFromFileSource(FilePath file, FILE *error_file, bool save_afb, FilePa
         return -1;
 
     char *sufix = getFileSurfix(file);
-    if (sufix == NULL || !EQ_STR(".af", sufix))
+    if (sufix == NULL || !EQ_STR(".aun", sufix))
         return -2;
 
     /* 若文件不存在则自动生成 */
     bool free_save_path = false;
     if (save_afb && !save_path) {
         char *path = getFileNameWithPath(file);
-        save_path = strJoin(path, ".afb", true, false);
+        save_path = strJoin(path, ".aub", true, false);
         free_save_path = true;
     } else if (!save_afb)
         save_path = NULL;
@@ -108,7 +108,7 @@ int runCodeFromStdin(char *name, FILE *error_file, af_Environment *env) {
         return -1;
 
     if (name == NULL)
-        name = "sys-stdin.af";
+        name = "sys-stdin.aun";
 
     if (error_file == NULL)
         error_file = stderr;
@@ -147,7 +147,7 @@ int runCodeFromFileByte(FilePath file, FILE *error_file, af_Environment *env) {
         return -1;
 
     char *sufix = getFileSurfix(file);
-    if (sufix == NULL || !EQ_STR(".afb", sufix))
+    if (sufix == NULL || !EQ_STR(".aub", sufix))
         return -2;
 
     if (error_file == NULL)
@@ -178,12 +178,12 @@ int runCodeFromFile(FilePath file, FILE *error_file, bool save_afb, af_Environme
         return -1;
 
     char *sufix = getFileSurfix(file);
-    if (sufix == NULL || (!EQ_STR(".af", sufix) && EQ_STR(".afb", sufix)))  // 不是源文件或字节码文件
+    if (sufix == NULL || (!EQ_STR(".aun", sufix) && EQ_STR(".aub", sufix)))  // 不是源文件或字节码文件
         return -2;
 
     char *path = getFileNameWithPath(file);
-    char *path_1 = strJoin(path, ".af", false, false);
-    char *path_2 = strJoin(path, ".afb", true, false);  // 此时释放path
+    char *path_1 = strJoin(path, ".aun", false, false);
+    char *path_2 = strJoin(path, ".aub", true, false);  // 此时释放path
 
     time_t time_1 = getFileMTime(path_1);
     time_t time_2 = getFileMTime(path_2);

+ 0 - 0
test/af/test1.afb → test/af/test1.aub


+ 0 - 0
test/af/test1.af → test/af/test1.aun


+ 0 - 0
test/af/test2.afb → test/af/test2.aub


+ 9 - 9
test/export/main.c

@@ -352,7 +352,7 @@ bool getInfo5(af_FuncInfo **fi, af_Object *obj, af_Code *code, void *mark, af_En
 
 bool getInfo10(af_FuncInfo **fi, af_Object *obj, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, true, true, true);
-    makeCodeFuncBodyToFuncInfo(makeElementCode("no-var", NUL, 1, "func9.info.af"), true, NULL, *fi);
+    makeCodeFuncBodyToFuncInfo(makeElementCode("no-var", NUL, 1, "func9.info.aun"), true, NULL, *fi);
     return true;
 }
 
@@ -1002,7 +1002,7 @@ int main() {
 
     {  // 对象函数的调用 (尾调递归优化)
         printf("TAG P:\n");
-        af_Code *bt1 = makeElementCode("func4", 0, 1, "TagP.af");
+        af_Code *bt1 = makeElementCode("func4", 0, 1, "TagP.aun");
 
         iterCode(bt1, env);
         freeAllCode(bt1);
@@ -1013,7 +1013,7 @@ int main() {
         printf("TAG U:\n");
 
         af_Code *bt2 = makeElementCode("func", 0, 1, NULL);
-        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "TagU.af", NULL);
+        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "TagU.aun", NULL);
 
         iterCode(bt1, env);
         freeAllCode(bt1);
@@ -1024,7 +1024,7 @@ int main() {
         printf("TAG Q:\n");
 
         af_Code *bt2 = makeElementCode("func5", 0, 1, NULL);
-        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "TagQ.af", NULL);
+        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "TagQ.aun", NULL);
         af_Code *bt3 = makeElementCode("global", 0, 1, NULL);
         af_Code *bt4 = makeElementCode("global", 0, 1, NULL);
 
@@ -1040,7 +1040,7 @@ int main() {
         printf("TAG R:\n");
 
         af_Code *bt2 = makeElementCode("func7", 0, 1, NULL);
-        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "TagR.af", NULL);
+        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "TagR.aun", NULL);
         af_Code *bt3 = makeElementCode("global", 0, 1, NULL);
 
         connectCode(&bt1, bt3);
@@ -1054,7 +1054,7 @@ int main() {
         printf("TAG S:\n");
 
         af_Code *bt2 = makeElementCode("func8", 0, 1, NULL);
-        af_Code *bt1 = makeBlockCode(brackets, bt2, 0, 1, "TagS.af", NULL);
+        af_Code *bt1 = makeBlockCode(brackets, bt2, 0, 1, "TagS.aun", NULL);
         af_Code *bt3 = makeElementCode("global", 0, 1, NULL);
 
         connectCode(&bt1, bt3);
@@ -1070,7 +1070,7 @@ int main() {
         printf("TAG T: ERROR\n");
 
         af_Code *bt2 = makeElementCode("func", 0, 1, NULL);
-        af_Code *bt1 = makeBlockCode(brackets, bt2, 0, 1, "TagT.error.af", NULL);
+        af_Code *bt1 = makeBlockCode(brackets, bt2, 0, 1, "TagT.error.aun", NULL);
         af_Code *bt3 = makeElementCode("global", 0, 1, NULL);
 
         connectCode(&bt1, bt3);
@@ -1111,7 +1111,7 @@ int main() {
         printf("TAG V: ERROR\n");
 
         af_Code *bt2 = makeElementCode("func8", 0, 2, NULL);
-        af_Code *bt1 = makeElementCode("global", 0, 1, "TagV.error.af");
+        af_Code *bt1 = makeElementCode("global", 0, 1, "TagV.error.aun");
 
         connectCode(&bt1, bt2);
 
@@ -1124,7 +1124,7 @@ int main() {
         printf("TAG W: ERROR\n");
 
         af_Code *bt2 = makeElementCode("func9", 0, 1, NULL);
-        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "TagW.error.af", NULL);
+        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "TagW.error.aun", NULL);
 
         af_Code *bt3 = makeElementCode("global", 0, 1, NULL);
         connectCode(&bt1, bt3);

+ 4 - 4
test/src/byte_code.c

@@ -16,14 +16,14 @@ int main() {
     af_Code *bt5 = makeBlockCode(parentheses, bt3, 0, 1, NULL, NULL);
     pushCode(&bt2, bt5);
 
-    if(!writeAllCode(bt1, "test.afb")) {
-        fprintf(stderr, "Write test.afb error.\n");
+    if(!writeAllCode(bt1, "test.aub")) {
+        fprintf(stderr, "Write test.aub error.\n");
         return EXIT_FAILURE;
     }
 
     af_Code *get;
-    if(!readAllCode(&get, "test.afb")) {
-        fprintf(stderr, "Read test.afb error.\n");
+    if(!readAllCode(&get, "test.aub")) {
+        fprintf(stderr, "Read test.aub error.\n");
         return EXIT_FAILURE;
     }
 

+ 27 - 27
test/src/run_code.c

@@ -351,13 +351,13 @@ bool getInfo5(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *m
 
 bool getInfo10(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, true, true, true);
-    makeCodeFuncBodyToFuncInfo(makeElementCode("no-var", NUL, 1, "func9.info.af"), true, NULL, *fi);
+    makeCodeFuncBodyToFuncInfo(makeElementCode("no-var", NUL, 1, "func9.info.aun"), true, NULL, *fi);
     return true;
 }
 
 bool getInfo11(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, false, true, true);
-    makeImportFuncBodyToFuncInfo(makeElementCode("global", NUL, 1, "func9.info.af"), true, NULL, *fi);
+    makeImportFuncBodyToFuncInfo(makeElementCode("global", NUL, 1, "func9.info.aun"), true, NULL, *fi);
     return true;
 }
 
@@ -874,7 +874,7 @@ int main() {
 
     {  // 正常程序
         printf("TAG A:\n");
-        af_Code *bt1 = makeElementCode("object", 0, 1, "taga.af");
+        af_Code *bt1 = makeElementCode("object", 0, 1, "taga.aun");
         af_Code *bt2 = makeElementCode("data", ',', 0, NULL);
         pushCode(&bt1, bt2);
 
@@ -892,7 +892,7 @@ int main() {
 
     {  // 宏函数
         printf("TAG L:\n");
-        af_Code *bt1 = makeElementCode("object", 0, 1, "tagl.af");
+        af_Code *bt1 = makeElementCode("object", 0, 1, "tagl.aun");
 
         af_Code *bt3 = makeElementCode("func2", 0, 1, NULL);
         af_Code *bt5 = makeBlockCode(curly, bt3, 0, 1, NULL, NULL);
@@ -909,7 +909,7 @@ int main() {
 
     {  // 尾调递归优化
         printf("TAG B:\n");
-        af_Code *bt1 = makeElementCode("data", ',', 0, "tagb.af");
+        af_Code *bt1 = makeElementCode("data", ',', 0, "tagb.aun");
         af_Code *bt2 = makeElementCode("object", 0, 1, NULL);
         pushCode(&bt1, bt2);
 
@@ -924,7 +924,7 @@ int main() {
 
     {  // 尾调递归优化2
         printf("TAG C:\n");
-        af_Code *bt1 = makeElementCode("data", ',', 0, "tagc.af");
+        af_Code *bt1 = makeElementCode("data", ',', 0, "tagc.aun");
 
         runCodeFromMemory(bt1, env);
         freeAllCode(bt1);
@@ -933,7 +933,7 @@ int main() {
 
     {  // 测试类前缀调用
         printf("TAG D:\n");
-        af_Code *bt1 = makeElementCode("data", ',', 0, "tagd.af");
+        af_Code *bt1 = makeElementCode("data", ',', 0, "tagd.aun");
         af_Code *bt2 = makeElementCode("func", 0, 1, NULL);
         pushCode(&bt1, bt2);
 
@@ -956,7 +956,7 @@ int main() {
 
         pushCode(&bt3, bt4);
 
-        af_Code *bt5 = makeBlockCode(parentheses, bt3, '\'', 1, "tage.af", NULL);
+        af_Code *bt5 = makeBlockCode(parentheses, bt3, '\'', 1, "tage.aun", NULL);
 
         af_Code *bt6 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt5, bt6);
@@ -973,7 +973,7 @@ int main() {
 
         pushCode(&bt3, bt4);
 
-        af_Code *bt5 = makeBlockCode(brackets, bt3, ',', 1, "tagf.af", NULL);
+        af_Code *bt5 = makeBlockCode(brackets, bt3, ',', 1, "tagf.aun", NULL);
 
         af_Code *bt6 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt5, bt6);
@@ -990,7 +990,7 @@ int main() {
 
         pushCode(&bt3, bt4);
 
-        af_Code *bt5 = makeBlockCode(parentheses, bt3, '\'', 1, "tagg.af", NULL);
+        af_Code *bt5 = makeBlockCode(parentheses, bt3, '\'', 1, "tagg.aun", NULL);
 
         runCodeFromMemory(bt5, env);
         freeAllCode(bt5);
@@ -1004,7 +1004,7 @@ int main() {
 
         pushCode(&bt3, bt4);
 
-        af_Code *bt5 = makeBlockCode(brackets, bt3, ',', 1, "tagh.af", NULL);
+        af_Code *bt5 = makeBlockCode(brackets, bt3, ',', 1, "tagh.aun", NULL);
 
         runCodeFromMemory(bt5, env);
         freeAllCode(bt5);
@@ -1014,7 +1014,7 @@ int main() {
     {  // 双层尾调递归优化 (函数内调用函数)
         printf("TAG I:\n");
         af_Code *bt2 = makeElementCode("func3", 0, 1, NULL);
-        af_Code *bt3 = makeBlockCode(curly, bt2, 0, 1, "tagi.af", NULL);
+        af_Code *bt3 = makeBlockCode(curly, bt2, 0, 1, "tagi.aun", NULL);
 
         af_Code *bt4 = makeElementCode("func3", 0, 1, NULL);
         af_Code *bt5 = makeBlockCode(curly, bt4, 0, 1, NULL, NULL);
@@ -1030,7 +1030,7 @@ int main() {
 
     {  // 对象函数的调用
         printf("TAG J:\n");
-        af_Code *bt1 = makeElementCode("func4", 0, 1, "tagj.af");
+        af_Code *bt1 = makeElementCode("func4", 0, 1, "tagj.aun");
         af_Code *bt2 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt1, bt2);
 
@@ -1041,7 +1041,7 @@ int main() {
 
     {  // 变量引用调用
         printf("TAG K:\n");
-        af_Code *bt1 = makeElementCode("func4", '\'', 1, "tagk.af");
+        af_Code *bt1 = makeElementCode("func4", '\'', 1, "tagk.aun");
         af_Code *bt2 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt1, bt2);
 
@@ -1052,7 +1052,7 @@ int main() {
 
     {  // 对象函数的调用 (尾调递归优化)
         printf("TAG L:\n");
-        af_Code *bt1 = makeElementCode("func4", 0, 1, "tagl.af");
+        af_Code *bt1 = makeElementCode("func4", 0, 1, "tagl.aun");
 
         runCodeFromMemory(bt1, env);
         freeAllCode(bt1);
@@ -1063,7 +1063,7 @@ int main() {
         printf("TAG M:\n");
 
         af_Code *bt2 = makeElementCode("func", 0, 1, NULL);
-        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "Tagm.af", NULL);
+        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "Tagm.aun", NULL);
 
         runCodeFromMemory(bt1, env);
         freeAllCode(bt1);
@@ -1074,7 +1074,7 @@ int main() {
         printf("TAG N:\n");
 
         af_Code *bt2 = makeElementCode("func5", 0, 1, NULL);
-        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "Tagn.af", NULL);
+        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "Tagn.aun", NULL);
         af_Code *bt3 = makeElementCode("global", 0, 1, NULL);
         af_Code *bt4 = makeElementCode("global", 0, 1, NULL);
 
@@ -1090,7 +1090,7 @@ int main() {
         printf("TAG O:\n");
 
         af_Code *bt2 = makeElementCode("func7", 0, 1, NULL);
-        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "Tago.af", NULL);
+        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "Tago.aun", NULL);
         af_Code *bt3 = makeElementCode("global", 0, 1, NULL);
 
         pushCode(&bt1, bt3);
@@ -1104,7 +1104,7 @@ int main() {
         printf("TAG P:\n");
 
         af_Code *bt2 = makeElementCode("func8", 0, 1, NULL);
-        af_Code *bt1 = makeBlockCode(brackets, bt2, 0, 1, "Tagp.af", NULL);
+        af_Code *bt1 = makeBlockCode(brackets, bt2, 0, 1, "Tagp.aun", NULL);
         af_Code *bt3 = makeElementCode("global", 0, 1, NULL);
 
         pushCode(&bt1, bt3);
@@ -1118,7 +1118,7 @@ int main() {
         printf("TAG Q:\n");
 
         af_Code *bt2 = makeElementCode("func10", 0, 1, NULL);
-        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "Tagq.af", NULL);
+        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "Tagq.aun", NULL);
         af_Code *bt3 = makeElementCode("global", 0, 1, NULL);
 
         pushCode(&bt1, bt3);
@@ -1130,7 +1130,7 @@ int main() {
 
     {  // 导入式运行
         printf("TAG R:\n");
-        af_Code *bt1 = makeElementCode("object", 0, 1, "tagr.af");
+        af_Code *bt1 = makeElementCode("object", 0, 1, "tagr.aun");
         af_Code *bt2 = makeElementCode("data", ',', 0, NULL);
         pushCode(&bt1, bt2);
 
@@ -1148,7 +1148,7 @@ int main() {
 
     {
         printf("TAG S: STRING\n");
-        int exit_code = runCodeFromString("object\ndata\n{func}\nglobal\n", "tags-string.af", NULL, env);
+        int exit_code = runCodeFromString("object\ndata\n{func}\nglobal\n", "tags-string.aun", NULL, env);
         printf("exit code = %d\n\n", exit_code);
     }
 
@@ -1167,7 +1167,7 @@ int main() {
         printf("TAG a: ERROR\n");
 
         af_Code *bt2 = makeElementCode("func", 0, 1, NULL);
-        af_Code *bt1 = makeBlockCode(brackets, bt2, 0, 1, "Taga-error.af", NULL);
+        af_Code *bt1 = makeBlockCode(brackets, bt2, 0, 1, "Taga-error.aun", NULL);
         af_Code *bt3 = makeElementCode("global", 0, 1, NULL);
 
         pushCode(&bt1, bt3);
@@ -1179,7 +1179,7 @@ int main() {
 
     {  // 测试错误 (无函数指定)
         printf("TAG b: ERROR\n");
-        af_Code *bt1 = makeElementCode("data", ',', 0, "Tagb-error.af");
+        af_Code *bt1 = makeElementCode("data", ',', 0, "Tagb-error.aun");
 
         af_Code *bt5 = makeBlockCode(curly, NULL, 0, 1, NULL, NULL);
         pushCode(&bt1, bt5);
@@ -1194,7 +1194,7 @@ int main() {
 
     {  // 测试错误 (object2 Var not found)
         printf("TAG c: ERROR\n");
-        af_Code *bt1 = makeElementCode("data", ',', 0, "Tagc-error.af");
+        af_Code *bt1 = makeElementCode("data", ',', 0, "Tagc-error.aun");
         af_Code *bt2 = makeElementCode("object2", 0, 1, NULL);
 
         pushCode(&bt1, bt2);
@@ -1208,7 +1208,7 @@ int main() {
         printf("TAG d: ERROR\n");
 
         af_Code *bt2 = makeElementCode("func8", 0, 2, NULL);
-        af_Code *bt1 = makeElementCode("global", 0, 1, "Tagd-error.af");
+        af_Code *bt1 = makeElementCode("global", 0, 1, "Tagd-error.aun");
 
         pushCode(&bt1, bt2);
 
@@ -1221,7 +1221,7 @@ int main() {
         printf("TAG e: ERROR\n");
 
         af_Code *bt2 = makeElementCode("func9", 0, 1, NULL);
-        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "Tage-error.af", NULL);
+        af_Code *bt1 = makeBlockCode(curly, bt2, 0, 1, "Tage-error.aun", NULL);
 
         af_Code *bt3 = makeElementCode("global", 0, 1, NULL);
         pushCode(&bt1, bt3);

+ 3 - 3
test/src/syntactic.c

@@ -21,13 +21,13 @@ int main() {
 
 void test1(void) {
     af_Parser *parser = makeParserByString(str, false, stderr);
-    af_Code *code = parserCode("test1.af", parser);
+    af_Code *code = parserCode("test1.aun", parser);
     freeParser(parser);
     freeAllCode(code);
 }
 
 void test2(void) {
-    FilePath path = "./test.af";
+    FilePath path = "./test.aun";
     FILE *file = fopen(path, "wb");
     if (file == NULL) {
         perror("File open error");
@@ -41,7 +41,7 @@ void test2(void) {
     fclose(file);
 
     af_Parser *parser = makeParserByFile(path, stderr);
-    af_Code *code = parserCode("test2.af", parser);
+    af_Code *code = parserCode("test2.aun", parser);
     printCode(code);
     freeParser(parser);
     freeAllCode(code);