code.h 1009 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef AFUN__BYTECODE_H_PUBLIC
  2. #define AFUN__BYTECODE_H_PUBLIC
  3. #include <stdio.h>
  4. #define CODE_STR_MAX_SIZE (50)
  5. typedef struct af_Code af_Code;
  6. /* 括号类型 */
  7. enum af_BlockType {
  8. parentheses = 0, // 小括号
  9. brackets, // 中括号
  10. curly, // 大括号
  11. };
  12. /* 代码块创建函数 */
  13. af_Code *makeElementCode(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. void freeAllCode(af_Code *bt);
  17. /* 代码块操作函数 */
  18. af_Code *connectCode(af_Code **base, af_Code *next);
  19. af_Code *copyCode(af_Code *base, FilePath *path);
  20. /* 代码块属性获取函数 */
  21. bool getCodeBlockNext(af_Code *bt, af_Code **next);
  22. void printCode(af_Code *bt);
  23. char *codeToStr(af_Code *code, int n);
  24. /* 代码块IO函数 */
  25. bool writeAllCode(af_Code *bt, FILE *file);
  26. bool readAllCode(af_Code **bt, FILE *file);
  27. #endif //AFUN__BYTECODE_H_PUBLIC