map<string, Procedure*>* IRWriter::writeProcedures(map<string, Procedure*>* procs){ map<string, Procedure*>::iterator it; map<string, Procedure*>* newProcs = new map<string, Procedure*>(); //Creation of procedure must be done in two times because function can call other functions for (it = procs->begin(); it != procs->end(); ++it){ Procedure* proc = (*it).second; Function* newFunction = NULL; //Write declaration of the function if (proc->isExternal()){ newFunction = writer->addFunctionProtosExternal(proc->getFunction()); }else{ newFunction = writer->addFunctionProtosInternal(proc->getFunction()); } //Create a new procedure Procedure* newProc = new Procedure(proc->getName(), proc->getExternal(), newFunction); newProcs->insert(pair<string, Procedure*>(proc->getName(), newProc)); } //Link body of the procedure for (it = procs->begin(); it != procs->end(); ++it){ Procedure* proc = (*it).second; writer->linkProcedureBody(proc->getFunction()); } return newProcs; }
void IRParser::putAction(ActionTag* tag, Action* action){ if (tag->isEmpty()){ Procedure* body = action->getBody(); untaggedActions.insert(pair<Function*, Action*>(body->getFunction(), action)); } else { actions.insert(pair<std::string, Action*>(tag->getIdentifier(), action)); } }