Script.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. SnuviArrays 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 sPopInt32(Script* sc, int32* i);
  23. bool sPushInt32(Script* sc, int32 i);
  24. bool sPopInt64(Script* sc, int64* i);
  25. bool sPushInt64(Script* sc, int64 i);
  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. bool sPopPointer(Script* sc, Pointer* p);
  31. bool sPushPointer(Script* sc, Pointer* p);
  32. bool sPushNullPointer(Script* sc);
  33. void* sCheckAddress(Script* sc, Pointer* p, int length);
  34. bool sGetPointerLength(Script* sc, Pointer* p, int32* length);
  35. #endif