Script.h 856 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef SCRIPT_H
  2. #define SCRIPT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <stdbool.h>
  7. #include "vm/Arrays.h"
  8. #include "vm/ByteCode.h"
  9. #define SCRIPT_STACK_SIZE 1000
  10. #define SCRIPT_ERROR_SIZE 256
  11. typedef struct {
  12. char error[SCRIPT_ERROR_SIZE];
  13. ByteCode* code;
  14. int readIndex;
  15. Value stack[SCRIPT_STACK_SIZE];
  16. int stackIndex;
  17. int stackVarIndex;
  18. int line;
  19. SnuviArrays arrays;
  20. } Script;
  21. Script* sInit(ByteCode* code);
  22. void sDelete(Script* sc);
  23. void sRun(Script* sc);
  24. check_format(2, 3) void sError(Script* sc, const char* format, ...);
  25. bool sPopInt32(Script* sc, int32* i);
  26. bool sPushInt32(Script* sc, int32 i);
  27. bool sPopFloat(Script* sc, float* f);
  28. bool sPushFloat(Script* sc, float f);
  29. SnuviArray* sGetArray(Script* sc);
  30. Value* sPopStructPointer(Script* sc, ValueType type);
  31. #ifdef __cplusplus
  32. }
  33. #endif
  34. #endif