You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vm.h 769B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef L2_VM_H
  2. #define L2_VM_H
  3. #include <stdlib.h>
  4. #include "bytecode.h"
  5. #include "bitset.h"
  6. struct l2_vm_value {
  7. enum l2_value_flags {
  8. L2_VAL_TYPE_INTEGER,
  9. L2_VAL_TYPE_REAL,
  10. L2_VAL_TYPE_STRING,
  11. L2_VAL_TYPE_ARRAY,
  12. L2_VAL_MARKED = 1 << 7,
  13. } flags;
  14. union {
  15. int64_t integer;
  16. double real;
  17. void *data;
  18. };
  19. };
  20. struct l2_vm_string {
  21. struct l2_vm_value val;
  22. size_t len;
  23. };
  24. struct l2_vm_array {
  25. struct l2_vm_value val;
  26. size_t len;
  27. size_t size;
  28. };
  29. struct l2_vm {
  30. struct l2_op *ops;
  31. size_t opcount;
  32. struct l2_vm_value *values;
  33. size_t valuessize;
  34. struct l2_bitset valueset;
  35. l2_word stack[1024];
  36. l2_word iptr;
  37. l2_word sptr;
  38. };
  39. void l2_vm_init(struct l2_vm *vm, struct l2_op *ops, size_t opcount);
  40. void l2_vm_step(struct l2_vm *vm);
  41. #endif