some more fixes, and tried to make smaller
This commit is contained in:
parent
3de7f959d3
commit
51169956dc
|
@ -32,7 +32,7 @@ int proclevel = 0; /* nesting level of procedures */
|
|||
int return_occurred; /* set if a return occurs in a block */
|
||||
|
||||
#define needs_static_link() (proclevel > 1)
|
||||
|
||||
extern struct node *EmptyStatement;
|
||||
}
|
||||
|
||||
/* inline in declaration: need space
|
||||
|
@ -82,11 +82,13 @@ block(struct node **pnd;) :
|
|||
[ %persistent
|
||||
declaration
|
||||
]*
|
||||
{ return_occurred = 0; *pnd = 0; }
|
||||
[ %persistent
|
||||
{ return_occurred = 0; }
|
||||
[ %default
|
||||
BEGIN
|
||||
StatementSequence(pnd)
|
||||
]?
|
||||
|
|
||||
{ *pnd = EmptyStatement; }
|
||||
]
|
||||
END
|
||||
;
|
||||
|
||||
|
@ -164,7 +166,7 @@ TypeDeclaration
|
|||
register struct node *nd;
|
||||
}:
|
||||
IDENT { df = define(dot.TOK_IDF, CurrentScope, D_TYPE);
|
||||
nd = MkLeaf(Name, &dot);
|
||||
nd = dot2leaf(Name);
|
||||
}
|
||||
'=' type(&tp)
|
||||
{ DeclareType(nd, df, tp);
|
||||
|
@ -218,10 +220,10 @@ IdentList(struct node **p;)
|
|||
{
|
||||
register struct node *q;
|
||||
} :
|
||||
IDENT { *p = q = MkLeaf(Value, &dot); }
|
||||
IDENT { *p = q = dot2leaf(Value); }
|
||||
[ %persistent
|
||||
',' IDENT
|
||||
{ q->nd_left = MkLeaf(Value, &dot);
|
||||
{ q->nd_left = dot2leaf(Value);
|
||||
q = q->nd_left;
|
||||
}
|
||||
]*
|
||||
|
@ -376,7 +378,7 @@ variant(struct scope *scope; arith *cnt; struct type *tp; int *palign;)
|
|||
CaseLabelList(struct type **ptp; struct node **pnd;):
|
||||
CaseLabels(ptp, pnd)
|
||||
[
|
||||
{ *pnd = MkNode(Link, *pnd, NULLNODE, &dot); }
|
||||
{ *pnd = dot2node(Link, *pnd, NULLNODE); }
|
||||
',' CaseLabels(ptp, &((*pnd)->nd_right))
|
||||
{ pnd = &((*pnd)->nd_right); }
|
||||
]*
|
||||
|
@ -394,7 +396,7 @@ CaseLabels(struct type **ptp; register struct node **pnd;)
|
|||
nd = *pnd;
|
||||
}
|
||||
[
|
||||
UPTO { *pnd = MkNode(Link,nd,NULLNODE,&dot); }
|
||||
UPTO { *pnd = dot2node(Link,nd,NULLNODE); }
|
||||
ConstExpression(&(*pnd)->nd_right)
|
||||
{ if (!ChkCompat(&((*pnd)->nd_right), nd->nd_type,
|
||||
"case label")) {
|
||||
|
@ -518,7 +520,7 @@ IdentAddr(struct node **pnd;)
|
|||
{
|
||||
register struct node *nd;
|
||||
} :
|
||||
IDENT { nd = MkLeaf(Name, &dot); }
|
||||
IDENT { nd = dot2leaf(Name); }
|
||||
[ '['
|
||||
ConstExpression(&(nd->nd_left))
|
||||
']'
|
||||
|
|
|
@ -239,7 +239,7 @@ DeclProc(type, id)
|
|||
/* In a definition module
|
||||
*/
|
||||
df = define(id, CurrentScope, type);
|
||||
df->for_node = MkLeaf(Name, &dot);
|
||||
df->for_node = dot2leaf(Name);
|
||||
if (CurrentScope->sc_definedby->df_flags & D_FOREIGN) {
|
||||
df->for_name = id->id_text;
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ GetDefinitionModule(id, incr)
|
|||
register struct node *n;
|
||||
extern struct node *Modules;
|
||||
|
||||
n = MkLeaf(Name, &dot);
|
||||
n = dot2leaf(Name);
|
||||
n->nd_IDF = id;
|
||||
n->nd_symb = IDENT;
|
||||
if (nd_end) nd_end->nd_left = n;
|
||||
|
|
|
@ -197,7 +197,7 @@ EnterParamList(ppr, Idlist, type, VARp, off)
|
|||
|
||||
if (! idlist) {
|
||||
/* Can only happen when a procedure type is defined */
|
||||
dummy = Idlist = idlist = MkLeaf(Name, &dot);
|
||||
dummy = Idlist = idlist = dot2leaf(Name);
|
||||
}
|
||||
for ( ; idlist; idlist = idlist->nd_left) {
|
||||
pr = new_paramlist();
|
||||
|
|
|
@ -36,7 +36,7 @@ number(struct node **p;) :
|
|||
INTEGER
|
||||
|
|
||||
REAL
|
||||
] { *p = MkLeaf(Value, &dot);
|
||||
] { *p = dot2leaf(Value);
|
||||
(*p)->nd_type = toktype;
|
||||
}
|
||||
;
|
||||
|
@ -45,14 +45,14 @@ number(struct node **p;) :
|
|||
qualident(struct node **p;)
|
||||
{
|
||||
} :
|
||||
IDENT { *p = MkLeaf(Name, &dot); }
|
||||
IDENT { *p = dot2leaf(Name); }
|
||||
[
|
||||
selector(p)
|
||||
]*
|
||||
;
|
||||
|
||||
selector(struct node **pnd;):
|
||||
'.' { *pnd = MkNode(Link,*pnd,NULLNODE,&dot); }
|
||||
'.' { *pnd = dot2node(Link,*pnd,NULLNODE); }
|
||||
IDENT { (*pnd)->nd_IDF = dot.TOK_IDF; }
|
||||
;
|
||||
|
||||
|
@ -60,11 +60,11 @@ ExpList(struct node **pnd;)
|
|||
{
|
||||
register struct node *nd;
|
||||
} :
|
||||
expression(pnd) { *pnd = nd = MkNode(Link,*pnd,NULLNODE,&dot);
|
||||
expression(pnd) { *pnd = nd = dot2node(Link,*pnd,NULLNODE);
|
||||
nd->nd_symb = ',';
|
||||
}
|
||||
[
|
||||
',' { nd->nd_right = MkLeaf(Link, &dot);
|
||||
',' { nd->nd_right = dot2leaf(Link);
|
||||
nd = nd->nd_right;
|
||||
}
|
||||
expression(&(nd->nd_left))
|
||||
|
@ -101,7 +101,7 @@ expression(struct node **pnd;)
|
|||
[
|
||||
/* relation */
|
||||
[ '=' | '#' | '<' | LESSEQUAL | '>' | GREATEREQUAL | IN ]
|
||||
{ *pnd = MkNode(Oper, *pnd, NULLNODE, &dot); }
|
||||
{ *pnd = dot2node(Oper, *pnd, NULLNODE); }
|
||||
SimpleExpression(&((*pnd)->nd_right))
|
||||
]?
|
||||
;
|
||||
|
@ -118,7 +118,7 @@ SimpleExpression(struct node **pnd;)
|
|||
} :
|
||||
[
|
||||
[ '+' | '-' ]
|
||||
{ nd = MkLeaf(Uoper, &dot);
|
||||
{ nd = dot2leaf(Uoper);
|
||||
/* priority of unary operator ??? */
|
||||
}
|
||||
]?
|
||||
|
@ -132,7 +132,7 @@ SimpleExpression(struct node **pnd;)
|
|||
[
|
||||
/* AddOperator */
|
||||
[ '+' | '-' | OR ]
|
||||
{ nd = MkNode(Oper, nd, NULLNODE, &dot); }
|
||||
{ nd = dot2node(Oper, nd, NULLNODE); }
|
||||
term(&(nd->nd_right))
|
||||
]*
|
||||
{ *pnd = nd; }
|
||||
|
@ -152,7 +152,7 @@ term(struct node **pnd;)
|
|||
[
|
||||
/* MulOperator */
|
||||
[ '*' | '/' | DIV | MOD | AND ]
|
||||
{ nd = MkNode(Oper, nd, NULLNODE, &dot); }
|
||||
{ nd = dot2node(Oper, nd, NULLNODE); }
|
||||
factor(&(nd->nd_right))
|
||||
]*
|
||||
{ *pnd = nd; }
|
||||
|
@ -172,7 +172,7 @@ factor(register struct node **p;)
|
|||
[
|
||||
designator_tail(p)?
|
||||
[
|
||||
{ *p = MkNode(Call, *p, NULLNODE, &dot); }
|
||||
{ *p = dot2node(Call, *p, NULLNODE); }
|
||||
ActualParameters(&((*p)->nd_right))
|
||||
]?
|
||||
|
|
||||
|
@ -189,11 +189,11 @@ factor(register struct node **p;)
|
|||
REAL
|
||||
|
|
||||
STRING
|
||||
] { *p = MkLeaf(Value, &dot);
|
||||
] { *p = dot2leaf(Value);
|
||||
(*p)->nd_type = toktype;
|
||||
}
|
||||
|
|
||||
'(' { nd = MkLeaf(Uoper, &dot); }
|
||||
'(' { nd = dot2leaf(Uoper); }
|
||||
expression(p)
|
||||
{ /* In some cases we must leave the '(' as an unary
|
||||
operator, because otherwise we cannot see that the
|
||||
|
@ -212,7 +212,7 @@ factor(register struct node **p;)
|
|||
}
|
||||
')'
|
||||
|
|
||||
NOT { *p = MkLeaf(Uoper, &dot); }
|
||||
NOT { *p = dot2leaf(Uoper); }
|
||||
factor(&((*p)->nd_right))
|
||||
;
|
||||
|
||||
|
@ -221,7 +221,7 @@ bare_set(struct node **pnd;)
|
|||
register struct node *nd;
|
||||
} :
|
||||
'{' { dot.tk_symb = SET;
|
||||
*pnd = nd = MkLeaf(Xset, &dot);
|
||||
*pnd = nd = dot2leaf(Xset);
|
||||
nd->nd_type = bitset_type;
|
||||
}
|
||||
[
|
||||
|
@ -244,10 +244,10 @@ element(register struct node *nd;)
|
|||
expression(&nd1)
|
||||
[
|
||||
UPTO
|
||||
{ nd1 = MkNode(Link, nd1, NULLNODE, &dot);}
|
||||
{ nd1 = dot2node(Link, nd1, NULLNODE);}
|
||||
expression(&(nd1->nd_right))
|
||||
]?
|
||||
{ nd->nd_right = MkNode(Link, nd1, NULLNODE, &dot);
|
||||
{ nd->nd_right = dot2node(Link, nd1, NULLNODE);
|
||||
nd->nd_right->nd_symb = ',';
|
||||
}
|
||||
;
|
||||
|
@ -273,18 +273,18 @@ visible_designator_tail(struct node **pnd;)
|
|||
register struct node *nd = *pnd;
|
||||
}:
|
||||
[
|
||||
'[' { nd = MkNode(Arrsel, nd, NULLNODE, &dot); }
|
||||
'[' { nd = dot2node(Arrsel, nd, NULLNODE); }
|
||||
expression(&(nd->nd_right))
|
||||
[
|
||||
','
|
||||
{ nd = MkNode(Arrsel, nd, NULLNODE, &dot);
|
||||
{ nd = dot2node(Arrsel, nd, NULLNODE);
|
||||
nd->nd_symb = '[';
|
||||
}
|
||||
expression(&(nd->nd_right))
|
||||
]*
|
||||
']'
|
||||
|
|
||||
'^' { nd = MkNode(Arrow, NULLNODE, nd, &dot); }
|
||||
'^' { nd = dot2node(Arrow, NULLNODE, nd); }
|
||||
]
|
||||
{ *pnd = nd; }
|
||||
;
|
||||
|
|
|
@ -40,6 +40,7 @@ int pass_1;
|
|||
struct def *Defined;
|
||||
extern int err_occurred;
|
||||
extern int fp_used; /* set if floating point used */
|
||||
struct node *EmptyStatement;
|
||||
|
||||
main(argc, argv)
|
||||
register char **argv;
|
||||
|
@ -86,6 +87,8 @@ Compile(src, dst)
|
|||
InitScope();
|
||||
InitTypes();
|
||||
AddStandards();
|
||||
EmptyStatement = dot2leaf(Stat);
|
||||
EmptyStatement->nd_symb = ';';
|
||||
#ifdef DEBUG
|
||||
if (options['l']) {
|
||||
LexScan();
|
||||
|
|
|
@ -43,7 +43,7 @@ struct node {
|
|||
|
||||
/* ALLOCDEF "node" 50 */
|
||||
|
||||
extern struct node *MkNode(), *MkLeaf();
|
||||
extern struct node *MkNode(), *MkLeaf(), *dot2node(), *dot2leaf();
|
||||
|
||||
#define NULLNODE ((struct node *) 0)
|
||||
|
||||
|
|
|
@ -37,18 +37,30 @@ MkNode(class, left, right, token)
|
|||
return nd;
|
||||
}
|
||||
|
||||
struct node *
|
||||
dot2node(class, left, right)
|
||||
struct node *left, *right;
|
||||
{
|
||||
return MkNode(class, left, right, &dot);
|
||||
}
|
||||
|
||||
struct node *
|
||||
MkLeaf(class, token)
|
||||
struct token *token;
|
||||
{
|
||||
register struct node *nd = new_node();
|
||||
|
||||
nd->nd_left = nd->nd_right = 0;
|
||||
nd->nd_token = *token;
|
||||
nd->nd_class = class;
|
||||
return nd;
|
||||
}
|
||||
|
||||
struct node *
|
||||
dot2leaf(class)
|
||||
{
|
||||
return MkLeaf(class, &dot);
|
||||
}
|
||||
|
||||
FreeNode(nd)
|
||||
register struct node *nd;
|
||||
{
|
||||
|
|
|
@ -99,7 +99,7 @@ import(int local;)
|
|||
extern struct def *GetDefinitionModule();
|
||||
} :
|
||||
[ FROM
|
||||
IDENT { FromId = MkLeaf(Name, &dot);
|
||||
IDENT { FromId = dot2leaf(Name);
|
||||
if (local) df = lookfor(FromId,enclosing(CurrVis),0);
|
||||
else df = GetDefinitionModule(dot.TOK_IDF, 1);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "node.h"
|
||||
|
||||
static int loopcount = 0; /* Count nested loops */
|
||||
extern struct node *EmptyStatement;
|
||||
}
|
||||
|
||||
statement(register struct node **pnd;)
|
||||
|
@ -35,7 +36,7 @@ statement(register struct node **pnd;)
|
|||
* but this gives LL(1) conflicts
|
||||
*/
|
||||
designator(pnd)
|
||||
[ { nd = MkNode(Call, *pnd, NULLNODE, &dot);
|
||||
[ { nd = dot2node(Call, *pnd, NULLNODE);
|
||||
nd->nd_symb = '(';
|
||||
}
|
||||
ActualParameters(&(nd->nd_right))?
|
||||
|
@ -45,7 +46,7 @@ statement(register struct node **pnd;)
|
|||
DOT = BECOMES;
|
||||
}
|
||||
]
|
||||
{ nd = MkNode(Stat, *pnd, NULLNODE, &dot); }
|
||||
{ nd = dot2node(Stat, *pnd, NULLNODE); }
|
||||
expression(&(nd->nd_right))
|
||||
]
|
||||
{ *pnd = nd; }
|
||||
|
@ -57,19 +58,19 @@ statement(register struct node **pnd;)
|
|||
|
|
||||
CaseStatement(pnd)
|
||||
|
|
||||
WHILE { *pnd = nd = MkLeaf(Stat, &dot); }
|
||||
WHILE { *pnd = nd = dot2leaf(Stat); }
|
||||
expression(&(nd->nd_left))
|
||||
DO
|
||||
StatementSequence(&(nd->nd_right))
|
||||
END
|
||||
|
|
||||
REPEAT { *pnd = nd = MkLeaf(Stat, &dot); }
|
||||
REPEAT { *pnd = nd = dot2leaf(Stat); }
|
||||
StatementSequence(&(nd->nd_left))
|
||||
UNTIL
|
||||
expression(&(nd->nd_right))
|
||||
|
|
||||
{ loopcount++; }
|
||||
LOOP { *pnd = nd = MkLeaf(Stat, &dot); }
|
||||
LOOP { *pnd = nd = dot2leaf(Stat); }
|
||||
StatementSequence(&((*pnd)->nd_right))
|
||||
END
|
||||
{ loopcount--; }
|
||||
|
@ -80,13 +81,13 @@ statement(register struct node **pnd;)
|
|||
|
|
||||
EXIT
|
||||
{ if (!loopcount) error("EXIT not in a LOOP");
|
||||
*pnd = MkLeaf(Stat, &dot);
|
||||
*pnd = dot2leaf(Stat);
|
||||
}
|
||||
|
|
||||
ReturnStatement(pnd)
|
||||
{ return_occurred = 1; }
|
||||
|
|
||||
/* empty */ { *pnd = 0; }
|
||||
/* empty */ { *pnd = EmptyStatement; }
|
||||
;
|
||||
|
||||
/*
|
||||
|
@ -108,14 +109,11 @@ StatementSequence(register struct node **pnd;)
|
|||
statement(pnd)
|
||||
[ %persistent
|
||||
';' statement(&nd)
|
||||
{ if (nd) {
|
||||
register struct node *nd1 =
|
||||
MkNode(Link, *pnd, nd, &dot);
|
||||
{ register struct node *nd1 = dot2node(Link, *pnd, nd);
|
||||
|
||||
*pnd = nd1;
|
||||
nd1->nd_symb = ';';
|
||||
pnd = &(nd1->nd_right);
|
||||
}
|
||||
*pnd = nd1;
|
||||
nd1->nd_symb = ';';
|
||||
pnd = &(nd1->nd_right);
|
||||
}
|
||||
]*
|
||||
;
|
||||
|
@ -124,21 +122,21 @@ IfStatement(struct node **pnd;)
|
|||
{
|
||||
register struct node *nd;
|
||||
} :
|
||||
IF { nd = MkLeaf(Stat, &dot);
|
||||
IF { nd = dot2leaf(Stat);
|
||||
*pnd = nd;
|
||||
}
|
||||
expression(&(nd->nd_left))
|
||||
THEN { nd->nd_right = MkLeaf(Link, &dot);
|
||||
THEN { nd->nd_right = dot2leaf(Link);
|
||||
nd = nd->nd_right;
|
||||
}
|
||||
StatementSequence(&(nd->nd_left))
|
||||
[
|
||||
ELSIF { nd->nd_right = MkLeaf(Stat, &dot);
|
||||
ELSIF { nd->nd_right = dot2leaf(Stat);
|
||||
nd = nd->nd_right;
|
||||
nd->nd_symb = IF;
|
||||
}
|
||||
expression(&(nd->nd_left))
|
||||
THEN { nd->nd_right = MkLeaf(Link, &dot);
|
||||
THEN { nd->nd_right = dot2leaf(Link);
|
||||
nd = nd->nd_right;
|
||||
}
|
||||
StatementSequence(&(nd->nd_left))
|
||||
|
@ -155,7 +153,7 @@ CaseStatement(struct node **pnd;)
|
|||
register struct node *nd;
|
||||
struct type *tp = 0;
|
||||
} :
|
||||
CASE { *pnd = nd = MkLeaf(Stat, &dot); }
|
||||
CASE { *pnd = nd = dot2leaf(Stat); }
|
||||
expression(&(nd->nd_left))
|
||||
OF
|
||||
case(&(nd->nd_right), &tp)
|
||||
|
@ -166,21 +164,16 @@ CaseStatement(struct node **pnd;)
|
|||
{ nd = nd->nd_right; }
|
||||
]*
|
||||
[ ELSE StatementSequence(&(nd->nd_right))
|
||||
{ if (! nd->nd_right) {
|
||||
nd->nd_right = MkLeaf(Stat, &dot);
|
||||
nd->nd_right->nd_symb = ';';
|
||||
}
|
||||
}
|
||||
]?
|
||||
END
|
||||
;
|
||||
|
||||
case(struct node **pnd; struct type **ptp;) :
|
||||
[ CaseLabelList(ptp, pnd)
|
||||
':' { *pnd = MkNode(Link, *pnd, NULLNODE, &dot); }
|
||||
':' { *pnd = dot2node(Link, *pnd, NULLNODE); }
|
||||
StatementSequence(&((*pnd)->nd_right))
|
||||
]?
|
||||
{ *pnd = MkNode(Link, *pnd, NULLNODE, &dot);
|
||||
{ *pnd = dot2node(Link, *pnd, NULLNODE);
|
||||
(*pnd)->nd_symb = '|';
|
||||
}
|
||||
;
|
||||
|
@ -190,7 +183,7 @@ WhileStatement(struct node **pnd;)
|
|||
{
|
||||
register struct node *nd;
|
||||
}:
|
||||
WHILE { *pnd = nd = MkLeaf(Stat, &dot); }
|
||||
WHILE { *pnd = nd = dot2leaf(Stat); }
|
||||
expression(&(nd->nd_left))
|
||||
DO
|
||||
StatementSequence(&(nd->nd_right))
|
||||
|
@ -201,7 +194,7 @@ RepeatStatement(struct node **pnd;)
|
|||
{
|
||||
register struct node *nd;
|
||||
}:
|
||||
REPEAT { *pnd = nd = MkLeaf(Stat, &dot); }
|
||||
REPEAT { *pnd = nd = dot2leaf(Stat); }
|
||||
StatementSequence(&(nd->nd_left))
|
||||
UNTIL
|
||||
expression(&(nd->nd_right))
|
||||
|
@ -213,9 +206,9 @@ ForStatement(struct node **pnd;)
|
|||
register struct node *nd, *nd1;
|
||||
struct node *dummy;
|
||||
}:
|
||||
FOR { *pnd = nd = MkLeaf(Stat, &dot); }
|
||||
FOR { *pnd = nd = dot2leaf(Stat); }
|
||||
IDENT { nd->nd_IDF = dot.TOK_IDF; }
|
||||
BECOMES { nd->nd_left = nd1 = MkLeaf(Stat, &dot); }
|
||||
BECOMES { nd->nd_left = nd1 = dot2leaf(Stat); }
|
||||
expression(&(nd1->nd_left))
|
||||
TO
|
||||
expression(&(nd1->nd_right))
|
||||
|
@ -238,7 +231,7 @@ ForStatement(struct node **pnd;)
|
|||
|
||||
/* inline in Statement; lack of space
|
||||
LoopStatement(struct node **pnd;):
|
||||
LOOP { *pnd = MkLeaf(Stat, &dot); }
|
||||
LOOP { *pnd = dot2leaf(Stat); }
|
||||
StatementSequence(&((*pnd)->nd_right))
|
||||
END
|
||||
;
|
||||
|
@ -248,7 +241,7 @@ WithStatement(struct node **pnd;)
|
|||
{
|
||||
register struct node *nd;
|
||||
}:
|
||||
WITH { *pnd = nd = MkLeaf(Stat, &dot); }
|
||||
WITH { *pnd = nd = dot2leaf(Stat); }
|
||||
designator(&(nd->nd_left))
|
||||
DO
|
||||
StatementSequence(&(nd->nd_right))
|
||||
|
@ -261,7 +254,7 @@ ReturnStatement(struct node **pnd;)
|
|||
register struct node *nd;
|
||||
} :
|
||||
|
||||
RETURN { *pnd = nd = MkLeaf(Stat, &dot); }
|
||||
RETURN { *pnd = nd = dot2leaf(Stat); }
|
||||
[
|
||||
expression(&(nd->nd_right))
|
||||
{ if (scopeclosed(CurrentScope)) {
|
||||
|
|
|
@ -396,6 +396,16 @@ WalkCall(nd)
|
|||
}
|
||||
}
|
||||
|
||||
STATIC
|
||||
ForLoopVarExpr(nd)
|
||||
register struct node *nd;
|
||||
{
|
||||
register struct type *tp;
|
||||
|
||||
CodePExpr(nd);
|
||||
CodeCoercion(tp, BaseType(tp));
|
||||
}
|
||||
|
||||
WalkStat(nd, exit_label)
|
||||
register struct node *nd;
|
||||
label exit_label;
|
||||
|
@ -430,9 +440,9 @@ WalkStat(nd, exit_label)
|
|||
C_bra(l2);
|
||||
C_df_ilb(l1);
|
||||
WalkNode(right->nd_right, exit_label);
|
||||
C_df_ilb(l2);
|
||||
l1 = l2;
|
||||
}
|
||||
else C_df_ilb(l1);
|
||||
C_df_ilb(l1);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -483,20 +493,21 @@ WalkStat(nd, exit_label)
|
|||
label l2 = ++text_label;
|
||||
int uns = 0;
|
||||
arith stepsize;
|
||||
struct type *bstp;
|
||||
|
||||
good_forvar = DoForInit(nd);
|
||||
if ((stepsize = left->nd_INT) == 0) {
|
||||
node_warning(left,
|
||||
W_ORDINARY,
|
||||
"zero stepsize in FOR loop");
|
||||
node_warning(left,
|
||||
W_ORDINARY,
|
||||
"zero stepsize in FOR loop");
|
||||
}
|
||||
if (stepsize < 0) {
|
||||
stepsize = -stepsize;
|
||||
}
|
||||
fnd = left->nd_right;
|
||||
if (good_forvar) {
|
||||
uns = BaseType(nd->nd_type)->tp_fund !=
|
||||
T_INTEGER;
|
||||
bstp = BaseType(nd->nd_type);
|
||||
uns = bstp->tp_fund != T_INTEGER;
|
||||
C_dup(int_size);
|
||||
CodePExpr(fnd);
|
||||
tmp = NewInt();
|
||||
|
@ -504,16 +515,17 @@ WalkStat(nd, exit_label)
|
|||
C_lol(tmp);
|
||||
if (uns) C_cmu(int_size);
|
||||
else C_cmi(int_size);
|
||||
RangeCheck(bstp, nd->nd_type);
|
||||
if (left->nd_INT >= 0) {
|
||||
C_zgt(l2);
|
||||
CodeDStore(nd);
|
||||
C_lol(tmp);
|
||||
CodePExpr(nd);
|
||||
ForLoopVarExpr(nd);
|
||||
}
|
||||
else {
|
||||
C_zlt(l2);
|
||||
C_dup(int_size);
|
||||
CodeDStore(nd);
|
||||
CodePExpr(nd);
|
||||
C_lol(tmp);
|
||||
}
|
||||
C_sbu(int_size);
|
||||
|
@ -534,8 +546,9 @@ WalkStat(nd, exit_label)
|
|||
C_dup(int_size);
|
||||
C_zeq(l2);
|
||||
C_loc(left->nd_INT);
|
||||
CodePExpr(nd);
|
||||
ForLoopVarExpr(nd);
|
||||
C_adu(int_size);
|
||||
RangeCheck(bstp, nd->nd_type);
|
||||
CodeDStore(nd);
|
||||
}
|
||||
C_bra(l1);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
extern int (*WalkTable[])();
|
||||
|
||||
#define WalkNode(xnd, xlab) if (! xnd) ; else (*WalkTable[(xnd)->nd_class])((xnd), (xlab))
|
||||
#define WalkNode(xnd, xlab) (*WalkTable[(xnd)->nd_class])((xnd), (xlab))
|
||||
|
||||
extern label text_label;
|
||||
extern label data_label;
|
||||
|
|
Loading…
Reference in a new issue