slackbuilds_ponce/development/kforth/ForthVM.diff

79 lines
2.2 KiB
Diff
Raw Normal View History

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);