aboutsummaryrefslogtreecommitdiff
path: root/development/kforth/ForthVM.diff
diff options
context:
space:
mode:
authorG. Schoenmakers <gschoen@iinet.net.au>2013-02-23 23:00:15 -0600
committerRobby Workman <rworkman@slackbuilds.org>2013-02-23 23:00:15 -0600
commitd34c34353b70a31ab7756d48a4e9fad87eb5d56c (patch)
tree79784551730938410a5e429e9962fa021c55827e /development/kforth/ForthVM.diff
parent86ef446c7f9f2b8ae76917b6837f2ec9dcec28a0 (diff)
development/kforth: Added (A Forth programming language and environment)
Signed-off-by: Robby Workman <rworkman@slackbuilds.org>
Diffstat (limited to 'development/kforth/ForthVM.diff')
-rw-r--r--development/kforth/ForthVM.diff78
1 files changed, 78 insertions, 0 deletions
diff --git a/development/kforth/ForthVM.diff b/development/kforth/ForthVM.diff
new file mode 100644
index 0000000000000..494b515fc4bb6
--- /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 <string.h>
+ #include <stdlib.h>
+@@ -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);