Script.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef SCRIPT_H
  2. #define SCRIPT_H
  3. #include <stdbool.h>
  4. #include "vm/Arrays.h"
  5. #include "vm/ByteCode.h"
  6. #define SCRIPT_STACK_SIZE 1000
  7. #define SCRIPT_ERROR_SIZE 256
  8. typedef struct {
  9. char error[SCRIPT_ERROR_SIZE];
  10. ByteCode* code;
  11. int readIndex;
  12. char stack[SCRIPT_STACK_SIZE];
  13. int stackIndex;
  14. int stackVarIndex;
  15. int line;
  16. Arrays arrays;
  17. } Script;
  18. Script* sInit(ByteCode* code);
  19. void sDelete(Script* sc);
  20. void sRun(Script* sc);
  21. void sError(Script* sc, const char* format, ...);
  22. bool sPopInt(Script* sc, int* i);
  23. bool sPushInt(Script* sc, int i);
  24. bool sPopLong(Script* sc, long* l);
  25. bool sPushLong(Script* sc, long l);
  26. bool sPopFloat(Script* sc, float* f);
  27. bool sPushFloat(Script* sc, float f);
  28. bool sPopBool(Script* sc, bool* b);
  29. bool sPushBool(Script* sc, bool b);
  30. typedef void (*IntPrinter)(int);
  31. void sSetIntPrinter(IntPrinter p);
  32. typedef void (*LongPrinter)(long);
  33. void sSetLongPrinter(LongPrinter p);
  34. typedef void (*FloatPrinter)(float);
  35. void sSetFloatPrinter(FloatPrinter p);
  36. typedef void (*BoolPrinter)(bool);
  37. void sSetBoolPrinter(BoolPrinter p);
  38. typedef void (*PointerPrinter)(Pointer*);
  39. void sSetPointerPrinter(PointerPrinter p);
  40. #endif