Made Setexpression iterative rather than recursive
This commit is contained in:
parent
5c0a5e2cf7
commit
2b655476c0
|
@ -133,14 +133,10 @@ struct Token* Tokenize_Line(struct Token* head)
|
||||||
|
|
||||||
void setExpression(struct Token* p, char match[], char Exp[])
|
void setExpression(struct Token* p, char match[], char Exp[])
|
||||||
{
|
{
|
||||||
if(NULL != p->next)
|
|
||||||
{
|
|
||||||
setExpression(p->next, match, Exp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Leave macros alone */
|
/* Leave macros alone */
|
||||||
if((p->type & macro))
|
if((p->type & macro))
|
||||||
{
|
{
|
||||||
|
setExpression(p->next, match, Exp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,6 +145,12 @@ void setExpression(struct Token* p, char match[], char Exp[])
|
||||||
{
|
{
|
||||||
p->Expression = Exp;
|
p->Expression = Exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(NULL != p->next)
|
||||||
|
{
|
||||||
|
setExpression(p->next, match, Exp);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void identify_macros(struct Token* p)
|
void identify_macros(struct Token* p)
|
||||||
|
|
|
@ -415,25 +415,28 @@
|
||||||
;; Preserve registers
|
;; Preserve registers
|
||||||
PUSHR R0 R15
|
PUSHR R0 R15
|
||||||
PUSHR R3 R15
|
PUSHR R3 R15
|
||||||
|
PUSHR R4 R15
|
||||||
|
|
||||||
LOAD32 R3 R0 0 ; Load Next
|
;; Initialize
|
||||||
SWAP R0 R3 ; Protect R0
|
MOVE R4 R1 ; Put Macro Text in a safe place
|
||||||
CMPSKIP.E R0 0 ; if Next is Null
|
:setExpression_0
|
||||||
CALLI R15 @setExpression ; Don't recurse
|
|
||||||
MOVE R0 R3 ; Restore R0
|
|
||||||
LOAD32 R3 R0 4 ; Load type into R3
|
LOAD32 R3 R0 4 ; Load type into R3
|
||||||
CMPSKIP.NE R3 1 ; If Node is a macro
|
CMPSKIP.NE R3 1 ; Check if Macro
|
||||||
JUMP @setExpression_Done ; Be done
|
JUMP @setExpression_1 ; Move to next if Macro
|
||||||
LOAD32 R3 R0 8 ; Load Text into R3
|
MOVE R3 R0 ; Preserve node Pointer
|
||||||
SWAP R0 R3 ; Prepare for strncmp
|
LOAD32 R0 R3 8 ; Load Text pointer into R0 for Comparision
|
||||||
|
COPY R1 R4 ; Put Macro Text for comparision
|
||||||
CALLI R15 @strcmp ; compare Text and Macro Text
|
CALLI R15 @strcmp ; compare Text and Macro Text
|
||||||
JUMP.NE R0 @setExpression_Done
|
JUMP.NE R0 @setExpression_1 ; Move to next if not Match
|
||||||
|
|
||||||
;; Node matches
|
|
||||||
STORE32 R2 R3 12 ; Set node->Expression = Exp
|
STORE32 R2 R3 12 ; Set node->Expression = Exp
|
||||||
|
|
||||||
|
:setExpression_1
|
||||||
|
LOAD32 R0 R3 0 ; Load Next
|
||||||
|
JUMP.NZ R0 @setExpression_0 ; Loop if next isn't NULL
|
||||||
|
|
||||||
:setExpression_Done
|
:setExpression_Done
|
||||||
;; Restore registers
|
;; Restore registers
|
||||||
|
POPR R4 R15
|
||||||
POPR R3 R15
|
POPR R3 R15
|
||||||
POPR R0 R15
|
POPR R0 R15
|
||||||
RET R15
|
RET R15
|
||||||
|
|
Loading…
Reference in New Issue