Logo Search packages:      
Sourcecode: fauhdlc version File versions

OpCode * ast::GenCode::setArgByValue ( intermediate::Reference callee,
ValDeclaration vd,
AssociationElement element,
const char *  foreign,
bool  copyBack 
) [private]

set an argument by value. used for

  • constant (non-composite)
  • variable (non-composite)

Parameters:
callee Reference name of the Callee
vd formal declaration (may be NULL, if the element contains a formal)
element AssociationElement with the actual.
foreign char value to annotate as foreign value, NULL if not foreign.
copyBack prepare target operand for copy back values?
Returns:
copy back command to copy back the actual to the formal if copyBack is true, NULL otherwise.

Definition at line 2118 of file GenCode.cpp.

References ast::AstNode::accept(), ast::AssociationElement::actual, intermediate::CodeContainer::addCode(), intermediate::Node::annotate(), ast::Expression::baseType, container, ast::AssociationElement::formal, ast::Name::getDeclaration(), ast::RegisterSet::getDestination(), ast::SymbolDeclaration::getICName(), ast::RegisterSet::getValue(), ast::SymbolDeclaration::name, and sourceRegs.

Referenced by setArg(), and setGenericMap().

{
      // sanity check
      switch (element.actual->baseType) {
      case BASE_TYPE_INTEGER:
      case BASE_TYPE_REAL:
      case BASE_TYPE_ENUM:
            break;

      default:
            // composites must be called by reference!
            assert(false);
      }

      if (vd != NULL) {
            assert(element.formal == NULL); // FIXME
      } else {
            // FIXME individual association
            SimpleName *sn = dynamic_cast<SimpleName*>(element.formal);
            assert(sn != NULL);
            vd = dynamic_cast<ValDeclaration*>(sn->getDeclaration());
            assert(vd != NULL);
      }

      element.actual->accept(*this);

      Reference *formal;
      if (foreign != NULL) {
            formal = new Reference(*vd->name);
      } else {
            formal = new Reference(vd->getICName());
      }

      Operand *value = this->sourceRegs.getValue(element.actual->baseType);
      SetParam *sp = new SetParam(value, callee, formal);
      this->container->addCode(sp);
      if (foreign != NULL) {
            sp->annotate("foreign", foreign);
      }

      if (copyBack) {
            Operand *dest = this->sourceRegs.getDestination(
                                    element.actual->baseType);
            GetParam *gp = new GetParam(formal, callee, dest);
            return gp;
      }
      return NULL;
}


Generated by  Doxygen 1.6.0   Back to index