コード例 #1
0
ファイル: Node.cpp プロジェクト: i2c2-caj/Compiler
void DeclarationAssignmentStatementNode::Code(InstructionsClass & machineCode) {
	in->DeclareVariable();
	machineCode.PushValue(0);
	machineCode.PopAndStore(in->GetIndex());
	en->CodeEvaluate(machineCode);
	machineCode.PopAndStore(in->GetIndex());
}
コード例 #2
0
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;
}
コード例 #3
0
ファイル: Node.cpp プロジェクト: kevbateman/cs4550
void TimesAssignmentStatementNode::Code(InstructionsClass &machinecode) {
	MSG("    CODING MINUSASSIGNMENTSTATEMENTNODE");
	this->mIdentifierNode->CodeEvaluate(machinecode);
	this->mExpressionNode->CodeEvaluate(machinecode);
	machinecode.PopPopMulPush();
	machinecode.PopAndStore(this->mIdentifierNode->GetIndex());
}
コード例 #4
0
ファイル: Node.cpp プロジェクト: i2c2-caj/Compiler
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());
}
コード例 #5
0
ファイル: Node.cpp プロジェクト: i2c2-caj/Compiler
void AssignmentStatementNode::Code(InstructionsClass &machineCode) {
	en->CodeEvaluate(machineCode);
	machineCode.PopAndStore(in->GetIndex());
}
コード例 #6
0
ファイル: Node.cpp プロジェクト: kevbateman/cs4550
void DeclarationAssignmentStatementNode::Code(InstructionsClass &machinecode) {
	MSG("    CODING DECLARATIONASSIGNMENTSTATEMENTNODE");
	this->mIdentifierNode->DeclareVariable();
	this->mExpressionNode->CodeEvaluate(machinecode);
	machinecode.PopAndStore(this->mIdentifierNode->GetIndex());
}