int main( void ) { cout << "in main of teste.cpp\n"; // Create an array of machine codes, and stuff it with initial // machine codes that are at the beginning of every function: InstructionsClass code; // Generate machine code to push a literal integer onto the stack: code.PushValue(17); // Generate machine code to pop and print integer on top of stack: code.PopAndWrite(); // Generate machine code to push a literal integer onto the stack: code.PushValue(27); // Generate machine code to pop the top of stack and move to variable index 99: code.PopAndStore(99); // Generate machine code to push variable 99's contents onto the stack: code.PushVariable(99); // (holds int 27 from before) // Generate machine code to pop and print integer on top of stack: code.PopAndWrite(); // Generate machine code to return to the calling code: code.Finish(); // Treat the array of machine codes like a function, and jump in! code.Execute(); return 0; }
void DivideAssignmentStatementNode::Code(InstructionsClass &machineCode) { // push vars value on stack machineCode.PushVariable(in->GetIndex()); // put modifier on stack en->CodeEvaluate(machineCode); // divide those values machineCode.PopPopDivPush(); // store result machineCode.PopAndStore(in->GetIndex()); }
void IdentifierNode::CodeEvaluate(InstructionsClass &machineCode) { machineCode.PushVariable(table->GetIndex(label)); }
void IdentifierNode::CodeEvaluate(InstructionsClass &machinecode) { MSG("\tCODING IDENTIFIERNODE"); machinecode.PushVariable(this->mSymbolTable->GetIndex(this->mLabel)); }