Functions.h 946 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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);
  29. void fsAdd(Functions* fs, Function* f);
  30. void gfInit(Function* f, const char* name, DataType r, ScriptFunction sf);
  31. void gfsInit();
  32. bool gfsAdd(Function* f);
  33. bool gfsCall(Script* sc, int id);
  34. void gfsDelete();
  35. #endif