Skip to content

Commit

Permalink
- Added missing SCodeTV.mo.
Browse files Browse the repository at this point in the history
- Normalised Absyn.ComponentRef.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9181 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed May 30, 2011
1 parent 60e8daf commit de74090
Show file tree
Hide file tree
Showing 15 changed files with 831 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Compiler/BackEnd/XMLDump.mo
Expand Up @@ -251,7 +251,7 @@ protected import ValuesUtil;
protected constant String BIND_VALUE = "bindValue";

//Name of the element representing the subscript, for example the array's index.
protected constant String SUBSCRIPT = "subScript";
protected constant String SUBSCRIPT = "subscript";

//Additional info for variables.
protected constant String HASH_TB_CREFS_LIST = "hashTb";
Expand Down
28 changes: 14 additions & 14 deletions Compiler/FrontEnd/Absyn.mo
Expand Up @@ -946,7 +946,7 @@ uniontype Subscript "The Subscript uniontype is used both in array declarations
record NOSUB end NOSUB;

record SUBSCRIPT
Exp subScript "subScript" ;
Exp subscript "subscript" ;
end SUBSCRIPT;

end Subscript;
Expand All @@ -961,7 +961,7 @@ uniontype ComponentRef "A component reference is the fully or partially qualifie
end CREF_FULLYQUALIFIED;
record CREF_QUAL
Ident name "name" ;
list<Subscript> subScripts "subScripts" ;
list<Subscript> subscripts "subscripts" ;
ComponentRef componentRef "componentRef" ;
end CREF_QUAL;

Expand Down Expand Up @@ -2026,7 +2026,7 @@ algorithm
then
(CREF_FULLYQUALIFIED(cr), tup);

case (CREF_QUAL(name = name, subScripts = subs, componentRef = cr), _)
case (CREF_QUAL(name = name, subscripts = subs, componentRef = cr), _)
equation
(subs, tup) = Util.listMapAndFold(subs, traverseExpBidirSubs, inTuple);
(cr, tup) = traverseExpBidirCref(cr, tup);
Expand Down Expand Up @@ -2065,7 +2065,7 @@ algorithm
Exp sub_exp;
tuple<FuncType, FuncType, Argument> tup;

case (SUBSCRIPT(subScript = sub_exp), tup)
case (SUBSCRIPT(subscript = sub_exp), tup)
equation
(sub_exp, tup) = traverseExpBidir(sub_exp, tup);
then
Expand Down Expand Up @@ -2920,7 +2920,7 @@ algorithm
equation
cr = crefReplaceFirstIdent(cr,replPath);
then CREF_FULLYQUALIFIED(cr);
case (CREF_QUAL(componentRef = cr, subScripts = subs),replPath)
case (CREF_QUAL(componentRef = cr, subscripts = subs),replPath)
equation
cref = pathToCref(replPath);
cref = addSubscriptsLast(cref,subs);
Expand Down Expand Up @@ -3550,8 +3550,8 @@ algorithm
list<Subscript> subs;

case (CREF_IDENT(name = _)) then fail();
case (CREF_QUAL(name = str,subScripts = subs, componentRef = CREF_IDENT(name = _))) then CREF_IDENT(str,subs);
case (CREF_QUAL(name = str,subScripts = subs,componentRef = c))
case (CREF_QUAL(name = str,subscripts = subs, componentRef = CREF_IDENT(name = _))) then CREF_IDENT(str,subs);
case (CREF_QUAL(name = str,subscripts = subs,componentRef = c))
equation
c_1 = crefStripLast(c);
then
Expand Down Expand Up @@ -3622,7 +3622,7 @@ algorithm
Path p;
ComponentRef c;
case CREF_IDENT(name = i,subscripts = {}) then IDENT(i);
case CREF_QUAL(name = i,subScripts = {},componentRef = c)
case CREF_QUAL(name = i,subscripts = {},componentRef = c)
equation
p = crefToPath(c);
then
Expand Down Expand Up @@ -3740,7 +3740,7 @@ algorithm
Ident id;
ComponentRef cr;
case CREF_IDENT(name = id, subscripts = {}) then id;
case CREF_QUAL(name = id, subScripts = {}) then id;
case CREF_QUAL(name = id, subscripts = {}) then id;
case CREF_FULLYQUALIFIED(componentRef = cr) then crefFirstIdentNoSubs(cr);
end match;
end crefFirstIdentNoSubs;
Expand Down Expand Up @@ -3794,7 +3794,7 @@ algorithm

