void	CSubtractCommandNode::GenerateCode( CCodeBlock* inCodeBlock )
{
	CValueNode					*	destValue = GetParamAtIndex( 1 );
	CValueNode					*	srcValue = GetParamAtIndex( 0 );
		
	srcValue->GenerateCode( inCodeBlock );
	destValue->GenerateCode( inCodeBlock );
	inCodeBlock->GenerateOperatorInstruction( SUBTRACT_COMMAND_INSTR );
}
void	CAssignCommandNode::GenerateCode( CCodeBlock* inCodeBlock )
{
	CValueNode					*	destValue = GetParamAtIndex( 0 );
	CValueNode					*	srcValue = GetParamAtIndex( 1 );
	CLocalVariableRefValueNode	*	varValue = NULL;
	
	srcValue->GenerateCode( inCodeBlock );
	
	if(( varValue = dynamic_cast<CLocalVariableRefValueNode*>(destValue) ))
		inCodeBlock->GeneratePopIntoVariableInstruction( varValue->GetBPRelativeOffset() );
	else
		throw std::runtime_error("Can't assign to this value.");
}
Beispiel #3
0
void	CObjectPropertyNode::Simplify()
{
	std::vector<CValueNode*>::iterator itty;
	
	for( itty = mParams.begin(); itty != mParams.end(); itty++ )
	{
		CValueNode	*	originalNode = *itty;
		originalNode->Simplify();	// Give subnodes a chance to apply transformations first. Might expose simpler sub-nodes we can then simplify.
		CNode* newNode = CNodeTransformationBase::Apply( originalNode );	// Returns either originalNode, or a totally new object, in which case we delete the old one.
		if( newNode != originalNode )
		{
			assert( dynamic_cast<CValueNode*>(newNode) != NULL );
			*itty = (CValueNode*)newNode;
		}
	}
	CValueNode::Simplify();
}