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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef VM_H
  2. #define VM_H
  3. #include <stdint.h>
  4. typedef enum vm_type
  5. {
  6. VM_TYPE_FUNCTION,
  7. VM_TYPE_INTEGER,
  8. VM_TYPE_STRING,
  9. VM_TYPE_ARRAY,
  10. VM_TYPE_ERROR,
  11. VM_TYPE_NULL,
  12. } vm_type;
  13. typedef struct vm_var
  14. {
  15. vm_type type;
  16. int isNull;
  17. int nullable;
  18. union
  19. {
  20. char* function;
  21. int32_t integer;
  22. char* string;
  23. struct vm_var* array;
  24. struct
  25. {
  26. char* msg;
  27. char* code;
  28. } error;
  29. } data;
  30. } vm_var;
  31. typedef struct vm
  32. {
  33. vm_var* vars;
  34. size_t numvars;
  35. } vm;
  36. //Initiate a VM
  37. vm* vm_create();
  38. //Execute
  39. vm_var* vm_exec();
  40. //Functions to create a variable
  41. vm_var* vm_var_create_function(char* function, int nullable);
  42. vm_var* vm_var_create_integer(int32_t integer, int nullable);
  43. vm_var* vm_var_create_string(char* string, int nullable);
  44. vm_var* vm_var_create_array(vm_var* array, int nullable);
  45. vm_var* vm_var_create_error(char* msg, char* code, int nullable);
  46. vm_var* vm_var_create_null();
  47. #endif