globals.c 718 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include "globals.h"
  4. #include "tags.h"
  5. #include "headers.h"
  6. scm vm_reg_ret;
  7. scm vm_reg_env;
  8. scm vm_globals[VM_GLOBALS_SIZE];
  9. scm vm_global_ref(scm idx) {
  10. if((0 <= idx) && (idx < VM_GLOBALS_SIZE)) {
  11. return vm_globals[idx];
  12. }
  13. else {
  14. fprintf(stderr, "global ref index out of range %ld\n", idx);
  15. exit(-1);
  16. }
  17. }
  18. int max_glob = 0;
  19. void vm_set_global(scm idx, scm obj) {
  20. if((0 <= idx) && (idx < VM_GLOBALS_SIZE)) {
  21. /*
  22. if(idx > max_glob) {
  23. max_glob = idx;
  24. fprintf(stderr, "MAX GLOBAL %d\n", max_glob);
  25. }
  26. */
  27. vm_globals[idx] = obj;
  28. }
  29. else {
  30. fprintf(stderr, "set global index out of range %ld\n", idx);
  31. exit(-1);
  32. }
  33. }