Skip to content

Commit

Permalink
Builtin attribute type checking for NFInst
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Nov 9, 2017
1 parent 1dfcc60 commit ea3a1f6
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 59 deletions.
4 changes: 4 additions & 0 deletions Compiler/NFFrontEnd/NFConvertDAE.mo
Expand Up @@ -247,6 +247,8 @@ algorithm
case "quantity" algorithm quantity := convertVarAttribute(m); then ();
case "start" algorithm start := convertVarAttribute(m); then ();
case "stateSelect" algorithm state_select := convertStateSelectAttribute(m); then ();
// TODO: VAR_ATTR_REAL has no field for unbounded.
case "unbounded" then ();
case "unit" algorithm unit := convertVarAttribute(m); then ();

// The attributes should already be type checked, so we shouldn't get any
Expand Down Expand Up @@ -333,6 +335,8 @@ algorithm
() := match Modifier.name(m)
case "quantity" algorithm quantity := convertVarAttribute(m); then ();
case "start" algorithm start := convertVarAttribute(m); then ();
// TODO: VAR_ATTR_STRING has no field for fixed.
case "fixed" then ();

// The attributes should already be type checked, so we shouldn't get any
// unknown attributes here.
Expand Down
9 changes: 9 additions & 0 deletions Compiler/NFFrontEnd/NFInst.mo
Expand Up @@ -1232,6 +1232,15 @@ algorithm
attribute.binding := instBinding(attribute.binding);
then
();

// Redeclaration of builtin attributes is not allowed.
case Modifier.REDECLARE()
algorithm
Error.addSourceMessage(Error.INVALID_REDECLARE_IN_BASIC_TYPE,
{Modifier.name(attribute)}, Modifier.info(attribute));
then
fail();

end match;
end instBuiltinAttribute;

Expand Down
3 changes: 2 additions & 1 deletion Compiler/NFFrontEnd/NFTypeCheck.mo
Expand Up @@ -2406,6 +2406,7 @@ end checkIfExpression;
function matchBinding
input output Binding binding;
input Type componentType;
input String name;
input InstNode component;
algorithm
() := match binding
Expand Down Expand Up @@ -2434,7 +2435,7 @@ algorithm

if not isCompatibleMatch(ty_match) then
Error.addSourceMessage(Error.VARIABLE_BINDING_TYPE_MISMATCH,
{InstNode.name(component), Binding.toString(binding), Type.toString(comp_ty),
{name, Binding.toString(binding), Type.toString(comp_ty),
Type.toString(binding.bindingType)}, binding.info);
fail();
elseif isCastMatch(ty_match) then
Expand Down

0 comments on commit ea3a1f6

Please sign in to comment.