コード例 #1
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;
}
コード例 #2
0
ファイル: Node.cpp プロジェクト: i2c2-caj/Compiler
void CoutStatementNode::Code(InstructionsClass &machineCode) {
	for (unsigned int i = 0; i < ens.size(); i++) {
		if (ens.at(i) == NULL) {
			machineCode.WriteEndl();
		}
		else {
			ens.at(i)->CodeEvaluate(machineCode);
			machineCode.PopAndWrite();
		}
	}
}
コード例 #3
0
ファイル: Node.cpp プロジェクト: kevbateman/cs4550
void CoutStatementNode::Code(InstructionsClass &machinecode) {
	MSG("    CODING COUTSTATEMENTNODE");
	for (unsigned int i = 0; i < this->mExpressionNodes.size(); i++) {
		if (this->mExpressionNodes[i])
		{
			this->mExpressionNodes[i]->CodeEvaluate(machinecode);
			machinecode.PopAndWrite();
		}
		else
		{
			machinecode.WriteEndl();
		}
	}
	//this->mExpressionNode->CodeEvaluate(machinecode);
	//machinecode.PopAndWrite();
}