case CREF_IDENT(name = i,subscripts = {}) then false;

case CREF_QUAL(name = i,subScripts = {},componentRef = c)
case CREF_QUAL(name = i,subscripts = {},componentRef = c)
equation
b = crefHasSubscripts(c);
then
Expand Down Expand Up @@ -3872,7 +3872,7 @@ algorithm
list<Subscript> subs,s;
ComponentRef cr_1,cr;
case (CREF_IDENT(name = id,subscripts= subs)) then CREF_IDENT(id,{});
case (CREF_QUAL(name= id,subScripts= s,componentRef = cr))
case (CREF_QUAL(name= id,subscripts= s,componentRef = cr))
equation
cr_1 = crefStripLastSubs(cr);
then
Expand Down Expand Up @@ -3901,7 +3901,7 @@ algorithm
equation
failure(CREF_FULLYQUALIFIED(_) = cr2);
then CREF_QUAL(id,sub,cr2);
case (CREF_QUAL(name = id,subScripts = sub,componentRef = cr),cr2)
case (CREF_QUAL(name = id,subscripts = sub,componentRef = cr),cr2)
equation
cr_1 = joinCrefs(cr, cr2);
then
Expand Down Expand Up @@ -4088,7 +4088,7 @@ algorithm
true = subscriptsEqual(ss1,ss2);
then
true;
case (CREF_QUAL(name = id,subScripts = ss1, componentRef = cr1),CREF_QUAL(name = id2,subScripts = ss2, componentRef = cr2))
case (CREF_QUAL(name = id,subscripts = ss1, componentRef = cr1),CREF_QUAL(name = id2,subscripts = ss2, componentRef = cr2))
equation
true = stringEq(id, id2);
true = subscriptsEqual(ss1,ss2);
Expand Down Expand Up @@ -5116,7 +5116,7 @@ algorithm
outExpOpt := matchcontinue(inSub)
local
Exp e;
case SUBSCRIPT(subScript = e)
case SUBSCRIPT(subscript = e)
then SOME(e);
case NOSUB()
then NONE();
Expand Down
6 changes: 3 additions & 3 deletions Compiler/FrontEnd/ComponentReference.mo
Expand Up @@ -358,7 +358,7 @@ algorithm
makeCrefIdent(id,DAE.ET_OTHER(),subs_1);

// qualified
case (Absyn.CREF_QUAL(name = id,subScripts = subs,componentRef = cr))
case (Absyn.CREF_QUAL(name = id,subscripts = subs,componentRef = cr))
equation
cr_1 = toExpCref(cr);
subs_1 = toExpCrefSubs(subs);
Expand Down Expand Up @@ -395,15 +395,15 @@ algorithm
case ({}) then {};

// integer subscripts become indexes of integers
case ((Absyn.SUBSCRIPT(subScript = Absyn.INTEGER(value = i)) :: xs))
case ((Absyn.SUBSCRIPT(subscript = Absyn.INTEGER(value = i)) :: xs))
equation
xs_1 = toExpCrefSubs(xs);
then
(DAE.INDEX(DAE.ICONST(i)) :: xs_1);

