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 677B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef L2_VM_H
  2. #define L2_VM_H
  3. #include <stdlib.h>
  4. #include "../bytecode.h"
  5. enum {
  6. L2_VAL_TYPE_STRING = (1 << 30) + 0,
  7. L2_VAL_TYPE_ARRAY = (1 << 30) + 1,
  8. L2_VAL_MARKED = 1 << 29,
  9. };
  10. struct l2_vm_value {
  11. l2_word flags;
  12. };
  13. struct l2_vm_string {
  14. struct l2_vm_value val;
  15. char *mem;
  16. size_t len;
  17. };
  18. struct l2_vm_array {
  19. struct l2_vm_value val;
  20. l2_word *data;
  21. size_t len;
  22. size_t size;
  23. };
  24. struct l2_vm {
  25. struct l2_op *ops;
  26. size_t opcount;
  27. struct l2_vm_value *allocs[1024];
  28. size_t allocslen;
  29. l2_word stack[1024];
  30. l2_word iptr;
  31. l2_word sptr;
  32. };
  33. void l2_vm_init(struct l2_vm *vm, struct l2_op *ops, size_t opcount);
  34. void l2_vm_step(struct l2_vm *vm);
  35. #endif