void execute() { string command = currentInstruction[0]; if (command == "add" || command == "sub" || command == "neg" || command == "eq" || command == "gt" || command == "lt" || command == "and" || command == "or" || command == "not") executeArithmetic(currentInstruction[0]); else if (command == "push") executePush(currentInstruction[1], atoi(currentInstruction[2].c_str())); else if (command == "pop") executePop(currentInstruction[1], atoi(currentInstruction[2].c_str())); else if (command == "label") executeLabel(currentInstruction[1]); else if (command == "goto") executeGoto(currentInstruction[1]); else if (command == "if-goto") executeIf(currentInstruction[1]); else if (command == "call") executeCall(currentInstruction[1], atoi(currentInstruction[2].c_str())); else if (command == "return") executeReturn(); else if (command == "function") executeFunction(currentInstruction[1], atoi(currentInstruction[2].c_str())); else if (command == "end") arriveEnd = true; }
void Executer::execute(TreeNode* node) { if (finished) return; // emit a signal for GUI Token* t = node->token(); // //qDebug() << "emitting token: '" << t->look() << "' - (" << t->startRow() << "," << t->startCol() << " - " << t->endRow() << "," << t->endCol() << ")"; // don't report scopes (their are not really executed) if (t->type() != Token::Scope) emit currentlyExecuting(node); // this method executes one node at the time // if (currentNode->token()->type() != Token::Scope) //qDebug() << "1234567890!!!!!"; switch (node->token()->type()) { //BEGIN GENERATED executer_switch_cpp CODE /* The code between the line that start with "//BEGIN GENERATED" and "//END GENERATED" * is generated by "generate.rb" according to the definitions specified in * "definitions.rb". Please make all changes in the "definitions.rb" file, since all * all change you make here will be overwritten the next time "generate.rb" is run. * Thanks for looking at the code! */ case Token::Root : executeRoot(node); break; case Token::Scope : executeScope(node); break; case Token::Variable : executeVariable(node); break; case Token::FunctionCall : executeFunctionCall(node); break; case Token::String : /* a constant; do nothing */ break; case Token::Number : /* a constant; do nothing */ break; case Token::True : /* a constant; do nothing */ break; case Token::False : /* a constant; do nothing */ break; case Token::Exit : executeExit(node); break; case Token::If : executeIf(node); break; case Token::Else : executeElse(node); break; case Token::Repeat : executeRepeat(node); break; case Token::While : executeWhile(node); break; case Token::For : executeFor(node); break; case Token::ForTo : executeForTo(node); break; case Token::Break : executeBreak(node); break; case Token::Return : executeReturn(node); break; case Token::Wait : executeWait(node); break; case Token::Assert : executeAssert(node); break; case Token::And : executeAnd(node); break; case Token::Or : executeOr(node); break; case Token::Not : executeNot(node); break; case Token::Equals : executeEquals(node); break; case Token::NotEquals : executeNotEquals(node); break; case Token::GreaterThan : executeGreaterThan(node); break; case Token::LessThan : executeLessThan(node); break; case Token::GreaterOrEquals : executeGreaterOrEquals(node); break; case Token::LessOrEquals : executeLessOrEquals(node); break; case Token::Addition : executeAddition(node); break; case Token::Substracton : executeSubstracton(node); break; case Token::Multiplication : executeMultiplication(node); break; case Token::Division : executeDivision(node); break; case Token::Power : executePower(node); break; case Token::Assign : executeAssign(node); break; case Token::Learn : executeLearn(node); break; case Token::ArgumentList : executeArgumentList(node); break; case Token::Reset : executeReset(node); break; case Token::Clear : executeClear(node); break; case Token::Center : executeCenter(node); break; case Token::Go : executeGo(node); break; case Token::GoX : executeGoX(node); break; case Token::GoY : executeGoY(node); break; case Token::Forward : executeForward(node); break; case Token::Backward : executeBackward(node); break; case Token::Direction : executeDirection(node); break; case Token::TurnLeft : executeTurnLeft(node); break; case Token::TurnRight : executeTurnRight(node); break; case Token::PenWidth : executePenWidth(node); break; case Token::PenUp : executePenUp(node); break; case Token::PenDown : executePenDown(node); break; case Token::PenColor : executePenColor(node); break; case Token::CanvasColor : executeCanvasColor(node); break; case Token::CanvasSize : executeCanvasSize(node); break; case Token::SpriteShow : executeSpriteShow(node); break; case Token::SpriteHide : executeSpriteHide(node); break; case Token::Print : executePrint(node); break; case Token::FontSize : executeFontSize(node); break; case Token::Random : executeRandom(node); break; case Token::GetX : executeGetX(node); break; case Token::GetY : executeGetY(node); break; case Token::Message : executeMessage(node); break; case Token::Ask : executeAsk(node); break; case Token::Pi : executePi(node); break; case Token::Tan : executeTan(node); break; case Token::Sin : executeSin(node); break; case Token::Cos : executeCos(node); break; case Token::ArcTan : executeArcTan(node); break; case Token::ArcSin : executeArcSin(node); break; case Token::ArcCos : executeArcCos(node); break; case Token::Sqrt : executeSqrt(node); break; case Token::Round : executeRound(node); break; case Token::GetDirection : executeGetDirection(node); break; case Token::Mod : executeMod(node); break; //END GENERATED executer_switch_cpp CODE default: //qDebug() << "Unrecognizd Token type (" << node->token()->type() << ", " << node->token()->look() << ") -- THIS SHOULDN'T HAPPEN!"; break; } }