// cref subscripts become indexes of crefs
// => Assumes index is INTEGER. FIXME! TODO!: what about if index is an array?
case ((Absyn.SUBSCRIPT(subScript = Absyn.CREF(componentRef = cr)) :: xs))
case ((Absyn.SUBSCRIPT(subscript = Absyn.CREF(componentRef = cr)) :: xs))
equation
cr_1 = toExpCref(cr);
xs_1 = toExpCrefSubs(xs);
Expand Down
20 changes: 10 additions & 10 deletions Compiler/FrontEnd/Dump.mo
Expand Up @@ -2345,7 +2345,7 @@ algorithm
Print.printBuf("Absyn.NOSUB");
then
();
case (Absyn.SUBSCRIPT(subScript = e1))
case (Absyn.SUBSCRIPT(subscript = e1))
equation
Print.printBuf("Absyn.SUBSCRIPT(");
printExp(e1);
Expand All @@ -2368,7 +2368,7 @@ algorithm
Ident s;
Absyn.Exp e1;
case (Absyn.NOSUB()) then ":";
case (Absyn.SUBSCRIPT(subScript = e1))
case (Absyn.SUBSCRIPT(subscript = e1))
equation
s = printExpStr(e1);
then
Expand Down Expand Up @@ -3501,7 +3501,7 @@ algorithm
then
();

case Absyn.CREF_QUAL(name = s,subScripts = subs,componentRef = cr)
case Absyn.CREF_QUAL(name = s,subscripts = subs,componentRef = cr)
equation
Print.printBuf("Absyn.CREF_QUAL(\"");
Print.printBuf(s);
Expand Down Expand Up @@ -3577,7 +3577,7 @@ algorithm
then
s_1;

case Absyn.CREF_QUAL(name = s,subScripts = subs,componentRef = cr)
case Absyn.CREF_QUAL(name = s,subscripts = subs,componentRef = cr)
equation
crs = printComponentRefStr(cr);
subsstr = printSubscriptsStr(subs);
Expand Down Expand Up @@ -5321,11 +5321,11 @@ algorithm
String s;
Absyn.ComponentRef p;
list<Absyn.Subscript> subscripts;
case Absyn.CREF_QUAL(name = s, subScripts = subscripts, componentRef = p)
case Absyn.CREF_QUAL(name = s, subscripts = subscripts, componentRef = p)
equation
Print.printBuf("record Absyn.CREF_QUAL name = \"");
Print.printBuf(s);
Print.printBuf("\", subScripts = ");
Print.printBuf("\", subscripts = ");
printListAsCorbaString(subscripts, printSubscriptAsCorbaString, ",");
Print.printBuf(", componentRef = ");
printComponentRefAsCorbaString(p);
Expand Down Expand Up @@ -6371,15 +6371,15 @@ protected function printSubscriptAsCorbaString
algorithm
_ := match subscript
local
Absyn.Exp subScript;
Absyn.Exp sub;
case Absyn.NOSUB()
equation
Print.printBuf("record Absyn.NOSUB end Absyn.NOSUB;");
then ();
case Absyn.SUBSCRIPT(subScript)
case Absyn.SUBSCRIPT(sub)
equation
Print.printBuf("record Absyn.SUBSCRIPT subScript = ");
printExpAsCorbaString(subScript);
Print.printBuf("record Absyn.SUBSCRIPT subscript = ");
printExpAsCorbaString(sub);
Print.printBuf(" end Absyn.SUBSCRIPT;");
then ();
end match;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/Inst.mo
Expand Up @@ -8571,7 +8571,7 @@ algorithm
list<Absyn.ComponentRef> l1,l2,res;
Absyn.Exp exp;
list<Absyn.Subscript> rest;
case ((Absyn.SUBSCRIPT(subScript = exp) :: rest))
case ((Absyn.SUBSCRIPT(subscript = exp) :: rest))
equation
l1 = getCrefFromDim(rest);
l2 = Absyn.getCrefFromExp(exp,true);
Expand Down
4 changes: 2 additions & 2 deletions Compiler/FrontEnd/SCode.mo
Expand Up @@ -2446,7 +2446,7 @@ algorithm
then
(Absyn.CREF_FULLYQUALIFIED(cr), tup);

