Logo Search packages:      
Sourcecode: fauhdlc version File versions

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

visit a SimpleName

Parameters:
node node that gets visited.

Reimplemented from ast::TopDownVisitor.

Definition at line 460 of file GenCode.cpp.

References intermediate::CodeContainer::addCode(), ast::Expression::baseType, ast::Name::candidates, container, ast::SimpleName::driver, getConstraints(), ast::Name::getDeclaration(), ast::Driver::getICName(), ast::Name::getName(), intermediate::RegisterFactory::getRegister(), ast::RegisterSet::isSignal, ast::SimpleName::isSignal(), isTarget, ast::ValDeclaration::isUnconstraint(), ast::RegisterSet::setPointer(), and sourceRegs.

{
      assert(node.candidates.size() == 1);
      Symbol *sym = node.candidates.front();

      bool refPointer = false;

      // sanity check only
      switch(sym->type) {
      case SYMBOL_VARIABLE:
            break;
      case SYMBOL_SIGNAL:
            break;

      case SYMBOL_PARAMETER:
      switch (node.baseType) {
            case BASE_TYPE_ARRAY:
            case BASE_TYPE_RECORD:
                  refPointer = true;
                  break;

            default:
                  break;
            }
            break;

      case SYMBOL_PORT:
            switch (node.baseType) {
            case BASE_TYPE_ARRAY:
            case BASE_TYPE_RECORD:
                  if (! this->isTarget) {
                        // the ports means that the 
                        // driver is *always* locally stored.
                        refPointer = true;
                  }
                  break;

            default:
                  break;
            }
            break;

      default:
            std::cerr << "unexpected symbol found: " << *sym << std::endl;
            assert(false);
      }

      ProcessStackedExpression pse = ProcessStackedExpression(*this, node);

      this->sourceRegs = RegisterSet(*this->container);

      Reference *ref;
      if (this->isTarget && node.isSignal()) {
            assert(node.driver != NULL);
            ref = new Reference(node.driver->getICName());
      } else {
            ref = new Reference(node.getName());
      }

      Operand *op = ref;

      if (refPointer) {
            Register *ptr = RegisterFactory::getRegister(OP_TYPE_POINTER);
            Mov *m = new Mov(ref, ptr);
            this->container->addCode(m);
            op = new IndirectOperand(ptr, OP_TYPE_POINTER);

            // check for unconstraint arrays.
            const ValDeclaration *decl = 
                  dynamic_cast<const ValDeclaration*>(
                                    node.getDeclaration());
            assert(decl != NULL);
            if (decl->isUnconstraint()) {
                  this->getConstraints(*decl);
            }

      }

      this->sourceRegs.setPointer(op);
      this->sourceRegs.isSignal = node.isSignal();
}


Generated by  Doxygen 1.6.0   Back to index