Skip to content

Commit

Permalink
- Dump the type of untyped components in InstDump.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13476 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Oct 18, 2012
1 parent 949be39 commit df40da6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
29 changes: 29 additions & 0 deletions Compiler/FrontEnd/InstDump.mo
Expand Up @@ -44,6 +44,7 @@ public import Connect2;
public import InstTypes;

protected import InstDumpTpl;
protected import List;
protected import Tpl;

public function modelStr
Expand Down Expand Up @@ -96,4 +97,32 @@ algorithm
outString := Tpl.tplString(InstDumpTpl.dumpConnections, inConnections);
end connectionsStr;

public function dimensionStr
input InstTypes.Dimension inDimension;
output String outString;
algorithm
outString := Tpl.tplString(InstDumpTpl.dumpDimension, inDimension);
end dimensionStr;

public function dumpUntypedComponentDims
input InstTypes.Component inComponent;
output String outString;
algorithm
outString := match(inComponent)
local
array<InstTypes.Dimension> adims;
list<InstTypes.Dimension> ldims;
list<String> dims_strl;
String dims_str;

case InstTypes.UNTYPED_COMPONENT(dimensions = adims)
equation
ldims = arrayList(adims);
dims_str = List.toString(ldims, dimensionStr, "", "[", ", ", "]", false);
then
dims_str;

end match;
end dumpUntypedComponentDims;

end InstDump;
7 changes: 7 additions & 0 deletions Compiler/Template/InstDumpTV.mo
Expand Up @@ -79,6 +79,13 @@ package Expression
end typeof;
end Expression;

package InstDump
function dumpUntypedComponentDims
input InstTypes.Component inComponent;
output String outString;
end dumpUntypedComponentDims;
end InstDump;

package InstTypes
type Prefix = list<tuple<String, DAE.Dimensions>>;

Expand Down
11 changes: 10 additions & 1 deletion Compiler/Template/InstDumpTpl.tpl
Expand Up @@ -19,7 +19,9 @@ match component
case UNTYPED_COMPONENT(__) then
let name_str = AbsynDumpTpl.dumpPath(name)
let bind_str = dumpBinding(binding)
'<%name_str%><%bind_str%>;'
let ty_str = ExpressionDumpTpl.dumpType(baseType)
let dims_str = InstDump.dumpUntypedComponentDims(component)
'{<%ty_str%><%dims_str%>} <%name_str%><%bind_str%>;'
case TYPED_COMPONENT(__) then
let name_str = AbsynDumpTpl.dumpPath(name)
let bind_str = dumpBinding(binding)
Expand Down Expand Up @@ -194,6 +196,13 @@ match face
case NO_FACE() then 'no_face'
end dumpFace;

template dumpDimension(InstTypes.Dimension dim)
::=
match dim
case UNTYPED_DIMENSION(__) then ExpressionDumpTpl.dumpDimension(dimension)
case TYPED_DIMENSION(__) then ExpressionDumpTpl.dumpDimension(dimension)
end dumpDimension;

template errorMsg(String errMessage)
::=
let() = Tpl.addTemplateError(errMessage)
Expand Down

0 comments on commit df40da6

Please sign in to comment.