void SplitTree::build( FunctionDef* inFunctionDef, const std::vector<SplitNode*>& inArguments ) { // TIM: hack to make temporaries have a shared position stream _outputPositionInterpolant = new InputInterpolantSplitNode( -1, 0, kSplitBasicType_Float2 ); FunctionType* functionType = getFunctionType( inFunctionDef ); SplitTreeBuilder builder( *this ); // std::cerr << "function args: " << functionType->nArgs << " args passed: " << inArguments.size(); assert( functionType->nArgs == inArguments.size() ); unsigned int i; for( i = 0; i < functionType->nArgs; i++ ) { Decl* argumentDecl = functionType->args[i]; builder.addArgument( argumentDecl, i, inArguments[i] ); } Statement* statement = inFunctionDef->head; while( statement ) { statement->buildSplitTree( builder ); statement = statement->next; } _resultValue = builder.getResultValue(); // we were called with arguments // thus we don't deal with creating // output nodes, or with building // the dominator tree... }
void SplitTree::build( FunctionDef* inFunctionDef ) { // TIM: hack to make temporaries have a shared position stream _outputPositionInterpolant = new InputInterpolantSplitNode( -1, 0, kSplitBasicType_Float2 ); FunctionType* functionType = getFunctionType( inFunctionDef ); Statement* headStatement = inFunctionDef->head; SplitTreeBuilder builder( *this ); unsigned int i; for( i = 0; i < functionType->nArgs; i++ ) { Decl* argumentDecl = functionType->args[i]; builder.addArgument( argumentDecl, i ); } Statement* statement = headStatement; while( statement ) { statement->buildSplitTree( builder ); statement = statement->next; } _pseudoRoot = new SplitRootNode(); _resultValue = builder.getResultValue(); for( i = 0; i < functionType->nArgs; i++ ) { Decl* argumentDecl = functionType->args[i]; Type* argumentType = argumentDecl->form; std::string name = argumentDecl->name->name; if( (argumentType->getQualifiers() & TQ_Out) != 0 ) { SplitNode* outputValue = builder.findVariable( name )->getValueNode(); _pseudoRoot->addChild( outputValue ); _outputList.push_back( outputValue ); _outputArgumentIndices.push_back( (i+1) ); } } if( _resultValue ) { _pseudoRoot->addChild( _resultValue ); _outputList.push_back( _resultValue ); _outputArgumentIndices.push_back( 0 ); } buildDominatorTree(); // std::cerr << "done" << std::endl; }