Browse Source

style: bytecode重命名为code

SongZihuan 3 years ago
parent
commit
4dea4c01e2
11 changed files with 102 additions and 102 deletions
  1. 1 1
      include/aFun.h
  2. 0 25
      include/bytecode.h
  3. 25 0
      include/code.h
  4. 3 3
      include/env.h
  5. 0 2
      include/macro.h
  6. 9 7
      src/core/__code.h
  7. 3 3
      src/core/__env.h
  8. 40 40
      src/core/code.c
  9. 5 5
      src/core/env.c
  10. 1 1
      src/core/run.c
  11. 15 15
      test/test_byte_code.c

+ 1 - 1
include/aFun.h

@@ -4,7 +4,7 @@
 #include "macro.h"
 #include "macro.h"
 #include "tool.h"
 #include "tool.h"
 
 
-#include "bytecode.h"
+#include "code.h"
 #include "object.h"
 #include "object.h"
 #include "var.h"
 #include "var.h"
 #include "env.h"
 #include "env.h"

+ 0 - 25
include/bytecode.h

@@ -1,25 +0,0 @@
-#ifndef AFUN__BYTECODE_H_PUBLIC
-#define AFUN__BYTECODE_H_PUBLIC
-#include <stdio.h>
-
-typedef struct af_ByteCode af_ByteCode;
-
-enum af_BlockType {
-    parentheses = 0,  // 小括号
-    brackets,  // 中括号
-    curly,  // 大括号
-};
-
-af_ByteCode *makeLiteralByteCode(char *literal_data, char *func, char prefix, FileLine line, FilePath path);
-af_ByteCode *makeVariableByteCode(char *var, char prefix, FileLine line, FilePath path);
-af_ByteCode *makeBlockByteCode(enum af_BlockType type, af_ByteCode *element, char prefix, FileLine line, FilePath path, af_ByteCode **next);
-af_ByteCode *connectByteCode(af_ByteCode **base, af_ByteCode *next);
-af_ByteCode *copyByteCode(af_ByteCode *base, FilePath *path);
-af_ByteCode *freeByteCode(af_ByteCode *bt);
-bool freeByteCodeWithElement(af_ByteCode *bt, af_ByteCode **next);
-void freeAllByteCode(af_ByteCode *bt);
-bool writeAllByteCode(af_ByteCode *bt, FILE *file);
-bool readAllByteCode(af_ByteCode **bt, FILE *file);
-void printByteCode(af_ByteCode *bt);
-
-#endif //AFUN__BYTECODE_H_PUBLIC

+ 25 - 0
include/code.h

@@ -0,0 +1,25 @@
+#ifndef AFUN__BYTECODE_H_PUBLIC
+#define AFUN__BYTECODE_H_PUBLIC
+#include <stdio.h>
+
+typedef struct af_Code af_Code;
+
+enum af_BlockType {
+    parentheses = 0,  // 小括号
+    brackets,  // 中括号
+    curly,  // 大括号
+};
+
+af_Code *makeLiteralCode(char *literal_data, char *func, char prefix, FileLine line, FilePath path);
+af_Code *makeVariableCode(char *var, char prefix, FileLine line, FilePath path);
+af_Code *makeBlockCode(enum af_BlockType type, af_Code *element, char prefix, FileLine line, FilePath path, af_Code **next);
+af_Code *connectCode(af_Code **base, af_Code *next);
+af_Code *copyCode(af_Code *base, FilePath *path);
+af_Code *freeCode(af_Code *bt);
+bool freeCodeWithElement(af_Code *bt, af_Code **next);
+void freeAllCode(af_Code *bt);
+bool writeAllCode(af_Code *bt, FILE *file);
+bool readAllCode(af_Code **bt, FILE *file);
+void printCode(af_Code *bt);
+
+#endif //AFUN__BYTECODE_H_PUBLIC

+ 3 - 3
include/env.h

@@ -4,16 +4,16 @@
 typedef struct af_Environment af_Environment;
 typedef struct af_Environment af_Environment;
 typedef struct af_Message af_Message;
 typedef struct af_Message af_Message;
 
 
