func.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.hpp"
  20. #include "object.hpp"
  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_VarList *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, af_Environment *env);
  39. /* af_ArgList 创建与释放 */
  40. AFUN_CORE_EXPORT af_ArgList *makeArgList(char *name, af_Object *obj);
  41. AFUN_CORE_EXPORT void freeAllArgList(af_ArgList *al, af_Environment *env);
  42. AFUN_CORE_EXPORT af_ArgList *makeArgListFromArgCodeList(const char *name, af_ArgCodeList *acl, af_Environment *env);
  43. /* FuncBody 创建与释放 */
  44. AFUN_CORE_EXPORT af_FuncBody *makeCodeFuncBody(af_Code *code, bool free_code, char **msg_type);
  45. AFUN_CORE_EXPORT af_FuncBody *makeImportFuncBody(af_Code *code, bool free_code, char **msg_type);
  46. AFUN_CORE_EXPORT af_FuncBody *makeCFuncBody(DLC_SYMBOL(callFuncBody) c_func, char **msg_type);
  47. AFUN_CORE_EXPORT af_FuncBody *makeDynamicFuncBody();
  48. AFUN_CORE_EXPORT af_FuncBody *freeFuncBody(af_FuncBody *fb);
  49. AFUN_CORE_EXPORT void freeAllFuncBody(af_FuncBody *fb);
  50. /* FuncInfo 创建与释放 */
  51. AFUN_CORE_EXPORT af_FuncInfo *makeFuncInfo(enum af_FuncInfoScope scope, enum af_FuncInfoEmbedded embedded,
  52. bool is_macro, bool var_this, bool var_func);
  53. AFUN_CORE_EXPORT void freeFuncInfo(af_FuncInfo *fi);
  54. /* af_ArgCodeList 相关操作 */
  55. AFUN_CORE_EXPORT af_ArgCodeList **pushArgCodeList(af_ArgCodeList **base, af_ArgCodeList *new_acl);
  56. /* af_ArgList 相关操作 */
  57. AFUN_CORE_EXPORT af_ArgList **pushArgList(af_ArgList **base, af_ArgList *new_al);
  58. /* af_FuncBody 相关操作 */
  59. AFUN_CORE_EXPORT void pushFuncBody(af_FuncBody **base, af_FuncBody *body);
  60. /* FuncInfo 相关操作 */
  61. AFUN_CORE_EXPORT af_FuncBody *makeCFuncBodyToFuncInfo(DLC_SYMBOL(callFuncBody) c_func, char **msg_type, af_FuncInfo *fi);
  62. AFUN_CORE_EXPORT af_FuncBody *makeCodeFuncBodyToFuncInfo(af_Code *code, bool free_code, char **msg_type, af_FuncInfo *fi);
  63. AFUN_CORE_EXPORT af_FuncBody *makeImportFuncBodyToFuncInfo(af_Code *code, bool free_code, char **msg_type, af_FuncInfo *fi);
  64. AFUN_CORE_EXPORT af_FuncBody *makeDynamicFuncBodyToFuncInfo(af_FuncInfo *fi);
  65. /* af_ArgCodeList 属性获取 */
  66. AFUN_CORE_EXPORT void *getArgCodeListData(af_ArgCodeList *acl);
  67. AFUN_CORE_EXPORT af_Object *getArgCodeListResult(af_ArgCodeList *acl);
  68. af_ArgCodeList *getArgCodeListNext(af_ArgCodeList *acl);
  69. bool getArgCodeListRunInFunc(af_ArgCodeList *acl);
  70. /* af_ArgList 属性获取 */
  71. af_ArgList *getArgListNext(af_ArgList *al);
  72. #endif //AFUN_FUNC