Script.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. char 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. void sError(Script* sc, const char* format, ...);
  25. bool sPopInt32(Script* sc, int32* i);
  26. bool sPushInt32(Script* sc, int32 i);
  27. bool sPopInt64(Script* sc, int64* i);
  28. bool sPushInt64(Script* sc, int64 i);
  29. bool sPopFloat(Script* sc, float* f);
  30. bool sPushFloat(Script* sc, float f);
  31. bool sPopBool(Script* sc, bool* b);
  32. bool sPushBool(Script* sc, bool b);
  33. bool sPopPointer(Script* sc, Pointer* p);
  34. bool sPushPointer(Script* sc, Pointer* p);
  35. bool sPushNullPointer(Script* sc);
  36. void* sCheckAddress(Script* sc, Pointer* p, int length);
  37. bool sGetPointerLength(Script* sc, Pointer* p, int32* length);
  38. #ifdef __cplusplus
  39. }
  40. #endif
  41. #endif