Skip to content

Commit

Permalink
Use lookupType instead of lookupClass to handle DIM_ENUM/DIM_BOOLEAN
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23228 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 6, 2014
1 parent 72320b3 commit 4385e1a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
1 change: 1 addition & 0 deletions Compiler/FrontEnd/Lookup.mo
Expand Up @@ -217,6 +217,7 @@ algorithm
// build names
(_,names) = SCode.getClassComponents(c);
// generate the enumeration type
path = FGraph.getGraphName(env_3);
ts = Types.mkTypeSource(SOME(path));
t = DAE.T_ENUMERATION(NONE(), path, names, types, {}, ts);
env_3 = FGraph.mkTypeNode(env_3, id, t);
Expand Down
32 changes: 12 additions & 20 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -14095,6 +14095,7 @@ algorithm
DAE.Properties prop;
list<SCode.Enum> enum_lst;
Absyn.Exp size_arg;
DAE.Type t;

// The : operator results in an unknown dimension.
case (_, _, _, Absyn.NOSUB(), _, _, _, _, _)
Expand All @@ -14120,29 +14121,20 @@ algorithm
then
(inCache, DAE.DIM_BOOLEAN());

// Array dimension from an enumeration.
case (_, _, _, Absyn.SUBSCRIPT(subscript = Absyn.CREF(cr)), _, _, _, _, _)
equation
type_path = Absyn.crefToPath(cr);
(_, cls as SCode.CLASS(name = name, restriction = SCode.R_ENUMERATION(),
classDef = SCode.PARTS(elementLst = _)), cenv) =
Lookup.lookupClass(inCache, inEnv, type_path, false);
enum_type_name = FGraph.joinScopePath(cenv, Absyn.IDENT(name));
enum_literals = SCode.componentNames(cls);
enum_size = listLength(enum_literals);
then
(inCache, DAE.DIM_ENUM(enum_type_name, enum_literals, enum_size));

// Frenkel TUD try next enum.
case (_, _, _, Absyn.SUBSCRIPT(subscript = Absyn.CREF(cr)), _, _, _, _, _)
// Array dimension from a Boolean or enumeration.
case (cache, _, _, Absyn.SUBSCRIPT(subscript = Absyn.CREF(cr)), _, _, _, _, _)
equation
type_path = Absyn.crefToPath(cr);
(_, SCode.CLASS(restriction = SCode.R_TYPE(), classDef =
SCode.ENUMERATION(enumLst = enum_lst)), _) =
Lookup.lookupClass(inCache, inEnv, type_path, false);
enum_size = listLength(enum_lst);
cache = Lookup.lookupClass(cache, inEnv, type_path, false);
(cache, t) = Lookup.lookupType(cache, inEnv, type_path, NONE());
dim = match t
case DAE.T_ENUMERATION(index=NONE())
then DAE.DIM_ENUM(t.path, t.names, listLength(t.names));
case DAE.T_BOOL()
then DAE.DIM_BOOLEAN();
end match;
then
(inCache, DAE.DIM_INTEGER(enum_size));
(cache, dim);

// For all other cases we need to elaborate the subscript expression, so the
// expression is elaborated and passed on to elabArrayDim2 to avoid doing
Expand Down

0 comments on commit 4385e1a

Please sign in to comment.