-#include "bytecode.h"
+#include "code.h"
 #include "object.h"
 #include "object.h"
 #include "var.h"
 #include "var.h"
 
 
 af_Object *getBaseObject(char *name, af_Environment *env);
 af_Object *getBaseObject(char *name, af_Environment *env);
 
 
 af_Environment *makeEnvironment(void);
 af_Environment *makeEnvironment(void);
-bool enableEnvironment(af_ByteCode *bt, af_Environment *env);
+bool enableEnvironment(af_Code *bt, af_Environment *env);
 void freeEnvironment(af_Environment *env);
 void freeEnvironment(af_Environment *env);
-void pushActivity(af_ByteCode *bt, bool new_vs, af_VarSpaceListNode *vsl, af_Object *belong,
+void pushActivity(af_Code *bt, bool new_vs, af_VarSpaceListNode *vsl, af_Object *belong,
                   af_Environment *env);
                   af_Environment *env);
 void popActivity(af_Environment *env);
 void popActivity(af_Environment *env);
 
 

+ 0 - 2
include/macro.h

@@ -21,6 +21,4 @@
 typedef uint32_t FileLine;  // 文件行号
 typedef uint32_t FileLine;  // 文件行号
 typedef char *FilePath;  // 文件路径
 typedef char *FilePath;  // 文件路径
 
 
-typedef unsigned int ByteCodeUint;  // ByteCode int
-
 #endif //AFUN__MACRO_H
 #endif //AFUN__MACRO_H

+ 9 - 7
src/core/__bytecode.h → src/core/__code.h

@@ -1,22 +1,24 @@
 /*
 /*
  * 文件名: __bytecode.h
  * 文件名: __bytecode.h
- * 目标: 定义ByteCode结构体
+ * 目标: 定义Code结构体
  */
  */
 
 
 #ifndef AFUN__BYTECODE_H
 #ifndef AFUN__BYTECODE_H
 #define AFUN__BYTECODE_H
 #define AFUN__BYTECODE_H
 #include "macro.h"
 #include "macro.h"
-#include "bytecode.h"
+#include "code.h"
 
 
-enum af_ByteCodeType {
+typedef unsigned int CodeUint;  // Code uint
+
+enum af_CodeType {
     literal = 0,
     literal = 0,
     variable,
     variable,
     block,  // 括号
     block,  // 括号
 };
 };
 
 
 
 
