Logo Search packages:      
Sourcecode: fauhdlc version File versions

template<typename T>
void ast::GenCode::callSubprog ( T &  node,
const char *  foreign 
) [inline, private]

Call a subprogram node. This function will push the arguments, and call the subprogram.

Parameters:
node subprogram to call.
foreign foreign annotation to pass on, NULL for non-foreign

Definition at line 1859 of file GenCode.cpp.

References intermediate::CodeContainer::addCode(), intermediate::Node::annotate(), assignExpression, container, destRegs, intermediate::ImmediateOperand::getOne(), and setArgList().

Referenced by visit().

{
      assert(node.definition != NULL);
      std::list<OpCode *> copyBackFormals = std::list<OpCode *>();
      
      // FIXME make use of foreign.
      Reference *subprog;
      if (foreign != NULL) {
            subprog = new Reference(*node.definition->name);
      } else {
            subprog = new Reference(node.definition->getICName());
      }
      BeginTransfer *bg = new BeginTransfer(subprog, new Reference(""));
      this->container->addCode(bg);

      if (foreign != NULL) {
            bg->annotate("foreign", foreign);
      }
      
      if (node.arguments != NULL) {
            RegisterSet backup = this->destRegs;
            bool assignExp = this->assignExpression;
            this->assignExpression = false;

            copyBackFormals = this->setArgList(node, foreign);
            this->destRegs = backup;
            this->assignExpression = assignExp;
      }

      Call *c = new Call(subprog);
      this->container->addCode(c);
      if (foreign != NULL) {
            c->annotate("foreign", foreign);
      }

      // copy back formals...
      for (std::list<OpCode *>::const_iterator i = copyBackFormals.begin();
            i != copyBackFormals.end(); i++) {
            
            this->container->addCode(*i);
      }

      ImmediateOperand *trueOp = ImmediateOperand::getOne();
      EndTransfer *et = new EndTransfer(subprog, trueOp);
      if (foreign != NULL) {
            et->annotate("foreign", foreign);
      }
      this->container->addCode(et);
}


Generated by  Doxygen 1.6.0   Back to index