summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-02-06 17:20:32 -0700
committerMike Buland <eichlan@xagasoft.com>2012-02-06 17:20:32 -0700
commit6a7a6d31870e4542f84fc01eaf777794296a0ebe (patch)
treeca8e12e50ef03a6dacaa7791fa65b2bbdf7ee92f
parentb6a2532da188088964cd6bf54da8c369d1608219 (diff)
downloadstage-6a7a6d31870e4542f84fc01eaf777794296a0ebe.tar.gz
stage-6a7a6d31870e4542f84fc01eaf777794296a0ebe.tar.bz2
stage-6a7a6d31870e4542f84fc01eaf777794296a0ebe.tar.xz
stage-6a7a6d31870e4542f84fc01eaf777794296a0ebe.zip
Another bugfix for function calling.
-rw-r--r--src/astnode.cpp1
-rw-r--r--src/astnode.h1
-rw-r--r--src/gamestate.cpp8
-rw-r--r--src/parser.y4
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 )
47 case AstNode::tInsert: return f << "tInsert"; 47 case AstNode::tInsert: return f << "tInsert";
48 case AstNode::tIndex: return f << "tIndex"; 48 case AstNode::tIndex: return f << "tIndex";
49 case AstNode::tPop: return f << "tPop"; 49 case AstNode::tPop: return f << "tPop";
50 case AstNode::tDeref: return f << "tDeref";
50 51
51 case AstNode::tLeafLiteral: return f << "!tLeafLiteral!"; 52 case AstNode::tLeafLiteral: return f << "!tLeafLiteral!";
52 case AstNode::tVarName: return f << "tVarName"; 53 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:
37 tInsert = 0x01000019, 37 tInsert = 0x01000019,
38 tIndex = 0x0100001A, 38 tIndex = 0x0100001A,
39 tPop = 0x0100001B, 39 tPop = 0x0100001B,
40 tDeref = 0x0100001C,
40 41
41 tLeafLiteral = 0x02000000, 42 tLeafLiteral = 0x02000000,
42 tVarName = 0x02000001, 43 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 )
520 bEscape = false; 520 bEscape = false;
521 for( AstBranch::NodeList::const_iterator i = lCode.begin(); i; i++ ) 521 for( AstBranch::NodeList::const_iterator i = lCode.begin(); i; i++ )
522 { 522 {
523 //sio << "Stack: " << lStack << sio.nl; 523 // sio << "Stack: " << lStack << sio.nl;
524 //sio << "exec: " << (*i)->getType() << sio.nl; 524 // sio << "exec: " << (*i)->getType() << sio.nl;
525 switch( (*i)->getType() ) 525 switch( (*i)->getType() )
526 { 526 {
527 // tLeaf 527 // tLeaf
@@ -752,6 +752,10 @@ void GameState::parse( const AstBranch::NodeList &lCode )
752 pop(); 752 pop();
753 break; 753 break;
754 754
755 case AstNode::tDeref:
756 push( popDeref() );
757 break;
758
755 // tLeafLiteral 759 // tLeafLiteral
756 case AstNode::tVarName: 760 case AstNode::tVarName:
757 case AstNode::tLiteral: 761 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
269 ; 269 ;
270 270
271funcCallParams: 271funcCallParams:
272 | expr funcCallParamsEx { bld.stackMod( AstNode::tPop ); } 272 | expr { bld.addNode( AstNode::tDeref ); } funcCallParamsEx { bld.stackMod( AstNode::tPop ); }
273 ; 273 ;
274 274
275funcCallParamsEx: 275funcCallParamsEx:
276 | funcCallParamsEx ',' expr { bld.stackMod( AstNode::tPop ); } 276 | funcCallParamsEx ',' expr { bld.addNode( AstNode::tDeref ); bld.stackMod( AstNode::tPop ); }
277 ; 277 ;
278 278
279listValues: expr { bld.addNode( AstNode::tAppend ); } 279listValues: expr { bld.addNode( AstNode::tAppend ); }