2
0

func.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef AFUN_FUNC
  2. #define AFUN_FUNC
  3. typedef struct af_ArgCodeList af_ArgCodeList;
  4. typedef struct af_ArgList af_ArgList;
  5. typedef struct af_FuncInfo af_FuncInfo;
  6. typedef struct af_FuncBody af_FuncBody;
  7. enum af_FuncInfoScope {
  8. normal_scope = 0,
  9. inline_scope,
  10. pure_scope,
  11. super_pure_scope,
  12. };
  13. enum af_FuncInfoEmbedded {
  14. not_embedded = 0,
  15. protect_embedded, // 内嵌函数
  16. super_embedded, // 超内嵌函数
  17. };
  18. #include "aFunCoreExport.h"
  19. #include "code.h"
  20. #include "object.h"
  21. typedef struct af_CallFuncInfo af_CallFuncInfo;
  22. struct af_CallFuncInfo {
  23. void *mark;
  24. af_FuncBody *body_next;
  25. af_Object *belong;
  26. af_Object *func;
  27. struct af_VarSpaceListNode *var_list;
  28. enum af_BlockType call_type;
  29. bool is_gc_call;
  30. bool is_literal;
  31. bool is_obj_func;
  32. bool is_macro_call;
  33. };
  34. typedef struct af_FuncBody *callFuncBody(af_CallFuncInfo *info, af_Environment *env);
  35. NEW_DLC_SYMBOL(callFuncBody, callFuncBody);
  36. /* af_ArgCodeList 创建与释放 */
  37. AFUN_CORE_EXPORT af_ArgCodeList *makeArgCodeList(af_Code *code, size_t size, bool free_code, bool run_in_func);
  38. AFUN_CORE_EXPORT void freeAllArgCodeList(af_ArgCodeList *acl);
  39. /* af_ArgList 创建与释放 */
  40. AFUN_CORE_EXPORT af_ArgList *makeArgList(char *name, af_Object *obj);
  41. AFUN_CORE_EXPORT void freeAllArgList(af_ArgList *al);
  42. /* FuncBody 创建与释放 */
  43. AFUN_CORE_EXPORT af_FuncBody *makeCodeFuncBody(af_Code *code, bool free_code, char **msg_type);
  44. AFUN_CORE_EXPORT af_FuncBody *makeImportFuncBody(af_Code *code, bool free_code, char **msg_type);
  45. AFUN_CORE_EXPORT af_FuncBody *makeCFuncBody(DLC_SYMBOL(callFuncBody) c_func, char **msg_type);
  46. AFUN_CORE_EXPORT af_FuncBody *makeDynamicFuncBody(void);
  47. AFUN_CORE_EXPORT af_FuncBody *freeFuncBody(af_FuncBody *fb);
  48. AFUN_CORE_EXPORT void freeAllFuncBody(af_FuncBody *fb);
  49. /* FuncInfo 创建与释放 */
  50. AFUN_CORE_EXPORT af_FuncInfo *makeFuncInfo(enum af_FuncInfoScope scope, enum af_FuncInfoEmbedded embedded,
  51. bool is_macro, bool var_this, bool var_func);
  52. AFUN_CORE_EXPORT void freeFuncInfo(af_FuncInfo *fi);
  53. /* af_ArgCodeList 相关操作 */
  54. AFUN_CORE_EXPORT af_ArgCodeList **pushArgCodeList(af_ArgCodeList **base, af_ArgCodeList *new);
  55. /* af_ArgList 相关操作 */
  56. AFUN_CORE_EXPORT af_ArgList **pushArgList(af_ArgList **base, af_ArgList *new);
  57. /* af_FuncBody 相关操作 */
  58. AFUN_CORE_EXPORT void pushFuncBody(af_FuncBody **base, af_FuncBody *body);
  59. /* FuncInfo 相关操作 */
  60. AFUN_CORE_EXPORT void makeCFuncBodyToFuncInfo(DLC_SYMBOL(callFuncBody) c_func, char **msg_type, af_FuncInfo *fi);
  61. AFUN_CORE_EXPORT void makeCodeFuncBodyToFuncInfo(af_Code *code, bool free_code, char **msg_type, af_FuncInfo *fi);
  62. AFUN_CORE_EXPORT void makeImportFuncBodyToFuncInfo(af_Code *code, bool free_code, char **msg_type, af_FuncInfo *fi);
  63. AFUN_CORE_EXPORT void makeDynamicFuncBodyToFuncInfo(af_FuncInfo *fi);
  64. /* af_ArgCodeList 属性获取 */
  65. AFUN_CORE_EXPORT void *getArgCodeListData(af_ArgCodeList *acl);
  66. AFUN_CORE_EXPORT af_Object *getArgCodeListResult(af_ArgCodeList *acl);
  67. af_ArgCodeList *getArgCodeListNext(af_ArgCodeList *acl);
  68. bool getArgCodeListRunInFunc(af_ArgCodeList *acl);
  69. /* af_ArgList 属性获取 */
  70. af_ArgList *getArgListNext(af_ArgList *al);
  71. #endif //AFUN_FUNC