Skip to content

Commit

Permalink
- Differentiate between generated and non-generated meta records.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Jul 3, 2015
1 parent ce51c36 commit 2362cf3
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions Compiler/FrontEnd/Absyn.mo
Expand Up @@ -1029,6 +1029,7 @@ uniontype Restriction "These constructors each correspond to a different kind of
Path name; //Name of the uniontype
Integer index; //Index in the uniontype
Boolean singleton;
Boolean moved; // true if moved outside uniontype, otherwise false.
end R_METARECORD;
record R_UNKNOWN "Helper restriction" end R_UNKNOWN; /* added by simbj */
end Restriction;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/ClassInf.mo
Expand Up @@ -789,7 +789,7 @@ algorithm
case TYPE_ENUM(p) then (SCode.R_PREDEFINED_ENUMERATION(),p);
/* Meta Modelica extensions */
case META_UNIONTYPE(p) then (SCode.R_UNIONTYPE(),p);
case META_RECORD(p) then (SCode.R_METARECORD(p, 0, false),p);
case META_RECORD(p) then (SCode.R_METARECORD(p, 0, false, false),p);
end match;
end stateToSCodeRestriction;

Expand Down
8 changes: 7 additions & 1 deletion Compiler/FrontEnd/MetaUtil.mo
Expand Up @@ -243,13 +243,19 @@ protected
Integer index = 0;
Boolean singleton = listLength(inElementItems) == 1;
Absyn.Class c;
Absyn.Restriction r;
algorithm
outElementItems := list(match e
case Absyn.ELEMENTITEM(element = Absyn.ELEMENT(specification =
Absyn.CLASSDEF(class_ = c as Absyn.CLASS(restriction = Absyn.R_RECORD()))))
algorithm
c.restriction := Absyn.R_METARECORD(Absyn.IDENT(inName), index, singleton);
// Change the record into a metarecord and add it to the list of metaclasses.
r := Absyn.R_METARECORD(Absyn.IDENT(inName), index, singleton, true);
c.restriction := r;
outMetaClasses := c :: outMetaClasses;
// Change the record into a metarecord and update the original class.
r := Absyn.R_METARECORD(Absyn.IDENT(inName), index, singleton, false);
c.restriction := r;
index := index + 1;
then
setElementItemClass(e, c);
Expand Down
1 change: 1 addition & 0 deletions Compiler/FrontEnd/SCode.mo
Expand Up @@ -88,6 +88,7 @@ uniontype Restriction
Absyn.Path name; //Name of the uniontype
Integer index; //Index in the uniontype
Boolean singleton;
Boolean moved; // true if moved outside uniontype, otherwise false.
end R_METARECORD; /* added by x07simbj */

record R_UNIONTYPE "Metamodelica extension"
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/SCodeDump.mo
Expand Up @@ -503,7 +503,7 @@ algorithm
case (SCode.IMPORT(visibility=SCode.PROTECTED()),OPTIONS(stripProtectedImports=true)) then false;
case (SCode.CLASS(prefixes=SCode.PREFIXES(visibility=SCode.PROTECTED())),OPTIONS(stripProtectedClasses=true)) then false;
case (SCode.COMPONENT(prefixes=SCode.PREFIXES(visibility=SCode.PROTECTED())),OPTIONS(stripProtectedComponents=true)) then false;
case (SCode.CLASS(restriction=SCode.R_METARECORD()),OPTIONS(stripMetaRecords=true)) then false;
case (SCode.CLASS(restriction=SCode.R_METARECORD(moved = true)),OPTIONS(stripMetaRecords=true)) then false;
else true;
end match;
end filterElement;
Expand Down
6 changes: 3 additions & 3 deletions Compiler/FrontEnd/SCodeUtil.mo
Expand Up @@ -293,7 +293,7 @@ algorithm
Absyn.Class d;
Absyn.Path name;
Integer index;
Boolean singleton, isImpure;
Boolean singleton, isImpure, moved;
Absyn.FunctionPurity purity;

// ?? Only normal functions can have 'external'
Expand Down Expand Up @@ -332,8 +332,8 @@ algorithm
case (_,Absyn.R_PREDEFINED_CLOCK()) then SCode.R_PREDEFINED_CLOCK();
case (_,Absyn.R_PREDEFINED_ENUMERATION()) then SCode.R_PREDEFINED_ENUMERATION();

case (_,Absyn.R_METARECORD(name,index,singleton)) //MetaModelica extension, added by x07simbj
then SCode.R_METARECORD(name,index,singleton);
case (_,Absyn.R_METARECORD(name,index,singleton,moved)) //MetaModelica extension, added by x07simbj
then SCode.R_METARECORD(name,index,singleton,moved);
case (_,Absyn.R_UNIONTYPE()) then SCode.R_UNIONTYPE(); /*MetaModelica extension added by x07simbj */

end match;
Expand Down
6 changes: 3 additions & 3 deletions Compiler/OpenModelicaBootstrappingHeader.h
Expand Up @@ -3995,7 +3995,7 @@ static void *Absyn__R_5fUNIONTYPE = MMC_REFSTRUCTLIT(Absyn__R_5fUNIONTYPE__struc
#ifdef ADD_METARECORD_DEFINITIONS
#ifndef Absyn_Restriction_R__METARECORD__desc_added
#define Absyn_Restriction_R__METARECORD__desc_added
ADD_METARECORD_DEFINITIONS const char* Absyn_Restriction_R__METARECORD__desc__fields[3] = {"name","index","singleton"};
ADD_METARECORD_DEFINITIONS const char* Absyn_Restriction_R__METARECORD__desc__fields[4] = {"name","index","singleton","moved"};
ADD_METARECORD_DEFINITIONS struct record_description Absyn_Restriction_R__METARECORD__desc = {
"Absyn_Restriction_R__METARECORD",
"Absyn.Restriction.R_METARECORD",
Expand All @@ -4005,8 +4005,8 @@ ADD_METARECORD_DEFINITIONS struct record_description Absyn_Restriction_R__METARE
#else /* Only use the file as a header */
extern struct record_description Absyn_Restriction_R__METARECORD__desc;
#endif
#define Absyn__R_5fMETARECORD_3dBOX3 23
#define Absyn__R_5fMETARECORD(name,index,singleton) (mmc_mk_box4(23,&Absyn_Restriction_R__METARECORD__desc,name,index,singleton))
#define Absyn__R_5fMETARECORD_3dBOX4 23
#define Absyn__R_5fMETARECORD(name,index,singleton,moved) (mmc_mk_box5(23,&Absyn_Restriction_R__METARECORD__desc,name,index,singleton,moved))
#ifdef ADD_METARECORD_DEFINITIONS
#ifndef Absyn_Restriction_R__UNKNOWN__desc_added
#define Absyn_Restriction_R__UNKNOWN__desc_added
Expand Down
1 change: 1 addition & 0 deletions Compiler/Template/SimCodeTV.mo
Expand Up @@ -2196,6 +2196,7 @@ uniontype Restriction
record R_METARECORD "Metamodelica extension"
Absyn.Path name; //Name of the uniontype
Integer index; //Index in the uniontype
Boolean moved;
end R_METARECORD; /* added by x07simbj */

record R_UNIONTYPE "Metamodelica extension"
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Template/Unparsing.tpl
Expand Up @@ -51,7 +51,7 @@ end metaHelperBoxStart;
template elementExternalHeader(SCode.Element elt, String pack)
::=
match elt
case c as SCode.CLASS(restriction=r as SCode.R_METARECORD(__),classDef=p as SCode.PARTS(__))
case c as SCode.CLASS(restriction=r as SCode.R_METARECORD(moved = true),classDef=p as SCode.PARTS(__))
then
let fields=(p.elementLst |> SCode.COMPONENT(__) => name; separator=",")
let fieldsStr=(p.elementLst |> SCode.COMPONENT(__) => '"<%name%>"'; separator=",")
Expand Down

0 comments on commit 2362cf3

Please sign in to comment.