ForthVM.diff 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. Index: ForthVM.cpp
  2. ===================================================================
  3. --- ForthVM.cpp (revision 7)
  4. +++ ForthVM.cpp (working copy)
  5. @@ -155,6 +155,14 @@
  6. // PUSH_IVAL and PUSH_ADDR
  7. // 2011-02-06 km fixed problem with FS. not restoring original precision.
  8. // 2011-03-05 km removed commented out code which was replaced by macros.
  9. +// 2011-03-10 km added global string dir_env_var to allow default directory
  10. +// environment variable to be specified externally, in the
  11. +// Makefile.
  12. +// 2011-11-01 km revised CPP_allot to ensure all created words which have
  13. +// ALLOTed memory also have appropriate execution code;
  14. +// This change also allows removal of common code from
  15. +// CPP_variable and CPP_fvariable.
  16. +const char* dir_env_var=DIR_ENV_VAR;
  17. #include <string.h>
  18. #include <stdlib.h>
  19. @@ -1550,6 +1558,13 @@
  20. {
  21. id->Pfa = new byte[n];
  22. if (id->Pfa) memset (id->Pfa, 0, n);
  23. +
  24. + // Provide execution code to the word to return its Pfa
  25. + byte *bp = new byte[6];
  26. + id->Cfa = bp;
  27. + bp[0] = OP_ADDR;
  28. + *((int*) &bp[1]) = (int) id->Pfa;
  29. + bp[5] = OP_RET;
  30. }
  31. else
  32. return E_V_REALLOT;
  33. @@ -1642,14 +1657,7 @@
  34. DEC_DSP
  35. STD_IVAL
  36. int e = CPP_allot();
  37. - if (e) return e;
  38. - WordIndex id = pCompilationWL->end() - 1;
  39. - byte *bp = new byte[6];
  40. - id->Cfa = bp;
  41. - bp[0] = OP_ADDR;
  42. - *((int*) &bp[1]) = (int) id->Pfa;
  43. - bp[5] = OP_RET;
  44. - return 0;
  45. + return e;
  46. }
  47. //-----------------------------------------------------------------
  48. @@ -1662,14 +1670,7 @@
  49. DEC_DSP
  50. STD_IVAL
  51. int e = CPP_allot();
  52. - if (e) return e;
  53. - WordIndex id = pCompilationWL->end() - 1;
  54. - byte *bp = new byte[6];
  55. - id->Cfa = bp;
  56. - bp[0] = OP_ADDR;
  57. - *((int*) &bp[1]) = (int) id->Pfa;
  58. - bp[5] = OP_RET;
  59. - return 0;
  60. + return e;
  61. }
  62. //------------------------------------------------------------------
  63. @@ -2464,10 +2465,10 @@
  64. ifstream f(filename);
  65. if (!f)
  66. {
  67. - if (getenv("KFORTH_DIR"))
  68. + if (getenv(dir_env_var))
  69. {
  70. char temp[256];
  71. - strcpy(temp, getenv("KFORTH_DIR"));
  72. + strcpy(temp, getenv(dir_env_var));
  73. strcat(temp, "/");
  74. strcat(temp, filename);
  75. strcpy(filename, temp);