Changeset 8a20ce0 in OpenModelica


Ignore:
Timestamp:
2019-01-21T16:29:30+01:00 (3 years ago)
Author:
hudson <openmodelica@…>
Branches:
Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, master, omlib-staging
Children:
5e72f06e
Parents:
25cfbd50
git-author:
Per Östlund <per.ostlund@…> (01/21/19 16:29:30)
git-committer:
hudson <openmodelica@…> (01/21/19 16:29:30)
Message:

[NF] Propagate structuralness via modifications.

  • Mark parameters that have a structural cref as binding as also structural.

Belonging to [master]:

  • OpenModelica/OMCompiler#2887
  • OpenModelica/OpenModelica-testsuite#1108
Location:
Compiler/NFFrontEnd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Compiler/NFFrontEnd/NFBinding.mo

    rbbc01270 r8a20ce0  
    260260  end isRecordExp;
    261261
     262  function isCrefExp
     263    input Binding binding;
     264    output Boolean isCref;
     265  algorithm
     266    isCref := match binding
     267      case TYPED_BINDING(bindingExp = Expression.CREF()) then true;
     268      else false;
     269    end match;
     270  end isCrefExp;
     271
    262272  function recordFieldBinding
    263273    input InstNode fieldNode;
  • Compiler/NFFrontEnd/NFTyping.mo

    r0861aa33 r8a20ce0  
    762762  MatchKind matchKind;
    763763  String name;
    764   Variability comp_var, comp_eff_var, bind_var;
     764  Variability comp_var, comp_eff_var, bind_var, bind_eff_var;
     765  Component.Attributes attrs;
    765766algorithm
    766767  if InstNode.isEmpty(component) then
     
    771772
    772773  () := match c
    773     case Component.TYPED_COMPONENT(binding = Binding.UNTYPED_BINDING())
     774    case Component.TYPED_COMPONENT(binding = Binding.UNTYPED_BINDING(), attributes = attrs)
    774775      algorithm
    775776        name := InstNode.name(component);
     
    784785          comp_var := Component.variability(c);
    785786          comp_eff_var := Prefixes.effectiveVariability(comp_var);
    786           bind_var := Prefixes.effectiveVariability(Binding.variability(binding));
    787 
    788           if bind_var > comp_eff_var and ExpOrigin.flagNotSet(origin, ExpOrigin.FUNCTION) then
     787          bind_var := Binding.variability(binding);
     788          bind_eff_var := Prefixes.effectiveVariability(bind_var);
     789
     790          if bind_eff_var > comp_eff_var and ExpOrigin.flagNotSet(origin, ExpOrigin.FUNCTION) then
    789791            Error.addSourceMessage(Error.HIGHER_VARIABILITY_BINDING, {
    790792              name, Prefixes.variabilityString(comp_eff_var),
    791               "'" + Binding.toString(c.binding) + "'", Prefixes.variabilityString(bind_var)},
     793              "'" + Binding.toString(c.binding) + "'", Prefixes.variabilityString(bind_eff_var)},
    792794              Binding.getInfo(binding));
    793795            fail();
     796          end if;
     797
     798          // Mark parameters that have a structural cref as binding as also
     799          // structural. This is perhaps not optimal, but is required right now
     800          // to avoid structural singularity and other issues.
     801          if bind_var == Variability.STRUCTURAL_PARAMETER and
     802             comp_var == Variability.PARAMETER and
     803             Binding.isCrefExp(binding) then
     804            attrs.variability := bind_var;
     805            c.attributes := attrs;
    794806          end if;
    795807        else
Note: See TracChangeset for help on using the changeset viewer.