From 6a7a6d31870e4542f84fc01eaf777794296a0ebe Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 6 Feb 2012 17:20:32 -0700 Subject: Another bugfix for function calling. --- src/astnode.cpp | 1 + src/astnode.h | 1 + src/gamestate.cpp | 8 ++++++-- src/parser.y | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/astnode.cpp b/src/astnode.cpp index 81d560f..9a16f43 100644 --- a/src/astnode.cpp +++ b/src/astnode.cpp @@ -47,6 +47,7 @@ Bu::Formatter &operator<<( Bu::Formatter &f, AstNode::Type t ) case AstNode::tInsert: return f << "tInsert"; case AstNode::tIndex: return f << "tIndex"; case AstNode::tPop: return f << "tPop"; + case AstNode::tDeref: return f << "tDeref"; case AstNode::tLeafLiteral: return f << "!tLeafLiteral!"; case AstNode::tVarName: return f << "tVarName"; diff --git a/src/astnode.h b/src/astnode.h index 94394f0..e2629cc 100644 --- a/src/astnode.h +++ b/src/astnode.h @@ -37,6 +37,7 @@ public: tInsert = 0x01000019, tIndex = 0x0100001A, tPop = 0x0100001B, + tDeref = 0x0100001C, tLeafLiteral = 0x02000000, tVarName = 0x02000001, diff --git a/src/gamestate.cpp b/src/gamestate.cpp index aeaaaed..7b2d228 100644 --- a/src/gamestate.cpp +++ b/src/gamestate.cpp @@ -520,8 +520,8 @@ void GameState::parse( const AstBranch::NodeList &lCode ) bEscape = false; for( AstBranch::NodeList::const_iterator i = lCode.begin(); i; i++ ) { - //sio << "Stack: " << lStack << sio.nl; - //sio << "exec: " << (*i)->getType() << sio.nl; + // sio << "Stack: " << lStack << sio.nl; + // sio << "exec: " << (*i)->getType() << sio.nl; switch( (*i)->getType() ) { // tLeaf @@ -752,6 +752,10 @@ void GameState::parse( const AstBranch::NodeList &lCode ) pop(); break; + case AstNode::tDeref: + push( popDeref() ); + break; + // tLeafLiteral case AstNode::tVarName: case AstNode::tLiteral: diff --git a/src/parser.y b/src/parser.y index bbe4840..024d61a 100644 --- a/src/parser.y +++ b/src/parser.y @@ -269,11 +269,11 @@ expr: literal ; funcCallParams: - | expr funcCallParamsEx { bld.stackMod( AstNode::tPop ); } + | expr { bld.addNode( AstNode::tDeref ); } funcCallParamsEx { bld.stackMod( AstNode::tPop ); } ; funcCallParamsEx: - | funcCallParamsEx ',' expr { bld.stackMod( AstNode::tPop ); } + | funcCallParamsEx ',' expr { bld.addNode( AstNode::tDeref ); bld.stackMod( AstNode::tPop ); } ; listValues: expr { bld.addNode( AstNode::tAppend ); } -- cgit v1.2.3