Functions.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef FUNCTIONS_H
  2. #define FUNCTIONS_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdbool.h>
  7. #include "DataType.h"
  8. #include "vm/Script.h"
  9. #define FUNCTION_ARGUMENTS 9
  10. typedef void (*ScriptFunction)(Script*);
  11. typedef struct {
  12. const char* name;
  13. int arguments;
  14. DataType argumentTypes[FUNCTION_ARGUMENTS];
  15. DataType returnType;
  16. int address;
  17. int size;
  18. int line;
  19. bool global;
  20. ScriptFunction scriptFunction;
  21. } Function;
  22. typedef struct {
  23. int capacity;
  24. int entries;
  25. Function* data;
  26. } Functions;
  27. void fInit(Function* f, const char* name, int line);
  28. bool fAddArgument(Function* f, DataType type, Structs* sts);
  29. void fsInit(Functions* fs);
  30. void fsDelete(Functions* fs);
  31. Function* fsSearch(Functions* fs, Function* f, bool constMatch);
  32. void fsAdd(Functions* fs, Function* f);
  33. void gfInit(Function* f, const char* name, DataType r, ScriptFunction sf);
  34. bool gfAddArgument(Function* f, DataType type);
  35. void gfsInit();
  36. bool gfsAdd(Function* f);
  37. bool gfsCall(Script* sc, int id);
  38. void gfsDelete();
  39. #ifdef __cplusplus
  40. }
  41. #endif
  42. #endif