Logo Search packages:      
Sourcecode: fauhdlc version File versions

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

visit a FunctionCall

Parameters:
node node that gets visited.

Reimplemented from ast::TopDownVisitor.

Definition at line 1371 of file GenCode.cpp.

References intermediate::CodeContainer::addCode(), ast::FunctionCall::arguments, ast::TypeDeclaration::baseType, callSubprog(), container, ast::FunctionCall::definition, ast::GCBuiltins::emitCode(), ast::FunctionDeclaration::gcBuiltin, intermediate::RegisterFactory::getRegister(), intermediate::RegisterFactory::getReturnRegister(), handleCompositeReturn(), ast::AttributableDeclaration::hasAttr(), ast::FunctionDeclaration::isBuiltin, isTarget, ast::SymbolDeclaration::name, ast::FunctionDeclaration::returnType, ast::RegisterSet::setValue(), and sourceRegs.

{
      ProcessStackedExpression pse = ProcessStackedExpression(*this, node);
      assert(! this->isTarget);

      if (node.definition->isBuiltin) {
            if (node.definition->gcBuiltin == NULL) {
                  std::cerr << "WARNING: builtin, but then again not a "
                        << "builtin: "
                        << *node.definition->name
                        << std::endl;
            }
            assert(node.definition->gcBuiltin != NULL);
            assert(node.arguments != NULL);
            this->sourceRegs = 
                  node.definition->gcBuiltin->emitCode(
                                          *this, 
                                          *node.arguments);
            return;
      }

      // not a builtin.
      AttributeSpecification *foreign = node.definition->hasAttr("foreign");
      const char *fattr = NULL;
      if (foreign != NULL) {
            fattr = "function";
      }

      this->callSubprog(node, fattr);

      // return type is always a *value*
      // simple type: move to register.
      // composite type: return value on stack, mov to temporary (from
      // process/fc)
      
      enum BaseType bt = node.definition->returnType->baseType;

      switch(bt) {
      case BASE_TYPE_INTEGER: 
      case BASE_TYPE_REAL:
      case BASE_TYPE_ENUM: {
            Register *retVal = RegisterFactory::getRegister(toOpType(bt));
            this->sourceRegs.setValue(retVal);
            Register *result = 
                  RegisterFactory::getReturnRegister(toOpType(bt));
            Mov *mov = new Mov(result, retVal);
            this->container->addCode(mov);

            break;
          }
      case BASE_TYPE_RECORD:
      case BASE_TYPE_ARRAY:
            this->handleCompositeReturn(node);
            break;

      default:
            assert(false);
      }
}


Generated by  Doxygen 1.6.0   Back to index