case (Absyn.CREF_QUAL(name = name, subScripts = subs, componentRef = cr), _)
case (Absyn.CREF_QUAL(name = name, subscripts = subs, componentRef = cr), _)
equation
(cr, tup) = traverseComponentRefExps(cr, inTuple);
(subs, tup) = Util.listMapAndFold(subs, traverseSubscriptExps, tup);
Expand Down Expand Up @@ -2483,7 +2483,7 @@ algorithm
TraverseFunc traverser;
Argument arg;

case (Absyn.SUBSCRIPT(subScript = sub_exp), (traverser, arg))
case (Absyn.SUBSCRIPT(subscript = sub_exp), (traverser, arg))
equation
((sub_exp, arg)) = traverser((sub_exp, arg));
then
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/SCodeFlattenImports.mo
Expand Up @@ -588,7 +588,7 @@ algorithm
local
Absyn.Exp exp;

case (Absyn.SUBSCRIPT(subScript = exp), _, _)
case (Absyn.SUBSCRIPT(subscript = exp), _, _)
equation
exp = flattenExp(exp, inEnv, inInfo);
then
Expand Down
8 changes: 4 additions & 4 deletions Compiler/FrontEnd/SCodeLookup.mo
Expand Up @@ -532,7 +532,7 @@ algorithm
(item, cref);

// Qualified identifier.
case (Absyn.CREF_QUAL(name = name, subScripts = subs,
case (Absyn.CREF_QUAL(name = name, subscripts = subs,
componentRef = cref_rest), _)
equation
// Look in the local scope.
Expand Down Expand Up @@ -905,7 +905,7 @@ algorithm
String cref_str, env_str;

// Special case for StateSelect, do nothing.
case (Absyn.CREF_QUAL(name = "StateSelect", subScripts = {},
case (Absyn.CREF_QUAL(name = "StateSelect", subscripts = {},
componentRef = Absyn.CREF_IDENT(name = _)), _, _)
then inCref;

Expand Down Expand Up @@ -991,14 +991,14 @@ algorithm
Absyn.ComponentRef cref;
Absyn.Path env_path;

case (Absyn.CREF_QUAL(name = id1, subScripts = {}, componentRef = cref),
case (Absyn.CREF_QUAL(name = id1, subscripts = {}, componentRef = cref),
Absyn.QUALIFIED(name = id2, path = env_path))
equation
true = stringEqual(id1, id2);
then
crefStripEnvPrefix2(cref, env_path);

case (Absyn.CREF_QUAL(name = id1, subScripts = {}, componentRef = cref),
case (Absyn.CREF_QUAL(name = id1, subscripts = {}, componentRef = cref),
Absyn.IDENT(name = id2))
equation
true = stringEqual(id1, id2);
Expand Down
4 changes: 2 additions & 2 deletions Compiler/FrontEnd/SCodeUtil.mo
Expand Up @@ -1708,7 +1708,7 @@ algorithm
Error.addMessage(Error.ILLEGAL_MODIFICATION, {mod_str,c_str});
then
fail();
case ((c as Absyn.CREF_QUAL(subScripts = (_ :: _))),(mod as SCode.MOD(subModLst = (_ :: _))))
case ((c as Absyn.CREF_QUAL(subscripts = (_ :: _))),(mod as SCode.MOD(subModLst = (_ :: _))))
equation
c_str = Dump.printComponentRefStr(c);
mod_str = SCodeDump.printModStr(mod);
Expand All @@ -1721,7 +1721,7 @@ algorithm
mod_1 = translateSubSub(ss, mod);
then
SCode.NAMEMOD(i,mod_1);
case (Absyn.CREF_QUAL(name = i,subScripts = ss,componentRef = path),mod)
case (Absyn.CREF_QUAL(name = i,subscripts = ss,componentRef = path),mod)
equation
sub = translateSub(path, mod);
mod = SCode.MOD(SCode.NOT_FINAL(),SCode.NOT_EACH(),{sub},NONE());
Expand Down

0 comments on commit de74090

Please sign in to comment.