コード例 #1
0
ファイル: Node.cpp プロジェクト: kevbateman/cs4550
void IfStatementNode::Code(InstructionsClass &machinecode) {
	MSG("    CODING IFSTATEMENTNODE");
	this->mExpressionNode->CodeEvaluate(machinecode);
	unsigned char * jump_address = machinecode.SkipIfZeroStack();

	unsigned char * address1 = machinecode.GetAddress();
	this->mStatementNode->Code(machinecode);
	unsigned char * address2 = machinecode.GetAddress();

	machinecode.SetOffset(jump_address, address2 - address1);
}
コード例 #2
0
ファイル: Node.cpp プロジェクト: i2c2-caj/Compiler
void IfStatementNode::Code(InstructionsClass &machineCode) {
	// evaluate test and put on stack
	test->CodeEvaluate(machineCode);
	// get variable to record 'size' of block
	unsigned char* jump_address = machineCode.SkipIfZeroStack();
	// measure block 'size'
	unsigned char* block_start = machineCode.GetAddress();
	block->Code(machineCode);
	unsigned char* block_end = machineCode.GetAddress();
	// set variable that records 'size' of block
	machineCode.SetOffset(jump_address, block_end - block_start);
}
コード例 #3
0
ファイル: Node.cpp プロジェクト: i2c2-caj/Compiler
void WhileStatementNode::Code(InstructionsClass &machineCode) {
	// store beginning of while evaluate
	unsigned char* begin_address = machineCode.GetAddress();
	// evaluate test and put on stack
	test->CodeEvaluate(machineCode);
	// get variable to record 'size' of block
	unsigned char* jump_address = machineCode.SkipIfZeroStack();
	// measure block 'size'
	unsigned char* block_start = machineCode.GetAddress();
	block->Code(machineCode);
	unsigned char* jump_address2 = machineCode.Jump();
	unsigned char* block_end = machineCode.GetAddress();
	// set variable that records 'size' of block
	machineCode.SetOffset(jump_address, block_end - block_start);
	// set variable that jumps to the while loop evaluate
	machineCode.SetOffset(jump_address2, begin_address - block_end);
}