Skip to content

Commit

Permalink
Constant evaluate fixed attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel authored and OpenModelica-Hudson committed Mar 17, 2017
1 parent 15883dd commit b93e15a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Compiler/NFFrontEnd/NFCeval.mo
Expand Up @@ -49,6 +49,11 @@ uniontype EvalTarget
SourceInfo info;
end DIMENSION;

record ATTRIBUTE
Expression exp;
SourceInfo info;
end ATTRIBUTE;

record IGNORE_ERRORS end IGNORE_ERRORS;
end EvalTarget;

Expand Down
29 changes: 29 additions & 0 deletions Compiler/NFFrontEnd/NFTyping.mo
Expand Up @@ -373,10 +373,39 @@ protected
algorithm
name := Modifier.name(attribute);
binding := Modifier.binding(attribute);

binding := typeBinding(binding, scope);

binding := match name
case "fixed" then evalBinding(binding);
else binding;
end match;

attribute := Modifier.setBinding(binding, attribute);
end typeTypeAttribute;

function evalBinding
input output Binding binding;
algorithm
binding := match binding
local
Expression exp;

case Binding.TYPED_BINDING()
algorithm
exp := Ceval.evalExp(binding.bindingExp, Ceval.EvalTarget.ATTRIBUTE(binding.bindingExp, binding.info));
exp := SimplifyExp.simplifyExp(exp);
then
Binding.TYPED_BINDING(exp, binding.bindingType, binding.variability, binding.propagatedDims, binding.info);

else
algorithm
assert(false, getInstanceName() + " failed for " + Binding.toString(binding));
then
fail();
end match;
end evalBinding;

function checkRealAttributes
input list<Modifier> attributes;
algorithm
Expand Down

0 comments on commit b93e15a

Please sign in to comment.