summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-11-08 09:08:20 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-11-08 09:08:20 -0600
commitd909d585495165363e6c6f5f45c2a7c37a1d6624 (patch)
treebd2329ba5dc98b92df572130e97b9bd11a03f047 /apps
parenta7e3a65762945732d33261865168b94aff97e126 (diff)
downloadnuttx-d909d585495165363e6c6f5f45c2a7c37a1d6624.tar.gz
nuttx-d909d585495165363e6c6f5f45c2a7c37a1d6624.tar.bz2
nuttx-d909d585495165363e6c6f5f45c2a7c37a1d6624.zip
BAS: Fix another case were allocated pointer not being nullified and, hence, crashing the next time referenced after restarting BAS. Also bring even more global varialbles and type names into NuttX coding standard
Diffstat (limited to 'apps')
-rw-r--r--apps/interpreters/bas/bas.c738
-rw-r--r--apps/interpreters/bas/fs.c32
-rw-r--r--apps/interpreters/bas/statement.c2194
3 files changed, 1485 insertions, 1479 deletions
diff --git a/apps/interpreters/bas/bas.c b/apps/interpreters/bas/bas.c
index fb7006a60..89b8716f9 100644
--- a/apps/interpreters/bas/bas.c
+++ b/apps/interpreters/bas/bas.c
@@ -90,14 +90,14 @@
* Pre-processor Definitions
****************************************************************************/
-#define DIRECTMODE (pc.line== -1)
+#define DIRECTMODE (g_pc.line== -1)
#define _(String) String
/****************************************************************************
* Private Types
****************************************************************************/
-enum LabelType
+enum labeltype_e
{
L_IF = 1,
L_ELSE,
@@ -113,9 +113,9 @@ enum LabelType
L_FUNC
};
-struct LabelStack
+struct labelstack_s
{
- enum LabelType type;
+ enum labeltype_e type;
struct Pc patch;
};
@@ -123,26 +123,27 @@ struct LabelStack
* Private Data
****************************************************************************/
-static unsigned int labelStackPointer, labelStackCapacity;
-static struct LabelStack *labelStack;
-static struct Pc *lastdata;
-static struct Pc curdata;
-static struct Pc nextdata;
+static unsigned int g_labelstack_index;
+static unsigned int g_labelstack_capacity;
+static struct labelstack_s *g_labelstack;
+static struct Pc *g_lastdata;
+static struct Pc g_curdata;
+static struct Pc g_nextdata;
static enum
{
DECLARE,
COMPILE,
INTERPRET
- } pass;
+ } g_pass;
-static int stopped;
+static int g_stopped;
static int optionbase;
-static struct Pc pc;
-static struct Auto stack;
-static struct Program program;
-static struct Global globals;
-static int run_restricted;
+static struct Pc g_pc;
+static struct Auto g_stack;
+static struct Program g_program;
+static struct Global g_globals;
+static int g_run_restricted;
/****************************************************************************
* Public Data
@@ -211,25 +212,25 @@ static int cat(const char *filename)
static struct Value *lvalue(struct Value *value)
{
struct Symbol *sym;
- struct Pc lvpc = pc;
+ struct Pc lvpc = g_pc;
- sym = pc.token->u.identifier->sym;
- assert(pass == DECLARE || sym->type == GLOBALVAR || sym->type == GLOBALARRAY
+ sym = g_pc.token->u.identifier->sym;
+ assert(g_pass == DECLARE || sym->type == GLOBALVAR || sym->type == GLOBALARRAY
|| sym->type == LOCALVAR);
- if ((pc.token + 1)->type == T_OP)
+ if ((g_pc.token + 1)->type == T_OP)
{
struct Pc idxpc;
unsigned int dim, capacity;
int *idx;
- pc.token += 2;
+ g_pc.token += 2;
dim = 0;
capacity = 0;
idx = (int *)0;
while (1)
{
- if (dim == capacity && pass == INTERPRET) /* enlarge idx */
+ if (dim == capacity && g_pass == INTERPRET) /* enlarge idx */
{
int *more;
@@ -247,7 +248,7 @@ static struct Value *lvalue(struct Value *value)
idx = more;
}
- idxpc = pc;
+ idxpc = g_pc;
if (eval(value, _("index"))->type == V_ERROR ||
VALUE_RETYPE(value, V_INTEGER)->type == V_ERROR)
{
@@ -256,20 +257,20 @@ static struct Value *lvalue(struct Value *value)
free(idx);
}
- pc = idxpc;
+ g_pc = idxpc;
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
idx[dim] = value->u.integer;
++dim;
}
Value_destroy(value);
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -277,24 +278,24 @@ static struct Value *lvalue(struct Value *value)
}
}
- if (pc.token->type != T_CP)
+ if (g_pc.token->type != T_CP)
{
- assert(pass != INTERPRET);
+ assert(g_pass != INTERPRET);
return Value_new_ERROR(value, MISSINGCP);
}
else
{
- ++pc.token;
+ ++g_pc.token;
}
- switch (pass)
+ switch (g_pass)
{
case INTERPRET:
{
if ((value =
Var_value(&(sym->u.var), dim, idx, value))->type == V_ERROR)
{
- pc = lvpc;
+ g_pc = lvpc;
}
free(idx);
@@ -310,7 +311,7 @@ static struct Value *lvalue(struct Value *value)
{
return Value_nullValue(sym->type ==
GLOBALARRAY ? sym->u.
- var.type : Auto_varType(&stack, sym));
+ var.type : Auto_varType(&g_stack, sym));
}
default:
@@ -321,12 +322,12 @@ static struct Value *lvalue(struct Value *value)
}
else
{
- ++pc.token;
- switch (pass)
+ ++g_pc.token;
+ switch (g_pass)
{
case INTERPRET:
return VAR_SCALAR_VALUE(sym->type ==
- GLOBALVAR ? &(sym->u.var) : Auto_local(&stack,
+ GLOBALVAR ? &(sym->u.var) : Auto_local(&g_stack,
sym->
u.local.offset));
@@ -336,7 +337,7 @@ static struct Value *lvalue(struct Value *value)
case COMPILE:
return Value_nullValue(sym->type ==
GLOBALVAR ? sym->u.
- var.type : Auto_varType(&stack, sym));
+ var.type : Auto_varType(&g_stack, sym));
default:
assert(0);
@@ -349,12 +350,12 @@ static struct Value *lvalue(struct Value *value)
static struct Value *func(struct Value *value)
{
struct Identifier *ident;
- struct Pc funcpc = pc;
+ struct Pc funcpc = g_pc;
int firstslot = -99;
int args = 0;
struct Symbol *sym;
- assert(pc.token->type == T_IDENTIFIER);
+ assert(g_pc.token->type == T_IDENTIFIER);
/* Evaluating a function in direct mode may start a program, so it needs to
* be compiled. If in direct mode, programs will be compiled after the
@@ -364,7 +365,7 @@ static struct Value *func(struct Value *value)
* this point, compile it again to get the error and abort.
*/
- if (DIRECTMODE && !program.runnable && pass != DECLARE)
+ if (DIRECTMODE && !g_program.runnable && g_pass != DECLARE)
{
if (compileProgram(value, 0)->type == V_ERROR)
{
@@ -374,29 +375,29 @@ static struct Value *func(struct Value *value)
Value_destroy(value);
}
- ident = pc.token->u.identifier;
- assert(pass == DECLARE || ident->sym->type == BUILTINFUNCTION ||
+ ident = g_pc.token->u.identifier;
+ assert(g_pass == DECLARE || ident->sym->type == BUILTINFUNCTION ||
ident->sym->type == USERFUNCTION);
- ++pc.token;
- if (pass != DECLARE)
+ ++g_pc.token;
+ if (g_pass != DECLARE)
{
- firstslot = stack.stackPointer;
+ firstslot = g_stack.stackPointer;
if (ident->sym->type == USERFUNCTION &&
ident->sym->u.sub.retType != V_VOID)
{
- struct Var *v = Auto_pushArg(&stack);
+ struct Var *v = Auto_pushArg(&g_stack);
Var_new(v, ident->sym->u.sub.retType, 0, (const unsigned int *)0, 0);
}
}
- if (pc.token->type == T_OP) /* push arguments to stack */
+ if (g_pc.token->type == T_OP) /* push arguments to stack */
{
- ++pc.token;
- if (pc.token->type != T_CP)
+ ++g_pc.token;
+ if (g_pc.token->type != T_CP)
{
while (1)
{
- if (pass == DECLARE)
+ if (g_pass == DECLARE)
{
if (eval(value, _("actual parameter"))->type == V_ERROR)
{
@@ -407,15 +408,15 @@ static struct Value *func(struct Value *value)
}
else
{
- struct Var *v = Auto_pushArg(&stack);
+ struct Var *v = Auto_pushArg(&g_stack);
Var_new_scalar(v);
if (eval(v->value, (const char *)0)->type == V_ERROR)
{
Value_clone(value, v->value);
- while (stack.stackPointer > firstslot)
+ while (g_stack.stackPointer > firstslot)
{
- Var_destroy(&stack.slot[--stack.stackPointer].var);
+ Var_destroy(&g_stack.slot[--g_stack.stackPointer].var);
}
return value;
@@ -425,9 +426,9 @@ static struct Value *func(struct Value *value)
}
++args;
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -435,24 +436,24 @@ static struct Value *func(struct Value *value)
}
}
- if (pc.token->type != T_CP)
+ if (g_pc.token->type != T_CP)
{
- if (pass != DECLARE)
+ if (g_pass != DECLARE)
{
- while (stack.stackPointer > firstslot)
+ while (g_stack.stackPointer > firstslot)
{
- Var_destroy(&stack.slot[--stack.stackPointer].var);
+ Var_destroy(&g_stack.slot[--g_stack.stackPointer].var);
}
}
return Value_new_ERROR(value, MISSINGCP);
}
- ++pc.token;
+ ++g_pc.token;
}
}
- if (pass == DECLARE)
+ if (g_pass == DECLARE)
{
Value_new_null(value, ident->defaultType);
}
@@ -463,24 +464,24 @@ static struct Value *func(struct Value *value)
int argerr;
int overloaded;
- if (pass == INTERPRET && ident->sym->type == USERFUNCTION)
+ if (g_pass == INTERPRET && ident->sym->type == USERFUNCTION)
{
for (i = 0; i < ident->sym->u.sub.u.def.localLength; ++i)
{
- struct Var *v = Auto_pushArg(&stack);
+ struct Var *v = Auto_pushArg(&g_stack);
Var_new(v, ident->sym->u.sub.u.def.localTypes[i], 0,
(const unsigned int *)0, 0);
}
}
- Auto_pushFuncRet(&stack, firstslot, &pc);
+ Auto_pushFuncRet(&g_stack, firstslot, &g_pc);
sym = ident->sym;
- overloaded = (pass == COMPILE && sym->type == BUILTINFUNCTION &&
+ overloaded = (g_pass == COMPILE && sym->type == BUILTINFUNCTION &&
sym->u.sub.u.bltin.next);
do
{
- nomore = (pass == COMPILE &&
+ nomore = (g_pass == COMPILE &&
!(sym->type == BUILTINFUNCTION && sym->u.sub.u.bltin.next));
argerr = 0;
if (args < sym->u.sub.argLength)
@@ -507,7 +508,7 @@ static struct Value *func(struct Value *value)
for (i = 0; i < args; ++i)
{
struct Value *arg =
- Var_value(Auto_local(&stack, i), 0, (int *)0, value);
+ Var_value(Auto_local(&g_stack, i), 0, (int *)0, value);
assert(arg->type != V_ERROR);
if (overloaded)
@@ -542,8 +543,8 @@ static struct Value *func(struct Value *value)
{
if (nomore)
{
- Auto_funcReturn(&stack, (struct Pc *)0);
- pc = funcpc;
+ Auto_funcReturn(&g_stack, (struct Pc *)0);
+ g_pc = funcpc;
return value;
}
else
@@ -557,11 +558,11 @@ static struct Value *func(struct Value *value)
ident->sym = sym;
if (sym->type == BUILTINFUNCTION)
{
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- if (sym->u.sub.u.bltin.call(value, &stack)->type == V_ERROR)
+ if (sym->u.sub.u.bltin.call(value, &g_stack)->type == V_ERROR)
{
- pc = funcpc;
+ g_pc = funcpc;
}
}
else
@@ -571,18 +572,18 @@ static struct Value *func(struct Value *value)
}
else if (sym->type == USERFUNCTION)
{
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
int r = 1;
- pc = sym->u.sub.u.def.scope.start;
- if (pc.token->type == T_COLON)
+ g_pc = sym->u.sub.u.def.scope.start;
+ if (g_pc.token->type == T_COLON)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
- Program_skipEOL(&program, &pc, STDCHANNEL, 1);
+ Program_skipEOL(&g_program, &g_pc, STDCHANNEL, 1);
}
do
@@ -591,20 +592,20 @@ static struct Value *func(struct Value *value)
{
if (strchr(value->u.error.msg, '\n') == (char *)0)
{
- Auto_setError(&stack,
- Program_lineNumber(&program, &pc), &pc,
+ Auto_setError(&g_stack,
+ Program_lineNumber(&g_program, &g_pc), &g_pc,
value);
- Program_PCtoError(&program, &pc, value);
+ Program_PCtoError(&g_program, &g_pc, value);
}
- if (stack.onerror.line != -1)
+ if (g_stack.onerror.line != -1)
{
- stack.resumeable = 1;
- pc = stack.onerror;
+ g_stack.resumeable = 1;
+ g_pc = g_stack.onerror;
}
else
{
- Auto_frameToError(&stack, &program, value);
+ Auto_frameToError(&g_stack, &g_program, value);
break;
}
}
@@ -615,7 +616,7 @@ static struct Value *func(struct Value *value)
Value_destroy(value);
}
- while ((r = Program_skipEOL(&program, &pc, STDCHANNEL, 1)));
+ while ((r = Program_skipEOL(&g_program, &g_pc, STDCHANNEL, 1)));
if (!r)
{
@@ -628,8 +629,8 @@ static struct Value *func(struct Value *value)
}
}
- Auto_funcReturn(&stack, pass == INTERPRET &&
- value->type != V_ERROR ? &pc : (struct Pc *)0);
+ Auto_funcReturn(&g_stack, g_pass == INTERPRET &&
+ value->type != V_ERROR ? &g_pc : (struct Pc *)0);
}
return value;
@@ -730,7 +731,7 @@ static struct Value *eval(struct Value *value, const char *desc)
stackEnd = pdastack + capacity - 1;
}
- ip = pc.token->type;
+ ip = g_pc.token->type;
switch (sp->state)
{
case 0:
@@ -745,22 +746,22 @@ static struct Value *eval(struct Value *value, const char *desc)
++sp;
sp->state = gotoState[(sp - 1)->state];
- if (pass == COMPILE)
+ if (g_pass == COMPILE)
{
- if (((pc.token + 1)->type == T_OP ||
- Auto_find(&stack, pc.token->u.identifier) == 0) &&
- Global_find(&globals, pc.token->u.identifier,
- (pc.token + 1)->type == T_OP) == 0)
+ if (((g_pc.token + 1)->type == T_OP ||
+ Auto_find(&g_stack, g_pc.token->u.identifier) == 0) &&
+ Global_find(&g_globals, g_pc.token->u.identifier,
+ (g_pc.token + 1)->type == T_OP) == 0)
{
Value_new_ERROR(value, UNDECLARED);
goto error;
}
}
- if (pass != DECLARE &&
- (pc.token->u.identifier->sym->type == GLOBALVAR ||
- pc.token->u.identifier->sym->type == GLOBALARRAY ||
- pc.token->u.identifier->sym->type == LOCALVAR))
+ if (g_pass != DECLARE &&
+ (g_pc.token->u.identifier->sym->type == GLOBALVAR ||
+ g_pc.token->u.identifier->sym->type == GLOBALARRAY ||
+ g_pc.token->u.identifier->sym->type == LOCALVAR))
{
struct Value *l;
@@ -770,12 +771,12 @@ static struct Value *eval(struct Value *value, const char *desc)
}
else
{
- struct Pc var = pc;
+ struct Pc var = g_pc;
func(&sp->u.value);
if (sp->u.value.type == V_VOID)
{
- pc = var;
+ g_pc = var;
Value_new_ERROR(value, VOIDVALUE);
goto error;
}
@@ -788,8 +789,8 @@ static struct Value *eval(struct Value *value, const char *desc)
++sp;
sp->state = gotoState[(sp - 1)->state];
- VALUE_NEW_INTEGER(&sp->u.value, pc.token->u.integer);
- ++pc.token;
+ VALUE_NEW_INTEGER(&sp->u.value, g_pc.token->u.integer);
+ ++g_pc.token;
}
else if (ip == T_REAL)
{
@@ -798,8 +799,8 @@ static struct Value *eval(struct Value *value, const char *desc)
++sp;
sp->state = gotoState[(sp - 1)->state];
- VALUE_NEW_REAL(&sp->u.value, pc.token->u.real);
- ++pc.token;
+ VALUE_NEW_REAL(&sp->u.value, g_pc.token->u.real);
+ ++g_pc.token;
}
else if (TOKEN_ISUNARYOPERATOR(ip))
{
@@ -808,7 +809,7 @@ static struct Value *eval(struct Value *value, const char *desc)
++sp;
sp->state = 2;
sp->u.token = ip;
- ++pc.token;
+ ++g_pc.token;
}
else if (ip == T_HEXINTEGER)
{
@@ -817,8 +818,8 @@ static struct Value *eval(struct Value *value, const char *desc)
++sp;
sp->state = gotoState[(sp - 1)->state];
- VALUE_NEW_INTEGER(&sp->u.value, pc.token->u.hexinteger);
- ++pc.token;
+ VALUE_NEW_INTEGER(&sp->u.value, g_pc.token->u.hexinteger);
+ ++g_pc.token;
}
else if (ip == T_OCTINTEGER)
{
@@ -827,8 +828,8 @@ static struct Value *eval(struct Value *value, const char *desc)
++sp;
sp->state = gotoState[(sp - 1)->state];
- VALUE_NEW_INTEGER(&sp->u.value, pc.token->u.octinteger);
- ++pc.token;
+ VALUE_NEW_INTEGER(&sp->u.value, g_pc.token->u.octinteger);
+ ++g_pc.token;
}
else if (ip == T_OP)
{
@@ -837,7 +838,7 @@ static struct Value *eval(struct Value *value, const char *desc)
++sp;
sp->state = 3;
sp->u.token = T_OP;
- ++pc.token;
+ ++g_pc.token;
}
else if (ip == T_STRING)
{
@@ -848,8 +849,8 @@ static struct Value *eval(struct Value *value, const char *desc)
sp->state = gotoState[(sp - 1)->state];
Value_new_STRING(&sp->u.value);
String_destroy(&sp->u.value.u.string);
- String_clone(&sp->u.value.u.string, pc.token->u.string);
- ++pc.token;
+ String_clone(&sp->u.value.u.string, g_pc.token->u.string);
+ ++g_pc.token;
}
else
{
@@ -886,7 +887,7 @@ static struct Value *eval(struct Value *value, const char *desc)
++sp;
sp->state = 1;
sp->u.token = ip;
- ++pc.token;
+ ++g_pc.token;
break;
}
else
@@ -913,7 +914,7 @@ static struct Value *eval(struct Value *value, const char *desc)
++sp;
sp->state = 1;
sp->u.token = ip;
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -930,11 +931,11 @@ static struct Value *eval(struct Value *value, const char *desc)
break;
case T_MINUS:
- Value_uneg(&sp->u.value, pass == INTERPRET);
+ Value_uneg(&sp->u.value, g_pass == INTERPRET);
break;
case T_NOT:
- Value_unot(&sp->u.value, pass == INTERPRET);
+ Value_unot(&sp->u.value, g_pass == INTERPRET);
break;
default:
@@ -962,7 +963,7 @@ static struct Value *eval(struct Value *value, const char *desc)
++sp;
sp->state = 1;
sp->u.token = ip;
- ++pc.token;
+ ++g_pc.token;
}
else if (ip == T_CP)
{
@@ -972,7 +973,7 @@ static struct Value *eval(struct Value *value, const char *desc)
--sp;
sp->state = gotoState[(sp - 1)->state];
sp->u.value = (sp + 1)->u.value;
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -999,7 +1000,7 @@ static struct Value *eval(struct Value *value, const char *desc)
++sp;
sp->state = 1;
sp->u.token = ip;
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -1021,91 +1022,91 @@ static struct Value *eval(struct Value *value, const char *desc)
{
case T_LT:
Value_lt(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_LE:
Value_le(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_EQ:
Value_eq(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_GE:
Value_ge(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_GT:
Value_gt(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_NE:
Value_ne(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_PLUS:
Value_add(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_MINUS:
Value_sub(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_MULT:
Value_mult(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_DIV:
Value_div(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_IDIV:
Value_idiv(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_MOD:
Value_mod(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_POW:
Value_pow(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_AND:
Value_and(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_OR:
Value_or(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_XOR:
Value_xor(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_EQV:
Value_eqv(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
case T_IMP:
Value_imp(&(sp - 2)->u.value, &sp->u.value,
- pass == INTERPRET);
+ g_pass == INTERPRET);
break;
default:
@@ -1170,14 +1171,14 @@ static inline struct Value *binarydown(struct Value *value,
{
struct Value x;
- op = pc.token->type;
+ op = g_pc.token->type;
if (!TOKEN_ISBINARYOPERATOR(op) || TOKEN_BINARYPRIORITY(op) != prio)
{
return value;
}
- oppc = pc;
- ++pc.token;
+ oppc = g_pc;
+ ++g_pc.token;
if (level(&x) == (struct Value *)0)
{
Value_destroy(value);
@@ -1202,75 +1203,75 @@ static inline struct Value *binarydown(struct Value *value,
switch (op)
{
case T_LT:
- Value_lt(value, &x, pass == INTERPRET);
+ Value_lt(value, &x, g_pass == INTERPRET);
break;
case T_LE:
- Value_le(value, &x, pass == INTERPRET);
+ Value_le(value, &x, g_pass == INTERPRET);
break;
case T_EQ:
- Value_eq(value, &x, pass == INTERPRET);
+ Value_eq(value, &x, g_pass == INTERPRET);
break;
case T_GE:
- Value_ge(value, &x, pass == INTERPRET);
+ Value_ge(value, &x, g_pass == INTERPRET);
break;
case T_GT:
- Value_gt(value, &x, pass == INTERPRET);
+ Value_gt(value, &x, g_pass == INTERPRET);
break;
case T_NE:
- Value_ne(value, &x, pass == INTERPRET);
+ Value_ne(value, &x, g_pass == INTERPRET);
break;
case T_PLUS:
- Value_add(value, &x, pass == INTERPRET);
+ Value_add(value, &x, g_pass == INTERPRET);
break;
case T_MINUS:
- Value_sub(value, &x, pass == INTERPRET);
+ Value_sub(value, &x, g_pass == INTERPRET);
break;
case T_MULT:
- Value_mult(value, &x, pass == INTERPRET);
+ Value_mult(value, &x, g_pass == INTERPRET);
break;
case T_DIV:
- Value_div(value, &x, pass == INTERPRET);
+ Value_div(value, &x, g_pass == INTERPRET);
break;
case T_IDIV:
- Value_idiv(value, &x, pass == INTERPRET);
+ Value_idiv(value, &x, g_pass == INTERPRET);
break;
case T_MOD:
- Value_mod(value, &x, pass == INTERPRET);
+ Value_mod(value, &x, g_pass == INTERPRET);
break;
case T_POW:
- Value_pow(value, &x, pass == INTERPRET);
+ Value_pow(value, &x, g_pass == INTERPRET);
break;
case T_AND:
- Value_and(value, &x, pass == INTERPRET);
+ Value_and(value, &x, g_pass == INTERPRET);
break;
case T_OR:
- Value_or(value, &x, pass == INTERPRET);
+ Value_or(value, &x, g_pass == INTERPRET);
break;
case T_XOR:
- Value_xor(value, &x, pass == INTERPRET);
+ Value_xor(value, &x, g_pass == INTERPRET);
break;
case T_EQV:
- Value_eqv(value, &x, pass == INTERPRET);
+ Value_eqv(value, &x, g_pass == INTERPRET);
break;
case T_IMP:
- Value_imp(value, &x, pass == INTERPRET);
+ Value_imp(value, &x, g_pass == INTERPRET);
break;
default:
@@ -1284,7 +1285,7 @@ static inline struct Value *binarydown(struct Value *value,
if (value->type == V_ERROR)
{
- pc = oppc;
+ g_pc = oppc;
}
return value;
@@ -1298,14 +1299,14 @@ static inline struct Value *unarydown(struct Value *value,
enum TokenType op;
struct Pc oppc;
- op = pc.token->type;
+ op = g_pc.token->type;
if (!TOKEN_ISUNARYOPERATOR(op) || TOKEN_UNARYPRIORITY(op) != prio)
{
return level(value);
}
- oppc = pc;
- ++pc.token;
+ oppc = g_pc;
+ ++g_pc.token;
if (unarydown(value, level, prio) == (struct Value *)0)
{
return Value_new_ERROR(value, MISSINGEXPR, _("unary operand"));
@@ -1319,15 +1320,15 @@ static inline struct Value *unarydown(struct Value *value,
switch (op)
{
case T_PLUS:
- Value_uplus(value, pass == INTERPRET);
+ Value_uplus(value, g_pass == INTERPRET);
break;
case T_MINUS:
- Value_uneg(value, pass == INTERPRET);
+ Value_uneg(value, g_pass == INTERPRET);
break;
case T_NOT:
- Value_unot(value, pass == INTERPRET);
+ Value_unot(value, g_pass == INTERPRET);
break;
default:
@@ -1336,7 +1337,7 @@ static inline struct Value *unarydown(struct Value *value,
if (value->type == V_ERROR)
{
- pc = oppc;
+ g_pc = oppc;
}
return value;
@@ -1344,28 +1345,28 @@ static inline struct Value *unarydown(struct Value *value,
static struct Value *eval8(struct Value *value)
{
- switch (pc.token->type)
+ switch (g_pc.token->type)
{
case T_IDENTIFIER:
{
struct Pc var;
struct Value *l;
- var = pc;
- if (pass == COMPILE)
+ var = g_pc;
+ if (g_pass == COMPILE)
{
- if (((pc.token + 1)->type == T_OP ||
- Auto_find(&stack, pc.token->u.identifier) == 0) &&
- Global_find(&globals, pc.token->u.identifier,
- (pc.token + 1)->type == T_OP) == 0)
+ if (((g_pc.token + 1)->type == T_OP ||
+ Auto_find(&g_stack, g_pc.token->u.identifier) == 0) &&
+ Global_find(&g_globals, g_pc.token->u.identifier,
+ (g_pc.token + 1)->type == T_OP) == 0)
return Value_new_ERROR(value, UNDECLARED);
}
- assert(pass == DECLARE || pc.token->u.identifier->sym);
- if (pass != DECLARE &&
- (pc.token->u.identifier->sym->type == GLOBALVAR ||
- pc.token->u.identifier->sym->type == GLOBALARRAY ||
- pc.token->u.identifier->sym->type == LOCALVAR))
+ assert(g_pass == DECLARE || g_pc.token->u.identifier->sym);
+ if (g_pass != DECLARE &&
+ (g_pc.token->u.identifier->sym->type == GLOBALVAR ||
+ g_pc.token->u.identifier->sym->type == GLOBALARRAY ||
+ g_pc.token->u.identifier->sym->type == LOCALVAR))
{
if ((l = lvalue(value))->type == V_ERROR)
{
@@ -1380,7 +1381,7 @@ static struct Value *eval8(struct Value *value)
if (value->type == V_VOID)
{
Value_destroy(value);
- pc = var;
+ g_pc = var;
return Value_new_ERROR(value, VOIDVALUE);
}
}
@@ -1390,15 +1391,15 @@ static struct Value *eval8(struct Value *value)
case T_INTEGER:
{
- VALUE_NEW_INTEGER(value, pc.token->u.integer);
- ++pc.token;
+ VALUE_NEW_INTEGER(value, g_pc.token->u.integer);
+ ++g_pc.token;
break;
}
case T_REAL:
{
- VALUE_NEW_REAL(value, pc.token->u.real);
- ++pc.token;
+ VALUE_NEW_REAL(value, g_pc.token->u.real);
+ ++g_pc.token;
break;
}
@@ -1406,40 +1407,40 @@ static struct Value *eval8(struct Value *value)
{
Value_new_STRING(value);
String_destroy(&value->u.string);
- String_clone(&value->u.string, pc.token->u.string);
- ++pc.token;
+ String_clone(&value->u.string, g_pc.token->u.string);
+ ++g_pc.token;
break;
}
case T_HEXINTEGER:
{
- VALUE_NEW_INTEGER(value, pc.token->u.hexinteger);
- ++pc.token;
+ VALUE_NEW_INTEGER(value, g_pc.token->u.hexinteger);
+ ++g_pc.token;
break;
}
case T_OCTINTEGER:
{
- VALUE_NEW_INTEGER(value, pc.token->u.octinteger);
- ++pc.token;
+ VALUE_NEW_INTEGER(value, g_pc.token->u.octinteger);
+ ++g_pc.token;
break;
}
case T_OP:
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("parenthetic"))->type == V_ERROR)
{
return value;
}
- if (pc.token->type != T_CP)
+ if (g_pc.token->type != T_CP)
{
Value_destroy(value);
return Value_new_ERROR(value, MISSINGCP);
}
- ++pc.token;
+ ++g_pc.token;
break;
}
@@ -1491,7 +1492,7 @@ static struct Value *eval(struct Value *value, const char *desc)
{
/* Avoid function calls for atomic expression */
- switch (pc.token->type)
+ switch (g_pc.token->type)
{
case T_STRING:
case T_REAL:
@@ -1499,8 +1500,8 @@ static struct Value *eval(struct Value *value, const char *desc)
case T_HEXINTEGER:
case T_OCTINTEGER:
case T_IDENTIFIER:
- if (!TOKEN_ISBINARYOPERATOR((pc.token + 1)->type) &&
- (pc.token + 1)->type != T_OP)
+ if (!TOKEN_ISBINARYOPERATOR((g_pc.token + 1)->type) &&
+ (g_pc.token + 1)->type != T_OP)
{
return eval7(value);
}
@@ -1529,55 +1530,55 @@ static struct Value *eval(struct Value *value, const char *desc)
static void new(void)
{
- Global_destroy(&globals);
- Global_new(&globals);
- Auto_destroy(&stack);
- Auto_new(&stack);
- Program_destroy(&program);
- Program_new(&program);
+ Global_destroy(&g_globals);
+ Global_new(&g_globals);
+ Auto_destroy(&g_stack);
+ Auto_new(&g_stack);
+ Program_destroy(&g_program);
+ Program_new(&g_program);
FS_closefiles();
optionbase = 0;
}
-static void pushLabel(enum LabelType type, struct Pc *patch)
+static void pushLabel(enum labeltype_e type, struct Pc *patch)
{
- if (labelStackPointer == labelStackCapacity)
+ if (g_labelstack_index == g_labelstack_capacity)
{
- struct LabelStack *more;
+ struct labelstack_s *more;
more =
- realloc(labelStack,
- sizeof(struct LabelStack) *
- (labelStackCapacity ? (labelStackCapacity *= 2) : (32)));
- labelStack = more;
+ realloc(g_labelstack,
+ sizeof(struct labelstack_s) *
+ (g_labelstack_capacity ? (g_labelstack_capacity *= 2) : (32)));
+ g_labelstack = more;
}
- labelStack[labelStackPointer].type = type;
- labelStack[labelStackPointer].patch = *patch;
- ++labelStackPointer;
+ g_labelstack[g_labelstack_index].type = type;
+ g_labelstack[g_labelstack_index].patch = *patch;
+ ++g_labelstack_index;
}
-static struct Pc *popLabel(enum LabelType type)
+static struct Pc *popLabel(enum labeltype_e type)
{
- if (labelStackPointer == 0 || labelStack[labelStackPointer - 1].type != type)
+ if (g_labelstack_index == 0 || g_labelstack[g_labelstack_index - 1].type != type)
{
return (struct Pc *)0;
}
else
{
- return &labelStack[--labelStackPointer].patch;
+ return &g_labelstack[--g_labelstack_index].patch;
}
}
-static struct Pc *findLabel(enum LabelType type)
+static struct Pc *findLabel(enum labeltype_e type)
{
int i;
- for (i = labelStackPointer - 1; i >= 0; --i)
+ for (i = g_labelstack_index - 1; i >= 0; --i)
{
- if (labelStack[i].type == type)
+ if (g_labelstack[i].type == type)
{
- return &labelStack[i].patch;
+ return &g_labelstack[i].patch;
}
}
@@ -1586,9 +1587,9 @@ static struct Pc *findLabel(enum LabelType type)
static void labelStackError(struct Value *v)
{
- assert(labelStackPointer);
- pc = labelStack[labelStackPointer - 1].patch;
- switch (labelStack[labelStackPointer - 1].type)
+ assert(g_labelstack_index);
+ g_pc = g_labelstack[g_labelstack_index - 1].patch;
+ switch (g_labelstack[g_labelstack_index - 1].type)
{
case L_IF:
Value_new_ERROR(v, STRAYIF);
@@ -1609,7 +1610,7 @@ static void labelStackError(struct Value *v)
case L_FOR_BODY:
{
Value_new_ERROR(v, STRAYFOR);
- pc = *findLabel(L_FOR);
+ g_pc = *findLabel(L_FOR);
break;
}
@@ -1636,12 +1637,12 @@ static void labelStackError(struct Value *v)
static const char *topLabelDescription(void)
{
- if (labelStackPointer == 0)
+ if (g_labelstack_index == 0)
{
return _("program");
}
- switch (labelStack[labelStackPointer - 1].type)
+ switch (g_labelstack[g_labelstack_index - 1].type)
{
case L_IF:
return _("`if' branch");
@@ -1683,30 +1684,30 @@ static struct Value *assign(struct Value *value)
{
struct Pc expr;
- if (strcasecmp(pc.token->u.identifier->name, "mid$") == 0)
+ if (strcasecmp(g_pc.token->u.identifier->name, "mid$") == 0)
{
long int n, m;
struct Value *l;
- ++pc.token;
- if (pc.token->type != T_OP)
+ ++g_pc.token;
+ if (g_pc.token->type != T_OP)
{
return Value_new_ERROR(value, MISSINGOP);
}
- ++pc.token;
- if (pc.token->type != T_IDENTIFIER)
+ ++g_pc.token;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGSTRIDENT);
}
- if (pass == DECLARE)
+ if (g_pass == DECLARE)
{
- if (((pc.token + 1)->type == T_OP ||
- Auto_find(&stack, pc.token->u.identifier) == 0) &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType,
- (pc.token + 1)->type ==
+ if (((g_pc.token + 1)->type == T_OP ||
+ Auto_find(&g_stack, g_pc.token->u.identifier) == 0) &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType,
+ (g_pc.token + 1)->type ==
T_OP ? GLOBALARRAY : GLOBALVAR, 0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
@@ -1718,17 +1719,17 @@ static struct Value *assign(struct Value *value)
return value;
}
- if (pass == COMPILE && l->type != V_STRING)
+ if (g_pass == COMPILE && l->type != V_STRING)
{
return Value_new_ERROR(value, TYPEMISMATCH4);
}
- if (pc.token->type != T_COMMA)
+ if (g_pc.token->type != T_COMMA)
{
return Value_new_ERROR(value, MISSINGCOMMA);
}
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("position"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -1737,14 +1738,14 @@ static struct Value *assign(struct Value *value)
n = value->u.integer;
Value_destroy(value);
- if (pass == INTERPRET && n < 1)
+ if (g_pass == INTERPRET && n < 1)
{
return Value_new_ERROR(value, OUTOFRANGE, "position");
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("length"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -1752,7 +1753,7 @@ static struct Value *assign(struct Value *value)
}
m = value->u.integer;
- if (pass == INTERPRET && m < 0)
+ if (g_pass == INTERPRET && m < 0)
{
return Value_new_ERROR(value, OUTOFRANGE, _("length"));
}
@@ -1764,25 +1765,25 @@ static struct Value *assign(struct Value *value)
m = -1;
}
- if (pc.token->type != T_CP)
+ if (g_pc.token->type != T_CP)
{
return Value_new_ERROR(value, MISSINGCP);
}
- ++pc.token;
- if (pc.token->type != T_EQ)
+ ++g_pc.token;
+ if (g_pc.token->type != T_EQ)
{
return Value_new_ERROR(value, MISSINGEQ);
}
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("rhs"))->type == V_ERROR ||
Value_retype(value, V_STRING)->type == V_ERROR)
{
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (m == -1)
{
@@ -1809,13 +1810,13 @@ static struct Value *assign(struct Value *value)
l = more;
}
- if (pass == DECLARE)
+ if (g_pass == DECLARE)
{
- if (((pc.token + 1)->type == T_OP ||
- Auto_find(&stack, pc.token->u.identifier) == 0) &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType,
- (pc.token + 1)->type ==
+ if (((g_pc.token + 1)->type == T_OP ||
+ Auto_find(&g_stack, g_pc.token->u.identifier) == 0) &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType,
+ (g_pc.token + 1)->type ==
T_OP ? GLOBALARRAY : GLOBALVAR, 0) == 0)
{
if (capacity)
@@ -1833,9 +1834,9 @@ static struct Value *assign(struct Value *value)
}
++used;
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -1843,13 +1844,13 @@ static struct Value *assign(struct Value *value)
}
}
- if (pc.token->type != T_EQ)
+ if (g_pc.token->type != T_EQ)
{
return Value_new_ERROR(value, MISSINGEQ);
}
- ++pc.token;
- expr = pc;
+ ++g_pc.token;
+ expr = g_pc;
if (eval(value, _("rhs"))->type == V_ERROR)
{
return value;
@@ -1858,17 +1859,17 @@ static struct Value *assign(struct Value *value)
for (i = 0; i < used; ++i)
{
Value_clone(&retyped_value, value);
- if (pass != DECLARE &&
+ if (g_pass != DECLARE &&
VALUE_RETYPE(&retyped_value, (l[i])->type)->type == V_ERROR)
{
- pc = expr;
+ g_pc = expr;
free(l);
Value_destroy(value);
*value = retyped_value;
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
Value_destroy(l[i]);
*(l[i]) = retyped_value;
@@ -1887,37 +1888,37 @@ static struct Value *compileProgram(struct Value *v, int clearGlobals)
{
struct Pc begin;
- stack.resumeable = 0;
+ g_stack.resumeable = 0;
if (clearGlobals)
{
- Global_destroy(&globals);
- Global_new(&globals);
+ Global_destroy(&g_globals);
+ Global_new(&g_globals);
}
else
{
- Global_clearFunctions(&globals);
+ Global_clearFunctions(&g_globals);
}
- if (Program_beginning(&program, &begin))
+ if (Program_beginning(&g_program, &begin))
{
struct Pc savepc;
int savepass;
- savepc = pc;
- savepass = pass;
- Program_norun(&program);
- for (pass = DECLARE; pass != INTERPRET; ++pass)
+ savepc = g_pc;
+ savepass = g_pass;
+ Program_norun(&g_program);
+ for (g_pass = DECLARE; g_pass != INTERPRET; ++g_pass)
{
- if (pass == DECLARE)
+ if (g_pass == DECLARE)
{
- stack.begindata.line = -1;
- lastdata = &stack.begindata;
+ g_stack.begindata.line = -1;
+ g_lastdata = &g_stack.begindata;
}
optionbase = 0;
- stopped = 0;
- program.runnable = 1;
- pc = begin;
+ g_stopped = 0;
+ g_program.runnable = 1;
+ g_pc = begin;
while (1)
{
statements(v);
@@ -1927,14 +1928,14 @@ static struct Value *compileProgram(struct Value *v, int clearGlobals)
}
Value_destroy(v);
- if (!Program_skipEOL(&program, &pc, 0, 0))
+ if (!Program_skipEOL(&g_program, &g_pc, 0, 0))
{
Value_new_NIL(v);
break;
}
}
- if (v->type != V_ERROR && labelStackPointer > 0)
+ if (v->type != V_ERROR && g_labelstack_index > 0)
{
Value_destroy(v);
labelStackError(v);
@@ -1942,35 +1943,35 @@ static struct Value *compileProgram(struct Value *v, int clearGlobals)
if (v->type == V_ERROR)
{
- labelStackPointer = 0;
- Program_norun(&program);
- if (stack.cur)
+ g_labelstack_index = 0;
+ Program_norun(&g_program);
+ if (g_stack.cur)
{
- Auto_funcEnd(&stack); /* Always correct? */
+ Auto_funcEnd(&g_stack); /* Always correct? */
}
- pass = savepass;
+ g_pass = savepass;
return v;
}
}
- pc = begin;
- if (Program_analyse(&program, &pc, v))
+ g_pc = begin;
+ if (Program_analyse(&g_program, &g_pc, v))
{
- labelStackPointer = 0;
- Program_norun(&program);
- if (stack.cur)
+ g_labelstack_index = 0;
+ Program_norun(&g_program);
+ if (g_stack.cur)
{
- Auto_funcEnd(&stack); /* Always correct? */
+ Auto_funcEnd(&g_stack); /* Always correct? */
}
- pass = savepass;
+ g_pass = savepass;
return v;
}
- curdata = stack.begindata;
- pc = savepc;
- pass = savepass;
+ g_curdata = g_stack.begindata;
+ g_pc = savepc;
+ g_pass = savepass;
}
return Value_new_NIL(v);
@@ -1981,21 +1982,21 @@ static void runline(struct Token *line)
struct Value value;
FS_flush(STDCHANNEL);
- for (pass = DECLARE; pass != INTERPRET; ++pass)
+ for (g_pass = DECLARE; g_pass != INTERPRET; ++g_pass)
{
- curdata.line = -1;
- pc.line = -1;
- pc.token = line;
+ g_curdata.line = -1;
+ g_pc.line = -1;
+ g_pc.token = line;
optionbase = 0;
- stopped = 0;
+ g_stopped = 0;
statements(&value);
- if (value.type != V_ERROR && pc.token->type != T_EOL)
+ if (value.type != V_ERROR && g_pc.token->type != T_EOL)
{
Value_destroy(&value);
Value_new_ERROR(&value, SYNTAX);
}
- if (value.type != V_ERROR && labelStackPointer > 0)
+ if (value.type != V_ERROR && g_labelstack_index > 0)
{
Value_destroy(&value);
labelStackError(&value);
@@ -2005,9 +2006,9 @@ static void runline(struct Token *line)
{
struct String s;
- Auto_setError(&stack, Program_lineNumber(&program, &pc), &pc, &value);
- Program_PCtoError(&program, &pc, &value);
- labelStackPointer = 0;
+ Auto_setError(&g_stack, Program_lineNumber(&g_program, &g_pc), &g_pc, &value);
+ Program_PCtoError(&g_program, &g_pc, &value);
+ g_labelstack_index = 0;
FS_putChars(STDCHANNEL, _("Error: "));
String_new(&s);
Value_toString(&value, &s, ' ', -1, 0, 0, 0, 0, -1, 0, 0);
@@ -2017,54 +2018,54 @@ static void runline(struct Token *line)
return;
}
- if (!program.runnable && pass == COMPILE)
+ if (!g_program.runnable && g_pass == COMPILE)
{
Value_destroy(&value);
(void)compileProgram(&value, 0);
}
}
- pc.line = -1;
- pc.token = line;
+ g_pc.line = -1;
+ g_pc.token = line;
optionbase = 0;
- curdata = stack.begindata;
- nextdata.line = -1;
+ g_curdata = g_stack.begindata;
+ g_nextdata.line = -1;
Value_destroy(&value);
- pass = INTERPRET;
+ g_pass = INTERPRET;
do
{
- assert(pass == INTERPRET);
+ assert(g_pass == INTERPRET);
statements(&value);
- assert(pass == INTERPRET);
+ assert(g_pass == INTERPRET);
if (value.type == V_ERROR)
{
if (strchr(value.u.error.msg, '\n') == (char *)0)
{
- Auto_setError(&stack, Program_lineNumber(&program, &pc), &pc,
+ Auto_setError(&g_stack, Program_lineNumber(&g_program, &g_pc), &g_pc,
&value);
- Program_PCtoError(&program, &pc, &value);
+ Program_PCtoError(&g_program, &g_pc, &value);
}
- if (stack.onerror.line != -1)
+ if (g_stack.onerror.line != -1)
{
- stack.resumeable = 1;
- pc = stack.onerror;
+ g_stack.resumeable = 1;
+ g_pc = g_stack.onerror;
}
else
{
struct String s;
String_new(&s);
- if (!stopped)
+ if (!g_stopped)
{
- stopped = 0;
+ g_stopped = 0;
FS_putChars(STDCHANNEL, _("Error: "));
}
- Auto_frameToError(&stack, &program, &value);
+ Auto_frameToError(&g_stack, &g_program, &value);
Value_toString(&value, &s, ' ', -1, 0, 0, 0, 0, -1, 0, 0);
- while (Auto_gosubReturn(&stack, (struct Pc *)0));
+ while (Auto_gosubReturn(&g_stack, (struct Pc *)0));
FS_putString(STDCHANNEL, &s);
String_destroy(&s);
Value_destroy(&value);
@@ -2074,44 +2075,44 @@ static void runline(struct Token *line)
Value_destroy(&value);
}
- while (pc.token->type != T_EOL ||
- Program_skipEOL(&program, &pc, STDCHANNEL, 1));
+ while (g_pc.token->type != T_EOL ||
+ Program_skipEOL(&g_program, &g_pc, STDCHANNEL, 1));
}
static struct Value *evalGeometry(struct Value *value, unsigned int *dim,
unsigned int geometry[])
{
- struct Pc exprpc = pc;
+ struct Pc exprpc = g_pc;
if (eval(value, _("dimension"))->type == V_ERROR ||
- (pass != DECLARE && Value_retype(value, V_INTEGER)->type == V_ERROR))
+ (g_pass != DECLARE && Value_retype(value, V_INTEGER)->type == V_ERROR))
{
return value;
}
- if (pass == INTERPRET && value->u.integer < optionbase)
+ if (g_pass == INTERPRET && value->u.integer < optionbase)
{
Value_destroy(value);
- pc = exprpc;
+ g_pc = exprpc;
return Value_new_ERROR(value, OUTOFRANGE, _("dimension"));
}
geometry[0] = value->u.integer - optionbase + 1;
Value_destroy(value);
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
- exprpc = pc;
+ ++g_pc.token;
+ exprpc = g_pc;
if (eval(value, _("dimension"))->type == V_ERROR ||
- (pass != DECLARE && Value_retype(value, V_INTEGER)->type == V_ERROR))
+ (g_pass != DECLARE && Value_retype(value, V_INTEGER)->type == V_ERROR))
{
return value;
}
- if (pass == INTERPRET && value->u.integer < optionbase)
+ if (g_pass == INTERPRET && value->u.integer < optionbase)
{
Value_destroy(value);
- pc = exprpc;
+ g_pc = exprpc;
return Value_new_ERROR(value, OUTOFRANGE, _("dimension"));
}
@@ -2124,9 +2125,9 @@ static struct Value *evalGeometry(struct Value *value, unsigned int *dim,
*dim = 1;
}
- if (pc.token->type == T_CP)
+ if (g_pc.token->type == T_CP)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -2223,30 +2224,30 @@ static struct Value *convert(struct Value *value, struct Value *l,
static struct Value *dataread(struct Value *value, struct Value *l)
{
- if (curdata.line == -1)
+ if (g_curdata.line == -1)
{
return Value_new_ERROR(value, ENDOFDATA);
}
- if (curdata.token->type == T_DATA)
+ if (g_curdata.token->type == T_DATA)
{
- nextdata = curdata.token->u.nextdata;
- ++curdata.token;
+ g_nextdata = g_curdata.token->u.nextdata;
+ ++g_curdata.token;
}
- if (convert(value, l, curdata.token))
+ if (convert(value, l, g_curdata.token))
{
return value;
}
- ++curdata.token;
- if (curdata.token->type == T_COMMA)
+ ++g_curdata.token;
+ if (g_curdata.token->type == T_COMMA)
{
- ++curdata.token;
+ ++g_curdata.token;
}
else
{
- curdata = nextdata;
+ g_curdata = g_nextdata;
}
return (struct Value *)0;
@@ -2257,11 +2258,11 @@ static struct Value more_statements;
static struct Value *statements(struct Value *value)
{
more:
- if (pc.token->statement)
+ if (g_pc.token->statement)
{
struct Value *v;
- if ((v = pc.token->statement(value)))
+ if ((v = g_pc.token->statement(value)))
{
if (v == &more_statements)
{
@@ -2278,18 +2279,18 @@ more:
return Value_new_ERROR(value, MISSINGSTATEMENT);
}
- if (pc.token->type == T_COLON && (pc.token + 1)->type == T_ELSE)
+ if (g_pc.token->type == T_COLON && (g_pc.token + 1)->type == T_ELSE)
{
- ++pc.token;
+ ++g_pc.token;
}
- else if ((pc.token->type == T_COLON && (pc.token + 1)->type != T_ELSE) ||
- pc.token->type == T_QUOTE)
+ else if ((g_pc.token->type == T_COLON && (g_pc.token + 1)->type != T_ELSE) ||
+ g_pc.token->type == T_QUOTE)
{
- ++pc.token;
+ ++g_pc.token;
goto more;
}
- else if ((pass == DECLARE || pass == COMPILE) && pc.token->type != T_EOL &&
- pc.token->type != T_ELSE)
+ else if ((g_pass == DECLARE || g_pass == COMPILE) && g_pc.token->type != T_EOL &&
+ g_pc.token->type != T_ELSE)
{
return Value_new_ERROR(value, MISSINGCOLON);
}
@@ -2303,14 +2304,14 @@ more:
void bas_init(int backslash_colon, int restricted, int uppercase, int lpfd)
{
- stack.begindata.line = -1;
+ g_stack.begindata.line = -1;
Token_init(backslash_colon, uppercase);
- Global_new(&globals);
- Auto_new(&stack);
- Program_new(&program);
+ Global_new(&g_globals);
+ Auto_new(&g_stack);
+ Program_new(&g_program);
FS_opendev(STDCHANNEL, 0, 1);
FS_opendev(LPCHANNEL, -1, lpfd);
- run_restricted = restricted;
+ g_run_restricted = restricted;
}
void bas_runFile(const char *runFile)
@@ -2329,7 +2330,7 @@ void bas_runFile(const char *runFile)
FS_putChars(0, errmsg);
FS_putChars(0, _(").\n"));
}
- else if (Program_merge(&program, dev, &value))
+ else if (Program_merge(&g_program, dev, &value))
{
struct String s;
@@ -2345,7 +2346,7 @@ void bas_runFile(const char *runFile)
{
struct Token line[2];
- Program_setname(&program, runFile);
+ Program_setname(&g_program, runFile);
line[0].type = T_RUN;
line[0].statement = stmt_RUN;
line[1].type = T_EOL;
@@ -2381,7 +2382,7 @@ void bas_interpreter(void)
struct Token *line;
struct String s;
- stopped = 0;
+ g_stopped = 0;
FS_nextline(STDCHANNEL);
if (FS_istty(STDCHANNEL))
{
@@ -2410,27 +2411,27 @@ void bas_interpreter(void)
{
if (line->type == T_INTEGER && line->u.integer > 0)
{
- if (program.numbered)
+ if (g_program.numbered)
{
if ((line + 1)->type == T_EOL)
{
struct Pc where;
- if (Program_goLine(&program, line->u.integer, &where) ==
+ if (Program_goLine(&g_program, line->u.integer, &where) ==
(struct Pc *)0)
{
FS_putChars(STDCHANNEL, (NOSUCHLINE));
}
else
{
- Program_delete(&program, &where, &where);
+ Program_delete(&g_program, &where, &where);
}
Token_destroy(line);
}
else
{
- Program_store(&program, line, line->u.integer);
+ Program_store(&g_program, line, line->u.integer);
}
}
else
@@ -2465,12 +2466,13 @@ void bas_interpreter(void)
void bas_exit(void)
{
- Auto_destroy(&stack);
- Global_destroy(&globals);
- Program_destroy(&program);
- if (labelStack)
+ Auto_destroy(&g_stack);
+ Global_destroy(&g_globals);
+ Program_destroy(&g_program);
+ if (g_labelstack)
{
- free(labelStack);
+ free(g_labelstack);
+ g_labelstack = (struct labelstack_s *)0;
}
FS_closefiles();
diff --git a/apps/interpreters/bas/fs.c b/apps/interpreters/bas/fs.c
index aea3a466e..5895dc5c0 100644
--- a/apps/interpreters/bas/fs.c
+++ b/apps/interpreters/bas/fs.c
@@ -97,10 +97,14 @@
static struct FileStream **g_file;
static int g_capacity;
static int g_used;
-static const int open_mode[4] = { 0, O_RDONLY, O_WRONLY, O_RDWR };
+static const int g_open_mode[4] = { 0, O_RDONLY, O_WRONLY, O_RDWR };
+static char g_errmsgbuf[80];
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
const char *FS_errmsg;
-static char FS_errmsgbuf[80];
/****************************************************************************
* Private Functions
@@ -139,9 +143,9 @@ static int opened(int dev, int mode)
if (dev < 0 || dev >= g_capacity || g_file[dev] == (struct FileStream *)0)
{
- snprintf(FS_errmsgbuf, sizeof(FS_errmsgbuf), _("channel #%d not open"),
+ snprintf(g_errmsgbuf, sizeof(g_errmsgbuf), _("channel #%d not open"),
dev);
- FS_errmsg = FS_errmsgbuf;
+ FS_errmsg = g_errmsgbuf;
return -1;
}
@@ -157,7 +161,7 @@ static int opened(int dev, int mode)
fd = g_file[dev]->outfd;
if (fd == -1)
{
- snprintf(FS_errmsgbuf, sizeof(FS_errmsgbuf),
+ snprintf(g_errmsgbuf, sizeof(g_errmsgbuf),
_("channel #%d not opened for writing"), dev);
}
break;
@@ -168,7 +172,7 @@ static int opened(int dev, int mode)
fd = g_file[dev]->infd;
if (fd == -1)
{
- snprintf(FS_errmsgbuf, sizeof(FS_errmsgbuf),
+ snprintf(g_errmsgbuf, sizeof(g_errmsgbuf),
_("channel #%d not opened for reading"), dev);
}
break;
@@ -179,7 +183,7 @@ static int opened(int dev, int mode)
fd = g_file[dev]->randomfd;
if (fd == -1)
{
- snprintf(FS_errmsgbuf, sizeof(FS_errmsgbuf),
+ snprintf(g_errmsgbuf, sizeof(g_errmsgbuf),
_("channel #%d not opened for random access"), dev);
}
break;
@@ -190,7 +194,7 @@ static int opened(int dev, int mode)
fd = g_file[dev]->binaryfd;
if (fd == -1)
{
- snprintf(FS_errmsgbuf, sizeof(FS_errmsgbuf),
+ snprintf(g_errmsgbuf, sizeof(g_errmsgbuf),
_("channel #%d not opened for binary access"), dev);
}
break;
@@ -201,7 +205,7 @@ static int opened(int dev, int mode)
fd = (g_file[dev]->randomfd != -1 ? g_file[dev]->randomfd : g_file[dev]->binaryfd);
if (fd == -1)
{
- snprintf(FS_errmsgbuf, sizeof(FS_errmsgbuf),
+ snprintf(g_errmsgbuf, sizeof(g_errmsgbuf),
_("channel #%d not opened for random or binary access"),
dev);
}
@@ -214,7 +218,7 @@ static int opened(int dev, int mode)
if (fd == -1)
{
- FS_errmsg = FS_errmsgbuf;
+ FS_errmsg = g_errmsgbuf;
return -1;
}
else
@@ -509,7 +513,7 @@ int FS_openinChn(int chn, const char *name, int mode)
return -1;
}
- fl = open_mode[mode];
+ fl = g_open_mode[mode];
/* Serial devices on Linux should be opened non-blocking, otherwise the
* open() may block already. Named pipes can not be opened non-blocking in
@@ -602,7 +606,7 @@ int FS_openoutChn(int chn, const char *name, int mode, int append)
return -1;
}
- fl = open_mode[mode] | (append ? O_APPEND : 0);
+ fl = g_open_mode[mode] | (append ? O_APPEND : 0);
/* Serial devices on Linux should be opened non-blocking, otherwise the */
/* open() may block already. Named pipes can not be opened non-blocking */
@@ -661,7 +665,7 @@ int FS_openrandomChn(int chn, const char *name, int mode, int recLength)
return -1;
}
- if ((fd = open(name, open_mode[mode] | O_CREAT, 0666)) == -1)
+ if ((fd = open(name, g_open_mode[mode] | O_CREAT, 0666)) == -1)
{
FS_errmsg = strerror(errno);
return -1;
@@ -700,7 +704,7 @@ int FS_openbinaryChn(int chn, const char *name, int mode)
return -1;
}
- if ((fd = open(name, open_mode[mode] | O_CREAT, 0666)) == -1)
+ if ((fd = open(name, g_open_mode[mode] | O_CREAT, 0666)) == -1)
{
FS_errmsg = strerror(errno);
return -1;
diff --git a/apps/interpreters/bas/statement.c b/apps/interpreters/bas/statement.c
index 8ed0256e9..8ecfd1d79 100644
--- a/apps/interpreters/bas/statement.c
+++ b/apps/interpreters/bas/statement.c
@@ -82,13 +82,13 @@
struct Value *stmt_CALL(struct Value *value)
{
- ++pc.token;
- if (pc.token->type != T_IDENTIFIER)
+ ++g_pc.token;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGPROCIDENT);
}
- if (pass == DECLARE)
+ if (g_pass == DECLARE)
{
if (func(value)->type == V_ERROR)
{
@@ -101,18 +101,18 @@ struct Value *stmt_CALL(struct Value *value)
}
else
{
- if (pass == COMPILE)
+ if (g_pass == COMPILE)
{
if (Global_find
- (&globals, pc.token->u.identifier,
- (pc.token + 1)->type == T_OP) == 0)
+ (&g_globals, g_pc.token->u.identifier,
+ (g_pc.token + 1)->type == T_OP) == 0)
{
return Value_new_ERROR(value, UNDECLARED);
}
}
- if (pc.token->u.identifier->sym->type != USERFUNCTION &&
- pc.token->u.identifier->sym->type != BUILTINFUNCTION)
+ if (g_pc.token->u.identifier->sym->type != USERFUNCTION &&
+ g_pc.token->u.identifier->sym->type != BUILTINFUNCTION)
{
return Value_new_ERROR(value, TYPEMISMATCH1, "variable", "function");
}
@@ -131,9 +131,9 @@ struct Value *stmt_CALL(struct Value *value)
struct Value *stmt_CASE(struct Value *value)
{
- struct Pc statementpc = pc;
+ struct Pc statementpc = g_pc;
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
struct Pc *selectcase, *nextcasevalue;
@@ -146,15 +146,15 @@ struct Value *stmt_CASE(struct Value *value)
nextcasevalue->line != -1;
nextcasevalue = &nextcasevalue->token->u.casevalue->nextcasevalue);
- *nextcasevalue = pc;
- if (pass == COMPILE)
+ *nextcasevalue = g_pc;
+ if (g_pass == COMPILE)
{
- pc.token->u.casevalue->endselect =
+ g_pc.token->u.casevalue->endselect =
selectcase->token->u.selectcase->endselect;
}
- pc.token->u.casevalue->nextcasevalue.line = -1;
- ++pc.token;
+ g_pc.token->u.casevalue->nextcasevalue.line = -1;
+ ++g_pc.token;
switch (statementpc.token->type)
{
case T_CASEELSE:
@@ -166,10 +166,10 @@ struct Value *stmt_CASE(struct Value *value)
do
{
- if (pc.token->type == T_IS)
+ if (g_pc.token->type == T_IS)
{
- ++pc.token;
- switch (pc.token->type)
+ ++g_pc.token;
+ switch (g_pc.token->type)
{
case T_LT:
case T_LE:
@@ -183,8 +183,8 @@ struct Value *stmt_CASE(struct Value *value)
return Value_new_ERROR(value, MISSINGRELOP);
}
- ++pc.token;
- exprpc = pc;
+ ++g_pc.token;
+ exprpc = g_pc;
if (eval(value, "`is'")->type == V_ERROR)
{
return value;
@@ -195,7 +195,7 @@ struct Value *stmt_CASE(struct Value *value)
selectcase->token->u.selectcase->type)->type ==
V_ERROR)
{
- pc = exprpc;
+ g_pc = exprpc;
return value;
}
@@ -204,7 +204,7 @@ struct Value *stmt_CASE(struct Value *value)
else /* value or range */
{
- exprpc = pc;
+ exprpc = g_pc;
if (eval(value, "`case'")->type == V_ERROR)
{
return value;
@@ -215,15 +215,15 @@ struct Value *stmt_CASE(struct Value *value)
selectcase->token->u.selectcase->type)->type ==
V_ERROR)
{
- pc = exprpc;
+ g_pc = exprpc;
return value;
}
Value_destroy(value);
- if (pc.token->type == T_TO)
+ if (g_pc.token->type == T_TO)
{
- ++pc.token;
- exprpc = pc;
+ ++g_pc.token;
+ exprpc = g_pc;
if (eval(value, "`case'")->type == V_ERROR)
{
return value;
@@ -234,7 +234,7 @@ struct Value *stmt_CASE(struct Value *value)
selectcase->token->u.selectcase->type)->type ==
V_ERROR)
{
- pc = exprpc;
+ g_pc = exprpc;
return value;
}
@@ -243,9 +243,9 @@ struct Value *stmt_CASE(struct Value *value)
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -263,7 +263,7 @@ struct Value *stmt_CASE(struct Value *value)
}
else
{
- pc = pc.token->u.casevalue->endselect;
+ g_pc = g_pc.token->u.casevalue->endselect;
}
return (struct Value *)0;
@@ -273,17 +273,17 @@ struct Value *stmt_CHDIR_MKDIR(struct Value *value)
{
int res = -1, err = -1;
struct Pc dirpc;
- struct Pc statementpc = pc;
+ struct Pc statementpc = g_pc;
- ++pc.token;
- dirpc = pc;
+ ++g_pc.token;
+ dirpc = g_pc;
if (eval(value, _("directory"))->type == V_ERROR ||
Value_retype(value, V_STRING)->type == V_ERROR)
{
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
switch (statementpc.token->type)
{
@@ -303,9 +303,9 @@ struct Value *stmt_CHDIR_MKDIR(struct Value *value)
}
Value_destroy(value);
- if (pass == INTERPRET && res == -1)
+ if (g_pass == INTERPRET && res == -1)
{
- pc = dirpc;
+ g_pc = dirpc;
return Value_new_ERROR(value, IOERROR, strerror(err));
}
@@ -314,13 +314,13 @@ struct Value *stmt_CHDIR_MKDIR(struct Value *value)
struct Value *stmt_CLEAR(struct Value *value)
{
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- Global_clear(&globals);
+ Global_clear(&g_globals);
FS_closefiles();
}
- ++pc.token;
+ ++g_pc.token;
return (struct Value *)0;
}
@@ -329,14 +329,14 @@ struct Value *stmt_CLOSE(struct Value *value)
int hasargs = 0;
struct Pc chnpc;
- ++pc.token;
+ ++g_pc.token;
while (1)
{
- chnpc = pc;
- if (pc.token->type == T_CHANNEL)
+ chnpc = g_pc;
+ if (g_pc.token->type == T_CHANNEL)
{
hasargs = 1;
- ++pc.token;
+ ++g_pc.token;
}
if (eval(value, (const char *)0) == (struct Value *)0)
@@ -358,16 +358,16 @@ struct Value *stmt_CLOSE(struct Value *value)
return value;
}
- if (pass == INTERPRET && FS_close(value->u.integer) == -1)
+ if (g_pass == INTERPRET && FS_close(value->u.integer) == -1)
{
Value_destroy(value);
- pc = chnpc;
+ g_pc = chnpc;
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -375,7 +375,7 @@ struct Value *stmt_CLOSE(struct Value *value)
}
}
- if (!hasargs && pass == INTERPRET)
+ if (!hasargs && g_pass == INTERPRET)
{
FS_closefiles();
}
@@ -385,12 +385,12 @@ struct Value *stmt_CLOSE(struct Value *value)
struct Value *stmt_CLS(struct Value *value)
{
- struct Pc statementpc = pc;
+ struct Pc statementpc = g_pc;
- ++pc.token;
- if (pass == INTERPRET && FS_cls(STDCHANNEL) == -1)
+ ++g_pc.token;
+ if (g_pass == INTERPRET && FS_cls(STDCHANNEL) == -1)
{
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
@@ -400,13 +400,13 @@ struct Value *stmt_CLS(struct Value *value)
struct Value *stmt_COLOR(struct Value *value)
{
int foreground = -1, background = -1;
- struct Pc statementpc = pc;
+ struct Pc statementpc = g_pc;
- ++pc.token;
+ ++g_pc.token;
if (eval(value, (const char *)0))
{
if (value->type == V_ERROR ||
- (pass != DECLARE && Value_retype(value, V_INTEGER)->type == V_ERROR))
+ (g_pass != DECLARE && Value_retype(value, V_INTEGER)->type == V_ERROR))
{
return value;
}
@@ -415,19 +415,19 @@ struct Value *stmt_COLOR(struct Value *value)
if (foreground < 0 || foreground > 15)
{
Value_destroy(value);
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, OUTOFRANGE, _("foreground colour"));
}
}
Value_destroy(value);
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, (const char *)0))
{
if (value->type == V_ERROR ||
- (pass != DECLARE &&
+ (g_pass != DECLARE &&
Value_retype(value, V_INTEGER)->type == V_ERROR))
{
return value;
@@ -437,21 +437,21 @@ struct Value *stmt_COLOR(struct Value *value)
if (background < 0 || background > 15)
{
Value_destroy(value);
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, OUTOFRANGE, _("background colour"));
}
}
Value_destroy(value);
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, (const char *)0))
{
int bordercolour = -1;
if (value->type == V_ERROR ||
- (pass != DECLARE &&
+ (g_pass != DECLARE &&
Value_retype(value, V_INTEGER)->type == V_ERROR))
{
return value;
@@ -461,7 +461,7 @@ struct Value *stmt_COLOR(struct Value *value)
if (bordercolour < 0 || bordercolour > 15)
{
Value_destroy(value);
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, OUTOFRANGE, _("border colour"));
}
}
@@ -470,7 +470,7 @@ struct Value *stmt_COLOR(struct Value *value)
}
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
FS_colour(STDCHANNEL, foreground, background);
}
@@ -485,28 +485,28 @@ struct Value *stmt_DATA(struct Value *value)
return Value_new_ERROR(value, NOTINDIRECTMODE);
}
- if (pass == DECLARE)
+ if (g_pass == DECLARE)
{
- *lastdata = pc;
- (lastdata = &(pc.token->u.nextdata))->line = -1;
+ *g_lastdata = g_pc;
+ (g_lastdata = &(g_pc.token->u.nextdata))->line = -1;
}
- ++pc.token;
+ ++g_pc.token;
while (1)
{
- if (pc.token->type != T_STRING && pc.token->type != T_DATAINPUT)
+ if (g_pc.token->type != T_STRING && g_pc.token->type != T_DATAINPUT)
{
return Value_new_ERROR(value, MISSINGDATAINPUT);
}
- ++pc.token;
- if (pc.token->type != T_COMMA)
+ ++g_pc.token;
+ if (g_pc.token->type != T_COMMA)
{
break;
}
else
{
- ++pc.token;
+ ++g_pc.token;
}
}
@@ -515,9 +515,9 @@ struct Value *stmt_DATA(struct Value *value)
struct Value *stmt_DEFFN_DEFPROC_FUNCTION_SUB(struct Value *value)
{
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
- struct Pc statementpc = pc;
+ struct Pc statementpc = g_pc;
struct Identifier *fn;
int proc;
int args = 0;
@@ -527,9 +527,9 @@ struct Value *stmt_DEFFN_DEFPROC_FUNCTION_SUB(struct Value *value)
return Value_new_ERROR(value, NOTINDIRECTMODE);
}
- proc = (pc.token->type == T_DEFPROC || pc.token->type == T_SUB);
- ++pc.token;
- if (pc.token->type != T_IDENTIFIER)
+ proc = (g_pc.token->type == T_DEFPROC || g_pc.token->type == T_SUB);
+ ++g_pc.token;
+ if (g_pc.token->type != T_IDENTIFIER)
{
if (proc)
{
@@ -541,42 +541,42 @@ struct Value *stmt_DEFFN_DEFPROC_FUNCTION_SUB(struct Value *value)
}
}
- fn = pc.token->u.identifier;
+ fn = g_pc.token->u.identifier;
if (proc)
{
fn->defaultType = V_VOID;
}
- ++pc.token;
+ ++g_pc.token;
if (findLabel(L_FUNC))
{
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, NESTEDDEFINITION);
}
- Auto_variable(&stack, fn);
- if (pc.token->type == T_OP) /* arguments */
+ Auto_variable(&g_stack, fn);
+ if (g_pc.token->type == T_OP) /* arguments */
{
- ++pc.token;
+ ++g_pc.token;
while (1)
{
- if (pc.token->type != T_IDENTIFIER)
+ if (g_pc.token->type != T_IDENTIFIER)
{
- Auto_funcEnd(&stack);
+ Auto_funcEnd(&g_stack);
return Value_new_ERROR(value, MISSINGFORMIDENT);
}
- if (Auto_variable(&stack, pc.token->u.identifier) == 0)
+ if (Auto_variable(&g_stack, g_pc.token->u.identifier) == 0)
{
- Auto_funcEnd(&stack);
+ Auto_funcEnd(&g_stack);
return Value_new_ERROR(value, ALREADYDECLARED);
}
++args;
- ++pc.token;
- if (pc.token->type == T_COMMA)
+ ++g_pc.token;
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -584,16 +584,16 @@ struct Value *stmt_DEFFN_DEFPROC_FUNCTION_SUB(struct Value *value)
}
}
- if (pc.token->type != T_CP)
+ if (g_pc.token->type != T_CP)
{
- Auto_funcEnd(&stack);
+ Auto_funcEnd(&g_stack);
return Value_new_ERROR(value, MISSINGCP);
}
- ++pc.token;
+ ++g_pc.token;
}
- if (pass == DECLARE)
+ if (g_pass == DECLARE)
{
enum ValueType *t =
args ? malloc(args * sizeof(enum ValueType)) : (enum ValueType *)0;
@@ -601,30 +601,30 @@ struct Value *stmt_DEFFN_DEFPROC_FUNCTION_SUB(struct Value *value)
for (i = 0; i < args; ++i)
{
- t[i] = Auto_argType(&stack, i);
+ t[i] = Auto_argType(&g_stack, i);
}
if (Global_function
- (&globals, fn, fn->defaultType, &pc, &statementpc, args, t) == 0)
+ (&g_globals, fn, fn->defaultType, &g_pc, &statementpc, args, t) == 0)
{
free(t);
- Auto_funcEnd(&stack);
- pc = statementpc;
+ Auto_funcEnd(&g_stack);
+ g_pc = statementpc;
return Value_new_ERROR(value, REDECLARATION);
}
- Program_addScope(&program, &fn->sym->u.sub.u.def.scope);
+ Program_addScope(&g_program, &fn->sym->u.sub.u.def.scope);
}
pushLabel(L_FUNC, &statementpc);
- if (pc.token->type == T_EQ)
+ if (g_pc.token->type == T_EQ)
{
return stmt_EQ_FNRETURN_FNEND(value);
}
}
else
{
- pc = (pc.token + 1)->u.identifier->sym->u.sub.u.def.scope.end;
+ g_pc = (g_pc.token + 1)->u.identifier->sym->u.sub.u.def.scope.end;
}
return (struct Value *)0;
@@ -634,23 +634,23 @@ struct Value *stmt_DEC_INC(struct Value *value)
{
int step;
- step = (pc.token->type == T_DEC ? -1 : 1);
- ++pc.token;
+ step = (g_pc.token->type == T_DEC ? -1 : 1);
+ ++g_pc.token;
while (1)
{
struct Value *l, stepValue;
struct Pc lvaluepc;
- lvaluepc = pc;
- if (pc.token->type != T_IDENTIFIER)
+ lvaluepc = g_pc;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGDECINCIDENT);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType,
- (pc.token + 1)->type ==
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType,
+ (g_pc.token + 1)->type ==
T_OP ? GLOBALARRAY : GLOBALVAR, 0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
@@ -671,19 +671,19 @@ struct Value *stmt_DEC_INC(struct Value *value)
}
else
{
- pc = lvaluepc;
+ g_pc = lvaluepc;
return Value_new_ERROR(value, TYPEMISMATCH5);
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
Value_add(l, &stepValue, 1);
}
Value_destroy(&stepValue);
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -698,7 +698,7 @@ struct Value *stmt_DEFINT_DEFDBL_DEFSTR(struct Value *value)
{
enum ValueType dsttype = V_NIL;
- switch (pc.token->type)
+ switch (g_pc.token->type)
{
case T_DEFINT:
dsttype = V_INTEGER;
@@ -716,17 +716,17 @@ struct Value *stmt_DEFINT_DEFDBL_DEFSTR(struct Value *value)
assert(0);
}
- ++pc.token;
+ ++g_pc.token;
while (1)
{
struct Identifier *ident;
- if (pc.token->type != T_IDENTIFIER)
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGVARIDENT);
}
- if (pc.token->u.identifier->defaultType != V_REAL)
+ if (g_pc.token->u.identifier->defaultType != V_REAL)
{
switch (dsttype)
{
@@ -744,9 +744,9 @@ struct Value *stmt_DEFINT_DEFDBL_DEFSTR(struct Value *value)
}
}
- ident = pc.token->u.identifier;
- ++pc.token;
- if (pc.token->type == T_MINUS)
+ ident = g_pc.token->u.identifier;
+ ++g_pc.token;
+ if (g_pc.token->type == T_MINUS)
{
struct Identifier i;
@@ -755,34 +755,34 @@ struct Value *stmt_DEFINT_DEFDBL_DEFSTR(struct Value *value)
return Value_new_ERROR(value, BADRANGE);
}
- ++pc.token;
- if (pc.token->type != T_IDENTIFIER)
+ ++g_pc.token;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGVARIDENT);
}
- if (strlen(pc.token->u.identifier->name) != 1)
+ if (strlen(g_pc.token->u.identifier->name) != 1)
{
return Value_new_ERROR(value, BADRANGE);
}
for (i.name[0] = tolower(ident->name[0]), i.name[1] = '\0';
- i.name[0] <= tolower(pc.token->u.identifier->name[0]);
+ i.name[0] <= tolower(g_pc.token->u.identifier->name[0]);
++i.name[0])
{
- Global_variable(&globals, &i, dsttype, GLOBALVAR, 1);
+ Global_variable(&g_globals, &i, dsttype, GLOBALVAR, 1);
}
- ++pc.token;
+ ++g_pc.token;
}
else
{
- Global_variable(&globals, ident, dsttype, GLOBALVAR, 1);
+ Global_variable(&g_globals, ident, dsttype, GLOBALVAR, 1);
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -798,39 +798,39 @@ struct Value *stmt_DELETE(struct Value *value)
struct Pc from, to;
int f = 0, t = 0;
- if (pass == INTERPRET && !DIRECTMODE)
+ if (g_pass == INTERPRET && !DIRECTMODE)
{
return Value_new_ERROR(value, NOTINPROGRAMMODE);
}
- ++pc.token;
- if (pc.token->type == T_INTEGER)
+ ++g_pc.token;
+ if (g_pc.token->type == T_INTEGER)
{
- if (pass == INTERPRET &&
- Program_goLine(&program, pc.token->u.integer,
+ if (g_pass == INTERPRET &&
+ Program_goLine(&g_program, g_pc.token->u.integer,
&from) == (struct Pc *)0)
{
return Value_new_ERROR(value, NOSUCHLINE);
}
f = 1;
- ++pc.token;
+ ++g_pc.token;
}
- if (pc.token->type == T_MINUS || pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_MINUS || g_pc.token->type == T_COMMA)
{
- ++pc.token;
- if (pc.token->type == T_INTEGER)
+ ++g_pc.token;
+ if (g_pc.token->type == T_INTEGER)
{
- if (pass == INTERPRET &&
- Program_goLine(&program, pc.token->u.integer,
+ if (g_pass == INTERPRET &&
+ Program_goLine(&g_program, g_pc.token->u.integer,
&to) == (struct Pc *)0)
{
return Value_new_ERROR(value, NOSUCHLINE);
}
t = 1;
- ++pc.token;
+ ++g_pc.token;
}
}
else if (f == 1)
@@ -844,9 +844,9 @@ struct Value *stmt_DELETE(struct Value *value)
return Value_new_ERROR(value, MISSINGLINENUMBER);
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- Program_delete(&program, f ? &from : (struct Pc *)0,
+ Program_delete(&g_program, f ? &from : (struct Pc *)0,
t ? &to : (struct Pc *)0);
}
@@ -855,7 +855,7 @@ struct Value *stmt_DELETE(struct Value *value)
struct Value *stmt_DIM(struct Value *value)
{
- ++pc.token;
+ ++g_pc.token;
while (1)
{
unsigned int capacity = 0, *geometry = (unsigned int *)0;
@@ -864,39 +864,39 @@ struct Value *stmt_DIM(struct Value *value)
unsigned int dim;
enum ValueType vartype;
- if (pc.token->type != T_IDENTIFIER)
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGARRIDENT);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType, GLOBALARRAY,
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType, GLOBALARRAY,
0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
}
- var = &pc.token->u.identifier->sym->u.var;
- if (pass == INTERPRET && var->dim)
+ var = &g_pc.token->u.identifier->sym->u.var;
+ if (g_pass == INTERPRET && var->dim)
{
return Value_new_ERROR(value, REDIM);
}
vartype = var->type;
- ++pc.token;
- if (pc.token->type != T_OP)
+ ++g_pc.token;
+ if (g_pc.token->type != T_OP)
{
return Value_new_ERROR(value, MISSINGOP);
}
- ++pc.token;
+ ++g_pc.token;
dim = 0;
while (1)
{
- dimpc = pc;
+ dimpc = g_pc;
if (eval(value, _("dimension"))->type == V_ERROR ||
- (pass != DECLARE &&
+ (g_pass != DECLARE &&
Value_retype(value, V_INTEGER)->type == V_ERROR))
{
if (capacity)
@@ -907,7 +907,7 @@ struct Value *stmt_DIM(struct Value *value)
return value;
}
- if (pass == INTERPRET && value->u.integer < optionbase) /* error */
+ if (g_pass == INTERPRET && value->u.integer < optionbase) /* error */
{
Value_destroy(value);
Value_new_ERROR(value, OUTOFRANGE, _("dimension"));
@@ -920,11 +920,11 @@ struct Value *stmt_DIM(struct Value *value)
free(geometry);
}
- pc = dimpc;
+ g_pc = dimpc;
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (dim == capacity) /* enlarge geometry */
{
@@ -942,9 +942,9 @@ struct Value *stmt_DIM(struct Value *value)
}
Value_destroy(value);
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -952,7 +952,7 @@ struct Value *stmt_DIM(struct Value *value)
}
}
- if (pc.token->type != T_CP) /* abort */
+ if (g_pc.token->type != T_CP) /* abort */
{
if (capacity)
{
@@ -962,8 +962,8 @@ struct Value *stmt_DIM(struct Value *value)
return Value_new_ERROR(value, MISSINGCP);
}
- ++pc.token;
- if (pass == INTERPRET)
+ ++g_pc.token;
+ if (g_pass == INTERPRET)
{
struct Var newarray;
@@ -980,9 +980,9 @@ struct Value *stmt_DIM(struct Value *value)
free(geometry);
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token; /* advance to next var */
+ ++g_pc.token; /* advance to next var */
}
else
{
@@ -995,21 +995,21 @@ struct Value *stmt_DIM(struct Value *value)
struct Value *stmt_DISPLAY(struct Value *value)
{
- struct Pc statementpc = pc;
+ struct Pc statementpc = g_pc;
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("file name"))->type == V_ERROR ||
- (pass != DECLARE && Value_retype(value, V_STRING)->type == V_ERROR))
+ (g_pass != DECLARE && Value_retype(value, V_STRING)->type == V_ERROR))
{
return value;
}
- if (pass == INTERPRET && cat(value->u.string.character) == -1)
+ if (g_pass == INTERPRET && cat(value->u.string.character) == -1)
{
const char *msg = strerror(errno);
Value_destroy(value);
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, IOERROR, msg);
}
else
@@ -1022,32 +1022,32 @@ struct Value *stmt_DISPLAY(struct Value *value)
struct Value *stmt_DO(struct Value *value)
{
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
- pushLabel(L_DO, &pc);
+ pushLabel(L_DO, &g_pc);
}
- ++pc.token;
+ ++g_pc.token;
return (struct Value *)0;
}
struct Value *stmt_DOcondition(struct Value *value)
{
- struct Pc dowhilepc = pc;
- int negate = (pc.token->type == T_DOUNTIL);
+ struct Pc dowhilepc = g_pc;
+ int negate = (g_pc.token->type == T_DOUNTIL);
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
- pushLabel(L_DOcondition, &pc);
+ pushLabel(L_DOcondition, &g_pc);
}
- ++pc.token;
+ ++g_pc.token;
if (eval(value, "condition")->type == V_ERROR)
{
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
int condition;
@@ -1059,7 +1059,7 @@ struct Value *stmt_DOcondition(struct Value *value)
if (condition)
{
- pc = dowhilepc.token->u.exitdo;
+ g_pc = dowhilepc.token->u.exitdo;
}
Value_destroy(value);
@@ -1072,17 +1072,17 @@ struct Value *stmt_EDIT(struct Value *value)
{
#ifdef CONFIG_ARCH_HAVE_VFORK
long int line;
- struct Pc statementpc = pc;
+ struct Pc statementpc = g_pc;
int status;
- ++pc.token;
- if (pc.token->type == T_INTEGER)
+ ++g_pc.token;
+ if (g_pc.token->type == T_INTEGER)
{
struct Pc where;
- if (program.numbered)
+ if (g_program.numbered)
{
- if (Program_goLine(&program, pc.token->u.integer, &where) ==
+ if (Program_goLine(&g_program, g_pc.token->u.integer, &where) ==
(struct Pc *)0)
{
return Value_new_ERROR(value, NOSUCHLINE);
@@ -1092,25 +1092,25 @@ struct Value *stmt_EDIT(struct Value *value)
}
else
{
- if (!Program_end(&program, &where))
+ if (!Program_end(&g_program, &where))
{
return Value_new_ERROR(value, NOPROGRAM);
}
- line = pc.token->u.integer;
+ line = g_pc.token->u.integer;
if (line < 1 || line > (where.line + 1))
{
return Value_new_ERROR(value, NOSUCHLINE);
}
}
- ++pc.token;
+ ++g_pc.token;
}
else
{
line = 1;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
/* variables */
@@ -1157,33 +1157,33 @@ struct Value *stmt_EDIT(struct Value *value)
if (!DIRECTMODE)
{
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, NOTINPROGRAMMODE);
}
if ((name = tmpnam(NULL)) == (char *)0)
{
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, IOERROR,
_("generating temporary file name failed"));
}
if ((chn = FS_openout(name)) == -1)
{
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, IOERRORCREATE, name, FS_errmsg);
}
FS_width(chn, 0);
- if (Program_list(&program, chn, 0, (struct Pc *)0, (struct Pc *)0, value))
+ if (Program_list(&g_program, chn, 0, (struct Pc *)0, (struct Pc *)0, value))
{
- pc = statementpc;
+ g_pc = statementpc;
return value;
}
if (FS_close(chn) == -1)
{
- pc = statementpc;
+ g_pc = statementpc;
unlink(name);
return Value_new_ERROR(value, IOERRORCLOSE, name, FS_errmsg);
}
@@ -1246,7 +1246,7 @@ struct Value *stmt_EDIT(struct Value *value)
String_destroy(&cmd);
if ((chn = FS_openin(name)) == -1)
{
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, IOERROROPEN, name, FS_errmsg);
}
@@ -1255,14 +1255,14 @@ struct Value *stmt_EDIT(struct Value *value)
{
FS_close(chn);
unlink(name);
- pc = statementpc;
+ g_pc = statementpc;
return value;
}
FS_close(chn);
- Program_setname(&newProgram, program.name.character);
- Program_destroy(&program);
- program = newProgram;
+ Program_setname(&newProgram, g_program.name.character);
+ Program_destroy(&g_program);
+ g_program = newProgram;
unlink(name);
}
@@ -1274,16 +1274,16 @@ struct Value *stmt_EDIT(struct Value *value)
struct Value *stmt_ELSE_ELSEIFELSE(struct Value *value)
{
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- pc = pc.token->u.endifpc;
+ g_pc = g_pc.token->u.endifpc;
}
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
- struct Pc elsepc = pc;
+ struct Pc elsepc = g_pc;
struct Pc *ifinstr;
- int elseifelse = (pc.token->type == T_ELSEIFELSE);
+ int elseifelse = (g_pc.token->type == T_ELSEIFELSE);
if ((ifinstr = popLabel(L_IF)) == (struct Pc *)0)
{
@@ -1292,11 +1292,11 @@ struct Value *stmt_ELSE_ELSEIFELSE(struct Value *value)
if (ifinstr->token->type == T_ELSEIFIF)
{
- (ifinstr->token - 1)->u.elsepc = pc;
+ (ifinstr->token - 1)->u.elsepc = g_pc;
}
- ++pc.token;
- ifinstr->token->u.elsepc = pc;
+ ++g_pc.token;
+ ifinstr->token->u.elsepc = g_pc;
assert(ifinstr->token->type == T_ELSEIFIF ||
ifinstr->token->type == T_IF);
if (elseifelse)
@@ -1313,27 +1313,27 @@ struct Value *stmt_ELSE_ELSEIFELSE(struct Value *value)
struct Value *stmt_END(struct Value *value)
{
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- pc = pc.token->u.endpc;
+ g_pc = g_pc.token->u.endpc;
bas_end = 1;
}
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
- if (Program_end(&program, &pc.token->u.endpc))
+ if (Program_end(&g_program, &g_pc.token->u.endpc))
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
struct Token *eol;
- for (eol = pc.token; eol->type != T_EOL; ++eol);
+ for (eol = g_pc.token; eol->type != T_EOL; ++eol);
- pc.token->u.endpc = pc;
- pc.token->u.endpc.token = eol;
- ++pc.token;
+ g_pc.token->u.endpc = g_pc;
+ g_pc.token->u.endpc.token = eol;
+ ++g_pc.token;
}
}
@@ -1342,9 +1342,9 @@ struct Value *stmt_END(struct Value *value)
struct Value *stmt_ENDIF(struct Value *value)
{
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
- struct Pc endifpc = pc;
+ struct Pc endifpc = g_pc;
struct Pc *ifpc;
struct Pc *elsepc;
@@ -1353,7 +1353,7 @@ struct Value *stmt_ENDIF(struct Value *value)
ifpc->token->u.elsepc = endifpc;
if (ifpc->token->type == T_ELSEIFIF)
{
- (ifpc->token - 1)->u.elsepc = pc;
+ (ifpc->token - 1)->u.elsepc = g_pc;
}
}
else if ((elsepc = popLabel(L_ELSE)))
@@ -1366,16 +1366,16 @@ struct Value *stmt_ENDIF(struct Value *value)
}
}
- ++pc.token;
+ ++g_pc.token;
return (struct Value *)0;
}
struct Value *stmt_ENDFN(struct Value *value)
{
struct Pc *curfn = (struct Pc *)0;
- struct Pc eqpc = pc;
+ struct Pc eqpc = g_pc;
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
if ((curfn = popLabel(L_FUNC)) == (struct Pc *)0)
{
@@ -1389,20 +1389,20 @@ struct Value *stmt_ENDFN(struct Value *value)
}
}
- ++pc.token;
- if (pass == INTERPRET)
+ ++g_pc.token;
+ if (g_pass == INTERPRET)
{
return Value_clone(value,
- Var_value(Auto_local(&stack, 0), 0, (int *)0,
+ Var_value(Auto_local(&g_stack, 0), 0, (int *)0,
(struct Value *)0));
}
else
{
- if (pass == DECLARE)
+ if (g_pass == DECLARE)
{
- Global_endfunction(&globals, (curfn->token + 1)->u.identifier, &pc);
+ Global_endfunction(&g_globals, (curfn->token + 1)->u.identifier, &g_pc);
}
- Auto_funcEnd(&stack);
+ Auto_funcEnd(&g_stack);
}
return (struct Value *)0;
@@ -1412,7 +1412,7 @@ struct Value *stmt_ENDPROC_SUBEND(struct Value *value)
{
struct Pc *curfn = (struct Pc *)0;
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
if ((curfn = popLabel(L_FUNC)) == (struct Pc *)0 ||
(curfn->token + 1)->u.identifier->defaultType != V_VOID)
@@ -1426,19 +1426,19 @@ struct Value *stmt_ENDPROC_SUBEND(struct Value *value)
}
}
- ++pc.token;
- if (pass == INTERPRET)
+ ++g_pc.token;
+ if (g_pass == INTERPRET)
{
return Value_new_VOID(value);
}
else
{
- if (pass == DECLARE)
+ if (g_pass == DECLARE)
{
- Global_endfunction(&globals, (curfn->token + 1)->u.identifier, &pc);
+ Global_endfunction(&g_globals, (curfn->token + 1)->u.identifier, &g_pc);
}
- Auto_funcEnd(&stack);
+ Auto_funcEnd(&g_stack);
}
return (struct Value *)0;
@@ -1446,20 +1446,20 @@ struct Value *stmt_ENDPROC_SUBEND(struct Value *value)
struct Value *stmt_ENDSELECT(struct Value *value)
{
- struct Pc statementpc = pc;
+ struct Pc statementpc = g_pc;
- ++pc.token;
- if (pass == DECLARE || pass == COMPILE)
+ ++g_pc.token;
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
struct Pc *selectcasepc;
if ((selectcasepc = popLabel(L_SELECTCASE)))
{
- selectcasepc->token->u.selectcase->endselect = pc;
+ selectcasepc->token->u.selectcase->endselect = g_pc;
}
else
{
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, STRAYENDSELECT);
}
}
@@ -1469,21 +1469,21 @@ struct Value *stmt_ENDSELECT(struct Value *value)
struct Value *stmt_ENVIRON(struct Value *value)
{
- struct Pc epc = pc;
+ struct Pc epc = g_pc;
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("environment variable"))->type == V_ERROR ||
Value_retype(value, V_STRING)->type == V_ERROR)
{
return value;
}
- if (pass == INTERPRET && value->u.string.character)
+ if (g_pass == INTERPRET && value->u.string.character)
{
if (putenv(value->u.string.character) == -1)
{
Value_destroy(value);
- pc = epc;
+ g_pc = epc;
return Value_new_ERROR(value, ENVIRONFAILED, strerror(errno));
}
}
@@ -1496,7 +1496,7 @@ struct Value *stmt_FNEXIT(struct Value *value)
{
struct Pc *curfn = (struct Pc *)0;
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
if ((curfn = findLabel(L_FUNC)) == (struct Pc *)0 ||
(curfn->token + 1)->u.identifier->defaultType == V_VOID)
@@ -1505,11 +1505,11 @@ struct Value *stmt_FNEXIT(struct Value *value)
}
}
- ++pc.token;
- if (pass == INTERPRET)
+ ++g_pc.token;
+ if (g_pass == INTERPRET)
{
return Value_clone(value,
- Var_value(Auto_local(&stack, 0), 0, (int *)0,
+ Var_value(Auto_local(&g_stack, 0), 0, (int *)0,
(struct Value *)0));
}
@@ -1523,17 +1523,17 @@ struct Value *stmt_COLON_EOL(struct Value *value)
struct Value *stmt_QUOTE_REM(struct Value *value)
{
- ++pc.token;
+ ++g_pc.token;
return (struct Value *)0;
}
struct Value *stmt_EQ_FNRETURN_FNEND(struct Value *value)
{
struct Pc *curfn = (struct Pc *)0;
- struct Pc eqpc = pc;
- enum TokenType t = pc.token->type;
+ struct Pc eqpc = g_pc;
+ enum TokenType t = g_pc.token->type;
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
if (t == T_EQ)
{
@@ -1576,20 +1576,20 @@ struct Value *stmt_EQ_FNRETURN_FNEND(struct Value *value)
}
}
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("return"))->type == V_ERROR ||
Value_retype(value, eqpc.token->u.type)->type == V_ERROR)
{
- if (pass != INTERPRET)
+ if (g_pass != INTERPRET)
{
- Auto_funcEnd(&stack);
+ Auto_funcEnd(&g_stack);
}
- pc = eqpc;
+ g_pc = eqpc;
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
return value;
}
@@ -1598,13 +1598,13 @@ struct Value *stmt_EQ_FNRETURN_FNEND(struct Value *value)
Value_destroy(value);
if (t == T_EQ || t == T_FNEND)
{
- if (pass == DECLARE)
+ if (g_pass == DECLARE)
{
- Global_endfunction(&globals, (curfn->token + 1)->u.identifier,
- &pc);
+ Global_endfunction(&g_globals, (curfn->token + 1)->u.identifier,
+ &g_pc);
}
- Auto_funcEnd(&stack);
+ Auto_funcEnd(&g_stack);
}
}
@@ -1613,31 +1613,31 @@ struct Value *stmt_EQ_FNRETURN_FNEND(struct Value *value)
struct Value *stmt_ERASE(struct Value *value)
{
- ++pc.token;
+ ++g_pc.token;
while (1)
{
- if (pc.token->type != T_IDENTIFIER)
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGARRIDENT);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType, GLOBALARRAY,
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType, GLOBALARRAY,
0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- Var_destroy(&pc.token->u.identifier->sym->u.var);
+ Var_destroy(&g_pc.token->u.identifier->sym->u.var);
}
- ++pc.token;
- if (pc.token->type == T_COMMA)
+ ++g_pc.token;
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -1650,13 +1650,13 @@ struct Value *stmt_ERASE(struct Value *value)
struct Value *stmt_EXITDO(struct Value *value)
{
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- pc = pc.token->u.exitdo;
+ g_pc = g_pc.token->u.exitdo;
}
else
{
- if (pass == COMPILE)
+ if (g_pass == COMPILE)
{
struct Pc *exitdo;
@@ -1666,10 +1666,10 @@ struct Value *stmt_EXITDO(struct Value *value)
return Value_new_ERROR(value, STRAYEXITDO);
}
- pc.token->u.exitdo = exitdo->token->u.exitdo;
+ g_pc.token->u.exitdo = exitdo->token->u.exitdo;
}
- ++pc.token;
+ ++g_pc.token;
}
return (struct Value *)0;
@@ -1677,13 +1677,13 @@ struct Value *stmt_EXITDO(struct Value *value)
struct Value *stmt_EXITFOR(struct Value *value)
{
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- pc = pc.token->u.exitfor;
+ g_pc = g_pc.token->u.exitfor;
}
else
{
- if (pass == COMPILE)
+ if (g_pass == COMPILE)
{
struct Pc *exitfor;
@@ -1692,10 +1692,10 @@ struct Value *stmt_EXITFOR(struct Value *value)
return Value_new_ERROR(value, STRAYEXITFOR);
}
- pc.token->u.exitfor = exitfor->token->u.exitfor;
+ g_pc.token->u.exitfor = exitfor->token->u.exitfor;
}
- ++pc.token;
+ ++g_pc.token;
}
return (struct Value *)0;
@@ -1705,10 +1705,10 @@ struct Value *stmt_FIELD(struct Value *value)
{
long int chn, offset, recLength = -1;
- ++pc.token;
- if (pc.token->type == T_CHANNEL)
+ ++g_pc.token;
+ if (g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
}
if (eval(value, _("channel"))->type == V_ERROR ||
@@ -1719,17 +1719,17 @@ struct Value *stmt_FIELD(struct Value *value)
chn = value->u.integer;
Value_destroy(value);
- if (pass == INTERPRET && (recLength = FS_recLength(chn)) == -1)
+ if (g_pass == INTERPRET && (recLength = FS_recLength(chn)) == -1)
{
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
- if (pc.token->type != T_COMMA)
+ if (g_pc.token->type != T_COMMA)
{
return Value_new_ERROR(value, MISSINGCOMMA);
}
- ++pc.token;
+ ++g_pc.token;
offset = 0;
while (1)
{
@@ -1737,7 +1737,7 @@ struct Value *stmt_FIELD(struct Value *value)
struct Value *l;
long int width;
- curpc = pc;
+ curpc = g_pc;
if (eval(value, _("field width"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -1746,28 +1746,28 @@ struct Value *stmt_FIELD(struct Value *value)
width = value->u.integer;
Value_destroy(value);
- if (pass == INTERPRET && offset + width > recLength)
+ if (g_pass == INTERPRET && offset + width > recLength)
{
- pc = curpc;
+ g_pc = curpc;
return Value_new_ERROR(value, OUTOFRANGE, _("field width"));
}
- if (pc.token->type != T_AS)
+ if (g_pc.token->type != T_AS)
{
return Value_new_ERROR(value, MISSINGAS);
}
- ++pc.token;
- curpc = pc;
- if (pc.token->type != T_IDENTIFIER)
+ ++g_pc.token;
+ curpc = g_pc;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGVARIDENT);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType,
- (pc.token + 1)->type ==
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType,
+ (g_pc.token + 1)->type ==
T_OP ? GLOBALARRAY : GLOBALVAR, 0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
@@ -1778,21 +1778,21 @@ struct Value *stmt_FIELD(struct Value *value)
return value;
}
- if (pass != DECLARE && l->type != V_STRING)
+ if (g_pass != DECLARE && l->type != V_STRING)
{
- pc = curpc;
+ g_pc = curpc;
return Value_new_ERROR(value, TYPEMISMATCH4);
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
FS_field(chn, &l->u.string, offset, width);
}
offset += width;
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -1805,14 +1805,14 @@ struct Value *stmt_FIELD(struct Value *value)
struct Value *stmt_FOR(struct Value *value)
{
- struct Pc forpc = pc;
+ struct Pc forpc = g_pc;
struct Pc varpc;
struct Pc limitpc;
struct Value limit, stepValue;
- ++pc.token;
- varpc = pc;
- if (pc.token->type != T_IDENTIFIER)
+ ++g_pc.token;
+ varpc = g_pc;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGLOOPIDENT);
}
@@ -1822,9 +1822,9 @@ struct Value *stmt_FOR(struct Value *value)
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(&limit, (const char *)0)->type == V_ERROR)
{
*value = limit;
@@ -1833,17 +1833,17 @@ struct Value *stmt_FOR(struct Value *value)
Value_retype(&limit, value->type);
assert(limit.type != V_ERROR);
- if (pc.token->type == T_STEP) /* STEP x */
+ if (g_pc.token->type == T_STEP) /* STEP x */
{
struct Pc stepPc;
- ++pc.token;
- stepPc = pc;
+ ++g_pc.token;
+ stepPc = g_pc;
if (eval(&stepValue, "`step'")->type == V_ERROR)
{
Value_destroy(value);
*value = stepValue;
- pc = stepPc;
+ g_pc = stepPc;
return value;
}
@@ -1864,7 +1864,7 @@ struct Value *stmt_FOR(struct Value *value)
if (Value_exitFor(value, &limit, &stepValue))
{
- pc = forpc.token->u.exitfor;
+ g_pc = forpc.token->u.exitfor;
}
Value_destroy(&limit);
@@ -1875,15 +1875,15 @@ struct Value *stmt_FOR(struct Value *value)
{
pushLabel(L_FOR, &forpc);
pushLabel(L_FOR_VAR, &varpc);
- if (pc.token->type != T_TO)
+ if (g_pc.token->type != T_TO)
{
Value_destroy(value);
return Value_new_ERROR(value, MISSINGTO);
}
- ++pc.token;
- pushLabel(L_FOR_LIMIT, &pc);
- limitpc = pc;
+ ++g_pc.token;
+ pushLabel(L_FOR_LIMIT, &g_pc);
+ limitpc = g_pc;
if (eval(&limit, (const char *)0) == (struct Value *)0)
{
Value_destroy(value);
@@ -1897,44 +1897,44 @@ struct Value *stmt_FOR(struct Value *value)
return value;
}
- if (pass != DECLARE)
+ if (g_pass != DECLARE)
{
struct Symbol *sym = varpc.token->u.identifier->sym;
if (VALUE_RETYPE
(&limit, sym->type == GLOBALVAR ||
- sym->type == GLOBALARRAY ? sym->u.var.type : Auto_varType(&stack,
+ sym->type == GLOBALARRAY ? sym->u.var.type : Auto_varType(&g_stack,
sym))->type
== V_ERROR)
{
Value_destroy(value);
*value = limit;
- pc = limitpc;
+ g_pc = limitpc;
return value;
}
}
Value_destroy(&limit);
- if (pc.token->type == T_STEP) /* STEP x */
+ if (g_pc.token->type == T_STEP) /* STEP x */
{
struct Pc stepPc;
- ++pc.token;
- stepPc = pc;
+ ++g_pc.token;
+ stepPc = g_pc;
if (eval(&stepValue, "`step'")->type == V_ERROR ||
- (pass != DECLARE &&
+ (g_pass != DECLARE &&
Value_retype(&stepValue, value->type)->type == V_ERROR))
{
Value_destroy(value);
*value = stepValue;
- pc = stepPc;
+ g_pc = stepPc;
return value;
}
}
else /* implicit numeric STEP */
{
VALUE_NEW_INTEGER(&stepValue, 1);
- if (pass != DECLARE &&
+ if (g_pass != DECLARE &&
VALUE_RETYPE(&stepValue, value->type)->type == V_ERROR)
{
Value_destroy(value);
@@ -1944,7 +1944,7 @@ struct Value *stmt_FOR(struct Value *value)
}
}
- pushLabel(L_FOR_BODY, &pc);
+ pushLabel(L_FOR_BODY, &g_pc);
Value_destroy(&stepValue);
Value_destroy(value);
}
@@ -1954,15 +1954,15 @@ struct Value *stmt_FOR(struct Value *value)
struct Value *stmt_GET_PUT(struct Value *value)
{
- struct Pc statementpc = pc;
- int put = pc.token->type == T_PUT;
+ struct Pc statementpc = g_pc;
+ int put = g_pc.token->type == T_PUT;
long int chn;
struct Pc errpc;
- ++pc.token;
- if (pc.token->type == T_CHANNEL)
+ ++g_pc.token;
+ if (g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
}
if (eval(value, _("channel"))->type == V_ERROR ||
@@ -1973,10 +1973,10 @@ struct Value *stmt_GET_PUT(struct Value *value)
chn = value->u.integer;
Value_destroy(value);
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
- errpc = pc;
+ ++g_pc.token;
+ errpc = g_pc;
if (eval(value, (const char *)0)) /* process record number/position */
{
int rec;
@@ -1989,17 +1989,17 @@ struct Value *stmt_GET_PUT(struct Value *value)
rec = value->u.integer;
Value_destroy(value);
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (rec < 1)
{
- pc = errpc;
+ g_pc = errpc;
return Value_new_ERROR(value, OUTOFRANGE, _("record number"));
}
if (FS_seek((int)chn, rec - 1) == -1)
{
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
}
@@ -2007,11 +2007,11 @@ struct Value *stmt_GET_PUT(struct Value *value)
}
- if (pc.token->type == T_COMMA) /* BINARY mode get/put */
+ if (g_pc.token->type == T_COMMA) /* BINARY mode get/put */
{
int res = -1;
- ++pc.token;
+ ++g_pc.token;
if (put)
{
if (eval(value, _("`put'/`get' data"))->type == V_ERROR)
@@ -2019,7 +2019,7 @@ struct Value *stmt_GET_PUT(struct Value *value)
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
switch (value->type)
{
@@ -2046,18 +2046,18 @@ struct Value *stmt_GET_PUT(struct Value *value)
{
struct Value *l;
- if (pc.token->type != T_IDENTIFIER)
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGPROCIDENT);
}
- if (pass == DECLARE)
+ if (g_pass == DECLARE)
{
- if (((pc.token + 1)->type == T_OP ||
- Auto_find(&stack, pc.token->u.identifier) == 0) &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType,
- (pc.token + 1)->type ==
+ if (((g_pc.token + 1)->type == T_OP ||
+ Auto_find(&g_stack, g_pc.token->u.identifier) == 0) &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType,
+ (g_pc.token + 1)->type ==
T_OP ? GLOBALARRAY : GLOBALVAR, 0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
@@ -2069,7 +2069,7 @@ struct Value *stmt_GET_PUT(struct Value *value)
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
switch (l->type)
{
@@ -2091,15 +2091,15 @@ struct Value *stmt_GET_PUT(struct Value *value)
}
}
- if (pass == INTERPRET && res == -1)
+ if (g_pass == INTERPRET && res == -1)
{
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
}
- else if (pass == INTERPRET && ((put ? FS_put : FS_get) (chn)) == -1)
+ else if (g_pass == INTERPRET && ((put ? FS_put : FS_get) (chn)) == -1)
{
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
@@ -2108,43 +2108,43 @@ struct Value *stmt_GET_PUT(struct Value *value)
struct Value *stmt_GOSUB(struct Value *value)
{
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- if (!program.runnable &&
+ if (!g_program.runnable &&
compileProgram(value, !DIRECTMODE)->type == V_ERROR)
{
return value;
}
- pc.token += 2;
- Auto_pushGosubRet(&stack, &pc);
- pc = (pc.token - 2)->u.gosubpc;
- Program_trace(&program, &pc, 0, 1);
+ g_pc.token += 2;
+ Auto_pushGosubRet(&g_stack, &g_pc);
+ g_pc = (g_pc.token - 2)->u.gosubpc;
+ Program_trace(&g_program, &g_pc, 0, 1);
}
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
- struct Token *gosubpc = pc.token;
+ struct Token *gosubpc = g_pc.token;
- ++pc.token;
- if (pc.token->type != T_INTEGER)
+ ++g_pc.token;
+ if (g_pc.token->type != T_INTEGER)
{
return Value_new_ERROR(value, MISSINGLINENUMBER);
}
- if (Program_goLine(&program, pc.token->u.integer, &gosubpc->u.gosubpc) ==
+ if (Program_goLine(&g_program, g_pc.token->u.integer, &gosubpc->u.gosubpc) ==
(struct Pc *)0)
{
return Value_new_ERROR(value, NOSUCHLINE);
}
- if (pass == COMPILE &&
- Program_scopeCheck(&program, &gosubpc->u.gosubpc, findLabel(L_FUNC)))
+ if (g_pass == COMPILE &&
+ Program_scopeCheck(&g_program, &gosubpc->u.gosubpc, findLabel(L_FUNC)))
{
return Value_new_ERROR(value, OUTOFSCOPE);
}
- ++pc.token;
+ ++g_pc.token;
}
return (struct Value *)0;
@@ -2152,50 +2152,50 @@ struct Value *stmt_GOSUB(struct Value *value)
struct Value *stmt_RESUME_GOTO(struct Value *value)
{
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- if (!program.runnable &&
+ if (!g_program.runnable &&
compileProgram(value, !DIRECTMODE)->type == V_ERROR)
{
return value;
}
- if (pc.token->type == T_RESUME)
+ if (g_pc.token->type == T_RESUME)
{
- if (!stack.resumeable)
+ if (!g_stack.resumeable)
{
return Value_new_ERROR(value, STRAYRESUME);
}
- stack.resumeable = 0;
+ g_stack.resumeable = 0;
}
- pc = pc.token->u.gotopc;
- Program_trace(&program, &pc, 0, 1);
+ g_pc = g_pc.token->u.gotopc;
+ Program_trace(&g_program, &g_pc, 0, 1);
}
- else if (pass == DECLARE || pass == COMPILE)
+ else if (g_pass == DECLARE || g_pass == COMPILE)
{
- struct Token *gotopc = pc.token;
+ struct Token *gotopc = g_pc.token;
- ++pc.token;
- if (pc.token->type != T_INTEGER)
+ ++g_pc.token;
+ if (g_pc.token->type != T_INTEGER)
{
return Value_new_ERROR(value, MISSINGLINENUMBER);
}
- if (Program_goLine(&program, pc.token->u.integer, &gotopc->u.gotopc) ==
+ if (Program_goLine(&g_program, g_pc.token->u.integer, &gotopc->u.gotopc) ==
(struct Pc *)0)
{
return Value_new_ERROR(value, NOSUCHLINE);
}
- if (pass == COMPILE &&
- Program_scopeCheck(&program, &gotopc->u.gotopc, findLabel(L_FUNC)))
+ if (g_pass == COMPILE &&
+ Program_scopeCheck(&g_program, &gotopc->u.gotopc, findLabel(L_FUNC)))
{
return Value_new_ERROR(value, OUTOFSCOPE);
}
- ++pc.token;
+ ++g_pc.token;
}
return (struct Value *)0;
@@ -2203,21 +2203,21 @@ struct Value *stmt_RESUME_GOTO(struct Value *value)
struct Value *stmt_KILL(struct Value *value)
{
- struct Pc statementpc = pc;
+ struct Pc statementpc = g_pc;
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("file name"))->type == V_ERROR ||
- (pass != DECLARE && Value_retype(value, V_STRING)->type == V_ERROR))
+ (g_pass != DECLARE && Value_retype(value, V_STRING)->type == V_ERROR))
{
return value;
}
- if (pass == INTERPRET && unlink(value->u.string.character) == -1)
+ if (g_pass == INTERPRET && unlink(value->u.string.character) == -1)
{
const char *msg = strerror(errno);
Value_destroy(value);
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, IOERROR, msg);
}
else
@@ -2230,8 +2230,8 @@ struct Value *stmt_KILL(struct Value *value)
struct Value *stmt_LET(struct Value *value)
{
- ++pc.token;
- if (pc.token->type != T_IDENTIFIER)
+ ++g_pc.token;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGVARIDENT);
}
@@ -2241,7 +2241,7 @@ struct Value *stmt_LET(struct Value *value)
return value;
}
- if (pass != INTERPRET)
+ if (g_pass != INTERPRET)
{
Value_destroy(value);
}
@@ -2255,10 +2255,10 @@ struct Value *stmt_LINEINPUT(struct Value *value)
struct Pc lpc;
struct Value *l;
- ++pc.token;
- if (pc.token->type == T_CHANNEL)
+ ++g_pc.token;
+ if (g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("channel"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -2267,66 +2267,66 @@ struct Value *stmt_LINEINPUT(struct Value *value)
channel = value->u.integer;
Value_destroy(value);
- if (pc.token->type != T_COMMA)
+ if (g_pc.token->type != T_COMMA)
{
return Value_new_ERROR(value, MISSINGCOMMA);
}
else
{
- ++pc.token;
+ ++g_pc.token;
}
}
/* prompt */
- if (pc.token->type == T_STRING)
+ if (g_pc.token->type == T_STRING)
{
- if (pass == INTERPRET && channel == 0)
+ if (g_pass == INTERPRET && channel == 0)
{
- FS_putString(channel, pc.token->u.string);
+ FS_putString(channel, g_pc.token->u.string);
}
- ++pc.token;
- if (pc.token->type != T_SEMICOLON && pc.token->type != T_COMMA)
+ ++g_pc.token;
+ if (g_pc.token->type != T_SEMICOLON && g_pc.token->type != T_COMMA)
{
return Value_new_ERROR(value, MISSINGSEMICOMMA);
}
- ++pc.token;
+ ++g_pc.token;
}
- if (pass == INTERPRET && channel == 0)
+ if (g_pass == INTERPRET && channel == 0)
{
FS_flush(channel);
}
- if (pc.token->type != T_IDENTIFIER)
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGVARIDENT);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType,
- (pc.token + 1)->type == T_OP ? GLOBALARRAY : GLOBALVAR,
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType,
+ (g_pc.token + 1)->type == T_OP ? GLOBALARRAY : GLOBALVAR,
0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
}
- lpc = pc;
+ lpc = g_pc;
if (((l = lvalue(value))->type) == V_ERROR)
{
return value;
}
- if (pass == COMPILE && l->type != V_STRING)
+ if (g_pass == COMPILE && l->type != V_STRING)
{
- pc = lpc;
+ g_pc = lpc;
return Value_new_ERROR(value, TYPEMISMATCH4);
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
String_size(&l->u.string, 0);
if (FS_appendToString(channel, &l->u.string, 1) == -1)
@@ -2353,33 +2353,33 @@ struct Value *stmt_LIST_LLIST(struct Value *value)
struct Pc from, to;
int f = 0, t = 0, channel;
- channel = (pc.token->type == T_LLIST ? LPCHANNEL : STDCHANNEL);
- ++pc.token;
- if (pc.token->type == T_INTEGER)
+ channel = (g_pc.token->type == T_LLIST ? LPCHANNEL : STDCHANNEL);
+ ++g_pc.token;
+ if (g_pc.token->type == T_INTEGER)
{
- if (pass == INTERPRET &&
- Program_fromLine(&program, pc.token->u.integer,
+ if (g_pass == INTERPRET &&
+ Program_fromLine(&g_program, g_pc.token->u.integer,
&from) == (struct Pc *)0)
{
return Value_new_ERROR(value, NOSUCHLINE);
}
f = 1;
- ++pc.token;
+ ++g_pc.token;
}
- else if (pc.token->type != T_MINUS && pc.token->type != T_COMMA)
+ else if (g_pc.token->type != T_MINUS && g_pc.token->type != T_COMMA)
{
if (eval(value, (const char *)0))
{
if (value->type == V_ERROR ||
- (pass != DECLARE &&
+ (g_pass != DECLARE &&
Value_retype(value, V_INTEGER)->type == V_ERROR))
{
return value;
}
- if (pass == INTERPRET &&
- Program_fromLine(&program, value->u.integer,
+ if (g_pass == INTERPRET &&
+ Program_fromLine(&g_program, value->u.integer,
&from) == (struct Pc *)0)
{
return Value_new_ERROR(value, NOSUCHLINE);
@@ -2390,20 +2390,20 @@ struct Value *stmt_LIST_LLIST(struct Value *value)
}
}
- if (pc.token->type == T_MINUS || pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_MINUS || g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, (const char *)0))
{
if (value->type == V_ERROR ||
- (pass != DECLARE &&
+ (g_pass != DECLARE &&
Value_retype(value, V_INTEGER)->type == V_ERROR))
{
return value;
}
- if (pass == INTERPRET &&
- Program_toLine(&program, value->u.integer, &to) == (struct Pc *)0)
+ if (g_pass == INTERPRET &&
+ Program_toLine(&g_program, value->u.integer, &to) == (struct Pc *)0)
{
return Value_new_ERROR(value, NOSUCHLINE);
}
@@ -2418,12 +2418,12 @@ struct Value *stmt_LIST_LLIST(struct Value *value)
t = 1;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
/* Some implementations do not require direct mode */
if (Program_list
- (&program, channel, channel == STDCHANNEL, f ? &from : (struct Pc *)0,
+ (&g_program, channel, channel == STDCHANNEL, f ? &from : (struct Pc *)0,
t ? &to : (struct Pc *)0, value))
{
return value;
@@ -2437,43 +2437,43 @@ struct Value *stmt_LOAD(struct Value *value)
{
struct Pc loadpc;
- if (pass == INTERPRET && !DIRECTMODE)
+ if (g_pass == INTERPRET && !DIRECTMODE)
{
return Value_new_ERROR(value, NOTINPROGRAMMODE);
}
- ++pc.token;
- loadpc = pc;
+ ++g_pc.token;
+ loadpc = g_pc;
if (eval(value, _("file name"))->type == V_ERROR ||
Value_retype(value, V_STRING)->type == V_ERROR)
{
- pc = loadpc;
+ g_pc = loadpc;
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
int dev;
new();
- Program_setname(&program, value->u.string.character);
+ Program_setname(&g_program, value->u.string.character);
if ((dev = FS_openin(value->u.string.character)) == -1)
{
- pc = loadpc;
+ g_pc = loadpc;
Value_destroy(value);
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
FS_width(dev, 0);
Value_destroy(value);
- if (Program_merge(&program, dev, value))
+ if (Program_merge(&g_program, dev, value))
{
- pc = loadpc;
+ g_pc = loadpc;
return value;
}
FS_close(dev);
- program.unsaved = 0;
+ g_program.unsaved = 0;
}
else
{
@@ -2487,27 +2487,27 @@ struct Value *stmt_LOCAL(struct Value *value)
{
struct Pc *curfn = (struct Pc *)0;
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
if ((curfn = findLabel(L_FUNC)) == (struct Pc *)0)
return Value_new_ERROR(value, STRAYLOCAL);
}
- ++pc.token;
+ ++g_pc.token;
while (1)
{
- if (pc.token->type != T_IDENTIFIER)
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGVARIDENT);
}
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
struct Symbol *fnsym;
- if (Auto_variable(&stack, pc.token->u.identifier) == 0)
+ if (Auto_variable(&g_stack, g_pc.token->u.identifier) == 0)
return Value_new_ERROR(value, ALREADYLOCAL);
- if (pass == DECLARE)
+ if (g_pass == DECLARE)
{
assert(curfn->token->type == T_DEFFN ||
curfn->token->type == T_DEFPROC ||
@@ -2520,15 +2520,15 @@ struct Value *stmt_LOCAL(struct Value *value)
sizeof(enum ValueType) *
(fnsym->u.sub.u.def.localLength + 1));
fnsym->u.sub.u.def.localTypes[fnsym->u.sub.u.def.localLength] =
- pc.token->u.identifier->defaultType;
+ g_pc.token->u.identifier->defaultType;
++fnsym->u.sub.u.def.localLength;
}
}
- ++pc.token;
- if (pc.token->type == T_COMMA)
+ ++g_pc.token;
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -2543,10 +2543,10 @@ struct Value *stmt_LOCATE(struct Value *value)
{
long int line, column;
struct Pc argpc;
- struct Pc statementpc = pc;
+ struct Pc statementpc = g_pc;
- ++pc.token;
- argpc = pc;
+ ++g_pc.token;
+ argpc = g_pc;
if (eval(value, _("row"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -2555,22 +2555,22 @@ struct Value *stmt_LOCATE(struct Value *value)
line = value->u.integer;
Value_destroy(value);
- if (pass == INTERPRET && line < 1)
+ if (g_pass == INTERPRET && line < 1)
{
- pc = argpc;
+ g_pc = argpc;
return Value_new_ERROR(value, OUTOFRANGE, _("row"));
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
return Value_new_ERROR(value, MISSINGCOMMA);
}
- argpc = pc;
+ argpc = g_pc;
if (eval(value, _("column"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -2579,15 +2579,15 @@ struct Value *stmt_LOCATE(struct Value *value)
column = value->u.integer;
Value_destroy(value);
- if (pass == INTERPRET && column < 1)
+ if (g_pass == INTERPRET && column < 1)
{
- pc = argpc;
+ g_pc = argpc;
return Value_new_ERROR(value, OUTOFRANGE, _("column"));
}
- if (pass == INTERPRET && FS_locate(STDCHANNEL, line, column) == -1)
+ if (g_pass == INTERPRET && FS_locate(STDCHANNEL, line, column) == -1)
{
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
@@ -2596,13 +2596,13 @@ struct Value *stmt_LOCATE(struct Value *value)
struct Value *stmt_LOCK_UNLOCK(struct Value *value)
{
- int lock = pc.token->type == T_LOCK;
+ int lock = g_pc.token->type == T_LOCK;
int channel;
- ++pc.token;
- if (pc.token->type == T_CHANNEL)
+ ++g_pc.token;
+ if (g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
}
if (eval(value, _("channel"))->type == V_ERROR ||
@@ -2613,7 +2613,7 @@ struct Value *stmt_LOCK_UNLOCK(struct Value *value)
channel = value->u.integer;
Value_destroy(value);
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (FS_lock(channel, 0, 0, lock ? FS_LOCK_EXCLUSIVE : FS_LOCK_NONE, 1) ==
-1)
@@ -2627,16 +2627,16 @@ struct Value *stmt_LOCK_UNLOCK(struct Value *value)
struct Value *stmt_LOOP(struct Value *value)
{
- struct Pc looppc = pc;
+ struct Pc looppc = g_pc;
struct Pc *dopc;
- ++pc.token;
- if (pass == INTERPRET)
+ ++g_pc.token;
+ if (g_pass == INTERPRET)
{
- pc = looppc.token->u.dopc;
+ g_pc = looppc.token->u.dopc;
}
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
if ((dopc = popLabel(L_DO)) == (struct Pc *)0 &&
(dopc = popLabel(L_DOcondition)) == (struct Pc *)0)
@@ -2645,7 +2645,7 @@ struct Value *stmt_LOOP(struct Value *value)
}
looppc.token->u.dopc = *dopc;
- dopc->token->u.exitdo = pc;
+ dopc->token->u.exitdo = g_pc;
}
return (struct Value *)0;
@@ -2653,23 +2653,23 @@ struct Value *stmt_LOOP(struct Value *value)
struct Value *stmt_LOOPUNTIL(struct Value *value)
{
- struct Pc loopuntilpc = pc;
+ struct Pc loopuntilpc = g_pc;
struct Pc *dopc;
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("condition"))->type == V_ERROR)
{
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (Value_isNull(value))
- pc = loopuntilpc.token->u.dopc;
+ g_pc = loopuntilpc.token->u.dopc;
Value_destroy(value);
}
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
if ((dopc = popLabel(L_DO)) == (struct Pc *)0)
{
@@ -2677,7 +2677,7 @@ struct Value *stmt_LOOPUNTIL(struct Value *value)
}
loopuntilpc.token->u.until = *dopc;
- dopc->token->u.exitdo = pc;
+ dopc->token->u.exitdo = g_pc;
}
return (struct Value *)0;
@@ -2687,49 +2687,49 @@ struct Value *stmt_LSET_RSET(struct Value *value)
{
struct Value *l;
struct Pc tmppc;
- int lset = (pc.token->type == T_LSET);
+ int lset = (g_pc.token->type == T_LSET);
- ++pc.token;
- if (pass == DECLARE)
+ ++g_pc.token;
+ if (g_pass == DECLARE)
{
- if (((pc.token + 1)->type == T_OP ||
- Auto_find(&stack, pc.token->u.identifier) == 0) &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType,
- (pc.token + 1)->type ==
+ if (((g_pc.token + 1)->type == T_OP ||
+ Auto_find(&g_stack, g_pc.token->u.identifier) == 0) &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType,
+ (g_pc.token + 1)->type ==
T_OP ? GLOBALARRAY : GLOBALVAR, 0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
}
}
- tmppc = pc;
+ tmppc = g_pc;
if ((l = lvalue(value))->type == V_ERROR)
{
return value;
}
- if (pass == COMPILE && l->type != V_STRING)
+ if (g_pass == COMPILE && l->type != V_STRING)
{
- pc = tmppc;
+ g_pc = tmppc;
return Value_new_ERROR(value, TYPEMISMATCH4);
}
- if (pc.token->type != T_EQ)
+ if (g_pc.token->type != T_EQ)
{
return Value_new_ERROR(value, MISSINGEQ);
}
- ++pc.token;
- tmppc = pc;
+ ++g_pc.token;
+ tmppc = g_pc;
if (eval(value, _("rhs"))->type == V_ERROR ||
- (pass != DECLARE && Value_retype(value, l->type)->type == V_ERROR))
+ (g_pass != DECLARE && Value_retype(value, l->type)->type == V_ERROR))
{
- pc = tmppc;
+ g_pc = tmppc;
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
(lset ? String_lset : String_rset) (&l->u.string, &value->u.string);
}
@@ -2740,9 +2740,9 @@ struct Value *stmt_LSET_RSET(struct Value *value)
struct Value *stmt_IDENTIFIER(struct Value *value)
{
- struct Pc here = pc;
+ struct Pc here = g_pc;
- if (pass == DECLARE)
+ if (g_pass == DECLARE)
{
if (func(value)->type == V_ERROR)
{
@@ -2753,9 +2753,9 @@ struct Value *stmt_IDENTIFIER(struct Value *value)
Value_destroy(value);
}
- if (pc.token->type == T_EQ || pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_EQ || g_pc.token->type == T_COMMA)
{
- pc = here;
+ g_pc = here;
if (assign(value)->type == V_ERROR)
{
return value;
@@ -2766,20 +2766,20 @@ struct Value *stmt_IDENTIFIER(struct Value *value)
}
else
{
- if (pass == COMPILE)
+ if (g_pass == COMPILE)
{
- if (((pc.token + 1)->type == T_OP ||
- Auto_find(&stack, pc.token->u.identifier) == 0) &&
- Global_find(&globals, pc.token->u.identifier,
- (pc.token + 1)->type == T_OP) == 0)
+ if (((g_pc.token + 1)->type == T_OP ||
+ Auto_find(&g_stack, g_pc.token->u.identifier) == 0) &&
+ Global_find(&g_globals, g_pc.token->u.identifier,
+ (g_pc.token + 1)->type == T_OP) == 0)
{
return Value_new_ERROR(value, UNDECLARED);
}
}
- if (strcasecmp(pc.token->u.identifier->name, "mid$")
- && (pc.token->u.identifier->sym->type == USERFUNCTION ||
- pc.token->u.identifier->sym->type == BUILTINFUNCTION))
+ if (strcasecmp(g_pc.token->u.identifier->name, "mid$")
+ && (g_pc.token->u.identifier->sym->type == USERFUNCTION ||
+ g_pc.token->u.identifier->sym->type == BUILTINFUNCTION))
{
func(value);
if (Value_retype(value, V_VOID)->type == V_ERROR)
@@ -2796,7 +2796,7 @@ struct Value *stmt_IDENTIFIER(struct Value *value)
return value;
}
- if (pass != INTERPRET)
+ if (g_pass != INTERPRET)
{
Value_destroy(value);
}
@@ -2808,26 +2808,26 @@ struct Value *stmt_IDENTIFIER(struct Value *value)
struct Value *stmt_IF_ELSEIFIF(struct Value *value)
{
- struct Pc ifpc = pc;
+ struct Pc ifpc = g_pc;
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("condition"))->type == V_ERROR)
{
return value;
}
- if (pc.token->type != T_THEN)
+ if (g_pc.token->type != T_THEN)
{
Value_destroy(value);
return Value_new_ERROR(value, MISSINGTHEN);
}
- ++pc.token;
- if (pass == INTERPRET)
+ ++g_pc.token;
+ if (g_pass == INTERPRET)
{
if (Value_isNull(value))
{
- pc = ifpc.token->u.elsepc;
+ g_pc = ifpc.token->u.elsepc;
}
Value_destroy(value);
@@ -2835,7 +2835,7 @@ struct Value *stmt_IF_ELSEIFIF(struct Value *value)
else
{
Value_destroy(value);
- if (pc.token->type == T_EOL)
+ if (g_pc.token->type == T_EOL)
{
pushLabel(L_IF, &ifpc);
}
@@ -2847,15 +2847,15 @@ struct Value *stmt_IF_ELSEIFIF(struct Value *value)
}
Value_destroy(value);
- if (pc.token->type == T_ELSE)
+ if (g_pc.token->type == T_ELSE)
{
- struct Pc elsepc = pc;
+ struct Pc elsepc = g_pc;
- ++pc.token;
- ifpc.token->u.elsepc = pc;
+ ++g_pc.token;
+ ifpc.token->u.elsepc = g_pc;
if (ifpc.token->type == T_ELSEIFIF)
{
- (ifpc.token - 1)->u.elsepc = pc;
+ (ifpc.token - 1)->u.elsepc = g_pc;
}
if (statements(value)->type == V_ERROR)
@@ -2864,14 +2864,14 @@ struct Value *stmt_IF_ELSEIFIF(struct Value *value)
}
Value_destroy(value);
- elsepc.token->u.endifpc = pc;
+ elsepc.token->u.endifpc = g_pc;
}
else
{
- ifpc.token->u.elsepc = pc;
+ ifpc.token->u.elsepc = g_pc;
if (ifpc.token->type == T_ELSEIFIF)
{
- (ifpc.token - 1)->u.elsepc = pc;
+ (ifpc.token - 1)->u.elsepc = g_pc;
}
}
}
@@ -2883,13 +2883,13 @@ struct Value *stmt_IF_ELSEIFIF(struct Value *value)
struct Value *stmt_IMAGE(struct Value *value)
{
- ++pc.token;
- if (pc.token->type != T_STRING)
+ ++g_pc.token;
+ if (g_pc.token->type != T_STRING)
{
return Value_new_ERROR(value, MISSINGFMT);
}
- ++pc.token;
+ ++g_pc.token;
return (struct Value *)0;
}
@@ -2901,10 +2901,10 @@ struct Value *stmt_INPUT(struct Value *value)
struct Token *inputdata = (struct Token *)0, *t = (struct Token *)0;
struct Pc lvaluepc;
- ++pc.token;
- if (pc.token->type == T_CHANNEL)
+ ++g_pc.token;
+ if (g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("channel"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -2913,40 +2913,40 @@ struct Value *stmt_INPUT(struct Value *value)
channel = value->u.integer;
Value_destroy(value);
- if (pc.token->type != T_COMMA)
+ if (g_pc.token->type != T_COMMA)
{
return Value_new_ERROR(value, MISSINGCOMMA);
}
else
{
- ++pc.token;
+ ++g_pc.token;
}
}
- if (pc.token->type == T_SEMICOLON)
+ if (g_pc.token->type == T_SEMICOLON)
{
nl = 0;
- ++pc.token;
+ ++g_pc.token;
}
/* prompt */
- if (pc.token->type == T_STRING)
+ if (g_pc.token->type == T_STRING)
{
- if (pass == INTERPRET && channel == STDCHANNEL)
+ if (g_pass == INTERPRET && channel == STDCHANNEL)
{
- FS_putString(STDCHANNEL, pc.token->u.string);
+ FS_putString(STDCHANNEL, g_pc.token->u.string);
}
- ++pc.token;
- if (pc.token->type == T_COMMA || pc.token->type == T_COLON)
+ ++g_pc.token;
+ if (g_pc.token->type == T_COMMA || g_pc.token->type == T_COLON)
{
- ++pc.token;
+ ++g_pc.token;
extraprompt = 0;
}
- else if (pc.token->type == T_SEMICOLON)
+ else if (g_pc.token->type == T_SEMICOLON)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -2954,13 +2954,13 @@ struct Value *stmt_INPUT(struct Value *value)
}
}
- if (pass == INTERPRET && channel == STDCHANNEL && extraprompt)
+ if (g_pass == INTERPRET && channel == STDCHANNEL && extraprompt)
{
FS_putChars(STDCHANNEL, "? ");
}
retry:
- if (pass == INTERPRET) /* read input line and tokenise it */
+ if (g_pass == INTERPRET) /* read input line and tokenise it */
{
struct String s;
@@ -2988,27 +2988,27 @@ retry:
{
struct Value *l;
- if (pc.token->type != T_IDENTIFIER)
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGVARIDENT);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType,
- (pc.token + 1)->type ==
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType,
+ (g_pc.token + 1)->type ==
T_OP ? GLOBALARRAY : GLOBALVAR, 0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
}
- lvaluepc = pc;
+ lvaluepc = g_pc;
if (((l = lvalue(value))->type) == V_ERROR)
{
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (t->type == T_COMMA || t->type == T_EOL)
{
@@ -3019,7 +3019,7 @@ retry:
}
else if (convert(value, l, t))
{
- pc = lvaluepc;
+ g_pc = lvaluepc;
if (channel == STDCHANNEL)
{
struct String s;
@@ -3044,7 +3044,7 @@ retry:
++t;
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
if (t->type == T_COMMA)
{
@@ -3056,21 +3056,21 @@ retry:
if (channel == STDCHANNEL)
{
FS_putChars(STDCHANNEL, "?? ");
- ++pc.token;
+ ++g_pc.token;
goto retry;
}
else
{
- pc = lvaluepc;
+ g_pc = lvaluepc;
return Value_new_ERROR(value, MISSINGINPUTDATA);
}
}
}
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -3078,7 +3078,7 @@ retry:
}
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (t->type != T_EOL)
{
@@ -3099,160 +3099,160 @@ struct Value *stmt_MAT(struct Value *value)
oppc.line = -1;
oppc.token = (struct Token *)0;
- ++pc.token;
- if (pc.token->type != T_IDENTIFIER)
+ ++g_pc.token;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGMATIDENT);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType, GLOBALARRAY, 0) == 0)
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType, GLOBALARRAY, 0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
}
- var1 = &pc.token->u.identifier->sym->u.var;
- ++pc.token;
- if (pc.token->type != T_EQ)
+ var1 = &g_pc.token->u.identifier->sym->u.var;
+ ++g_pc.token;
+ if (g_pc.token->type != T_EQ)
{
return Value_new_ERROR(value, MISSINGEQ);
}
- ++pc.token;
- if (pc.token->type == T_IDENTIFIER) /* a = b [ +|-|* c ] */
+ ++g_pc.token;
+ if (g_pc.token->type == T_IDENTIFIER) /* a = b [ +|-|* c ] */
{
- if (pass == COMPILE)
+ if (g_pass == COMPILE)
{
- if (((pc.token + 1)->type == T_OP ||
- Auto_find(&stack, pc.token->u.identifier) == 0) &&
- Global_find(&globals, pc.token->u.identifier, 1) == 0)
+ if (((g_pc.token + 1)->type == T_OP ||
+ Auto_find(&g_stack, g_pc.token->u.identifier) == 0) &&
+ Global_find(&g_globals, g_pc.token->u.identifier, 1) == 0)
return Value_new_ERROR(value, UNDECLARED);
}
- var2 = &pc.token->u.identifier->sym->u.var;
- if (pass == INTERPRET &&
+ var2 = &g_pc.token->u.identifier->sym->u.var;
+ if (g_pass == INTERPRET &&
((var2->dim != 1 && var2->dim != 2) || var2->base < 0 ||
var2->base > 1))
{
return Value_new_ERROR(value, NOMATRIX, var2->dim, var2->base);
}
- if (pass == COMPILE &&
+ if (g_pass == COMPILE &&
Value_commonType[var1->type][var2->type] == V_ERROR)
{
return Value_new_typeError(value, var2->type, var1->type);
}
- ++pc.token;
- if (pc.token->type == T_PLUS || pc.token->type == T_MINUS ||
- pc.token->type == T_MULT)
+ ++g_pc.token;
+ if (g_pc.token->type == T_PLUS || g_pc.token->type == T_MINUS ||
+ g_pc.token->type == T_MULT)
{
- oppc = pc;
- op = pc.token->type;
- ++pc.token;
- if (pc.token->type != T_IDENTIFIER)
+ oppc = g_pc;
+ op = g_pc.token->type;
+ ++g_pc.token;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGARRIDENT);
}
- if (pass == COMPILE)
+ if (g_pass == COMPILE)
{
- if (((pc.token + 1)->type == T_OP ||
- Auto_find(&stack, pc.token->u.identifier) == 0) &&
- Global_find(&globals, pc.token->u.identifier, 1) == 0)
+ if (((g_pc.token + 1)->type == T_OP ||
+ Auto_find(&g_stack, g_pc.token->u.identifier) == 0) &&
+ Global_find(&g_globals, g_pc.token->u.identifier, 1) == 0)
{
return Value_new_ERROR(value, UNDECLARED);
}
}
- var3 = &pc.token->u.identifier->sym->u.var;
- if (pass == INTERPRET &&
+ var3 = &g_pc.token->u.identifier->sym->u.var;
+ if (g_pass == INTERPRET &&
((var3->dim != 1 && var3->dim != 2) || var3->base < 0 ||
var3->base > 1))
{
return Value_new_ERROR(value, NOMATRIX, var3->dim, var3->base);
}
- ++pc.token;
+ ++g_pc.token;
}
- if (pass != DECLARE)
+ if (g_pass != DECLARE)
{
if (var3 == (struct Var *)0)
{
- if (Var_mat_assign(var1, var2, value, pass == INTERPRET))
+ if (Var_mat_assign(var1, var2, value, g_pass == INTERPRET))
{
assert(oppc.line != -1);
- pc = oppc;
+ g_pc = oppc;
return value;
}
}
else if (op == T_MULT)
{
- if (Var_mat_mult(var1, var2, var3, value, pass == INTERPRET))
+ if (Var_mat_mult(var1, var2, var3, value, g_pass == INTERPRET))
{
assert(oppc.line != -1);
- pc = oppc;
+ g_pc = oppc;
return value;
}
}
else if (Var_mat_addsub
- (var1, var2, var3, op == T_PLUS, value, pass == INTERPRET))
+ (var1, var2, var3, op == T_PLUS, value, g_pass == INTERPRET))
{
assert(oppc.line != -1);
- pc = oppc;
+ g_pc = oppc;
return value;
}
}
}
- else if (pc.token->type == T_OP)
+ else if (g_pc.token->type == T_OP)
{
if (var1->type == V_STRING)
{
return Value_new_ERROR(value, TYPEMISMATCH5);
}
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("factor"))->type == V_ERROR)
{
return value;
}
- if (pass == COMPILE &&
+ if (g_pass == COMPILE &&
Value_commonType[var1->type][value->type] == V_ERROR)
{
return Value_new_typeError(value, var1->type, value->type);
}
- if (pc.token->type != T_CP)
+ if (g_pc.token->type != T_CP)
{
Value_destroy(value);
return Value_new_ERROR(value, MISSINGCP);
}
- ++pc.token;
- if (pc.token->type != T_MULT)
+ ++g_pc.token;
+ if (g_pc.token->type != T_MULT)
{
Value_destroy(value);
return Value_new_ERROR(value, MISSINGMULT);
}
- oppc = pc;
- ++pc.token;
- if (pass == COMPILE)
+ oppc = g_pc;
+ ++g_pc.token;
+ if (g_pass == COMPILE)
{
- if (((pc.token + 1)->type == T_OP ||
- Auto_find(&stack, pc.token->u.identifier) == 0) &&
- Global_find(&globals, pc.token->u.identifier, 1) == 0)
+ if (((g_pc.token + 1)->type == T_OP ||
+ Auto_find(&g_stack, g_pc.token->u.identifier) == 0) &&
+ Global_find(&g_globals, g_pc.token->u.identifier, 1) == 0)
{
Value_destroy(value);
return Value_new_ERROR(value, UNDECLARED);
}
}
- var2 = &pc.token->u.identifier->sym->u.var;
- if (pass == INTERPRET &&
+ var2 = &g_pc.token->u.identifier->sym->u.var;
+ if (g_pass == INTERPRET &&
((var2->dim != 1 && var2->dim != 2) || var2->base < 0 ||
var2->base > 1))
{
@@ -3260,47 +3260,47 @@ struct Value *stmt_MAT(struct Value *value)
return Value_new_ERROR(value, NOMATRIX, var2->dim, var2->base);
}
- if (pass != DECLARE &&
- Var_mat_scalarMult(var1, value, var2, pass == INTERPRET))
+ if (g_pass != DECLARE &&
+ Var_mat_scalarMult(var1, value, var2, g_pass == INTERPRET))
{
assert(oppc.line != -1);
- pc = oppc;
+ g_pc = oppc;
return value;
}
Value_destroy(value);
- ++pc.token;
+ ++g_pc.token;
}
- else if (pc.token->type == T_CON || pc.token->type == T_ZER ||
- pc.token->type == T_IDN)
+ else if (g_pc.token->type == T_CON || g_pc.token->type == T_ZER ||
+ g_pc.token->type == T_IDN)
{
- op = pc.token->type;
- if (pass == COMPILE && Value_commonType[var1->type][V_INTEGER] == V_ERROR)
+ op = g_pc.token->type;
+ if (g_pass == COMPILE && Value_commonType[var1->type][V_INTEGER] == V_ERROR)
{
return Value_new_typeError(value, V_INTEGER, var1->type);
}
- ++pc.token;
- if (pc.token->type == T_OP)
+ ++g_pc.token;
+ if (g_pc.token->type == T_OP)
{
unsigned int dim, geometry[2];
enum ValueType vartype = var1->type;
- ++pc.token;
+ ++g_pc.token;
if (evalGeometry(value, &dim, geometry))
{
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
Var_destroy(var1);
Var_new(var1, vartype, dim, geometry, optionbase);
}
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
unsigned int i;
int unused = 1 - var1->base;
@@ -3394,39 +3394,39 @@ struct Value *stmt_MAT(struct Value *value)
}
}
- else if (pc.token->type == T_TRN || pc.token->type == T_INV)
+ else if (g_pc.token->type == T_TRN || g_pc.token->type == T_INV)
{
- op = pc.token->type;
- ++pc.token;
- if (pc.token->type != T_OP)
+ op = g_pc.token->type;
+ ++g_pc.token;
+ if (g_pc.token->type != T_OP)
{
return Value_new_ERROR(value, MISSINGOP);
}
- ++pc.token;
- if (pc.token->type != T_IDENTIFIER)
+ ++g_pc.token;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGMATIDENT);
}
- if (pass == COMPILE)
+ if (g_pass == COMPILE)
{
- if (((pc.token + 1)->type == T_OP ||
- Auto_find(&stack, pc.token->u.identifier) == 0) &&
- Global_find(&globals, pc.token->u.identifier, 1) == 0)
+ if (((g_pc.token + 1)->type == T_OP ||
+ Auto_find(&g_stack, g_pc.token->u.identifier) == 0) &&
+ Global_find(&g_globals, g_pc.token->u.identifier, 1) == 0)
{
return Value_new_ERROR(value, UNDECLARED);
}
}
- var2 = &pc.token->u.identifier->sym->u.var;
- if (pass == COMPILE &&
+ var2 = &g_pc.token->u.identifier->sym->u.var;
+ if (g_pass == COMPILE &&
Value_commonType[var1->type][var2->type] == V_ERROR)
{
return Value_new_typeError(value, var2->type, var1->type);
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (var2->dim != 2 || var2->base < 0 || var2->base > 1)
{
@@ -3440,7 +3440,7 @@ struct Value *stmt_MAT(struct Value *value)
break;
case T_INV:
- if (Var_mat_invert(var1, var2, &stack.lastdet, value))
+ if (Var_mat_invert(var1, var2, &g_stack.lastdet, value))
{
return value;
}
@@ -3452,13 +3452,13 @@ struct Value *stmt_MAT(struct Value *value)
}
}
- ++pc.token;
- if (pc.token->type != T_CP)
+ ++g_pc.token;
+ if (g_pc.token->type != T_CP)
{
return Value_new_ERROR(value, MISSINGCP);
}
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -3472,10 +3472,10 @@ struct Value *stmt_MATINPUT(struct Value *value)
{
int channel = STDCHANNEL;
- ++pc.token;
- if (pc.token->type == T_CHANNEL)
+ ++g_pc.token;
+ if (g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("channel"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -3484,13 +3484,13 @@ struct Value *stmt_MATINPUT(struct Value *value)
channel = value->u.integer;
Value_destroy(value);
- if (pc.token->type != T_COMMA)
+ if (g_pc.token->type != T_COMMA)
{
return Value_new_ERROR(value, MISSINGCOMMA);
}
else
{
- ++pc.token;
+ ++g_pc.token;
}
}
@@ -3499,41 +3499,41 @@ struct Value *stmt_MATINPUT(struct Value *value)
struct Pc lvaluepc;
struct Var *var;
- lvaluepc = pc;
- if (pc.token->type != T_IDENTIFIER)
+ lvaluepc = g_pc;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGMATIDENT);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType, GLOBALARRAY,
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType, GLOBALARRAY,
0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
}
- var = &pc.token->u.identifier->sym->u.var;
- ++pc.token;
- if (pc.token->type == T_OP)
+ var = &g_pc.token->u.identifier->sym->u.var;
+ ++g_pc.token;
+ if (g_pc.token->type == T_OP)
{
unsigned int dim, geometry[2];
enum ValueType vartype = var->type;
- ++pc.token;
+ ++g_pc.token;
if (evalGeometry(value, &dim, geometry))
{
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
Var_destroy(var);
Var_new(var, vartype, dim, geometry, optionbase);
}
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
unsigned int i, j;
int unused = 1 - var->base;
@@ -3592,7 +3592,7 @@ struct Value *stmt_MATINPUT(struct Value *value)
else if (convert(value, &(var->value[j * columns + i]), t))
{
Token_destroy(inputdata);
- pc = lvaluepc;
+ g_pc = lvaluepc;
return value;
}
else
@@ -3618,9 +3618,9 @@ struct Value *stmt_MATINPUT(struct Value *value)
}
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -3640,10 +3640,10 @@ struct Value *stmt_MATPRINT(struct Value *value)
size_t usingpos = 0;
int notfirst = 0;
- ++pc.token;
- if (chn == STDCHANNEL && pc.token->type == T_CHANNEL)
+ ++g_pc.token;
+ if (chn == STDCHANNEL && g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("channel"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -3652,34 +3652,34 @@ struct Value *stmt_MATPRINT(struct Value *value)
chn = value->u.integer;
Value_destroy(value);
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
}
- if (pc.token->type == T_USING)
+ if (g_pc.token->type == T_USING)
{
struct Pc usingpc;
- usingpc = pc;
+ usingpc = g_pc;
printusing = 1;
- ++pc.token;
- if (pc.token->type == T_INTEGER)
+ ++g_pc.token;
+ if (g_pc.token->type == T_INTEGER)
{
- if (pass == COMPILE &&
- Program_imageLine(&program, pc.token->u.integer,
+ if (g_pass == COMPILE &&
+ Program_imageLine(&g_program, g_pc.token->u.integer,
&usingpc.token->u.image) == (struct Pc *)0)
{
return Value_new_ERROR(value, NOSUCHIMAGELINE);
}
- else if (pass == INTERPRET)
+ else if (g_pass == INTERPRET)
{
using = usingpc.token->u.image.token->u.string;
}
Value_new_STRING(&usingval);
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -3693,13 +3693,13 @@ struct Value *stmt_MATPRINT(struct Value *value)
using = &usingval.u.string;
}
- if (pc.token->type != T_SEMICOLON)
+ if (g_pc.token->type != T_SEMICOLON)
{
Value_destroy(&usingval);
return Value_new_ERROR(value, MISSINGSEMICOLON);
}
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -3711,7 +3711,7 @@ struct Value *stmt_MATPRINT(struct Value *value)
struct Var *var;
int zoned = 1;
- if (pc.token->type != T_IDENTIFIER)
+ if (g_pc.token->type != T_IDENTIFIER)
{
if (notfirst)
{
@@ -3722,23 +3722,23 @@ struct Value *stmt_MATPRINT(struct Value *value)
return Value_new_ERROR(value, MISSINGMATIDENT);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType, GLOBALARRAY,
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType, GLOBALARRAY,
0) == 0)
{
Value_destroy(&usingval);
return Value_new_ERROR(value, REDECLARATION);
}
- var = &pc.token->u.identifier->sym->u.var;
- ++pc.token;
- if (pc.token->type == T_SEMICOLON)
+ var = &g_pc.token->u.identifier->sym->u.var;
+ ++g_pc.token;
+ if (g_pc.token->type == T_SEMICOLON)
{
zoned = 0;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
unsigned int i, j;
int unused = 1 - var->base;
@@ -3797,9 +3797,9 @@ struct Value *stmt_MATPRINT(struct Value *value)
}
}
- if (pc.token->type == T_COMMA || pc.token->type == T_SEMICOLON)
+ if (g_pc.token->type == T_COMMA || g_pc.token->type == T_SEMICOLON)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -3810,7 +3810,7 @@ struct Value *stmt_MATPRINT(struct Value *value)
}
Value_destroy(&usingval);
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (FS_flush(chn) == -1)
{
@@ -3823,47 +3823,47 @@ struct Value *stmt_MATPRINT(struct Value *value)
struct Value *stmt_MATREAD(struct Value *value)
{
- ++pc.token;
+ ++g_pc.token;
while (1)
{
struct Pc lvaluepc;
struct Var *var;
- lvaluepc = pc;
- if (pc.token->type != T_IDENTIFIER)
+ lvaluepc = g_pc;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGMATIDENT);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType, GLOBALARRAY,
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType, GLOBALARRAY,
0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
}
- var = &pc.token->u.identifier->sym->u.var;
- ++pc.token;
- if (pc.token->type == T_OP)
+ var = &g_pc.token->u.identifier->sym->u.var;
+ ++g_pc.token;
+ if (g_pc.token->type == T_OP)
{
unsigned int dim, geometry[2];
enum ValueType vartype = var->type;
- ++pc.token;
+ ++g_pc.token;
if (evalGeometry(value, &dim, geometry))
{
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
Var_destroy(var);
Var_new(var, vartype, dim, geometry, optionbase);
}
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
unsigned int i;
int unused = 1 - var->base;
@@ -3880,7 +3880,7 @@ struct Value *stmt_MATREAD(struct Value *value)
{
if (dataread(value, &(var->value[i])))
{
- pc = lvaluepc;
+ g_pc = lvaluepc;
return value;
}
}
@@ -3896,7 +3896,7 @@ struct Value *stmt_MATREAD(struct Value *value)
if (dataread
(value, &(var->value[i * var->geometry[1] + j])))
{
- pc = lvaluepc;
+ g_pc = lvaluepc;
return value;
}
}
@@ -3904,9 +3904,9 @@ struct Value *stmt_MATREAD(struct Value *value)
}
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -3919,47 +3919,47 @@ struct Value *stmt_MATREAD(struct Value *value)
struct Value *stmt_MATREDIM(struct Value *value)
{
- ++pc.token;
+ ++g_pc.token;
while (1)
{
struct Var *var;
unsigned int dim, geometry[2];
- if (pc.token->type != T_IDENTIFIER)
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGMATIDENT);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType, GLOBALARRAY,
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType, GLOBALARRAY,
0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
}
- var = &pc.token->u.identifier->sym->u.var;
- ++pc.token;
- if (pc.token->type != T_OP)
+ var = &g_pc.token->u.identifier->sym->u.var;
+ ++g_pc.token;
+ if (g_pc.token->type != T_OP)
{
return Value_new_ERROR(value, MISSINGOP);
}
- ++pc.token;
+ ++g_pc.token;
if (evalGeometry(value, &dim, geometry))
{
return value;
}
- if (pass == INTERPRET &&
+ if (g_pass == INTERPRET &&
Var_mat_redim(var, dim, geometry, value) != (struct Value *)0)
{
return value;
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -3976,10 +3976,10 @@ struct Value *stmt_MATWRITE(struct Value *value)
int notfirst = 0;
int comma = 0;
- ++pc.token;
- if (pc.token->type == T_CHANNEL)
+ ++g_pc.token;
+ if (g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("channel"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -3988,9 +3988,9 @@ struct Value *stmt_MATWRITE(struct Value *value)
chn = value->u.integer;
Value_destroy(value);
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
}
@@ -3998,7 +3998,7 @@ struct Value *stmt_MATWRITE(struct Value *value)
{
struct Var *var;
- if (pc.token->type != T_IDENTIFIER)
+ if (g_pc.token->type != T_IDENTIFIER)
{
if (notfirst)
{
@@ -4009,17 +4009,17 @@ struct Value *stmt_MATWRITE(struct Value *value)
}
notfirst = 1;
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType, GLOBALARRAY,
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType, GLOBALARRAY,
0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
}
- var = &pc.token->u.identifier->sym->u.var;
- ++pc.token;
- if (pass == INTERPRET)
+ var = &g_pc.token->u.identifier->sym->u.var;
+ ++g_pc.token;
+ if (g_pass == INTERPRET)
{
unsigned int i, j;
int unused = 1 - var->base;
@@ -4067,9 +4067,9 @@ struct Value *stmt_MATWRITE(struct Value *value)
}
}
- if (pc.token->type == T_COMMA || pc.token->type == T_SEMICOLON)
+ if (g_pc.token->type == T_COMMA || g_pc.token->type == T_SEMICOLON)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -4077,7 +4077,7 @@ struct Value *stmt_MATWRITE(struct Value *value)
}
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (FS_flush(chn) == -1)
{
@@ -4090,25 +4090,25 @@ struct Value *stmt_MATWRITE(struct Value *value)
struct Value *stmt_NAME(struct Value *value)
{
- struct Pc namepc = pc;
+ struct Pc namepc = g_pc;
struct Value old;
int res = -1, reserrno = -1;
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("file name"))->type == V_ERROR ||
Value_retype(value, V_STRING)->type == V_ERROR)
{
return value;
}
- if (pc.token->type != T_AS)
+ if (g_pc.token->type != T_AS)
{
Value_destroy(value);
return Value_new_ERROR(value, MISSINGAS);
}
old = *value;
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("file name"))->type == V_ERROR ||
Value_retype(value, V_STRING)->type == V_ERROR)
{
@@ -4116,7 +4116,7 @@ struct Value *stmt_NAME(struct Value *value)
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
res = rename(old.u.string.character, value->u.string.character);
reserrno = errno;
@@ -4124,9 +4124,9 @@ struct Value *stmt_NAME(struct Value *value)
Value_destroy(&old);
Value_destroy(value);
- if (pass == INTERPRET && res == -1)
+ if (g_pass == INTERPRET && res == -1)
{
- pc = namepc;
+ g_pc = namepc;
return Value_new_ERROR(value, IOERROR, strerror(reserrno));
}
@@ -4135,7 +4135,7 @@ struct Value *stmt_NAME(struct Value *value)
struct Value *stmt_NEW(struct Value *value)
{
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (!DIRECTMODE)
{
@@ -4145,38 +4145,38 @@ struct Value *stmt_NEW(struct Value *value)
new();
}
- ++pc.token;
+ ++g_pc.token;
return (struct Value *)0;
}
struct Value *stmt_NEXT(struct Value *value)
{
- struct Next **next = &pc.token->u.next;
+ struct Next **next = &g_pc.token->u.next;
int level = 0;
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
struct Value *l, inc;
struct Pc savepc;
- ++pc.token;
+ ++g_pc.token;
while (1)
{
/* get variable lvalue */
- savepc = pc;
- pc = (*next)[level].var;
+ savepc = g_pc;
+ g_pc = (*next)[level].var;
if ((l = lvalue(value))->type == V_ERROR)
{
return value;
}
- pc = savepc;
+ g_pc = savepc;
/* get limit value and increment */
- savepc = pc;
- pc = (*next)[level].limit;
+ savepc = g_pc;
+ g_pc = (*next)[level].limit;
if (eval(value, _("limit"))->type == V_ERROR)
{
return value;
@@ -4184,9 +4184,9 @@ struct Value *stmt_NEXT(struct Value *value)
Value_retype(value, l->type);
assert(value->type != V_ERROR);
- if (pc.token->type == T_STEP)
+ if (g_pc.token->type == T_STEP)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(&inc, _("step"))->type == V_ERROR)
{
Value_destroy(value);
@@ -4201,23 +4201,23 @@ struct Value *stmt_NEXT(struct Value *value)
VALUE_RETYPE(&inc, l->type);
assert(inc.type != V_ERROR);
- pc = savepc;
+ g_pc = savepc;
Value_add(l, &inc, 1);
if (Value_exitFor(l, value, &inc))
{
Value_destroy(value);
Value_destroy(&inc);
- if (pc.token->type == T_IDENTIFIER)
+ if (g_pc.token->type == T_IDENTIFIER)
{
if (lvalue(value)->type == V_ERROR)
{
return value;
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
++level;
}
else
@@ -4232,7 +4232,7 @@ struct Value *stmt_NEXT(struct Value *value)
}
else
{
- pc = (*next)[level].body;
+ g_pc = (*next)[level].body;
Value_destroy(value);
Value_destroy(&inc);
break;
@@ -4243,7 +4243,7 @@ struct Value *stmt_NEXT(struct Value *value)
{
struct Pc *body;
- ++pc.token;
+ ++g_pc.token;
while (1)
{
if ((body = popLabel(L_FOR_BODY)) == (struct Pc *)0)
@@ -4263,19 +4263,19 @@ struct Value *stmt_NEXT(struct Value *value)
(*next)[level].limit = *popLabel(L_FOR_LIMIT);
(*next)[level].var = *popLabel(L_FOR_VAR);
(*next)[level].fr = *popLabel(L_FOR);
- if (pc.token->type == T_IDENTIFIER)
+ if (g_pc.token->type == T_IDENTIFIER)
{
if (cistrcmp
- (pc.token->u.identifier->name,
+ (g_pc.token->u.identifier->name,
(*next)[level].var.token->u.identifier->name))
{
return Value_new_ERROR(value, FORMISMATCH);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType,
- (pc.token + 1)->type ==
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType,
+ (g_pc.token + 1)->type ==
T_OP ? GLOBALARRAY : GLOBALVAR, 0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
@@ -4286,9 +4286,9 @@ struct Value *stmt_NEXT(struct Value *value)
return value;
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
++level;
}
else
@@ -4304,7 +4304,7 @@ struct Value *stmt_NEXT(struct Value *value)
while (level >= 0)
{
- (*next)[level--].fr.token->u.exitfor = pc;
+ (*next)[level--].fr.token->u.exitfor = g_pc;
}
}
@@ -4313,9 +4313,9 @@ struct Value *stmt_NEXT(struct Value *value)
struct Value *stmt_ON(struct Value *value)
{
- struct On *on = &pc.token->u.on;
+ struct On *on = &g_pc.token->u.on;
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("selector"))->type == V_ERROR)
{
return value;
@@ -4326,7 +4326,7 @@ struct Value *stmt_ON(struct Value *value)
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
struct Pc newpc;
@@ -4339,55 +4339,55 @@ struct Value *stmt_ON(struct Value *value)
newpc = on->pc[0];
}
- if (pc.token->type == T_GOTO)
+ if (g_pc.token->type == T_GOTO)
{
- pc = newpc;
+ g_pc = newpc;
}
else
{
- pc = on->pc[0];
- Auto_pushGosubRet(&stack, &pc);
- pc = newpc;
+ g_pc = on->pc[0];
+ Auto_pushGosubRet(&g_stack, &g_pc);
+ g_pc = newpc;
}
- Program_trace(&program, &pc, 0, 1);
+ Program_trace(&g_program, &g_pc, 0, 1);
}
- else if (pass == DECLARE || pass == COMPILE)
+ else if (g_pass == DECLARE || g_pass == COMPILE)
{
Value_destroy(value);
- if (pc.token->type != T_GOTO && pc.token->type != T_GOSUB)
+ if (g_pc.token->type != T_GOTO && g_pc.token->type != T_GOSUB)
{
return Value_new_ERROR(value, MISSINGGOTOSUB);
}
- ++pc.token;
+ ++g_pc.token;
on->pcLength = 1;
while (1)
{
on->pc = realloc(on->pc, sizeof(struct Pc) * ++on->pcLength);
- if (pc.token->type != T_INTEGER)
+ if (g_pc.token->type != T_INTEGER)
{
return Value_new_ERROR(value, MISSINGLINENUMBER);
}
if (Program_goLine
- (&program, pc.token->u.integer,
+ (&g_program, g_pc.token->u.integer,
&on->pc[on->pcLength - 1]) == (struct Pc *)0)
{
return Value_new_ERROR(value, NOSUCHLINE);
}
- if (pass == COMPILE &&
- Program_scopeCheck(&program, &on->pc[on->pcLength - 1],
+ if (g_pass == COMPILE &&
+ Program_scopeCheck(&g_program, &on->pc[on->pcLength - 1],
findLabel(L_FUNC)))
{
return Value_new_ERROR(value, OUTOFSCOPE);
}
- ++pc.token;
- if (pc.token->type == T_COMMA)
+ ++g_pc.token;
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -4395,7 +4395,7 @@ struct Value *stmt_ON(struct Value *value)
}
}
- on->pc[0] = pc;
+ on->pc[0] = g_pc;
}
return (struct Value *)0;
@@ -4408,11 +4408,11 @@ struct Value *stmt_ONERROR(struct Value *value)
return Value_new_ERROR(value, NOTINDIRECTMODE);
}
- ++pc.token;
- if (pass == INTERPRET)
+ ++g_pc.token;
+ if (g_pass == INTERPRET)
{
- stack.onerror = pc;
- Program_nextLine(&program, &pc);
+ g_stack.onerror = g_pc;
+ Program_nextLine(&g_program, &g_pc);
return (struct Value *)0;
}
else
@@ -4428,17 +4428,17 @@ struct Value *stmt_ONERRORGOTO0(struct Value *value)
return Value_new_ERROR(value, NOTINDIRECTMODE);
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- stack.onerror.line = -1;
- if (stack.resumeable)
+ g_stack.onerror.line = -1;
+ if (g_stack.resumeable)
{
- pc = stack.erpc;
- return Value_clone(value, &stack.err);
+ g_pc = g_stack.erpc;
+ return Value_clone(value, &g_stack.err);
}
}
- ++pc.token;
+ ++g_pc.token;
return (struct Value *)0;
}
@@ -4449,12 +4449,12 @@ struct Value *stmt_ONERROROFF(struct Value *value)
return Value_new_ERROR(value, NOTINDIRECTMODE);
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- stack.onerror.line = -1;
+ g_stack.onerror.line = -1;
}
- ++pc.token;
+ ++g_pc.token;
return (struct Value *)0;
}
@@ -4466,17 +4466,17 @@ struct Value *stmt_OPEN(struct Value *value)
long int recLength = -1;
struct Pc errpc;
struct Value recLengthValue;
- struct Pc statementpc = pc;
+ struct Pc statementpc = g_pc;
- ++pc.token;
- errpc = pc;
+ ++g_pc.token;
+ errpc = g_pc;
if (eval(value, _("mode or file"))->type == V_ERROR ||
Value_retype(value, V_STRING)->type == V_ERROR)
{
return value;
}
- if (pc.token->type == T_COMMA) /* parse MBASIC syntax */
+ if (g_pc.token->type == T_COMMA) /* parse MBASIC syntax */
{
if (value->u.string.length >= 1)
{
@@ -4506,44 +4506,44 @@ struct Value *stmt_OPEN(struct Value *value)
}
Value_destroy(value);
- if (pass == INTERPRET && inout == -1)
+ if (g_pass == INTERPRET && inout == -1)
{
- pc = errpc;
+ g_pc = errpc;
return Value_new_ERROR(value, BADMODE);
}
- if (pc.token->type != T_COMMA)
+ if (g_pc.token->type != T_COMMA)
{
return Value_new_ERROR(value, MISSINGCOMMA);
}
- ++pc.token;
- if (pc.token->type == T_CHANNEL)
+ ++g_pc.token;
+ if (g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
}
- errpc = pc;
+ errpc = g_pc;
if (eval(value, _("channel"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
- pc = errpc;
+ g_pc = errpc;
return value;
}
channel = value->u.integer;
Value_destroy(value);
- if (pass == INTERPRET && channel < 0)
+ if (g_pass == INTERPRET && channel < 0)
{
return Value_new_ERROR(value, OUTOFRANGE, _("channel"));
}
- if (pc.token->type != T_COMMA)
+ if (g_pc.token->type != T_COMMA)
{
return Value_new_ERROR(value, MISSINGCOMMA);
}
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("file name"))->type == V_ERROR ||
Value_retype(value, V_STRING)->type == V_ERROR)
{
@@ -4552,14 +4552,14 @@ struct Value *stmt_OPEN(struct Value *value)
if (inout == 3)
{
- if (pc.token->type != T_COMMA)
+ if (g_pc.token->type != T_COMMA)
{
Value_destroy(value);
return Value_new_ERROR(value, MISSINGCOMMA);
}
- ++pc.token;
- errpc = pc;
+ ++g_pc.token;
+ errpc = g_pc;
if (eval(&recLengthValue, _("record length"))->type == V_ERROR ||
Value_retype(&recLengthValue, V_INTEGER)->type == V_ERROR)
{
@@ -4570,10 +4570,10 @@ struct Value *stmt_OPEN(struct Value *value)
recLength = recLengthValue.u.integer;
Value_destroy(&recLengthValue);
- if (pass == INTERPRET && recLength <= 0)
+ if (g_pass == INTERPRET && recLength <= 0)
{
Value_destroy(value);
- pc = errpc;
+ g_pc = errpc;
return Value_new_ERROR(value, OUTOFRANGE, _("record length"));
}
}
@@ -4583,37 +4583,37 @@ struct Value *stmt_OPEN(struct Value *value)
struct Value channelValue;
int newMode;
- switch (pc.token->type)
+ switch (g_pc.token->type)
{
case T_FOR_INPUT:
inout = 0;
mode = FS_ACCESS_READ;
- ++pc.token;
+ ++g_pc.token;
break;
case T_FOR_OUTPUT:
inout = 1;
mode = FS_ACCESS_WRITE;
- ++pc.token;
+ ++g_pc.token;
break;
case T_FOR_APPEND:
inout = 1;
mode = FS_ACCESS_WRITE;
append = 1;
- ++pc.token;
+ ++g_pc.token;
break;
case T_FOR_RANDOM:
inout = 3;
mode = FS_ACCESS_READWRITE;
- ++pc.token;
+ ++g_pc.token;
break;
case T_FOR_BINARY:
inout = 4;
mode = FS_ACCESS_READWRITE;
- ++pc.token;
+ ++g_pc.token;
break;
default:
@@ -4622,7 +4622,7 @@ struct Value *stmt_OPEN(struct Value *value)
break;
}
- switch (pc.token->type)
+ switch (g_pc.token->type)
{
case T_ACCESS_READ:
newMode = FS_ACCESS_READ;
@@ -4648,46 +4648,46 @@ struct Value *stmt_OPEN(struct Value *value)
}
mode = newMode;
- ++pc.token;
+ ++g_pc.token;
}
- switch (pc.token->type)
+ switch (g_pc.token->type)
{
case T_SHARED:
lock = FS_LOCK_NONE;
- ++pc.token;
+ ++g_pc.token;
break;
case T_LOCK_READ:
lock = FS_LOCK_SHARED;
- ++pc.token;
+ ++g_pc.token;
break;
case T_LOCK_WRITE:
lock = FS_LOCK_EXCLUSIVE;
- ++pc.token;
+ ++g_pc.token;
break;
default:;
}
- if (pc.token->type != T_AS)
+ if (g_pc.token->type != T_AS)
{
Value_destroy(value);
return Value_new_ERROR(value, MISSINGAS);
}
- ++pc.token;
- if (pc.token->type == T_CHANNEL)
+ ++g_pc.token;
+ if (g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
}
- errpc = pc;
+ errpc = g_pc;
if (eval(&channelValue, _("channel"))->type == V_ERROR ||
Value_retype(&channelValue, V_INTEGER)->type == V_ERROR)
{
- pc = errpc;
+ g_pc = errpc;
Value_destroy(value);
*value = channelValue;
return value;
@@ -4697,23 +4697,23 @@ struct Value *stmt_OPEN(struct Value *value)
Value_destroy(&channelValue);
if (inout == 3)
{
- if (pc.token->type == T_IDENTIFIER)
+ if (g_pc.token->type == T_IDENTIFIER)
{
- if (cistrcmp(pc.token->u.identifier->name, "len"))
+ if (cistrcmp(g_pc.token->u.identifier->name, "len"))
{
Value_destroy(value);
return Value_new_ERROR(value, MISSINGLEN);
}
- ++pc.token;
- if (pc.token->type != T_EQ)
+ ++g_pc.token;
+ if (g_pc.token->type != T_EQ)
{
Value_destroy(value);
return Value_new_ERROR(value, MISSINGEQ);
}
- ++pc.token;
- errpc = pc;
+ ++g_pc.token;
+ errpc = g_pc;
if (eval(&recLengthValue, _("record length"))->type == V_ERROR ||
Value_retype(&recLengthValue, V_INTEGER)->type == V_ERROR)
{
@@ -4724,10 +4724,10 @@ struct Value *stmt_OPEN(struct Value *value)
recLength = recLengthValue.u.integer;
Value_destroy(&recLengthValue);
- if (pass == INTERPRET && recLength <= 0)
+ if (g_pass == INTERPRET && recLength <= 0)
{
Value_destroy(value);
- pc = errpc;
+ g_pc = errpc;
return Value_new_ERROR(value, OUTOFRANGE, _("record length"));
}
}
@@ -4739,7 +4739,7 @@ struct Value *stmt_OPEN(struct Value *value)
}
/* open file with name value */
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
int res = -1;
@@ -4764,7 +4764,7 @@ struct Value *stmt_OPEN(struct Value *value)
if (res == -1)
{
- pc = statementpc;
+ g_pc = statementpc;
Value_destroy(value);
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
@@ -4772,7 +4772,7 @@ struct Value *stmt_OPEN(struct Value *value)
{
if (lock != FS_LOCK_NONE && FS_lock(channel, 0, 0, lock, 0) == -1)
{
- pc = statementpc;
+ g_pc = statementpc;
Value_destroy(value);
Value_new_ERROR(value, IOERROR, FS_errmsg);
FS_close(channel);
@@ -4787,14 +4787,14 @@ struct Value *stmt_OPEN(struct Value *value)
struct Value *stmt_OPTIONBASE(struct Value *value)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("array subscript base"))->type == V_ERROR ||
- (pass != DECLARE && Value_retype(value, V_INTEGER)->type == V_ERROR))
+ (g_pass != DECLARE && Value_retype(value, V_INTEGER)->type == V_ERROR))
{
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
optionbase = value->u.integer;
}
@@ -4805,8 +4805,8 @@ struct Value *stmt_OPTIONBASE(struct Value *value)
struct Value *stmt_OPTIONRUN(struct Value *value)
{
- ++pc.token;
- if (pass == INTERPRET)
+ ++g_pc.token;
+ if (g_pass == INTERPRET)
{
FS_xonxoff(STDCHANNEL, 0);
}
@@ -4816,8 +4816,8 @@ struct Value *stmt_OPTIONRUN(struct Value *value)
struct Value *stmt_OPTIONSTOP(struct Value *value)
{
- ++pc.token;
- if (pass == INTERPRET)
+ ++g_pc.token;
+ if (g_pass == INTERPRET)
{
FS_xonxoff(STDCHANNEL, 1);
}
@@ -4830,9 +4830,9 @@ struct Value *stmt_OUT_POKE(struct Value *value)
int out, address, val;
struct Pc lpc;
- out = (pc.token->type == T_OUT);
- lpc = pc;
- ++pc.token;
+ out = (g_pc.token->type == T_OUT);
+ lpc = g_pc;
+ ++g_pc.token;
if (eval(value, _("address"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -4841,12 +4841,12 @@ struct Value *stmt_OUT_POKE(struct Value *value)
address = value->u.integer;
Value_destroy(value);
- if (pc.token->type != T_COMMA)
+ if (g_pc.token->type != T_COMMA)
{
return Value_new_ERROR(value, MISSINGCOMMA);
}
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("output value"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -4855,11 +4855,11 @@ struct Value *stmt_OUT_POKE(struct Value *value)
val = value->u.integer;
Value_destroy(value);
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if ((out ? FS_portOutput : FS_memOutput) (address, val) == -1)
{
- pc = lpc;
+ g_pc = lpc;
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
}
@@ -4870,16 +4870,16 @@ struct Value *stmt_OUT_POKE(struct Value *value)
struct Value *stmt_PRINT_LPRINT(struct Value *value)
{
int nl = 1;
- int chn = (pc.token->type == T_PRINT ? STDCHANNEL : LPCHANNEL);
+ int chn = (g_pc.token->type == T_PRINT ? STDCHANNEL : LPCHANNEL);
int printusing = 0;
struct Value usingval;
struct String *using = (struct String *)0;
size_t usingpos = 0;
- ++pc.token;
- if (chn == STDCHANNEL && pc.token->type == T_CHANNEL)
+ ++g_pc.token;
+ if (chn == STDCHANNEL && g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("channel"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -4888,34 +4888,34 @@ struct Value *stmt_PRINT_LPRINT(struct Value *value)
chn = value->u.integer;
Value_destroy(value);
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
}
- if (pc.token->type == T_USING)
+ if (g_pc.token->type == T_USING)
{
struct Pc usingpc;
- usingpc = pc;
+ usingpc = g_pc;
printusing = 1;
- ++pc.token;
- if (pc.token->type == T_INTEGER)
+ ++g_pc.token;
+ if (g_pc.token->type == T_INTEGER)
{
- if (pass == COMPILE &&
- Program_imageLine(&program, pc.token->u.integer,
+ if (g_pass == COMPILE &&
+ Program_imageLine(&g_program, g_pc.token->u.integer,
&usingpc.token->u.image) == (struct Pc *)0)
{
return Value_new_ERROR(value, NOSUCHIMAGELINE);
}
- else if (pass == INTERPRET)
+ else if (g_pass == INTERPRET)
{
using = usingpc.token->u.image.token->u.string;
}
Value_new_STRING(&usingval);
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -4929,13 +4929,13 @@ struct Value *stmt_PRINT_LPRINT(struct Value *value)
using = &usingval.u.string;
}
- if (pc.token->type != T_SEMICOLON)
+ if (g_pc.token->type != T_SEMICOLON)
{
Value_destroy(&usingval);
return Value_new_ERROR(value, MISSINGSEMICOLON);
}
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -4947,7 +4947,7 @@ struct Value *stmt_PRINT_LPRINT(struct Value *value)
{
struct Pc valuepc;
- valuepc = pc;
+ valuepc = g_pc;
if (eval(value, (const char *)0))
{
if (value->type == V_ERROR)
@@ -4956,7 +4956,7 @@ struct Value *stmt_PRINT_LPRINT(struct Value *value)
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
struct String s;
@@ -4966,7 +4966,7 @@ struct Value *stmt_PRINT_LPRINT(struct Value *value)
{
Value_destroy(&usingval);
String_destroy(&s);
- pc = valuepc;
+ g_pc = valuepc;
return value;
}
@@ -4984,18 +4984,18 @@ struct Value *stmt_PRINT_LPRINT(struct Value *value)
Value_destroy(value);
nl = 1;
}
- else if (pc.token->type == T_TAB || pc.token->type == T_SPC)
+ else if (g_pc.token->type == T_TAB || g_pc.token->type == T_SPC)
{
- int tab = pc.token->type == T_TAB;
+ int tab = g_pc.token->type == T_TAB;
- ++pc.token;
- if (pc.token->type != T_OP)
+ ++g_pc.token;
+ if (g_pc.token->type != T_OP)
{
Value_destroy(&usingval);
return Value_new_ERROR(value, MISSINGOP);
}
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("count"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -5003,7 +5003,7 @@ struct Value *stmt_PRINT_LPRINT(struct Value *value)
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
int s = value->u.integer;
int r = 0;
@@ -5026,26 +5026,26 @@ struct Value *stmt_PRINT_LPRINT(struct Value *value)
}
Value_destroy(value);
- if (pc.token->type != T_CP)
+ if (g_pc.token->type != T_CP)
{
Value_destroy(&usingval);
return Value_new_ERROR(value, MISSINGCP);
}
- ++pc.token;
+ ++g_pc.token;
nl = 1;
}
- else if (pc.token->type == T_SEMICOLON)
+ else if (g_pc.token->type == T_SEMICOLON)
{
- ++pc.token;
+ ++g_pc.token;
nl = 0;
}
- else if (pc.token->type == T_COMMA)
+ else if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
- if (pass == INTERPRET && !printusing)
+ ++g_pc.token;
+ if (g_pass == INTERPRET && !printusing)
{
FS_nextcol(chn);
}
@@ -5058,7 +5058,7 @@ struct Value *stmt_PRINT_LPRINT(struct Value *value)
break;
}
- if (pass == INTERPRET && FS_flush(chn) == -1)
+ if (g_pass == INTERPRET && FS_flush(chn) == -1)
{
Value_destroy(&usingval);
return Value_new_ERROR(value, IOERROR, FS_errmsg);
@@ -5066,7 +5066,7 @@ struct Value *stmt_PRINT_LPRINT(struct Value *value)
}
Value_destroy(&usingval);
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (nl && FS_putChar(chn, '\n') == -1)
{
@@ -5086,22 +5086,22 @@ struct Value *stmt_RANDOMIZE(struct Value *value)
{
struct Pc argpc;
- ++pc.token;
- argpc = pc;
+ ++g_pc.token;
+ argpc = g_pc;
if (eval(value, (const char *)0))
{
Value_retype(value, V_INTEGER);
if (value->type == V_ERROR)
{
- pc = argpc;
+ g_pc = argpc;
Value_destroy(value);
return Value_new_ERROR(value, MISSINGEXPR,
_("random number generator seed"));
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- srand(pc.token->u.integer);
+ srand(g_pc.token->u.integer);
}
Value_destroy(value);
@@ -5116,22 +5116,22 @@ struct Value *stmt_RANDOMIZE(struct Value *value)
struct Value *stmt_READ(struct Value *value)
{
- ++pc.token;
+ ++g_pc.token;
while (1)
{
struct Value *l;
struct Pc lvaluepc;
- lvaluepc = pc;
- if (pc.token->type != T_IDENTIFIER)
+ lvaluepc = g_pc;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGREADIDENT);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType,
- (pc.token + 1)->type ==
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType,
+ (g_pc.token + 1)->type ==
T_OP ? GLOBALARRAY : GLOBALVAR, 0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
@@ -5142,15 +5142,15 @@ struct Value *stmt_READ(struct Value *value)
return value;
}
- if (pass == INTERPRET && dataread(value, l))
+ if (g_pass == INTERPRET && dataread(value, l))
{
- pc = lvaluepc;
+ g_pc = lvaluepc;
return value;
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -5165,34 +5165,34 @@ struct Value *stmt_COPY_RENAME(struct Value *value)
{
struct Pc argpc;
struct Value from;
- struct Pc statementpc = pc;
+ struct Pc statementpc = g_pc;
- ++pc.token;
- argpc = pc;
+ ++g_pc.token;
+ argpc = g_pc;
if (eval(&from, _("source file"))->type == V_ERROR ||
- (pass != DECLARE && Value_retype(&from, V_STRING)->type == V_ERROR))
+ (g_pass != DECLARE && Value_retype(&from, V_STRING)->type == V_ERROR))
{
- pc = argpc;
+ g_pc = argpc;
*value = from;
return value;
}
- if (pc.token->type != T_TO)
+ if (g_pc.token->type != T_TO)
{
Value_destroy(&from);
return Value_new_ERROR(value, MISSINGTO);
}
- ++pc.token;
- argpc = pc;
+ ++g_pc.token;
+ argpc = g_pc;
if (eval(value, _("destination file"))->type == V_ERROR ||
- (pass != DECLARE && Value_retype(value, V_STRING)->type == V_ERROR))
+ (g_pass != DECLARE && Value_retype(value, V_STRING)->type == V_ERROR))
{
- pc = argpc;
+ g_pc = argpc;
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
const char *msg;
int res;
@@ -5212,7 +5212,7 @@ struct Value *stmt_COPY_RENAME(struct Value *value)
{
Value_destroy(&from);
Value_destroy(value);
- pc = statementpc;
+ g_pc = statementpc;
return Value_new_ERROR(value, IOERROR, msg);
}
}
@@ -5226,29 +5226,29 @@ struct Value *stmt_RENUM(struct Value *value)
{
int first = 10, inc = 10;
- ++pc.token;
- if (pc.token->type == T_INTEGER)
+ ++g_pc.token;
+ if (g_pc.token->type == T_INTEGER)
{
- first = pc.token->u.integer;
- ++pc.token;
- if (pc.token->type == T_COMMA)
+ first = g_pc.token->u.integer;
+ ++g_pc.token;
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
- if (pc.token->type != T_INTEGER)
+ ++g_pc.token;
+ if (g_pc.token->type != T_INTEGER)
return Value_new_ERROR(value, MISSINGINCREMENT);
- inc = pc.token->u.integer;
- ++pc.token;
+ inc = g_pc.token->u.integer;
+ ++g_pc.token;
}
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (!DIRECTMODE)
{
return Value_new_ERROR(value, NOTINPROGRAMMODE);
}
- Program_renum(&program, first, inc);
+ Program_renum(&g_program, first, inc);
}
return (struct Value *)0;
@@ -5256,39 +5256,39 @@ struct Value *stmt_RENUM(struct Value *value)
struct Value *stmt_REPEAT(struct Value *value)
{
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
- pushLabel(L_REPEAT, &pc);
+ pushLabel(L_REPEAT, &g_pc);
}
- ++pc.token;
+ ++g_pc.token;
return (struct Value *)0;
}
struct Value *stmt_RESTORE(struct Value *value)
{
- struct Token *restorepc = pc.token;
+ struct Token *restorepc = g_pc.token;
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- curdata = pc.token->u.restore;
+ g_curdata = g_pc.token->u.restore;
}
- ++pc.token;
- if (pc.token->type == T_INTEGER)
+ ++g_pc.token;
+ if (g_pc.token->type == T_INTEGER)
{
- if (pass == COMPILE &&
- Program_dataLine(&program, pc.token->u.integer,
+ if (g_pass == COMPILE &&
+ Program_dataLine(&g_program, g_pc.token->u.integer,
&restorepc->u.restore) == (struct Pc *)0)
{
return Value_new_ERROR(value, NOSUCHDATALINE);
}
- ++pc.token;
+ ++g_pc.token;
}
- else if (pass == COMPILE)
+ else if (g_pass == COMPILE)
{
- restorepc->u.restore = stack.begindata;
+ restorepc->u.restore = g_stack.begindata;
}
return (struct Value *)0;
@@ -5296,16 +5296,16 @@ struct Value *stmt_RESTORE(struct Value *value)
struct Value *stmt_RETURN(struct Value *value)
{
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
- ++pc.token;
+ ++g_pc.token;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- if (Auto_gosubReturn(&stack, &pc))
+ if (Auto_gosubReturn(&g_stack, &g_pc))
{
- Program_trace(&program, &pc, 0, 1);
+ Program_trace(&g_program, &g_pc, 0, 1);
}
else
{
@@ -5320,41 +5320,41 @@ struct Value *stmt_RUN(struct Value *value)
{
struct Pc argpc, begin;
- stack.resumeable = 0;
- ++pc.token;
- argpc = pc;
- if (pc.token->type == T_INTEGER)
+ g_stack.resumeable = 0;
+ ++g_pc.token;
+ argpc = g_pc;
+ if (g_pc.token->type == T_INTEGER)
{
- if (Program_goLine(&program, pc.token->u.integer, &begin) ==
+ if (Program_goLine(&g_program, g_pc.token->u.integer, &begin) ==
(struct Pc *)0)
{
return Value_new_ERROR(value, NOSUCHLINE);
}
- if (pass == COMPILE &&
- Program_scopeCheck(&program, &begin, findLabel(L_FUNC)))
+ if (g_pass == COMPILE &&
+ Program_scopeCheck(&g_program, &begin, findLabel(L_FUNC)))
{
return Value_new_ERROR(value, OUTOFSCOPE);
}
- ++pc.token;
+ ++g_pc.token;
}
else if (eval(value, (const char *)0))
{
if (value->type == V_ERROR ||
Value_retype(value, V_STRING)->type == V_ERROR)
{
- pc = argpc;
+ g_pc = argpc;
return value;
}
- else if (pass == INTERPRET)
+ else if (g_pass == INTERPRET)
{
int chn;
struct Program newprogram;
if ((chn = FS_openin(value->u.string.character)) == -1)
{
- pc = argpc;
+ g_pc = argpc;
Value_destroy(value);
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
@@ -5363,16 +5363,16 @@ struct Value *stmt_RUN(struct Value *value)
Program_new(&newprogram);
if (Program_merge(&newprogram, chn, value))
{
- pc = argpc;
+ g_pc = argpc;
Program_destroy(&newprogram);
return value;
}
FS_close(chn);
new();
- Program_destroy(&program);
- program = newprogram;
- if (Program_beginning(&program, &begin) == (struct Pc *)0)
+ Program_destroy(&g_program);
+ g_program = newprogram;
+ if (Program_beginning(&g_program, &begin) == (struct Pc *)0)
{
return Value_new_ERROR(value, NOPROGRAM);
}
@@ -5384,24 +5384,24 @@ struct Value *stmt_RUN(struct Value *value)
}
else
{
- if (Program_beginning(&program, &begin) == (struct Pc *)0)
+ if (Program_beginning(&g_program, &begin) == (struct Pc *)0)
{
return Value_new_ERROR(value, NOPROGRAM);
}
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (compileProgram(value, 1)->type == V_ERROR)
{
return value;
}
- pc = begin;
- curdata = stack.begindata;
- Global_clear(&globals);
+ g_pc = begin;
+ g_curdata = g_stack.begindata;
+ Global_clear(&g_globals);
FS_closefiles();
- Program_trace(&program, &pc, 0, 1);
+ Program_trace(&g_program, &g_pc, 0, 1);
}
return (struct Value *)0;
@@ -5412,14 +5412,14 @@ struct Value *stmt_SAVE(struct Value *value)
struct Pc loadpc;
int name;
- if (pass == INTERPRET && !DIRECTMODE)
+ if (g_pass == INTERPRET && !DIRECTMODE)
{
return Value_new_ERROR(value, NOTINPROGRAMMODE);
}
- ++pc.token;
- loadpc = pc;
- if (pc.token->type == T_EOL && program.name.length)
+ ++g_pc.token;
+ loadpc = g_pc;
+ if (g_pc.token->type == T_EOL && g_program.name.length)
{
name = 0;
}
@@ -5429,23 +5429,23 @@ struct Value *stmt_SAVE(struct Value *value)
if (eval(value, _("file name"))->type == V_ERROR ||
Value_retype(value, V_STRING)->type == V_ERROR)
{
- pc = loadpc;
+ g_pc = loadpc;
return value;
}
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
int chn;
if (name)
{
- Program_setname(&program, value->u.string.character);
+ Program_setname(&g_program, value->u.string.character);
}
- if ((chn = FS_openout(program.name.character)) == -1)
+ if ((chn = FS_openout(g_program.name.character)) == -1)
{
- pc = loadpc;
+ g_pc = loadpc;
if (name)
{
Value_destroy(value);
@@ -5460,14 +5460,14 @@ struct Value *stmt_SAVE(struct Value *value)
Value_destroy(value);
}
- if (Program_list(&program, chn, 0, (struct Pc *)0, (struct Pc *)0, value))
+ if (Program_list(&g_program, chn, 0, (struct Pc *)0, (struct Pc *)0, value))
{
- pc = loadpc;
+ g_pc = loadpc;
return value;
}
FS_close(chn);
- program.unsaved = 0;
+ g_program.unsaved = 0;
}
else if (name)
{
@@ -5479,20 +5479,20 @@ struct Value *stmt_SAVE(struct Value *value)
struct Value *stmt_SELECTCASE(struct Value *value)
{
- struct Pc statementpc = pc;
+ struct Pc statementpc = g_pc;
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
- pushLabel(L_SELECTCASE, &pc);
+ pushLabel(L_SELECTCASE, &g_pc);
}
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("selector"))->type == V_ERROR)
{
return value;
}
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
statementpc.token->u.selectcase->type = value->type;
statementpc.token->u.selectcase->nextcasevalue.line = -1;
@@ -5502,10 +5502,10 @@ struct Value *stmt_SELECTCASE(struct Value *value)
struct Pc casevaluepc;
int match = 0;
- pc = casevaluepc = statementpc.token->u.selectcase->nextcasevalue;
+ g_pc = casevaluepc = statementpc.token->u.selectcase->nextcasevalue;
do
{
- ++pc.token;
+ ++g_pc.token;
switch (casevaluepc.token->type)
{
case T_CASEVALUE:
@@ -5514,13 +5514,13 @@ struct Value *stmt_SELECTCASE(struct Value *value)
{
struct Value casevalue1;
- if (pc.token->type == T_IS)
+ if (g_pc.token->type == T_IS)
{
enum TokenType relop;
- ++pc.token;
- relop = pc.token->type;
- ++pc.token;
+ ++g_pc.token;
+ relop = g_pc.token->type;
+ ++g_pc.token;
if (eval(&casevalue1, "`is'")->type == V_ERROR)
{
Value_destroy(value);
@@ -5583,11 +5583,11 @@ struct Value *stmt_SELECTCASE(struct Value *value)
Value_retype(&casevalue1,
statementpc.token->u.selectcase->type);
assert(casevalue1.type != V_ERROR);
- if (pc.token->type == T_TO) /* match range */
+ if (g_pc.token->type == T_TO) /* match range */
{
struct Value casevalue2;
- ++pc.token;
+ ++g_pc.token;
if (eval(&casevalue2, "`case'")->type == V_ERROR)
{
Value_destroy(&casevalue1);
@@ -5633,9 +5633,9 @@ struct Value *stmt_SELECTCASE(struct Value *value)
Value_destroy(&casevalue1);
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -5661,12 +5661,12 @@ struct Value *stmt_SELECTCASE(struct Value *value)
{
if (casevaluepc.token->u.casevalue->nextcasevalue.line != -1)
{
- pc = casevaluepc =
+ g_pc = casevaluepc =
casevaluepc.token->u.casevalue->nextcasevalue;
}
else
{
- pc = statementpc.token->u.selectcase->endselect;
+ g_pc = statementpc.token->u.selectcase->endselect;
break;
}
}
@@ -5684,7 +5684,7 @@ struct Value *stmt_SHELL(struct Value *value)
pid_t pid;
int status;
- ++pc.token;
+ ++g_pc.token;
if (eval(value, (const char *)0))
{
if (value->type == V_ERROR ||
@@ -5693,9 +5693,9 @@ struct Value *stmt_SHELL(struct Value *value)
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- if (run_restricted)
+ if (g_run_restricted)
{
Value_destroy(value);
return Value_new_ERROR(value, RESTRICTED, strerror(errno));
@@ -5733,9 +5733,9 @@ struct Value *stmt_SHELL(struct Value *value)
}
else
{
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
- if (run_restricted)
+ if (g_run_restricted)
{
return Value_new_ERROR(value, RESTRICTED, strerror(errno));
}
@@ -5787,7 +5787,7 @@ struct Value *stmt_SLEEP(struct Value *value)
{
double s;
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("pause"))->type == V_ERROR ||
Value_retype(value, V_REAL)->type == V_ERROR)
{
@@ -5796,7 +5796,7 @@ struct Value *stmt_SLEEP(struct Value *value)
s = value->u.real;
Value_destroy(value);
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (s < 0.0)
{
@@ -5811,9 +5811,9 @@ struct Value *stmt_SLEEP(struct Value *value)
struct Value *stmt_STOP(struct Value *value)
{
- if (pass != INTERPRET)
+ if (g_pass != INTERPRET)
{
- ++pc.token;
+ ++g_pc.token;
}
return (struct Value *)0;
@@ -5823,7 +5823,7 @@ struct Value *stmt_SUBEXIT(struct Value *value)
{
struct Pc *curfn = (struct Pc *)0;
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
if ((curfn = findLabel(L_FUNC)) == (struct Pc *)0 ||
(curfn->token + 1)->u.identifier->defaultType != V_VOID)
@@ -5832,8 +5832,8 @@ struct Value *stmt_SUBEXIT(struct Value *value)
}
}
- ++pc.token;
- if (pass == INTERPRET)
+ ++g_pc.token;
+ if (g_pass == INTERPRET)
{
return Value_new_VOID(value);
}
@@ -5846,17 +5846,17 @@ struct Value *stmt_SWAP(struct Value *value)
struct Value *l1, *l2;
struct Pc lvaluepc;
- ++pc.token;
- lvaluepc = pc;
- if (pc.token->type != T_IDENTIFIER)
+ ++g_pc.token;
+ lvaluepc = g_pc;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGSWAPIDENT);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType,
- (pc.token + 1)->type == T_OP ? GLOBALARRAY : GLOBALVAR,
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType,
+ (g_pc.token + 1)->type == T_OP ? GLOBALARRAY : GLOBALVAR,
0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
@@ -5867,25 +5867,25 @@ struct Value *stmt_SWAP(struct Value *value)
return value;
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
return Value_new_ERROR(value, MISSINGCOMMA);
}
- lvaluepc = pc;
- if (pc.token->type != T_IDENTIFIER)
+ lvaluepc = g_pc;
+ if (g_pc.token->type != T_IDENTIFIER)
{
return Value_new_ERROR(value, MISSINGSWAPIDENT);
}
- if (pass == DECLARE &&
- Global_variable(&globals, pc.token->u.identifier,
- pc.token->u.identifier->defaultType,
- (pc.token + 1)->type == T_OP ? GLOBALARRAY : GLOBALVAR,
+ if (g_pass == DECLARE &&
+ Global_variable(&g_globals, g_pc.token->u.identifier,
+ g_pc.token->u.identifier->defaultType,
+ (g_pc.token + 1)->type == T_OP ? GLOBALARRAY : GLOBALVAR,
0) == 0)
{
return Value_new_ERROR(value, REDECLARATION);
@@ -5898,11 +5898,11 @@ struct Value *stmt_SWAP(struct Value *value)
if (l1->type != l2->type)
{
- pc = lvaluepc;
+ g_pc = lvaluepc;
return Value_new_typeError(value, l2->type, l1->type);
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
struct Value foo;
@@ -5916,10 +5916,10 @@ struct Value *stmt_SWAP(struct Value *value)
struct Value *stmt_SYSTEM(struct Value *value)
{
- ++pc.token;
- if (pass == INTERPRET)
+ ++g_pc.token;
+ if (g_pass == INTERPRET)
{
- if (program.unsaved)
+ if (g_program.unsaved)
{
int ch;
@@ -5949,15 +5949,15 @@ struct Value *stmt_SYSTEM(struct Value *value)
struct Value *stmt_TROFF(struct Value *value)
{
- ++pc.token;
- program.trace = 0;
+ ++g_pc.token;
+ g_program.trace = 0;
return (struct Value *)0;
}
struct Value *stmt_TRON(struct Value *value)
{
- ++pc.token;
- program.trace = 1;
+ ++g_pc.token;
+ g_program.trace = 1;
return (struct Value *)0;
}
@@ -5966,11 +5966,11 @@ struct Value *stmt_TRUNCATE(struct Value *value)
struct Pc chnpc;
int chn;
- chnpc = pc;
- ++pc.token;
- if (pc.token->type == T_CHANNEL)
+ chnpc = g_pc;
+ ++g_pc.token;
+ if (g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
}
if (eval(value, (const char *)0) == (struct Value *)0)
@@ -5985,9 +5985,9 @@ struct Value *stmt_TRUNCATE(struct Value *value)
chn = value->u.integer;
Value_destroy(value);
- if (pass == INTERPRET && FS_truncate(chn) == -1)
+ if (g_pass == INTERPRET && FS_truncate(chn) == -1)
{
- pc = chnpc;
+ g_pc = chnpc;
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
@@ -5996,15 +5996,15 @@ struct Value *stmt_TRUNCATE(struct Value *value)
struct Value *stmt_UNNUM(struct Value *value)
{
- ++pc.token;
- if (pass == INTERPRET)
+ ++g_pc.token;
+ if (g_pass == INTERPRET)
{
if (!DIRECTMODE)
{
return Value_new_ERROR(value, NOTINPROGRAMMODE);
}
- Program_unnum(&program);
+ Program_unnum(&g_program);
}
return (struct Value *)0;
@@ -6012,26 +6012,26 @@ struct Value *stmt_UNNUM(struct Value *value)
struct Value *stmt_UNTIL(struct Value *value)
{
- struct Pc untilpc = pc;
+ struct Pc untilpc = g_pc;
struct Pc *repeatpc;
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("condition"))->type == V_ERROR)
{
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (Value_isNull(value))
{
- pc = untilpc.token->u.until;
+ g_pc = untilpc.token->u.until;
}
Value_destroy(value);
}
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
if ((repeatpc = popLabel(L_REPEAT)) == (struct Pc *)0)
{
@@ -6049,8 +6049,8 @@ struct Value *stmt_WAIT(struct Value *value)
int address, mask, sel = -1, usesel;
struct Pc lpc;
- lpc = pc;
- ++pc.token;
+ lpc = g_pc;
+ ++g_pc.token;
if (eval(value, _("address"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -6059,12 +6059,12 @@ struct Value *stmt_WAIT(struct Value *value)
address = value->u.integer;
Value_destroy(value);
- if (pc.token->type != T_COMMA)
+ if (g_pc.token->type != T_COMMA)
{
return Value_new_ERROR(value, MISSINGCOMMA);
}
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("mask"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -6073,9 +6073,9 @@ struct Value *stmt_WAIT(struct Value *value)
mask = value->u.integer;
Value_destroy(value);
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("select"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -6091,7 +6091,7 @@ struct Value *stmt_WAIT(struct Value *value)
usesel = 0;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
int v;
@@ -6099,7 +6099,7 @@ struct Value *stmt_WAIT(struct Value *value)
{
if ((v = FS_portInput(address)) == -1)
{
- pc = lpc;
+ g_pc = lpc;
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
}
@@ -6110,24 +6110,24 @@ struct Value *stmt_WAIT(struct Value *value)
struct Value *stmt_WHILE(struct Value *value)
{
- struct Pc whilepc = pc;
+ struct Pc whilepc = g_pc;
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
- pushLabel(L_WHILE, &pc);
+ pushLabel(L_WHILE, &g_pc);
}
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("condition"))->type == V_ERROR)
{
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
if (Value_isNull(value))
{
- pc = *whilepc.token->u.afterwend;
+ g_pc = *whilepc.token->u.afterwend;
}
Value_destroy(value);
@@ -6138,7 +6138,7 @@ struct Value *stmt_WHILE(struct Value *value)
struct Value *stmt_WEND(struct Value *value)
{
- if (pass == DECLARE || pass == COMPILE)
+ if (g_pass == DECLARE || g_pass == COMPILE)
{
struct Pc *whilepc;
@@ -6147,13 +6147,13 @@ struct Value *stmt_WEND(struct Value *value)
return Value_new_ERROR(value, STRAYWEND, topLabelDescription());
}
- *pc.token->u.whilepc = *whilepc;
- ++pc.token;
- *(whilepc->token->u.afterwend) = pc;
+ *g_pc.token->u.whilepc = *whilepc;
+ ++g_pc.token;
+ *(whilepc->token->u.afterwend) = g_pc;
}
else
{
- pc = *pc.token->u.whilepc;
+ g_pc = *g_pc.token->u.whilepc;
}
return (struct Value *)0;
@@ -6163,10 +6163,10 @@ struct Value *stmt_WIDTH(struct Value *value)
{
int chn = STDCHANNEL, width;
- ++pc.token;
- if (pc.token->type == T_CHANNEL)
+ ++g_pc.token;
+ if (g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("channel"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -6175,9 +6175,9 @@ struct Value *stmt_WIDTH(struct Value *value)
chn = value->u.integer;
Value_destroy(value);
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
}
@@ -6191,15 +6191,15 @@ struct Value *stmt_WIDTH(struct Value *value)
width = value->u.integer;
Value_destroy(value);
- if (pass == INTERPRET && FS_width(chn, width) == -1)
+ if (g_pass == INTERPRET && FS_width(chn, width) == -1)
{
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
}
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("zone width"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -6208,7 +6208,7 @@ struct Value *stmt_WIDTH(struct Value *value)
width = value->u.integer;
Value_destroy(value);
- if (pass == INTERPRET && FS_zone(chn, width) == -1)
+ if (g_pass == INTERPRET && FS_zone(chn, width) == -1)
{
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
@@ -6222,10 +6222,10 @@ struct Value *stmt_WRITE(struct Value *value)
int chn = STDCHANNEL;
int comma = 0;
- ++pc.token;
- if (pc.token->type == T_CHANNEL)
+ ++g_pc.token;
+ if (g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("channel"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -6234,9 +6234,9 @@ struct Value *stmt_WRITE(struct Value *value)
chn = value->u.integer;
Value_destroy(value);
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
}
@@ -6249,7 +6249,7 @@ struct Value *stmt_WRITE(struct Value *value)
return value;
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
struct String s;
@@ -6276,9 +6276,9 @@ struct Value *stmt_WRITE(struct Value *value)
Value_destroy(value);
comma = 1;
}
- else if (pc.token->type == T_COMMA || pc.token->type == T_SEMICOLON)
+ else if (g_pc.token->type == T_COMMA || g_pc.token->type == T_SEMICOLON)
{
- ++pc.token;
+ ++g_pc.token;
}
else
{
@@ -6286,7 +6286,7 @@ struct Value *stmt_WRITE(struct Value *value)
}
}
- if (pass == INTERPRET)
+ if (g_pass == INTERPRET)
{
FS_putChar(chn, '\n');
if (FS_flush(chn) == -1)
@@ -6300,16 +6300,16 @@ struct Value *stmt_WRITE(struct Value *value)
struct Value *stmt_XREF(struct Value *value)
{
- stack.resumeable = 0;
- ++pc.token;
- if (pass == INTERPRET)
+ g_stack.resumeable = 0;
+ ++g_pc.token;
+ if (g_pass == INTERPRET)
{
- if (!program.runnable && compileProgram(value, 1)->type == V_ERROR)
+ if (!g_program.runnable && compileProgram(value, 1)->type == V_ERROR)
{
return value;
}
- Program_xref(&program, STDCHANNEL);
+ Program_xref(&g_program, STDCHANNEL);
}
return (struct Value *)0;
@@ -6319,10 +6319,10 @@ struct Value *stmt_ZONE(struct Value *value)
{
int chn = STDCHANNEL, width;
- ++pc.token;
- if (pc.token->type == T_CHANNEL)
+ ++g_pc.token;
+ if (g_pc.token->type == T_CHANNEL)
{
- ++pc.token;
+ ++g_pc.token;
if (eval(value, _("channel"))->type == V_ERROR ||
Value_retype(value, V_INTEGER)->type == V_ERROR)
{
@@ -6331,9 +6331,9 @@ struct Value *stmt_ZONE(struct Value *value)
chn = value->u.integer;
Value_destroy(value);
- if (pc.token->type == T_COMMA)
+ if (g_pc.token->type == T_COMMA)
{
- ++pc.token;
+ ++g_pc.token;
}
}
@@ -6345,7 +6345,7 @@ struct Value *stmt_ZONE(struct Value *value)
width = value->u.integer;
Value_destroy(value);
- if (pass == INTERPRET && FS_zone(chn, width) == -1)
+ if (g_pass == INTERPRET && FS_zone(chn, width) == -1)
{
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}