Added the possibility to disable range-checks
This commit is contained in:
parent
d0b452373b
commit
a7b7fa4162
8 changed files with 71 additions and 18 deletions
|
@ -42,6 +42,7 @@ extern int cntlines;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int eofseen;
|
static int eofseen;
|
||||||
|
extern char options[];
|
||||||
|
|
||||||
STATIC
|
STATIC
|
||||||
SkipComment()
|
SkipComment()
|
||||||
|
@ -65,6 +66,21 @@ SkipComment()
|
||||||
*/
|
*/
|
||||||
ForeignFlag = D_FOREIGN;
|
ForeignFlag = D_FOREIGN;
|
||||||
break;
|
break;
|
||||||
|
case 'R':
|
||||||
|
/* Range checks, on or off */
|
||||||
|
LoadChar(ch);
|
||||||
|
if (ch == '-') {
|
||||||
|
options['R'] = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ch == '+') {
|
||||||
|
options['R'] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* fall through */
|
||||||
|
default:
|
||||||
|
PushBack();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
|
@ -1330,5 +1330,5 @@ int (*DesigChkTable[])() = {
|
||||||
done_before,
|
done_before,
|
||||||
NodeCrash,
|
NodeCrash,
|
||||||
ChkLinkOrName,
|
ChkLinkOrName,
|
||||||
done_before
|
NodeCrash
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
extern char *long2str();
|
extern char *long2str();
|
||||||
extern char *symbol2str();
|
extern char *symbol2str();
|
||||||
extern int proclevel;
|
extern int proclevel;
|
||||||
|
extern char options[];
|
||||||
int fp_used;
|
int fp_used;
|
||||||
|
|
||||||
CodeConst(cst, size)
|
CodeConst(cst, size)
|
||||||
|
@ -263,21 +264,21 @@ CodeCoercion(t1, t2)
|
||||||
C_cfi();
|
C_cfi();
|
||||||
break;
|
break;
|
||||||
case T_CARDINAL:
|
case T_CARDINAL:
|
||||||
{
|
if (! options['R']) {
|
||||||
label lb = ++text_label;
|
label lb = ++text_label;
|
||||||
|
|
||||||
C_dup(t1->tp_size);
|
C_dup(t1->tp_size);
|
||||||
C_zrf(t1->tp_size);
|
C_zrf(t1->tp_size);
|
||||||
C_cmf(t1->tp_size);
|
C_cmf(t1->tp_size);
|
||||||
C_zge(lb);
|
C_zge(lb);
|
||||||
C_loc((arith) ECONV);
|
C_loc((arith) ECONV);
|
||||||
C_trp();
|
C_trp();
|
||||||
C_df_ilb(lb);
|
C_df_ilb(lb);
|
||||||
|
}
|
||||||
C_loc(t1->tp_size);
|
C_loc(t1->tp_size);
|
||||||
C_loc(t2->tp_size);
|
C_loc(t2->tp_size);
|
||||||
C_cfu();
|
C_cfu();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
crash("Funny REAL conversion");
|
crash("Funny REAL conversion");
|
||||||
}
|
}
|
||||||
|
@ -583,6 +584,8 @@ RangeCheck(tpl, tpr)
|
||||||
|
|
||||||
arith llo, lhi, rlo, rhi;
|
arith llo, lhi, rlo, rhi;
|
||||||
|
|
||||||
|
if (options['R']) return;
|
||||||
|
|
||||||
if (bounded(tpl)) {
|
if (bounded(tpl)) {
|
||||||
/* in this case we might need a range check */
|
/* in this case we might need a range check */
|
||||||
if (!bounded(tpr)) {
|
if (!bounded(tpr)) {
|
||||||
|
|
|
@ -39,6 +39,7 @@ int nDEF, mDEF;
|
||||||
int pass_1;
|
int pass_1;
|
||||||
struct def *Defined;
|
struct def *Defined;
|
||||||
extern int err_occurred;
|
extern int err_occurred;
|
||||||
|
extern int Roption;
|
||||||
extern int fp_used; /* set if floating point used */
|
extern int fp_used; /* set if floating point used */
|
||||||
struct node *EmptyStatement;
|
struct node *EmptyStatement;
|
||||||
|
|
||||||
|
@ -89,6 +90,7 @@ Compile(src, dst)
|
||||||
AddStandards();
|
AddStandards();
|
||||||
EmptyStatement = dot2leaf(Stat);
|
EmptyStatement = dot2leaf(Stat);
|
||||||
EmptyStatement->nd_symb = ';';
|
EmptyStatement->nd_symb = ';';
|
||||||
|
Roption = options['R'];
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (options['l']) {
|
if (options['l']) {
|
||||||
LexScan();
|
LexScan();
|
||||||
|
|
|
@ -25,7 +25,7 @@ struct node {
|
||||||
#define Def 9 /* an identified name */
|
#define Def 9 /* an identified name */
|
||||||
#define Stat 10 /* a statement */
|
#define Stat 10 /* a statement */
|
||||||
#define Link 11
|
#define Link 11
|
||||||
#define LinkDef 12
|
#define Option 12
|
||||||
/* do NOT change the order or the numbers!!! */
|
/* do NOT change the order or the numbers!!! */
|
||||||
struct type *nd_type; /* type of this node */
|
struct type *nd_type; /* type of this node */
|
||||||
struct token nd_token;
|
struct token nd_token;
|
||||||
|
@ -51,5 +51,5 @@ extern struct node *MkNode(), *MkLeaf(), *dot2node(), *dot2leaf();
|
||||||
#define VARIABLE 004
|
#define VARIABLE 004
|
||||||
#define VALUE 010
|
#define VALUE 010
|
||||||
|
|
||||||
#define IsCast(lnd) (((lnd)->nd_class == Def || (lnd)->nd_class == LinkDef) && is_type((lnd)->nd_def))
|
#define IsCast(lnd) ((lnd)->nd_class == Def && is_type((lnd)->nd_def))
|
||||||
#define IsProcCall(lnd) ((lnd)->nd_type->tp_fund == T_PROCEDURE)
|
#define IsProcCall(lnd) ((lnd)->nd_type->tp_fund == T_PROCEDURE)
|
||||||
|
|
|
@ -40,6 +40,7 @@ DoOption(text)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'L': /* no fil/lin */
|
case 'L': /* no fil/lin */
|
||||||
|
case 'R': /* no range checks */
|
||||||
case 'p': /* call procentry/procexit */
|
case 'p': /* call procentry/procexit */
|
||||||
case 'n': /* no register messages */
|
case 'n': /* no register messages */
|
||||||
case 'x': /* every name global */
|
case 'x': /* every name global */
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
|
|
||||||
static int loopcount = 0; /* Count nested loops */
|
static int loopcount = 0; /* Count nested loops */
|
||||||
|
int Roption;
|
||||||
|
extern char options[];
|
||||||
extern struct node *EmptyStatement;
|
extern struct node *EmptyStatement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +32,23 @@ statement(register struct node **pnd;)
|
||||||
register struct node *nd;
|
register struct node *nd;
|
||||||
extern int return_occurred;
|
extern int return_occurred;
|
||||||
} :
|
} :
|
||||||
|
/* We need some method for making sure lookahead is done, so ...
|
||||||
|
*/
|
||||||
|
[ PROGRAM
|
||||||
|
/* LLlex never returns this */
|
||||||
|
| %default
|
||||||
|
{ if (options['R'] != Roption) {
|
||||||
|
Roption = options['R'];
|
||||||
|
nd = dot2leaf(Option);
|
||||||
|
nd->nd_symb = 'R';
|
||||||
|
*pnd = nd =
|
||||||
|
dot2node(Link, nd, NULLNODE);
|
||||||
|
nd->nd_symb = ';';
|
||||||
|
pnd = &(nd->nd_right);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
[
|
||||||
/*
|
/*
|
||||||
* This part is not in the reference grammar. The reference grammar
|
* This part is not in the reference grammar. The reference grammar
|
||||||
* states : assignment | ProcedureCall | ...
|
* states : assignment | ProcedureCall | ...
|
||||||
|
@ -88,6 +107,7 @@ statement(register struct node **pnd;)
|
||||||
{ return_occurred = 1; }
|
{ return_occurred = 1; }
|
||||||
|
|
|
|
||||||
/* empty */ { *pnd = EmptyStatement; }
|
/* empty */ { *pnd = EmptyStatement; }
|
||||||
|
]
|
||||||
;
|
;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -105,12 +125,13 @@ ProcedureCall:
|
||||||
StatementSequence(register struct node **pnd;)
|
StatementSequence(register struct node **pnd;)
|
||||||
{
|
{
|
||||||
struct node *nd;
|
struct node *nd;
|
||||||
|
register struct node *nd1;
|
||||||
} :
|
} :
|
||||||
statement(pnd)
|
statement(pnd)
|
||||||
[ %persistent
|
[ %persistent
|
||||||
';' statement(&nd)
|
';'
|
||||||
{ register struct node *nd1 = dot2node(Link, *pnd, nd);
|
statement(&nd)
|
||||||
|
{ nd1 = dot2node(Link, *pnd, nd);
|
||||||
*pnd = nd1;
|
*pnd = nd1;
|
||||||
nd1->nd_symb = ';';
|
nd1->nd_symb = ';';
|
||||||
pnd = &(nd1->nd_right);
|
pnd = &(nd1->nd_right);
|
||||||
|
|
|
@ -417,7 +417,7 @@ WalkStat(nd, exit_label)
|
||||||
|
|
||||||
assert(nd->nd_class == Stat);
|
assert(nd->nd_class == Stat);
|
||||||
|
|
||||||
if (! options['L']) C_lin((arith) nd->nd_lineno);
|
if (! options['L'] && nd->nd_lineno) C_lin((arith) nd->nd_lineno);
|
||||||
switch(nd->nd_symb) {
|
switch(nd->nd_symb) {
|
||||||
case ';':
|
case ';':
|
||||||
break;
|
break;
|
||||||
|
@ -630,6 +630,16 @@ WalkStat(nd, exit_label)
|
||||||
|
|
||||||
extern int NodeCrash();
|
extern int NodeCrash();
|
||||||
|
|
||||||
|
STATIC
|
||||||
|
WalkOption(nd)
|
||||||
|
struct node *nd;
|
||||||
|
{
|
||||||
|
/* Toggle option indicated by node "nd"
|
||||||
|
*/
|
||||||
|
|
||||||
|
options[nd->nd_symb] = ! options[nd->nd_symb];
|
||||||
|
}
|
||||||
|
|
||||||
int (*WalkTable[])() = {
|
int (*WalkTable[])() = {
|
||||||
NodeCrash,
|
NodeCrash,
|
||||||
NodeCrash,
|
NodeCrash,
|
||||||
|
@ -643,7 +653,7 @@ int (*WalkTable[])() = {
|
||||||
NodeCrash,
|
NodeCrash,
|
||||||
WalkStat,
|
WalkStat,
|
||||||
WalkLink,
|
WalkLink,
|
||||||
NodeCrash
|
WalkOption
|
||||||
};
|
};
|
||||||
|
|
||||||
ExpectBool(nd, true_label, false_label)
|
ExpectBool(nd, true_label, false_label)
|
||||||
|
|
Loading…
Add table
Reference in a new issue