func.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #include "aFunCoreExport.h"
  8. #include "code.h"
  9. #include "object.h"
  10. enum af_FuncInfoScope {
  11. normal_scope = 0,
  12. inline_scope,
  13. pure_scope,
  14. super_pure_scope,
  15. };
  16. enum af_FuncInfoEmbedded {
  17. not_embedded = 0,
  18. protect_embedded, // 内嵌函数
  19. super_embedded, // 超内嵌函数
  20. };
  21. typedef struct af_FuncBody *callFuncBody(void *make, af_Environment *env);
  22. DEFINE_DLC_SYMBOL(callFuncBody);
  23. /* af_ArgCodeList 创建与释放 */
  24. AFUN_CORE_EXPORT af_ArgCodeList *makeArgCodeList(af_Code *code, size_t size, bool free_code, bool run_in_func);
  25. AFUN_CORE_EXPORT af_ArgCodeList *freeArgCodeList(af_ArgCodeList *acl);
  26. AFUN_CORE_EXPORT void freeAllArgCodeList(af_ArgCodeList *acl);
  27. /* af_ArgCodeList 操作函数 */
  28. AFUN_CORE_EXPORT af_ArgCodeList **pushArgCodeList(af_ArgCodeList **base, af_ArgCodeList *new);
  29. AFUN_CORE_EXPORT af_ArgCodeList **pushNewArgCodeList(af_ArgCodeList **base, af_Code *code, size_t size, bool free_code,
  30. bool run_in_func);
  31. AFUN_CORE_EXPORT void *getArgCodeListData(af_ArgCodeList *acl);
  32. AFUN_CORE_EXPORT af_Object *getArgCodeListResult(af_ArgCodeList *acl);
  33. /* af_ArgList 创建与释放 */
  34. AFUN_CORE_EXPORT af_ArgList *makeArgList(char *name, af_Object *obj);
  35. AFUN_CORE_EXPORT af_ArgList *freeArgList(af_ArgList *al);
  36. AFUN_CORE_EXPORT void freeAllArgList(af_ArgList *al);
  37. /* af_ArgList 操作函数 */
  38. AFUN_CORE_EXPORT af_ArgList **pushArgList(af_ArgList **base, af_ArgList *new);
  39. AFUN_CORE_EXPORT af_ArgList **pushNewArgList(af_ArgList **base, char *name, af_Object *obj);
  40. AFUN_CORE_EXPORT bool runArgList(af_ArgList *al, af_VarSpaceListNode *vsl, af_Environment *env);
  41. /* FuncBody 创建与释放 */
  42. AFUN_CORE_EXPORT af_FuncBody *makeCodeFuncBody(af_Code *code, bool free_code, char **msg_type);
  43. AFUN_CORE_EXPORT af_FuncBody *makeCFuncBody(DLC_SYMBOL(callFuncBody) c_func, char **msg_type);
  44. AFUN_CORE_EXPORT af_FuncBody *makeDynamicFuncBody(void);
  45. AFUN_CORE_EXPORT af_FuncBody *freeFuncBody(af_FuncBody *fb);
  46. AFUN_CORE_EXPORT void freeAllFuncBody(af_FuncBody *fb);
  47. /* FuncInfo 创建与释放 */
  48. AFUN_CORE_EXPORT af_FuncInfo *makeFuncInfo(enum af_FuncInfoScope scope, enum af_FuncInfoEmbedded embedded,
  49. bool is_macro, bool var_this, bool var_func);
  50. AFUN_CORE_EXPORT void freeFuncInfo(af_FuncInfo *fi);
  51. /* FuncInfo 操作函数 */
  52. AFUN_CORE_EXPORT void makeCFuncBodyToFuncInfo(DLC_SYMBOL(callFuncBody) c_func, char **msg_type, af_FuncInfo *fi);
  53. AFUN_CORE_EXPORT void makeCodeFuncBodyToFuncInfo(af_Code *code, bool free_code, char **msg_type, af_FuncInfo *fi);
  54. AFUN_CORE_EXPORT void makeDynamicFuncBodyToFuncInfo(af_FuncInfo *fi);
  55. #endif //AFUN_FUNC