Logo Search packages:      
Sourcecode: fauhdlc version File versions

void ast::GenCode::visit ( ReturnStat node  )  [private, virtual]

visit a ReturnStat

Parameters:
node node that gets visited.

Reimplemented from ast::TopDownVisitor.

Definition at line 1566 of file GenCode.cpp.

References ast::AstNode::accept(), intermediate::CodeContainer::addCode(), assignExpression, ast::Expression::baseType, container, destRegs, intermediate::RegisterFactory::getReturnRegister(), ast::RegisterSet::getValue(), ast::ReturnStat::result, and sourceRegs.

{
      if (node.result != NULL) {
            /* FIXME composite results... there needs to be
             *       an assignment! */
            this->destRegs = RegisterSet(*this->container);
            this->sourceRegs = RegisterSet(*this->container);
            this->assignExpression = false;
            node.result->accept(*this);

            switch(node.result->baseType) {
            case BASE_TYPE_ENUM:
            case BASE_TYPE_INTEGER:
            case BASE_TYPE_REAL: {
                  Register *r = 
                        RegisterFactory::getReturnRegister(
                              toOpType(node.result->baseType));
                  Operand *src = 
                        this->sourceRegs.getValue(
                              node.result->baseType);
                  Mov *m = new Mov(src, r);
                  this->container->addCode(m);
                  break;
                }
            case BASE_TYPE_ARRAY:
            case BASE_TYPE_RECORD:
                  /* TODO allocate space on stack, and have a pointer
                   * return register point to it */
                  assert(false);
                  break;

            default:
                  /* must not happen */
                  assert(false);
            }

      }

      Return *ret = new Return();
      this->container->addCode(ret);
}


Generated by  Doxygen 1.6.0   Back to index