code.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef AFUN__BYTECODE_H_PUBLIC
  2. #define AFUN__BYTECODE_H_PUBLIC
  3. #include <stdio.h>
  4. typedef struct af_Code af_Code;
  5. /* 括号类型 */
  6. enum af_BlockType {
  7. parentheses = 0, // 小括号
  8. brackets, // 中括号
  9. curly, // 大括号
  10. };
  11. /* 代码块创建函数 */
  12. af_Code *makeLiteralCode(char *literal_data, char *func, bool in_protect, char prefix, FileLine line, FilePath path);
  13. af_Code *makeVariableCode(char *var, char prefix, FileLine line, FilePath path);
  14. af_Code *makeBlockCode(enum af_BlockType type, af_Code *element, char prefix, FileLine line, FilePath path, af_Code **next);
  15. /* 代码块释放函数 */
  16. bool freeCodeWithElement(af_Code *bt, af_Code **next);
  17. void freeAllCode(af_Code *bt);
  18. /* 代码块操作函数 */
  19. af_Code *connectCode(af_Code **base, af_Code *next);
  20. af_Code *copyCode(af_Code *base, FilePath *path);
  21. /* 代码块属性获取函数 */
  22. bool getCodeBlockNext(af_Code *bt, af_Code **next);
  23. void printCode(af_Code *bt);
  24. /* 代码块IO函数 */
  25. bool writeAllCode(af_Code *bt, FILE *file);
  26. bool readAllCode(af_Code **bt, FILE *file);
  27. #endif //AFUN__BYTECODE_H_PUBLIC