本文整理汇总了C++中NodeBase::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeBase::GetType方法的具体用法?C++ NodeBase::GetType怎么用?C++ NodeBase::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeBase
的用法示例。
在下文中一共展示了NodeBase::GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Evaluate
void Runtime::Evaluate(NodeBase* node,WQState* state)
{
if (node->GetType() == NT_EXPRESSION)
{
ExpressionNode* expnode = (ExpressionNode*)node;
Evaluate(expnode->Expression, state);
}
else if (node->GetType() == NT_ASSIGNMENT)
{
AssignmentNode* assignment = (AssignmentNode*)node;
//Evaluate the right side
Evaluate((NodeBase*)assignment->RightSide, state);
CurrentLineNumber = assignment->GetLineNumber();
if (assignment->TargetType == AT_VARIABLE)
{
VariableNode* var = assignment->LeftSideVariable;
Evaluate(var, state);
WQObject* left =state->GetReturnObject();
Evaluate(assignment->RightSide, state);
PerformAssignment(left, assignment->AssignmentOperator, state->GetReturnObject());
environment->SetVariable(*var->Value,left );
}
else if (assignment->TargetType == AT_ELEMENT)
{
ElementNode* ele = assignment->LeftSideElement;
Evaluate(ele->Variable, state);
WQObject* lsobj = state->GetReturnObject();
if (lsobj->Type == DT_LIST)
{
Evaluate(ele->key, state);
//get the index
long index = state->GetReturnObject()->GetIntValue();
WQObject *left = lsobj->GetListElement(index);
Evaluate(assignment->RightSide, state);
PerformAssignment(left, assignment->AssignmentOperator, state->GetReturnObject());
lsobj->SetListElement(index,*left);
}
else if (lsobj->Type == DT_DICTIONARY)
{
Evaluate(ele->key, state);
//get the index
string key = state->GetReturnObject()->ToString();
WQObject *left = lsobj->GetDictionaryElement(key);
Evaluate(assignment->RightSide, state);
PerformAssignment(left, assignment->AssignmentOperator, state->GetReturnObject());
}
//environment->GetVariable()
}
}
else if (node->GetType() == NT_VARIABLE)
{
VariableNode* varnode = (VariableNode*)node;
//
//printf(varnode->Value->c_str());
WQObject* obj=environment->GetVariable(*varnode->Value);
if (obj == NULL)
{
state->ReturnReference(environment->CreateVariable(*(varnode->Value)));
}
else
{
state->ReturnReference(obj);
}
}
//else if (node->GetType() == NT_ELEMENT)
//{
// ElementNode* elenode = (ElementNode*)node;
// Evaluate(elenode->key, state);
// int index = state->GetReturnObject()->GetIntValue();
// WQObject* obj = environment->GetVariable(*elenode->Variable->Value)->GetListElement(index);
// state->ReturnReference(obj);
//}
else if (node->GetType() == NT_STRING)
{
StringNode* strnode = (StringNode*)node;
state->GetReturnObject()->SetStringValue( *strnode->Value);
}
else if (node->GetType() == NT_BOOLEAN)
{
BooleanNode * boolnode = (BooleanNode*)node;
state->GetReturnObject()->SetBoolValue(boolnode->Value);
}
else if (node->GetType() == NT_OPERATION)
{
OperationNode* opnode = (OperationNode*)node;
//
list<ExpressionNode*>::iterator expit = opnode->Terms->begin();
list<string*>::iterator opit = opnode->Operators->begin();
stack<string*> lowops;
stack<WQObject*> lowexps;
//.........这里部分代码省略.........