From d34c34353b70a31ab7756d48a4e9fad87eb5d56c Mon Sep 17 00:00:00 2001 From: "G. Schoenmakers" Date: Sat, 23 Feb 2013 23:00:15 -0600 Subject: development/kforth: Added (A Forth programming language and environment) Signed-off-by: Robby Workman --- development/kforth/ForthVM.diff | 78 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 development/kforth/ForthVM.diff (limited to 'development/kforth/ForthVM.diff') diff --git a/development/kforth/ForthVM.diff b/development/kforth/ForthVM.diff new file mode 100644 index 0000000000..494b515fc4 --- /dev/null +++ b/development/kforth/ForthVM.diff @@ -0,0 +1,78 @@ +Index: ForthVM.cpp +=================================================================== +--- ForthVM.cpp (revision 7) ++++ ForthVM.cpp (working copy) +@@ -155,6 +155,14 @@ + // PUSH_IVAL and PUSH_ADDR + // 2011-02-06 km fixed problem with FS. not restoring original precision. + // 2011-03-05 km removed commented out code which was replaced by macros. ++// 2011-03-10 km added global string dir_env_var to allow default directory ++// environment variable to be specified externally, in the ++// Makefile. ++// 2011-11-01 km revised CPP_allot to ensure all created words which have ++// ALLOTed memory also have appropriate execution code; ++// This change also allows removal of common code from ++// CPP_variable and CPP_fvariable. ++const char* dir_env_var=DIR_ENV_VAR; + + #include + #include +@@ -1550,6 +1558,13 @@ + { + id->Pfa = new byte[n]; + if (id->Pfa) memset (id->Pfa, 0, n); ++ ++ // Provide execution code to the word to return its Pfa ++ byte *bp = new byte[6]; ++ id->Cfa = bp; ++ bp[0] = OP_ADDR; ++ *((int*) &bp[1]) = (int) id->Pfa; ++ bp[5] = OP_RET; + } + else + return E_V_REALLOT; +@@ -1642,14 +1657,7 @@ + DEC_DSP + STD_IVAL + int e = CPP_allot(); +- if (e) return e; +- WordIndex id = pCompilationWL->end() - 1; +- byte *bp = new byte[6]; +- id->Cfa = bp; +- bp[0] = OP_ADDR; +- *((int*) &bp[1]) = (int) id->Pfa; +- bp[5] = OP_RET; +- return 0; ++ return e; + } + //----------------------------------------------------------------- + +@@ -1662,14 +1670,7 @@ + DEC_DSP + STD_IVAL + int e = CPP_allot(); +- if (e) return e; +- WordIndex id = pCompilationWL->end() - 1; +- byte *bp = new byte[6]; +- id->Cfa = bp; +- bp[0] = OP_ADDR; +- *((int*) &bp[1]) = (int) id->Pfa; +- bp[5] = OP_RET; +- return 0; ++ return e; + } + //------------------------------------------------------------------ + +@@ -2464,10 +2465,10 @@ + ifstream f(filename); + if (!f) + { +- if (getenv("KFORTH_DIR")) ++ if (getenv(dir_env_var)) + { + char temp[256]; +- strcpy(temp, getenv("KFORTH_DIR")); ++ strcpy(temp, getenv(dir_env_var)); + strcat(temp, "/"); + strcat(temp, filename); + strcpy(filename, temp); -- cgit v1.2.3