Script.h 638 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef SCRIPT_H
  2. #define SCRIPT_H
  3. #include <stdbool.h>
  4. #include "vm/Allocator.h"
  5. #include "vm/ByteCode.h"
  6. #include "vm/Object.h"
  7. #define SCRIPT_STACK_SIZE 1000
  8. #define SCRIPT_ERROR_SIZE 256
  9. typedef struct {
  10. char error[SCRIPT_ERROR_SIZE];
  11. ByteCode* code;
  12. int readIndex;
  13. Object returnValue;
  14. Object stack[SCRIPT_STACK_SIZE];
  15. int stackIndex;
  16. int stackVarIndex;
  17. int line;
  18. Allocator allocator;
  19. } Script;
  20. Script* sInit(ByteCode* code);
  21. void sDelete(Script* sc);
  22. void sRun(Script* sc);
  23. typedef bool (*ObjectPrinter)(Object*);
  24. void sSetPrinter(ObjectPrinter p);
  25. void sCollectGarbage(Script* sc);
  26. #endif