Functions.h 1011 B

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