NodePointer Parser::statement() { NodePointer result; switch (currentSymbol_.symbolType_) { case IF: return ifStatement(); case WHILE: return whileStatement(); case IDENTIFIER: case GLOBAL: case ARGUMENT: case CALL: case CONSTANT: result = expression(); accept(SEMICOLON); return result; case MY: return localVariable(); case PRINT: return printStatement(); case SUBROUTINE: return procedureDefinition(); case RETURN: return returnStatement(); case LEFT_BRACE: return blockStatement(); default: throw ErrorMessage("Unexpected symbol " + symbolToString(currentSymbol_), getLineNumber()); } }
dScriptCompiler::dUserVariable dScriptCompiler::ConcatenateExpressions(const dUserVariable& expressionA, const dUserVariable& expressionB) { dUserVariable returnNode; dDAGExpressionNode* const nodeA = (dDAGExpressionNode*)expressionA.m_node; dDAGExpressionNode* const nodeB = (dDAGExpressionNode*)expressionB.m_node; dAssert (nodeA->IsType(dDAGExpressionNode::GetRttiType())); dAssert (nodeB->IsType(dDAGExpressionNode::GetRttiType())); dDAGExpressionNode* nextNode = nodeA; for (; nextNode->m_next; nextNode = (dDAGExpressionNode*) nextNode->m_next); nextNode->m_next = nodeB; dDAGExpressionNodeVariable* const leftVarListA = nodeA->FindLeftVariable(); if (leftVarListA && leftVarListA->m_type) { dDAGExpressionNodeVariable* const leftVarListB = nodeB->FindLeftVariable(); if (leftVarListB && !leftVarListB->m_type) { dUserVariable localVariable(NewVariableStatement (leftVarListB->m_name, "")); dDAGParameterNode* const variableNode = (dDAGParameterNode*)localVariable.m_node; dAssert (variableNode->IsType(dDAGParameterNode::GetRttiType())); variableNode->SetType((dDAGTypeNode*) leftVarListA->m_type->Clone(m_allNodes)); leftVarListB->SetType((dDAGTypeNode*) leftVarListA->m_type->Clone(m_allNodes)); if (m_scopeStack.GetCount()) { dDAGScopeBlockNode* const block = GetCurrentScope(); block->AddStatement(variableNode); } else { dAssert (0); //dDAGClassNode* const curClass = GetCurrentClass(); //curClass->AddVariable(variableNode); } } } returnNode.m_node = nodeA; return returnNode; }