diff --git a/Compiler/NFFrontEnd/NFBinding.mo b/Compiler/NFFrontEnd/NFBinding.mo index 76ae72559d..d4233adc5e 100644 --- a/Compiler/NFFrontEnd/NFBinding.mo +++ b/Compiler/NFFrontEnd/NFBinding.mo @@ -29,26 +29,20 @@ * */ - -encapsulated package NFBinding -" file: NFMod.mo - package: NFMod - description: A type for bindings in NFInst. -" - +encapsulated uniontype NFBinding public -import DAE; -import NFExpression.Expression; -import NFInstNode.InstNode; -import SCode; -import Type = NFType; + import DAE; + import NFExpression.Expression; + import NFInstNode.InstNode; + import SCode; + import Type = NFType; protected -import Dump; -import ExpressionDump; + import Dump; + import ExpressionDump; + import Binding = NFBinding; public -uniontype Binding record UNBOUND end UNBOUND; record RAW_BINDING @@ -165,7 +159,5 @@ public end match; end toString; -end Binding; - annotation(__OpenModelica_Interface="frontend"); end NFBinding; diff --git a/Compiler/NFFrontEnd/NFClass.mo b/Compiler/NFFrontEnd/NFClass.mo index e90700f158..58d88d91a5 100644 --- a/Compiler/NFFrontEnd/NFClass.mo +++ b/Compiler/NFFrontEnd/NFClass.mo @@ -111,11 +111,15 @@ uniontype Class record PARTIAL_BUILTIN Type ty; + ClassTree.Tree elements; + array components; Modifier modifier; end PARTIAL_BUILTIN; record INSTANCED_BUILTIN Type ty; + ClassTree.Tree elements; + array components; list attributes; end INSTANCED_BUILTIN; @@ -197,6 +201,8 @@ uniontype Class components := match cls case EXPANDED_CLASS() then cls.components; case INSTANCED_CLASS() then cls.components; + case PARTIAL_BUILTIN() then cls.components; + case INSTANCED_BUILTIN() then cls.components; end match; end components; @@ -284,6 +290,8 @@ uniontype Class scope := match cls case EXPANDED_CLASS() then cls.elements; case INSTANCED_CLASS() then cls.elements; + case PARTIAL_BUILTIN() then cls.elements; + case INSTANCED_BUILTIN() then cls.elements; end match; element := ClassTree.get(scope, name); @@ -418,6 +426,18 @@ uniontype Class (); end match; end updateExtends; + + function getType + input Class cls; + output Type ty; + algorithm + ty := match cls + case PARTIAL_BUILTIN() then cls.ty; + case INSTANCED_BUILTIN() then cls.ty; + else Type.UNKNOWN(); + end match; + end getType; + end Class; annotation(__OpenModelica_Interface="frontend"); diff --git a/Compiler/NFFrontEnd/NFComponent.mo b/Compiler/NFFrontEnd/NFComponent.mo index 63c5b851f3..f51080deb7 100644 --- a/Compiler/NFFrontEnd/NFComponent.mo +++ b/Compiler/NFFrontEnd/NFComponent.mo @@ -32,7 +32,8 @@ encapsulated package NFComponent import DAE; -import NFBinding.Binding; +import Binding = NFBinding; +import NFClass.Class; import Dimension = NFDimension; import NFInstNode.InstNode; import NFMod.Modifier; @@ -53,6 +54,15 @@ constant Component.Attributes DEFAULT_ATTR = DAE.NOT_INNER_OUTER(), DAE.PUBLIC()); +constant Component.Attributes CONST_ATTR = + Component.Attributes.ATTRIBUTES( + DAE.NON_CONNECTOR(), + DAE.NON_PARALLEL(), + DAE.VARIABLE(), + DAE.BIDIR(), + DAE.NOT_INNER_OUTER(), + DAE.PUBLIC()); + constant Component.Attributes INPUT_ATTR = Component.Attributes.ATTRIBUTES( DAE.NON_CONNECTOR(), @@ -164,6 +174,7 @@ uniontype Component algorithm ty := match component case TYPED_COMPONENT() then component.ty; + case UNTYPED_COMPONENT() then Class.getType(InstNode.getClass(component.classInst)); else Type.UNKNOWN(); end match; end getType; @@ -213,7 +224,7 @@ uniontype Component function getBinding input Component component; - output NFBinding.Binding b; + output Binding b; algorithm b := match component case UNTYPED_COMPONENT() then component.binding; diff --git a/Compiler/NFFrontEnd/NFExpression.mo b/Compiler/NFFrontEnd/NFExpression.mo index ee9759ae78..b235db9dc2 100644 --- a/Compiler/NFFrontEnd/NFExpression.mo +++ b/Compiler/NFFrontEnd/NFExpression.mo @@ -82,10 +82,10 @@ uniontype Expression Boolean value; end BOOLEAN; - record ENUM - Absyn.Path name; + record ENUM_LITERAL + Type ty; Integer index; - end ENUM; + end ENUM_LITERAL; record CREF InstNode component; @@ -518,7 +518,7 @@ uniontype Expression i := match exp case INTEGER() then exp.value; case BOOLEAN() then if exp.value then 1 else 0; - case ENUM() then exp.index; + case ENUM_LITERAL() then exp.index; end match; end toInteger; @@ -535,7 +535,9 @@ uniontype Expression case STRING() then exp.value; case BOOLEAN() then String(exp.value); - case ENUM() then Absyn.pathString(exp.name); + case ENUM_LITERAL(ty = t as Type.ENUMERATION()) + then Absyn.pathString(t.typePath) + "." + listGet(t.literals, exp.index); + case CREF() then Prefix.toString(exp.prefix); case ARRAY() then "{" + stringDelimitList(List.map(exp.elements, toString), ", ") + "}"; @@ -574,11 +576,15 @@ uniontype Expression output DAE.Exp dexp; algorithm dexp := match exp + local + Absyn.Path path; + case INTEGER() then DAE.ICONST(exp.value); case REAL() then DAE.RCONST(exp.value); case STRING() then DAE.SCONST(exp.value); case BOOLEAN() then DAE.BCONST(exp.value); - case ENUM() then DAE.ENUM_LITERAL(exp.name, exp.index); + case ENUM_LITERAL(ty = Type.ENUMERATION(typePath = path)) + then DAE.ENUM_LITERAL(path, exp.index); case CREF() then DAE.CREF(Prefix.toCref(exp.prefix), DAE.T_UNKNOWN_DEFAULT); diff --git a/Compiler/NFFrontEnd/NFFlatten.mo b/Compiler/NFFrontEnd/NFFlatten.mo index 7b2ea7438c..24f7295e0e 100644 --- a/Compiler/NFFrontEnd/NFFlatten.mo +++ b/Compiler/NFFrontEnd/NFFlatten.mo @@ -39,7 +39,7 @@ encapsulated package NFFlatten " import Inst = NFInst; -import NFBinding.Binding; +import Binding = NFBinding; import NFClass.Class; import NFComponent.Component; import NFEquation.Equation; @@ -192,9 +192,9 @@ algorithm then flattenArrayBoolDim(element, rest_dims, prefix, subscripts, scalarFunc, elements); - case Dimension.ENUM() - then flattenArrayEnumDim(element, dim.enumTypeName, dim.literals, - rest_dims, prefix, subscripts, scalarFunc, elements); + //case Dimension.ENUM() + // then flattenArrayEnumDim(element, dim.enumTypeName, dim.literals, + // rest_dims, prefix, subscripts, scalarFunc, elements); else algorithm @@ -239,28 +239,28 @@ algorithm elements := flattenArray(element, restDims, prefix, scalarFunc, elements, subs); end flattenArrayBoolDim; -function flattenArrayEnumDim - input ElementT element; - input Absyn.Path typeName; - input list literals; - input list restDims; - input Prefix prefix; - input list subscripts; - input ExpandScalarFunc scalarFunc; - input output list elements; -protected - Integer i = 1; - Expression enum_exp; - list subs; -algorithm - for l in literals loop - enum_exp := Expression.ENUM(Absyn.suffixPath(typeName, l), i); - i := i + 1; - - subs := Subscript.INDEX(enum_exp) :: subscripts; - elements := flattenArray(element, restDims, prefix, scalarFunc, elements, subs); - end for; -end flattenArrayEnumDim; +//function flattenArrayEnumDim +// input ElementT element; +// input Absyn.Path typeName; +// input list literals; +// input list restDims; +// input Prefix prefix; +// input list subscripts; +// input ExpandScalarFunc scalarFunc; +// input output list elements; +//protected +// Integer i = 1; +// Expression enum_exp; +// list subs; +//algorithm +// for l in literals loop +// enum_exp := Expression.ENUM_LITERAL(Absyn.suffixPath(typeName, l), i); +// i := i + 1; +// +// subs := Subscript.INDEX(enum_exp) :: subscripts; +// elements := flattenArray(element, restDims, prefix, scalarFunc, elements, subs); +// end for; +//end flattenArrayEnumDim; function flattenScalar input Component component; diff --git a/Compiler/NFFrontEnd/NFFunc.mo b/Compiler/NFFrontEnd/NFFunc.mo index e37d185fcf..05936e7deb 100644 --- a/Compiler/NFFrontEnd/NFFunc.mo +++ b/Compiler/NFFrontEnd/NFFunc.mo @@ -38,7 +38,7 @@ encapsulated package NFFunc Functions used by NFInst for handling functions. " -import NFBinding.Binding; +import Binding = NFBinding; import NFClass.Class; import NFComponent.Component; import Dimension = NFDimension; diff --git a/Compiler/NFFrontEnd/NFInst.mo b/Compiler/NFFrontEnd/NFInst.mo index 80b5785873..18ffe28856 100644 --- a/Compiler/NFFrontEnd/NFInst.mo +++ b/Compiler/NFFrontEnd/NFInst.mo @@ -41,9 +41,10 @@ import Absyn; import SCode; import Builtin = NFBuiltin; -import NFBinding.Binding; +import Binding = NFBinding; import NFComponent.Component; import Dimension = NFDimension; +import Expression = NFExpression; import NFClass.ClassTree; import NFClass.Class; import NFInstNode.InstNode; @@ -286,19 +287,66 @@ algorithm cls := match definition local SCode.ClassDef cdef; - ClassTree.Tree classes; + ClassTree.Tree class_tree; list elements; + Type ty; + array comps; case SCode.CLASS(classDef = cdef as SCode.PARTS()) algorithm - (classes, elements) := makeScope(cdef.elementLst, scope); + (class_tree, elements) := makeScope(cdef.elementLst, scope); then - Class.PARTIAL_CLASS(classes, elements, Modifier.NOMOD()); + Class.PARTIAL_CLASS(class_tree, elements, Modifier.NOMOD()); + + case SCode.CLASS(classDef = cdef as SCode.ENUMERATION()) + algorithm + ty := makeEnumerationType(cdef.enumLst, scope); + (class_tree, comps) := makeEnumerationScope(cdef.enumLst, ty, scope); + then + Class.PARTIAL_BUILTIN(ty, class_tree, comps, Modifier.NOMOD()); else Class.PARTIAL_CLASS(ClassTree.new(), {}, Modifier.NOMOD()); end match; end partialInstClass2; +function makeEnumerationType + input list literals; + input InstNode scope; + output Type ty; +protected + list lits; + Absyn.Path path; +algorithm + path := InstNode.path(scope); + lits := list(e.literal for e in literals); + ty := Type.ENUMERATION(path, lits); +end makeEnumerationType; + +function makeEnumerationScope + input list literals; + input Type enumType; + input InstNode enumClass; + output ClassTree.Tree scope; + output array literalNodes; +protected + list lit_nodes = {}; + SCode.Element enum_def = InstNode.definition(enumClass); + SourceInfo info = SCode.elementInfo(enum_def); + Binding binding; + Component comp; + Integer index = 1; +algorithm + for lit in literals loop + binding := Binding.TYPED_BINDING(Expression.ENUM_LITERAL(enumType, index), + enumType, DAE.C_CONST(), 0, info); + comp := Component.TYPED_COMPONENT(enumClass, enumType, binding, NFComponent.CONST_ATTR); + lit_nodes := InstNode.fromComponent(lit.literal, comp, enum_def, enumClass) :: lit_nodes; + end for; + + scope := addComponentsToScope(lit_nodes, ClassTree.new()); + literalNodes := listArray(lit_nodes); +end makeEnumerationScope; + function expandClass input output InstNode node; algorithm @@ -385,14 +433,6 @@ algorithm then node; - // transform SCode.ENUMERATION into a normal class - case SCode.CLASS(name=name, prefixes = prefixes, classDef = SCode.ENUMERATION(enumLst), cmt = cmt, info = info) - algorithm - cls := SCodeUtil.expandEnumeration(name, enumLst, prefixes, cmt, info); - node := InstNode.setDefinition(cls, node); - then - expandClass2(node); - else algorithm assert(false, getInstanceName() + " got unknown class"); @@ -719,6 +759,7 @@ protected Binding binding; InstNode n, cur_scope, par; Type ty; + ClassTree.Tree tree; algorithm () := match InstNode.getClass(node) // A normal class. @@ -753,7 +794,9 @@ algorithm // Clone the node, since each component needs a unique type. node := InstNode.clone(node); c := InstNode.getClass(node); - Class.PARTIAL_BUILTIN(ty = ty, modifier = mod) := c; + + Class.PARTIAL_BUILTIN(ty = ty, elements = tree, + components = components, modifier = mod) := c; // Merge any outer modifiers on the class with the class' own modifier. type_mod := Modifier.merge(modifier, mod); @@ -781,7 +824,7 @@ algorithm end for; end if; - c := Class.INSTANCED_BUILTIN(ty, inst_type_mods); + c := Class.INSTANCED_BUILTIN(ty, tree, components, inst_type_mods); node := InstNode.updateClass(c, node); then (); diff --git a/Compiler/NFFrontEnd/NFInstNode.mo b/Compiler/NFFrontEnd/NFInstNode.mo index 74ffb3b407..85fd36de33 100644 --- a/Compiler/NFFrontEnd/NFInstNode.mo +++ b/Compiler/NFFrontEnd/NFInstNode.mo @@ -123,6 +123,19 @@ uniontype InstNode node := COMPONENT_NODE(name, definition, c, parent); end newComponent; + function fromComponent + input String name; + input Component component; + input SCode.Element definition; + input InstNode parent; + output InstNode node; + protected + array c; + algorithm + c := arrayCreate(1, component); + node := COMPONENT_NODE(name, definition, c, parent); + end fromComponent; + function isClass input InstNode node; output Boolean isClass; @@ -402,6 +415,21 @@ uniontype InstNode end match; end info; + function getType + input InstNode node; + output Type ty; + algorithm + ty := match node + case CLASS_NODE() then + if Class.isBuiltin(node.cls[1]) then + Class.getType(node.cls[1]) + else + Type.COMPLEX(node); + + case COMPONENT_NODE() then Component.getType(node.component[1]); + end match; + end getType; + function clone input InstNode node; output InstNode clone; diff --git a/Compiler/NFFrontEnd/NFLookup.mo b/Compiler/NFFrontEnd/NFLookup.mo index 769a2cda3c..76baa7d91b 100644 --- a/Compiler/NFFrontEnd/NFLookup.mo +++ b/Compiler/NFFrontEnd/NFLookup.mo @@ -36,6 +36,7 @@ encapsulated package NFLookup " import Absyn; +import Binding = NFBinding; import Dump; import Error; import Global; @@ -44,35 +45,39 @@ import NFComponent.Component; import NFClass.ClassTree; import NFClass.Class; import NFInstNode.InstNode; +import NFInstNode.InstNodeType; import NFLookupState.LookupState; import NFMod.Modifier; import NFPrefix.Prefix; import Type = NFType; -constant NFInst.InstNode REAL_TYPE = NFInstNode.CLASS_NODE("Real", +constant InstNode REAL_TYPE = InstNode.CLASS_NODE("Real", NFBuiltin.BUILTIN_REAL, - listArray({NFClass.PARTIAL_BUILTIN(Type.REAL(), Modifier.NOMOD())}), - NFInstNode.EMPTY_NODE(), NFInstNode.NORMAL_CLASS()); -constant NFInst.InstNode INT_TYPE = NFInstNode.CLASS_NODE("Integer", + listArray({Class.PARTIAL_BUILTIN(Type.REAL(), ClassTree.EMPTY(), listArray({}), Modifier.NOMOD())}), + InstNode.EMPTY_NODE(), InstNodeType.NORMAL_CLASS()); + +constant InstNode INT_TYPE = InstNode.CLASS_NODE("Integer", NFBuiltin.BUILTIN_INTEGER, - listArray({NFClass.PARTIAL_BUILTIN(Type.INTEGER(), Modifier.NOMOD())}), - NFInstNode.EMPTY_NODE(), NFInstNode.NORMAL_CLASS()); -constant NFInst.InstNode BOOL_TYPE = NFInstNode.CLASS_NODE("Boolean", + listArray({Class.PARTIAL_BUILTIN(Type.INTEGER(), ClassTree.EMPTY(), listArray({}), Modifier.NOMOD())}), + InstNode.EMPTY_NODE(), InstNodeType.NORMAL_CLASS()); + +constant InstNode BOOL_TYPE = InstNode.CLASS_NODE("Boolean", NFBuiltin.BUILTIN_BOOLEAN, - listArray({NFClass.PARTIAL_BUILTIN(Type.BOOLEAN(), Modifier.NOMOD())}), - NFInstNode.EMPTY_NODE(), NFInstNode.NORMAL_CLASS()); -constant NFInst.InstNode STRING_TYPE = NFInstNode.CLASS_NODE("String", + listArray({Class.PARTIAL_BUILTIN(Type.BOOLEAN(), ClassTree.EMPTY(), listArray({}), Modifier.NOMOD())}), + InstNode.EMPTY_NODE(), InstNodeType.NORMAL_CLASS()); + +constant InstNode STRING_TYPE = InstNode.CLASS_NODE("String", NFBuiltin.BUILTIN_STRING, - listArray({NFClass.PARTIAL_BUILTIN(Type.STRING(), Modifier.NOMOD())}), - NFInstNode.EMPTY_NODE(), NFInstNode.NORMAL_CLASS()); + listArray({NFClass.PARTIAL_BUILTIN(Type.STRING(), ClassTree.EMPTY(), listArray({}), Modifier.NOMOD())}), + InstNode.EMPTY_NODE(), InstNodeType.NORMAL_CLASS()); -constant NFInstNode.InstNode BUILTIN_TIME = - NFInstNode.COMPONENT_NODE("time", +constant InstNode BUILTIN_TIME = + InstNode.COMPONENT_NODE("time", NFBuiltin.BUILTIN_TIME, - listArray({NFComponent.TYPED_COMPONENT( + listArray({Component.TYPED_COMPONENT( REAL_TYPE, - NFType.REAL(), - NFBinding.UNBOUND(), + Type.REAL(), + Binding.UNBOUND(), NFComponent.INPUT_ATTR)}), NFInstNode.EMPTY_NODE()); diff --git a/Compiler/NFFrontEnd/NFLookupState.mo b/Compiler/NFFrontEnd/NFLookupState.mo index 131d365650..a682c5335a 100644 --- a/Compiler/NFFrontEnd/NFLookupState.mo +++ b/Compiler/NFFrontEnd/NFLookupState.mo @@ -289,28 +289,28 @@ uniontype LookupState LookupState entry_ty; SCode.Element el; algorithm - el := InstNode.definition(node); // Check that the element is allowed to be accessed given its visibility. - checkProtection(el, currentState); + checkProtection(node, currentState); // Check that we're allowed to look in the current scope. //checkPackageLikeAccess(inCurrentState, el, inEnv); // Get the state for the found element, and check that the transition to the // new state is valid. - entry_ty := elementState(el); - nextState := next2(entry_ty, currentState, el); + entry_ty := nodeState(node); + nextState := next2(entry_ty, currentState, node); end next; function checkProtection "Checks if a found element is protected during lookup, and prints an error if the element was not the first part of a name while being protected. I.e. P.a is allowed if P is protected, but not e.g. a.P or a.P.b." - input SCode.Element element; + input InstNode node; input LookupState currentState; algorithm () := match currentState local String name; SourceInfo info; + SCode.Element element; // The first part of a name is allowed to be protected, it's only // accessing a protected element via dot-notation that's illegal. @@ -318,6 +318,8 @@ uniontype LookupState else algorithm + element := InstNode.definition(node); + // A protected element generates an error. if SCode.isElementProtected(element) then (name, info) := SCode.elementNameInfo(element); @@ -334,7 +336,11 @@ uniontype LookupState input InstNode node; output LookupState state; algorithm - state := elementState(InstNode.definition(node)); + if InstNode.isComponent(node) then + state := STATE_COMP(); + else + state := elementState(InstNode.definition(node)); + end if; end nodeState; function elementState @@ -343,10 +349,14 @@ uniontype LookupState output LookupState state; algorithm state := match element - case SCode.COMPONENT() then STATE_COMP(); case SCode.CLASS(restriction = SCode.R_PACKAGE()) then STATE_PACKAGE(); case SCode.CLASS(restriction = SCode.R_FUNCTION()) then STATE_FUNC(); case SCode.CLASS() then STATE_CLASS(); + else + algorithm + assert(false, getInstanceName() + " got unknown element."); + then + fail(); end match; end elementState; @@ -377,7 +387,7 @@ uniontype LookupState " input LookupState elementState; input LookupState currentState; - input SCode.Element element; + input InstNode node; output LookupState nextState; algorithm nextState := match (elementState, currentState) @@ -430,7 +440,7 @@ uniontype LookupState else algorithm assert(false, getInstanceName() + " failed on unknown transition for element " - + SCode.elementName(element)); + + InstNode.name(node)); then fail(); diff --git a/Compiler/NFFrontEnd/NFMod.mo b/Compiler/NFFrontEnd/NFMod.mo index 5c4e63577a..d15d009aac 100644 --- a/Compiler/NFFrontEnd/NFMod.mo +++ b/Compiler/NFFrontEnd/NFMod.mo @@ -42,7 +42,7 @@ encapsulated package NFMod public import Absyn; import BaseAvlTree; -import NFBinding.Binding; +import Binding = NFBinding; import NFComponent.Component; import NFInstNode.InstNode; import SCode; diff --git a/Compiler/NFFrontEnd/NFPrefix.mo b/Compiler/NFFrontEnd/NFPrefix.mo index 9b9273dc1f..cea2dfd542 100644 --- a/Compiler/NFFrontEnd/NFPrefix.mo +++ b/Compiler/NFFrontEnd/NFPrefix.mo @@ -73,7 +73,7 @@ uniontype Prefix prefix := PREFIX(InstNode.name(node), {}, Type.UNKNOWN(), prefix, PrefixType.CLASS); else prefix := PREFIX(InstNode.name(node), {}, - Component.getType(InstNode.component(node)), prefix, PrefixType.COMPONENT); + InstNode.getType(node), prefix, PrefixType.COMPONENT); end if; end addNode; diff --git a/Compiler/NFFrontEnd/NFRecord.mo b/Compiler/NFFrontEnd/NFRecord.mo index c03d91c581..5789ffa62c 100644 --- a/Compiler/NFFrontEnd/NFRecord.mo +++ b/Compiler/NFFrontEnd/NFRecord.mo @@ -38,7 +38,7 @@ encapsulated package NFRecord Functions used by NFInst for handling records. " -import NFBinding.Binding; +import Binding = NFBinding; import NFClass.Class; import NFComponent.Component; import Dimension = NFDimension; diff --git a/Compiler/NFFrontEnd/NFType.mo b/Compiler/NFFrontEnd/NFType.mo index 4ec845b2a2..07c730bd87 100644 --- a/Compiler/NFFrontEnd/NFType.mo +++ b/Compiler/NFFrontEnd/NFType.mo @@ -54,6 +54,8 @@ public end CLOCK; record ENUMERATION + Absyn.Path typePath; + list literals; end ENUMERATION; record ARRAY @@ -340,6 +342,7 @@ public case Type.REAL() then DAE.T_REAL_DEFAULT; case Type.STRING() then DAE.T_STRING_DEFAULT; case Type.BOOLEAN() then DAE.T_BOOL_DEFAULT; + case Type.ENUMERATION() then DAE.T_ENUMERATION(NONE(), ty.typePath, ty.literals, {}, {}); case Type.CLOCK() then DAE.T_CLOCK_DEFAULT; case Type.ENUMERATION() then DAE.T_ENUMERATION_DEFAULT; case Type.ARRAY() diff --git a/Compiler/NFFrontEnd/NFTyping.mo b/Compiler/NFFrontEnd/NFTyping.mo index a64f93afb2..e53e6fd87b 100644 --- a/Compiler/NFFrontEnd/NFTyping.mo +++ b/Compiler/NFFrontEnd/NFTyping.mo @@ -38,7 +38,7 @@ encapsulated package NFTyping Functions used by NFInst for typing. " -import NFBinding.Binding; +import Binding = NFBinding; import NFComponent.Component; import Dimension = NFDimension; import NFEquation.Equation; @@ -623,6 +623,7 @@ algorithm case Type.INTEGER() then checkIntAttributes(attributes); case Type.BOOLEAN() then checkBoolAttributes(attributes); case Type.STRING() then checkStringAttributes(attributes); + case Type.ENUMERATION() then checkEnumAttributes(attributes); else algorithm assert(false, getInstanceName() + " got unknown type"); @@ -672,6 +673,13 @@ algorithm // bindings have the correct types. end checkStringAttributes; +function checkEnumAttributes + input list attributes; +algorithm + // TODO: Check that the attributes are valid enumeration attributes and that their + // bindings have the correct types. +end checkEnumAttributes; + function typeExp input Absyn.Exp untypedExp; input InstNode scope; @@ -937,13 +945,13 @@ algorithm prefix := match (cref, prefix) case (Absyn.ComponentRef.CREF_IDENT(), Prefix.PREFIX(prefixTy = PrefixType.CREF)) algorithm - prefix.ty := Component.getType(InstNode.component(component)); + prefix.ty := InstNode.getType(component); then prefix; case (Absyn.ComponentRef.CREF_QUAL(), Prefix.PREFIX(prefixTy = PrefixType.CREF)) algorithm - prefix.ty := Component.getType(InstNode.component(component)); + prefix.ty := InstNode.getType(component); prefix.restPrefix := updateCrefPrefix(cref.componentRef, InstNode.parent(component), prefix.restPrefix); then