Logo Search packages:      
Sourcecode: fauhdlc version File versions

Data * ast::GenCode::processValDecl ( ValDeclaration node,
enum intermediate::StorageType  st 
) [private]

process a signal/constant/vardeclaration

Parameters:
node declaration to process
st desired storage type for intermediate code.
Returns:
resulting Data declaration that is already added to the current code container.

Definition at line 1649 of file GenCode.cpp.

References ast::SubtypeIndication::accept(), intermediate::CodeContainer::addData(), addUnconstraintParams(), annotateDataSize(), ast::TypeDeclaration::baseType, ast::GCTypes::GenTypeElements::composite, container, intermediate::CodeContainer::DATA_TRANSFER, intermediate::CodeContainer::dataMode, ast::SymbolDeclaration::getICName(), intermediate::ImmediateOperand::getZero(), ast::ValDeclaration::init, ast::ValDeclaration::isUnconstraint(), ast::ValDeclaration::subtypeIndic, ast::ValDeclaration::usage, and ast::ValDeclaration::USAGE_NONE.

Referenced by visit().

{
      // skip unused declarations (but *not* signals, as these might be
      // ports.
      // FIXME this shouldn't be done in GenCode, but rather beforehand.
      // Ports are a little bit problematic though. If unused, 
      // NormalizeAssocs will add unassociated ports as association
      // elements.
      // If used in a port map statement, the port is signal is 
      // "kind of" used, i.e. it shouldn't get optimized out --
      // unless the association is *also* removed.

#if 0 /* FIXME deficiency in WarnUnused */
      if (   (node.usage == ValDeclaration::USAGE_NONE)
          && (st != STORAGE_TYPE_SIGNAL)) {
            return NULL;
      }
#endif

      bool usePointer = false;

      // for transfer segments:
      // * signals/drivers will always be passed as pointers
      // * records/arrays will always be passed as pointers
      switch (this->container->dataMode) {
      case CodeContainer::DATA_TRANSFER:
            switch (st) {
            case STORAGE_TYPE_SIGNAL:
            case STORAGE_TYPE_DRIVER:
                  usePointer = true;
                  break;

            default:
                  switch (node.subtypeIndic->baseType) {
                  case BASE_TYPE_RECORD:
                  case BASE_TYPE_ARRAY:
                        usePointer = true;
                        break;

                  default:
                        break;
                  }
            }
      default:
            break;
      }

            
      if (usePointer) {
            TypeElement *typeE = 
                  new TypeElement("__pointer__", 
                              ImmediateOperand::getZero(),
                              1);
            Data *d = new Data(node.getICName(), 
                              STORAGE_TYPE_VARIABLE,
                              typeE);
            this->container->addData(d);
            if (node.isUnconstraint()) {
                  this->addUnconstraintParams(node);
            }
            return d;
      }

      GCTypes::GenTypeElements gte = 
            GCTypes::GenTypeElements(true, 
                              "Cannot instantiate a data type "
                              "of an unconstraint array.",
                              node,
                              node.init);
      assert(node.subtypeIndic != NULL);
      node.subtypeIndic->accept(gte);
      if (gte.composite.size() != 1) {
            //error (already reported, hopefully), e.g.
            //instantiating an unconstraint array.
            return NULL;
      }

      TypeElement *te = gte.composite.front();

      Data *d = new Data(node.getICName(), st, te);
      this->container->addData(d);
      GenCode::annotateDataSize(*d, node.subtypeIndic);

      return d;
}


Generated by  Doxygen 1.6.0   Back to index