__func.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef AFUN_FUNC_H_
  2. #define AFUN_FUNC_H_
  3. #include "tool.hpp"
  4. #include "func.hpp"
  5. #include "__object.hpp"
  6. #include "__code.hpp"
  7. struct af_ArgCodeList {
  8. void *info; // info信息
  9. size_t size;
  10. struct af_Code *code;
  11. bool free_code; // code 是否释放
  12. bool run_in_func; // 是否在函数的变量空间内运行
  13. struct af_Object *result; // 有gc引用计数
  14. struct af_ArgCodeList *next;
  15. };
  16. struct af_ArgList {
  17. char *name;
  18. struct af_Object *obj; // 有gc引用计数
  19. struct af_ArgList *next;
  20. };
  21. enum af_FuncBodyType {
  22. func_body_c = 0, // 回调C函数
  23. func_body_code, // 执行af_Code
  24. func_body_import, // import内容
  25. func_body_dynamic,
  26. };
  27. struct af_FuncBody {
  28. enum af_FuncBodyType type;
  29. union {
  30. DLC_SYMBOL(callFuncBody) c_func;
  31. struct {
  32. af_Code *code;
  33. bool free_code;
  34. };
  35. };
  36. char **msg_type; // 表示对应函数可以处理的msg类型
  37. struct af_FuncBody *next;
  38. };
  39. struct af_FuncInfo {
  40. // 函数属性
  41. enum af_FuncInfoScope scope; // 定义在 func.h
  42. enum af_FuncInfoEmbedded embedded; // 定义在 func.h
  43. bool is_macro; // 宏函数
  44. bool var_this; // 是否写入self参数
  45. bool var_func; // 是否写入func参数
  46. // 函数信息
  47. struct af_FuncBody *body;
  48. };
  49. /* FuncInfo 相关操作 */
  50. AFUN_CORE_NO_EXPORT bool pushDynamicFuncBody(af_FuncBody *new_fb, af_FuncBody *body);
  51. /* ArgList 相关操作 */
  52. AFUN_CORE_NO_EXPORT bool runArgList(af_ArgList *al, af_VarList *vsl, af_Environment *env);
  53. #endif //AFUN_FUNC_H_