parent
4937b8dd25
commit
44a33d1f1d
|
@ -67,7 +67,6 @@ static int declargs(symbol * sym);
|
|||
static void doarg(char *name, int ident, int offset,
|
||||
int tags[], int numtags,
|
||||
int fpublic, int fconst, arginfo * arg);
|
||||
static void dump_referrers(symbol * root, FILE * log, char *sourcefile);
|
||||
static void reduce_referrers(symbol * root);
|
||||
static int testsymbols(symbol * root, int level,
|
||||
int testlabs, int testconst);
|
||||
|
@ -581,11 +580,11 @@ initglobals(void)
|
|||
litmax = sDEF_LITMAX; /* current size of the literal table */
|
||||
errnum = 0; /* number of errors */
|
||||
warnnum = 0; /* number of warnings */
|
||||
/* // sc_debug=sCHKBOUNDS; /* by default: bounds checking+assertions */
|
||||
/* sc_debug=sCHKBOUNDS; by default: bounds checking+assertions */
|
||||
sc_debug = 0; /* by default: no debug */
|
||||
charbits = 8; /* a "char" is 8 bits */
|
||||
sc_packstr = FALSE; /* strings are unpacked by default */
|
||||
/* // sc_compress=TRUE; /* compress output bytecodes */
|
||||
/* sc_compress=TRUE; compress output bytecodes */
|
||||
sc_compress = FALSE; /* compress output bytecodes */
|
||||
sc_needsemicolon = FALSE; /* semicolon required to terminate
|
||||
* expressions? */
|
||||
|
@ -651,35 +650,6 @@ set_extension(char *filename, char *extension, int force)
|
|||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
toggle_option(char *optptr, int option)
|
||||
{
|
||||
switch (*(optptr + 1))
|
||||
{
|
||||
case '\0':
|
||||
option = !option;
|
||||
break;
|
||||
case '-':
|
||||
option = FALSE;
|
||||
break;
|
||||
case '+':
|
||||
option = TRUE;
|
||||
break;
|
||||
default:
|
||||
about();
|
||||
} /* switch */
|
||||
return option;
|
||||
}
|
||||
|
||||
/* Parsing command line options is indirectly recursive: parseoptions()
|
||||
* calls parserespf() to handle options in a a response file and
|
||||
* parserespf() calls parseoptions() at its turn after having created
|
||||
* an "option list" from the contents of the file.
|
||||
*/
|
||||
static void parserespf(char *filename, char *iname,
|
||||
char *oname, char *ename,
|
||||
char *pname, char *rname);
|
||||
|
||||
static void
|
||||
parseoptions(int argc, char **argv, char *iname, char *oname,
|
||||
char *ename, char *pname, char *rname)
|
||||
|
@ -901,12 +871,6 @@ setconfig(char *root)
|
|||
} /* if */
|
||||
}
|
||||
|
||||
static int
|
||||
waitkey(void)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
setcaption(void)
|
||||
{
|
||||
|
@ -1423,7 +1387,7 @@ declloc(int fstatic)
|
|||
* of a global variable or to that of a local variable at a lower
|
||||
* level might indicate a bug.
|
||||
*/
|
||||
if ((sym = findloc(name)) != NULL && sym->compound != nestlevel
|
||||
if (((sym = findloc(name)) != NULL && sym->compound != nestlevel)
|
||||
|| findglb(name) != NULL)
|
||||
error(219, name); /* variable shadows another symbol */
|
||||
while (matchtoken('['))
|
||||
|
@ -2114,7 +2078,7 @@ operatoradjust(int opertok, symbol * sym, char *opername, int resulttag)
|
|||
} /* switch */
|
||||
|
||||
if (tags[0] == 0
|
||||
&& (opertok != '=' && tags[1] == 0 || opertok == '=' && resulttag == 0))
|
||||
&& ((opertok != '=' && tags[1] == 0) || (opertok == '=' && resulttag == 0)))
|
||||
error(64); /* cannot change predefined operators */
|
||||
|
||||
/* change the operator name */
|
||||
|
@ -2298,7 +2262,7 @@ funcstub(int native)
|
|||
if (native)
|
||||
{
|
||||
if (tok == tPUBLIC || tok == tSTOCK || tok == tSTATIC ||
|
||||
tok == tSYMBOL && *str == PUBLIC_CHAR)
|
||||
(tok == tSYMBOL && *str == PUBLIC_CHAR))
|
||||
error(42); /* invalid combination of class specifiers */
|
||||
}
|
||||
else
|
||||
|
@ -2426,7 +2390,7 @@ newfunc(char *firstname, int firsttag, int fpublic, int fstatic, int stock)
|
|||
tag = (firsttag >= 0) ? firsttag : sc_addtag(NULL);
|
||||
tok = lex(&val, &str);
|
||||
assert(!fpublic);
|
||||
if (tok == tNATIVE || tok == tPUBLIC && stock)
|
||||
if (tok == tNATIVE || (tok == tPUBLIC && stock))
|
||||
error(42); /* invalid combination of class specifiers */
|
||||
if (tok == tOPERATOR)
|
||||
{
|
||||
|
@ -2798,7 +2762,7 @@ declargs(symbol * sym)
|
|||
error(10); /* illegal function or declaration */
|
||||
} /* switch */
|
||||
}
|
||||
while (tok == '&' || tok == tLABEL || tok == tCONST || tok != tELLIPS && matchtoken(',')); /* more? */
|
||||
while (tok == '&' || tok == tLABEL || tok == tCONST || (tok != tELLIPS && matchtoken(','))); /* more? */
|
||||
/* if the next token is not ",", it should be ")" */
|
||||
needtoken(')');
|
||||
} /* if */
|
||||
|
|
|
@ -1176,9 +1176,9 @@ command(void)
|
|||
sym = findloc(str);
|
||||
if (sym == NULL)
|
||||
sym = findglb(str);
|
||||
if (sym == NULL || sym->ident != iFUNCTN
|
||||
if (sym == NULL || (sym->ident != iFUNCTN
|
||||
&& sym->ident != iREFFUNC
|
||||
&& (sym->usage & uDEFINE) == 0)
|
||||
&& (sym->usage & uDEFINE) == 0))
|
||||
{
|
||||
error(17, str); /* undefined symbol */
|
||||
}
|
||||
|
@ -1974,7 +1974,7 @@ lex(cell * lexvalue, char **lexsym)
|
|||
lptr += 1; /* skip colon */
|
||||
} /* if */
|
||||
}
|
||||
else if (*lptr == '\"' || *lptr == sc_ctrlchar && *(lptr + 1) == '\"')
|
||||
else if (*lptr == '\"' || (*lptr == sc_ctrlchar && *(lptr + 1) == '\"'))
|
||||
{ /* unpacked string literal */
|
||||
_lextok = tSTRING;
|
||||
rawstring = (*lptr == sc_ctrlchar);
|
||||
|
@ -1990,10 +1990,10 @@ lex(cell * lexvalue, char **lexsym)
|
|||
else
|
||||
error(37); /* invalid (non-terminated) string */
|
||||
}
|
||||
else if (*lptr == '!' && *(lptr + 1) == '\"'
|
||||
|| *lptr == '!' && *(lptr + 1) == sc_ctrlchar && *(lptr + 2) == '\"'
|
||||
|| *lptr == sc_ctrlchar && *(lptr + 1) == '!'
|
||||
&& *(lptr + 2) == '\"')
|
||||
else if ((*lptr == '!' && *(lptr + 1) == '\"')
|
||||
|| (*lptr == '!' && *(lptr + 1) == sc_ctrlchar && *(lptr + 2) == '\"')
|
||||
|| (*lptr == sc_ctrlchar && *(lptr + 1) == '!'
|
||||
&& *(lptr + 2) == '\"'))
|
||||
{ /* packed string literal */
|
||||
_lextok = tSTRING;
|
||||
rawstring = (*lptr == sc_ctrlchar || *(lptr + 1) == sc_ctrlchar);
|
||||
|
@ -2082,7 +2082,7 @@ matchtoken(int token)
|
|||
int tok;
|
||||
|
||||
tok = lex(&val, &str);
|
||||
if (tok == token || token == tTERM && (tok == ';' || tok == tENDEXPR))
|
||||
if (tok == token || (token == tTERM && (tok == ';' || tok == tENDEXPR)))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1002,7 +1002,7 @@ hier14(value * lval1)
|
|||
if (lval3.sym->dim.array.level != level)
|
||||
return error(48); /* array dimensions must match */
|
||||
else if (lval3.sym->dim.array.length < val
|
||||
|| exactmatch && lval3.sym->dim.array.length > val)
|
||||
|| (exactmatch && lval3.sym->dim.array.length > val))
|
||||
return error(47); /* array sizes must match */
|
||||
if (level > 0)
|
||||
{
|
||||
|
@ -1544,8 +1544,8 @@ hier1(value * lval1)
|
|||
if (close == ']')
|
||||
{
|
||||
/* normal array index */
|
||||
if (lval2.constval < 0 || sym->dim.array.length != 0
|
||||
&& sym->dim.array.length <= lval2.constval)
|
||||
if (lval2.constval < 0 || (sym->dim.array.length != 0
|
||||
&& sym->dim.array.length <= lval2.constval))
|
||||
error(32, sym->name); /* array index out of bounds */
|
||||
if (lval2.constval != 0)
|
||||
{
|
||||
|
@ -1561,10 +1561,10 @@ hier1(value * lval1)
|
|||
else
|
||||
{
|
||||
/* character index */
|
||||
if (lval2.constval < 0 || sym->dim.array.length != 0
|
||||
if (lval2.constval < 0 || (sym->dim.array.length != 0
|
||||
&& sym->dim.array.length * ((8 * sizeof(cell)) /
|
||||
charbits) <=
|
||||
(ucell) lval2.constval)
|
||||
(ucell) lval2.constval))
|
||||
error(32, sym->name); /* array index out of bounds */
|
||||
if (lval2.constval != 0)
|
||||
{
|
||||
|
@ -2094,11 +2094,11 @@ callfunction(symbol * sym)
|
|||
* function argument; a literal string may be smaller than
|
||||
* the function argument.
|
||||
*/
|
||||
if (lval.constval > 0
|
||||
&& arg[argidx].dim[0] != lval.constval
|
||||
|| lval.constval < 0
|
||||
if ((lval.constval > 0
|
||||
&& arg[argidx].dim[0] != lval.constval)
|
||||
|| (lval.constval < 0
|
||||
&& arg[argidx].dim[0] <
|
||||
-lval.constval)
|
||||
-lval.constval))
|
||||
error(47); /* array sizes must match */
|
||||
} /* if */
|
||||
} /* if */
|
||||
|
|
|
@ -1023,8 +1023,8 @@ assemble(FILE * fout, FILE * fin)
|
|||
instr = skipwhitespace(line);
|
||||
/* ignore empty lines and labels (labels have a special syntax, so these
|
||||
* must be parsed separately) */
|
||||
if (*instr == '\0' || tolower(*instr) == 'l'
|
||||
&& *(instr + 1) == '.')
|
||||
if (*instr == '\0' || (tolower(*instr) == 'l'
|
||||
&& *(instr + 1) == '.'))
|
||||
continue;
|
||||
/* get to the end of the instruction (make use of the '\n' that fgets()
|
||||
* added at the end of the line; this way we will *always* drop on a
|
||||
|
|
|
@ -490,18 +490,18 @@ matchsequence(char *start, char *end, char *pattern,
|
|||
case ' ':
|
||||
if (*start != '\t' && *start != ' ')
|
||||
return FALSE;
|
||||
while (start < end && *start == '\t' || *start == ' ')
|
||||
while ((start < end && *start == '\t') || *start == ' ')
|
||||
start++;
|
||||
break;
|
||||
case '!':
|
||||
while (start < end && *start == '\t' || *start == ' ')
|
||||
while ((start < end && *start == '\t') || *start == ' ')
|
||||
start++; /* skip trailing white space */
|
||||
if (*start != '\n')
|
||||
return FALSE;
|
||||
assert(*(start + 1) == '\0');
|
||||
start += 2; /* skip '\n' and '\0' */
|
||||
if (*(pattern + 1) != '\0')
|
||||
while (start < end && *start == '\t' || *start == ' ')
|
||||
while ((start < end && *start == '\t') || *start == ' ')
|
||||
start++; /* skip leading white space of next instruction */
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -239,7 +239,7 @@ adjustindex(char c)
|
|||
{
|
||||
stringpair *cur;
|
||||
|
||||
assert(c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c == '_');
|
||||
assert((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c == '_');
|
||||
assert('A' < '_' && '_' < 'z');
|
||||
|
||||
for (cur = substpair.next; cur != NULL && cur->first[0] != c;
|
||||
|
@ -270,7 +270,7 @@ find_subst(char *name, int length)
|
|||
|
||||
assert(name != NULL);
|
||||
assert(length > 0);
|
||||
assert(*name >= 'A' && *name <= 'Z' || *name >= 'a' && *name <= 'z'
|
||||
assert((*name >= 'A' && *name <= 'Z') || (*name >= 'a' && *name <= 'z')
|
||||
|| *name == '_');
|
||||
item = substindex[(int)*name - 'A'];
|
||||
if (item != NULL)
|
||||
|
@ -285,7 +285,7 @@ delete_subst(char *name, int length)
|
|||
|
||||
assert(name != NULL);
|
||||
assert(length > 0);
|
||||
assert(*name >= 'A' && *name <= 'Z' || *name >= 'a' && *name <= 'z'
|
||||
assert((*name >= 'A' && *name <= 'Z') || (*name >= 'a' && *name <= 'z')
|
||||
|| *name == '_');
|
||||
item = substindex[(int)*name - 'A'];
|
||||
if (item != NULL)
|
||||
|
|
|
@ -130,7 +130,6 @@ exported_printf(Embryo_Program *ep, Embryo_Cell *params)
|
|||
static Embryo_Cell
|
||||
exported_rec(Embryo_Program *ep, Embryo_Cell *params)
|
||||
{
|
||||
Embryo_Cell *cptr;
|
||||
Embryo_Function fn;
|
||||
Embryo_Cell ret, arg1, arg2;
|
||||
|
||||
|
|
|
@ -23,32 +23,11 @@
|
|||
|
||||
#define JUMPABS(base, ip) ((Embryo_Cell *)(code + (*ip)))
|
||||
|
||||
static void _embryo_byte_swap_16 (unsigned short *v);
|
||||
static void _embryo_byte_swap_32 (unsigned int *v);
|
||||
static int _embryo_native_call (Embryo_Program *ep, Embryo_Cell index, Embryo_Cell *result, Embryo_Cell *params);
|
||||
static int _embryo_func_get (Embryo_Program *ep, int index, char *funcname);
|
||||
static int _embryo_var_get (Embryo_Program *ep, int index, char *varname, Embryo_Cell *ep_addr);
|
||||
static int _embryo_program_init (Embryo_Program *ep, void *code);
|
||||
|
||||
static void
|
||||
_embryo_byte_swap_16(unsigned short *v)
|
||||
{
|
||||
unsigned char *s, t;
|
||||
|
||||
s = (unsigned char *)v;
|
||||
t = s[0]; s[0] = s[1]; s[1] = t;
|
||||
}
|
||||
|
||||
static void
|
||||
_embryo_byte_swap_32(unsigned int *v)
|
||||
{
|
||||
unsigned char *s, t;
|
||||
|
||||
s = (unsigned char *)v;
|
||||
t = s[0]; s[0] = s[3]; s[3] = t;
|
||||
t = s[1]; s[1] = s[2]; s[2] = t;
|
||||
}
|
||||
|
||||
static int
|
||||
_embryo_native_call(Embryo_Program *ep, Embryo_Cell index, Embryo_Cell *result, Embryo_Cell *params)
|
||||
{
|
||||
|
@ -1555,7 +1534,7 @@ embryo_program_run(Embryo_Program *ep, Embryo_Function fn)
|
|||
break;
|
||||
case EMBRYO_OP_SWITCH:
|
||||
{
|
||||
Embryo_Cell *cptr, *tbl;
|
||||
Embryo_Cell *cptr;
|
||||
|
||||
/* +1, to skip the "casetbl" opcode */
|
||||
cptr = (Embryo_Cell *)(code + (*cip)) + 1;
|
||||
|
|
Loading…
Reference in New Issue