Logo Search packages:      
Sourcecode: fauhdlc version File versions

void ast::GenCode::process ( Callable node  )  [private, virtual]

Process a generic Callable.

This function will get called for each Callable (or class derived from Callable) that gets visited.

Parameters:
node Callable instance.

Reimplemented from ast::TopDownVisitor.

Definition at line 1754 of file GenCode.cpp.

References ast::SubprogBody::accept(), intermediate::CodeContainer::addChild(), intermediate::CodeContainer::addCode(), intermediate::CodeContainer::addData(), ast::ErrorRegistry::addError(), ast::Callable::arguments, container, currentSubprog, intermediate::CodeContainer::DATA_STACK, intermediate::CodeContainer::DATA_TRANSFER, intermediate::CodeContainer::dataMode, ast::Callable::definition, ast::Callable::drivers, ast::SymbolDeclaration::getICName(), intermediate::ImmediateOperand::getZero(), ast::AttributableDeclaration::hasAttr(), and ast::Visitor::listTraverse().

Referenced by visit().

{
      if (node.hasAttr("foreign") != NULL) {
            // foreign subprogram
            if (node.definition != NULL) {
                  CompileError *ce = 
                        new CompileError(node,
                              "Implementation of foreign "
                              "subprogram found.");
                  ErrorRegistry::addError(ce);
            }
            return;
      }

      if (node.definition == NULL) {
            CompileError *ce = 
                  new CompileError(node, 
                        "Subprogram declaration w.o. specification.");
                  ErrorRegistry::addError(ce);
            return;
      }

      CodeContainer *current = this->container;
      this->container = new CodeContainer(node.getICName());
      
      this->container->dataMode = CodeContainer::DATA_TRANSFER;
      if (node.arguments != NULL) {
            this->listTraverse(*node.arguments);
      }

      for (std::list<Driver*>::const_iterator i = node.drivers.begin(); 
            i != node.drivers.end(); i++) {
            // only the pointer to the driver is transferred, so 
            // it's a variable of type pointer.
            TypeElement *te = 
                  new TypeElement("__pointer__", 
                              ImmediateOperand::getZero());
            Data *d = new Data((*i)->getICName(), 
                              STORAGE_TYPE_VARIABLE,
                              te);
            this->container->addData(d);
      }
      this->container->dataMode = CodeContainer::DATA_STACK;

      this->currentSubprog = &node;
      node.definition->accept(*this);
      this->currentSubprog = NULL;
      Return *ret = new Return();
      this->container->addCode(ret);

      current->addChild(this->container);
      this->container = current;
}


Generated by  Doxygen 1.6.0   Back to index