__code.h 844 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * 文件名: __bytecode.h
  3. * 目标: 定义Code结构体
  4. */
  5. #ifndef AFUN__BYTECODE_H
  6. #define AFUN__BYTECODE_H
  7. #include "macro.h"
  8. #include "code.h"
  9. typedef unsigned int CodeUint; // Code uint
  10. enum af_CodeType {
  11. literal = 0,
  12. variable,
  13. block, // 括号
  14. };
  15. struct af_Code { // 一个 Code 的结构体
  16. enum af_CodeType type;
  17. char prefix; // 前缀
  18. union {
  19. struct {
  20. char *literal_data;
  21. char *func; // 函数名称
  22. } literal;
  23. struct {
  24. char *name;
  25. } variable;
  26. struct {
  27. CodeUint elements; // 元素个数
  28. enum af_BlockType type; // 括号类型
  29. } block;
  30. };
  31. FileLine line;
  32. FilePath path; // path == NULL表示沿用上层地址
  33. struct af_Code *next;
  34. };
  35. #endif //AFUN__BYTECODE_H