-struct af_ByteCode {  // 一个 ByteCode 的结构体
-    enum af_ByteCodeType type;
+struct af_Code {  // 一个 Code 的结构体
+    enum af_CodeType type;
     char prefix;  // 前缀
     char prefix;  // 前缀
     union {
     union {
         struct {
         struct {
@@ -29,7 +31,7 @@ struct af_ByteCode {  // 一个 ByteCode 的结构体
         } variable;
         } variable;
 
 
         struct {
         struct {
-            ByteCodeUint elements;  // 元素个数
+            CodeUint elements;  // 元素个数
             enum af_BlockType type;  // 括号类型
             enum af_BlockType type;  // 括号类型
         } block;
         } block;
     };
     };
@@ -37,7 +39,7 @@ struct af_ByteCode {  // 一个 ByteCode 的结构体
     FileLine line;
     FileLine line;
     FilePath path;  // path == NULL表示沿用上层地址
     FilePath path;  // path == NULL表示沿用上层地址
 
 
-    struct af_ByteCode *next;
+    struct af_Code *next;
 };
 };
 
 
 #endif //AFUN__BYTECODE_H
 #endif //AFUN__BYTECODE_H

+ 3 - 3
src/core/__env.h

@@ -10,7 +10,7 @@ typedef struct af_EnvVar af_EnvVar;
 #include "env.h"
 #include "env.h"
 #include "__object.h"
 #include "__object.h"
 #include "__var.h"
 #include "__var.h"
-#include "__bytecode.h"
+#include "__code.h"
 #include "__gc.h"
 #include "__gc.h"
 
 
 #define ENV_VAR_HASH_SIZE (8)
 #define ENV_VAR_HASH_SIZE (8)
@@ -45,8 +45,8 @@ struct af_Activity {  // 活动记录器
     struct af_Message *msg_down;  // 被调用者向调用者传递信息
     struct af_Message *msg_down;  // 被调用者向调用者传递信息
     struct af_Message *msg_up;  // 调用者向被调用者传递信息
     struct af_Message *msg_up;  // 调用者向被调用者传递信息
 
 
-    struct af_ByteCode *bt_start;  // 代码的起始位置
-    struct af_ByteCode *bt;  // 指示代码运行的地方
+    struct af_Code *bt_start;  // 代码的起始位置
+    struct af_Code *bt;  // 指示代码运行的地方
 
 
     struct af_VarSpaceListNode *var_list;  // 变量空间
     struct af_VarSpaceListNode *var_list;  // 变量空间
     ActivityCount new_vs_count;  // 需要释放的空间数
     ActivityCount new_vs_count;  // 需要释放的空间数

+ 40 - 40
src/core/bytecode.c → src/core/code.c

@@ -1,15 +1,15 @@
 /*
 /*
  * 文件名: bytecode.c
  * 文件名: bytecode.c
- * 目标: 管理ByteCode结构体的函数
+ * 目标: 管理Code结构体的函数
  */
  */
 
 
 #include <stdio.h>
 #include <stdio.h>
 #include "aFun.h"
 #include "aFun.h"
-#include "__bytecode.h"
+#include "__code.h"
 #include "tool.h"
 #include "tool.h"
 
 
-static af_ByteCode *makeByteCode(char prefix, FileLine line, FilePath path) {
-    af_ByteCode *bt = calloc(1, sizeof(af_ByteCode));
+static af_Code *makeCode(char prefix, FileLine line, FilePath path) {
+    af_Code *bt = calloc(1, sizeof(af_Code));
     bt->line = line;
     bt->line = line;
     bt->prefix = prefix;
     bt->prefix = prefix;
     if (path != NULL)
     if (path != NULL)
@@ -17,8 +17,8 @@ static af_ByteCode *makeByteCode(char prefix, FileLine line, FilePath path) {
     return bt;
     return bt;
 }
 }
 
 
-af_ByteCode *makeLiteralByteCode(char *literal_data, char *func, char prefix, FileLine line, FilePath path) {
-    af_ByteCode *bt = makeByteCode(prefix, line, path);
+af_Code *makeLiteralCode(char *literal_data, char *func, char prefix, FileLine line, FilePath path) {
+    af_Code *bt = makeCode(prefix, line, path);
     bt->type = literal;
     bt->type = literal;
     bt->literal.literal_data = strCopy(literal_data);
     bt->literal.literal_data = strCopy(literal_data);
     bt->literal.func = strCopy(func);
     bt->literal.func = strCopy(func);
@@ -26,8 +26,8 @@ af_ByteCode *makeLiteralByteCode(char *literal_data, char *func, char prefix, Fi
 }
 }
 
 
 
 
-af_ByteCode *makeVariableByteCode(char *var, char prefix, FileLine line, FilePath path) {
-    af_ByteCode *bt = makeByteCode(prefix, line, path);
+af_Code *makeVariableCode(char *var, char prefix, FileLine line, FilePath path) {
+    af_Code *bt = makeCode(prefix, line, path);
     bt->type = variable;
     bt->type = variable;
     bt->variable.name = strCopy(var);
     bt->variable.name = strCopy(var);
     return bt;
     return bt;
@@ -37,8 +37,8 @@ af_ByteCode *makeVariableByteCode(char *var, char prefix, FileLine line, FilePat
  * 函数名: countElement
  * 函数名: countElement
  * 目标: 统计元素个数(不包括元素的子元素)
  * 目标: 统计元素个数(不包括元素的子元素)
  */
  */
-static bool countElement(af_ByteCode *element, ByteCodeUint *count, af_ByteCode **next) {
-    ByteCodeUint to_next = 0;  // 表示紧接着的元素都不纳入统计(指block的子元素)
+static bool countElement(af_Code *element, CodeUint *count, af_Code **next) {
+    CodeUint to_next = 0;  // 表示紧接着的元素都不纳入统计(指block的子元素)
 
 
     for (*count = 0; element != NULL; *next = element, element = element->next) {
     for (*count = 0; element != NULL; *next = element, element = element->next) {
         if (to_next == 0)
         if (to_next == 0)
@@ -55,10 +55,10 @@ static bool countElement(af_ByteCode *element, ByteCodeUint *count, af_ByteCode
     return true;
     return true;
 }
 }
 
 
-af_ByteCode *makeBlockByteCode(enum af_BlockType type, af_ByteCode *element, char prefix, FileLine line, FilePath path, af_ByteCode **next) {
-    af_ByteCode *bt = NULL;
-    af_ByteCode *tmp = NULL;
-    ByteCodeUint count = 0;
+af_Code *makeBlockCode(enum af_BlockType type, af_Code *element, char prefix, FileLine line, FilePath path, af_Code **next) {
+    af_Code *bt = NULL;
+    af_Code *tmp = NULL;
+    CodeUint count = 0;
 
 
     if (next == NULL)
     if (next == NULL)
         next = &tmp;
         next = &tmp;
@@ -66,7 +66,7 @@ af_ByteCode *makeBlockByteCode(enum af_BlockType type, af_ByteCode *element, cha
     if (!countElement(element, &count, next))
     if (!countElement(element, &count, next))
         return NULL;
         return NULL;
 
 
-    bt = makeByteCode(prefix, line, path);
+    bt = makeCode(prefix, line, path);
     bt->type = block;
     bt->type = block;
     bt->block.type = type;
     bt->block.type = type;
     bt->block.elements = count;
     bt->block.elements = count;
@@ -74,7 +74,7 @@ af_ByteCode *makeBlockByteCode(enum af_BlockType type, af_ByteCode *element, cha
     return bt;
     return bt;
 }
 }
 
 
-af_ByteCode *connectByteCode(af_ByteCode **base, af_ByteCode *next) {
+af_Code *connectCode(af_Code **base, af_Code *next) {
     while ((*base) != NULL)
     while ((*base) != NULL)
         base = &((*base)->next);
         base = &((*base)->next);
     *base = next;
     *base = next;
@@ -85,12 +85,12 @@ af_ByteCode *connectByteCode(af_ByteCode **base, af_ByteCode *next) {
     return next;
     return next;
 }
 }
 
 
-af_ByteCode *copyByteCode(af_ByteCode *base, FilePath *path) {
-    af_ByteCode *dest = NULL;
-    af_ByteCode **pdest = &dest;
+af_Code *copyCode(af_Code *base, FilePath *path) {
+    af_Code *dest = NULL;
+    af_Code **pdest = &dest;
 
 
     for (NULL; base != NULL; base = base->next) {
     for (NULL; base != NULL; base = base->next) {
-        *pdest = makeByteCode(base->prefix, base->line, base->path);
+        *pdest = makeCode(base->prefix, base->line, base->path);
         (*pdest)->type = base->type;
         (*pdest)->type = base->type;
         switch (base->type) {
         switch (base->type) {
             case literal:
             case literal:
@@ -120,11 +120,11 @@ af_ByteCode *copyByteCode(af_ByteCode *base, FilePath *path) {
     return dest;
     return dest;
 }
 }
 
 
-af_ByteCode *freeByteCode(af_ByteCode *bt) {
+af_Code *freeCode(af_Code *bt) {
     if (bt == NULL)
     if (bt == NULL)
         return NULL;
         return NULL;
 
 
-    af_ByteCode *next = bt->next;
+    af_Code *next = bt->next;
     free(bt->path);
     free(bt->path);
     switch (bt->type) {
     switch (bt->type) {
         case literal:
         case literal:
@@ -142,28 +142,28 @@ af_ByteCode *freeByteCode(af_ByteCode *bt) {
     return next;
     return next;
 }
 }
 
 
-bool freeByteCodeWithElement(af_ByteCode *bt, af_ByteCode **next) {
-    ByteCodeUint count = 1;  // 要释放的元素个数
+bool freeCodeWithElement(af_Code *bt, af_Code **next) {
+    CodeUint count = 1;  // 要释放的元素个数
     for (NULL; count != 0; count--) {
     for (NULL; count != 0; count--) {
         if (bt == NULL)
         if (bt == NULL)
             return false;
             return false;
         if (bt->type == block)
         if (bt->type == block)
             count += bt->block.elements;
             count += bt->block.elements;
-        bt = freeByteCode(bt);
+        bt = freeCode(bt);
     }
     }
 
 
     *next = bt;
     *next = bt;
     return true;
     return true;
 }
 }
 
 
-void freeAllByteCode(af_ByteCode *bt) {
+void freeAllCode(af_Code *bt) {
     while (bt != NULL)
     while (bt != NULL)
-        bt = freeByteCode(bt);
+        bt = freeCode(bt);
 }
 }
 
 
 #define Done(write) do{if(!(write)){return false;}}while(0)
 #define Done(write) do{if(!(write)){return false;}}while(0)
 
 
-static bool writeByteCode(af_ByteCode *bt, FILE *file) {
+static bool writeCode(af_Code *bt, FILE *file) {
     Done(byteWriteUint_8(file, bt->type));
     Done(byteWriteUint_8(file, bt->type));
     Done(byteWriteUint_8(file, bt->prefix));
     Done(byteWriteUint_8(file, bt->prefix));
     Done(byteWriteUint_32(file, bt->line));
     Done(byteWriteUint_32(file, bt->line));
@@ -194,29 +194,29 @@ static bool writeByteCode(af_ByteCode *bt, FILE *file) {
 }
 }
 
 
 /*
 /*
- * 函数名: writeAllByteCode
- * 目标: 将ByteCode写入字节码文件中
+ * 函数名: writeAllCode
+ * 目标: 将Code写入字节码文件中
  * 备注: 写入字节码时不做语义检查, 在读取时最语义检查即可
  * 备注: 写入字节码时不做语义检查, 在读取时最语义检查即可
  */
  */
-bool writeAllByteCode(af_ByteCode *bt, FILE *file) {
+bool writeAllCode(af_Code *bt, FILE *file) {
     uint32_t count = 0;
     uint32_t count = 0;
 
 
     if (bt == NULL || bt->path == NULL)
     if (bt == NULL || bt->path == NULL)
         return false;
         return false;
 
 
-    for (af_ByteCode *tmp = bt; tmp != NULL; tmp = tmp->next)  // 统计个数
+    for (af_Code *tmp = bt; tmp != NULL; tmp = tmp->next)  // 统计个数
         count++;
         count++;
 
 
     Done(byteWriteUint_32(file,count));
     Done(byteWriteUint_32(file,count));
     for (NULL; bt != NULL; bt = bt->next) {
     for (NULL; bt != NULL; bt = bt->next) {
-        if (!writeByteCode(bt, file))
+        if (!writeCode(bt, file))
             return false;
             return false;
     }
     }
 
 
     return true;
     return true;
 }
 }
 
 
-static bool readByteCode(af_ByteCode **bt, FILE *file) {
+static bool readCode(af_Code **bt, FILE *file) {
     uint8_t type;
     uint8_t type;
     uint8_t prefix;
     uint8_t prefix;
     uint32_t line;
     uint32_t line;
@@ -231,7 +231,7 @@ static bool readByteCode(af_ByteCode **bt, FILE *file) {
     if (have_path)
     if (have_path)
         Done(byteReadStr(file, &path));
         Done(byteReadStr(file, &path));
 
 
-    *bt = makeByteCode((char)prefix, line, path);
+    *bt = makeCode((char)prefix, line, path);
     free(path);
     free(path);
     (*bt)->type = type;
     (*bt)->type = type;
 
 
@@ -259,22 +259,22 @@ static bool readByteCode(af_ByteCode **bt, FILE *file) {
 }
 }
 
 
 /*
 /*
- * 函数名: writeAllByteCode
- * 目标: 将ByteCode写入字节码文件中
+ * 函数名: writeAllCode
+ * 目标: 将Code写入字节码文件中
  * 备注: 写入字节码时不做语义检查, 在读取时最语义检查即可 【语义检查还未实现】
  * 备注: 写入字节码时不做语义检查, 在读取时最语义检查即可 【语义检查还未实现】
  */
  */
-bool readAllByteCode(af_ByteCode **bt, FILE *file) {
+bool readAllCode(af_Code **bt, FILE *file) {
     uint32_t count;
     uint32_t count;
     Done(byteReadUint_32(file,&count));
     Done(byteReadUint_32(file,&count));
 
 
     for (NULL; count != 0; count--, bt = &((*bt)->next)) {
     for (NULL; count != 0; count--, bt = &((*bt)->next)) {
-        if(!readByteCode(bt, file))
+        if(!readCode(bt, file))
             return false;
             return false;
     }
     }
     return true;
     return true;
 }
 }
 
 
-void printByteCode(af_ByteCode *bt) {
+void printCode(af_Code *bt) {
     for (NULL; bt != NULL; bt = bt->next) {
     for (NULL; bt != NULL; bt = bt->next) {
         switch (bt->type) {
         switch (bt->type) {
             case literal:
             case literal:

+ 5 - 5
src/core/env.c

@@ -6,7 +6,7 @@ static bool checkInheritAPI(af_ObjectData *od);
 static void checkInherit(af_Inherit **ih, af_Object *obj);
 static void checkInherit(af_Inherit **ih, af_Object *obj);
 static bool enableCore(af_Core *core);
 static bool enableCore(af_Core *core);
 
 
-static af_Activity *makeActivity(af_ByteCode *bt,bool new_vs, af_VarSpaceListNode *vsl, af_Object *belong);
+static af_Activity *makeActivity(af_Code *bt, bool new_vs, af_VarSpaceListNode *vsl, af_Object *belong);
 static af_Activity *freeActivity(af_Activity *activity);
 static af_Activity *freeActivity(af_Activity *activity);
 static void freeAllActivity(af_Activity *activity);
 static void freeAllActivity(af_Activity *activity);
 
 
@@ -115,7 +115,7 @@ static bool enableCore(af_Core *core) {
     return true;
     return true;
 }
 }
 
 
-static af_Activity *makeActivity(af_ByteCode *bt, bool new_vs, af_VarSpaceListNode *vsl, af_Object *belong) {
+static af_Activity *makeActivity(af_Code *bt, bool new_vs, af_VarSpaceListNode *vsl, af_Object *belong) {
     af_Activity *activity = calloc(sizeof(af_Activity), 1);
     af_Activity *activity = calloc(sizeof(af_Activity), 1);
     activity->bt = bt;
     activity->bt = bt;
     activity->bt_start = bt;
     activity->bt_start = bt;
@@ -271,7 +271,7 @@ af_Environment *makeEnvironment(void) {
     return env;
     return env;
 }
 }
 
 
-bool enableEnvironment(af_ByteCode *bt, af_Environment *env) {
+bool enableEnvironment(af_Code *bt, af_Environment *env) {
     if (!enableCore(env->core))
     if (!enableCore(env->core))
         return false;
         return false;
 
 
@@ -290,8 +290,8 @@ void freeEnvironment(af_Environment *env) {
     free(env);
     free(env);
 }
 }
 
 
-void pushActivity(af_ByteCode *bt, bool new_vs, af_VarSpaceListNode *vsl, af_Object *belong,
-                 af_Environment *env) {
+void pushActivity(af_Code *bt, bool new_vs, af_VarSpaceListNode *vsl, af_Object *belong,
+                  af_Environment *env) {
     af_Activity *activity = makeActivity(bt, new_vs, vsl, belong);
     af_Activity *activity = makeActivity(bt, new_vs, vsl, belong);
     activity->prev = env->activity;
     activity->prev = env->activity;
     env->activity = activity;
     env->activity = activity;

+ 1 - 1
src/core/run.c

@@ -4,4 +4,4 @@
 #include "__object.h"
 #include "__object.h"
 #include "__var.h"
 #include "__var.h"
 #include "__gc.h"
 #include "__gc.h"
-#include "__bytecode.h"
+#include "__code.h"

+ 15 - 15
test/test_byte_code.c

@@ -3,17 +3,17 @@
 #include "aFun.h"
 #include "aFun.h"
 
 
 int main() {
 int main() {
-    af_ByteCode *bt1 = makeLiteralByteCode("data", "func", ',', 0, "Unknow");
-    af_ByteCode *bt2 = makeVariableByteCode("var1", 0, 1, NULL);
+    af_Code *bt1 = makeLiteralCode("data", "func", ',', 0, "Unknow");
+    af_Code *bt2 = makeVariableCode("var1", 0, 1, NULL);
 
 
-    af_ByteCode *bt3 = makeLiteralByteCode("data2", "func", 0, 0, NULL);
-    af_ByteCode *bt4 = makeVariableByteCode("var2", 0, 1, NULL);
+    af_Code *bt3 = makeLiteralCode("data2", "func", 0, 0, NULL);
+    af_Code *bt4 = makeVariableCode("var2", 0, 1, NULL);
 
 
-    connectByteCode(&bt1, bt2);
-    connectByteCode(&bt3, bt4);
+    connectCode(&bt1, bt2);
+    connectCode(&bt3, bt4);
 
 
-    af_ByteCode *bt5 = makeBlockByteCode(parentheses, bt3, 0, 1, NULL, NULL);
-    connectByteCode(&bt2, bt5);
+    af_Code *bt5 = makeBlockCode(parentheses, bt3, 0, 1, NULL, NULL);
+    connectCode(&bt2, bt5);
 
 
     FILE *file = fopen("test.afb", "wb");
     FILE *file = fopen("test.afb", "wb");
     if (file == NULL) {
     if (file == NULL) {
@@ -21,31 +21,31 @@ int main() {
         return EXIT_FAILURE;
         return EXIT_FAILURE;
     }
     }
 
 
-    if(!writeAllByteCode(bt1, file)) {
+    if(!writeAllCode(bt1, file)) {
         fprintf(stderr, "Write test.afb error.\n");
         fprintf(stderr, "Write test.afb error.\n");
         return EXIT_FAILURE;
         return EXIT_FAILURE;
     }
     }
     fclose(file);
     fclose(file);
 
 
-    af_ByteCode *get;
+    af_Code *get;
     file = fopen("test.afb", "rb");
     file = fopen("test.afb", "rb");
     if (file == NULL) {
     if (file == NULL) {
         fprintf(stderr, "Can't not read file: test.afb\n");
         fprintf(stderr, "Can't not read file: test.afb\n");
         return EXIT_FAILURE;
         return EXIT_FAILURE;
     }
     }
 
 
-    if(!readAllByteCode(&get, file)) {
+    if(!readAllCode(&get, file)) {
         fprintf(stderr, "Read test.afb error.\n");
         fprintf(stderr, "Read test.afb error.\n");
         return EXIT_FAILURE;
         return EXIT_FAILURE;
     }
     }
     fclose(file);
     fclose(file);
 
 
     printf("out:\n");
     printf("out:\n");
-    printByteCode(bt1);
+    printCode(bt1);
     printf("in:\n");
     printf("in:\n");
-    printByteCode(get);
-    freeAllByteCode(bt1);
-    freeAllByteCode(get);
+    printCode(get);
+    freeAllCode(bt1);
+    freeAllCode(get);
     return EXIT_SUCCESS;
     return EXIT_SUCCESS;
 }
 }