Skip to content

Commit

Permalink
- Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund committed Oct 25, 2010
2 parents 01b0382 + 4a51f60 commit 82122c0
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 105 deletions.
8 changes: 4 additions & 4 deletions Compiler/Builtin.mo
Expand Up @@ -1944,6 +1944,9 @@ protected constant tuple<DAE.TType, Option<Type_a>> array9dimbool2array1dimint=(


// MetaModelica extension. KS
protected constant tuple<DAE.TType, Option<Type_a>> typeBoxedAny = (DAE.T_BOXED((DAE.T_NOTYPE(),NONE())),NONE());
protected constant tuple<DAE.TType, Option<Type_a>> typeA = (DAE.T_POLYMORPHIC("Type_A"),NONE());

protected constant tuple<DAE.TType, Option<Type_a>> listA2listA=(
DAE.T_FUNCTION({("x",(DAE.T_LIST(typeA),NONE()))},(DAE.T_LIST(typeA),NONE()),DAE.NO_INLINE()),NONE());

Expand Down Expand Up @@ -1995,14 +1998,11 @@ protected constant tuple<DAE.TType, Option<Type_a>> void2int =(
protected constant tuple<DAE.TType, Option<Type_a>> void2real =(
DAE.T_FUNCTION({},DAE.T_REAL_DEFAULT,DAE.NO_INLINE()),NONE());

protected constant tuple<DAE.TType, Option<Type_a>> typeBoxedAny = (DAE.T_BOXED((DAE.T_NOTYPE,NONE())),NONE());
protected constant tuple<DAE.TType, Option<Type_a>> typeA = (DAE.T_POLYMORPHIC("Type_A"),NONE());

protected constant tuple<DAE.TType, Option<Type_a>> boolBoxedBoxed2boxed =(
DAE.T_FUNCTION({("x1",DAE.T_BOOL_DEFAULT),("x2",typeBoxedAny),("x3",typeBoxedAny)},typeBoxedAny,DAE.NO_INLINE()),NONE());

protected constant tuple<DAE.TType, Option<Type_a>> AA2void =(
DAE.T_FUNCTION({("x1",typeA),("x2",typeA)},(DAE.T_NORETCALL,NONE()),DAE.NO_INLINE()),NONE());
DAE.T_FUNCTION({("x1",typeA),("x2",typeA)},(DAE.T_NORETCALL(),NONE()),DAE.NO_INLINE()),NONE());

protected constant tuple<DAE.TType, Option<Type_a>> AA2bool =(
DAE.T_FUNCTION({("x1",typeA),("x2",typeA)},DAE.T_BOOL_DEFAULT,DAE.NO_INLINE()),NONE());
Expand Down
12 changes: 6 additions & 6 deletions Compiler/DAEDump.mo
Expand Up @@ -1246,9 +1246,9 @@ public function printInlineTypeStr
output String str;
algorithm
str := matchcontinue(it)
case(DAE.NO_INLINE) then "No inline";
case(DAE.AFTER_INDEX_RED_INLINE) then "Inline after index reduction";
case(DAE.NORM_INLINE) then "Inline before index reduction";
case(DAE.NO_INLINE()) then "No inline";
case(DAE.AFTER_INDEX_RED_INLINE()) then "Inline after index reduction";
case(DAE.NORM_INLINE()) then "Inline before index reduction";
end matchcontinue;
end printInlineTypeStr;

Expand Down Expand Up @@ -1348,9 +1348,9 @@ protected function dumpInlineTypeStr
output String str;
algorithm
str := matchcontinue(inlineType)
case(DAE.NO_INLINE) then "";
case(DAE.AFTER_INDEX_RED_INLINE) then " \"Inline after index reduction\"";
case(DAE.NORM_INLINE) then " \"Inline before index reduction\"";
case(DAE.NO_INLINE()) then "";
case(DAE.AFTER_INDEX_RED_INLINE()) then " \"Inline after index reduction\"";
case(DAE.NORM_INLINE()) then " \"Inline before index reduction\"";
end matchcontinue;
end dumpInlineTypeStr;

Expand Down
22 changes: 11 additions & 11 deletions Compiler/Exp.mo
Expand Up @@ -4549,7 +4549,7 @@ algorithm
case (DAE.REDUCTION(expr = e)) then typeof(e);
case (DAE.END()) then DAE.ET_OTHER(); /* Can be any type. */
case (DAE.SIZE(_,NONE())) then DAE.ET_INT();
case (DAE.SIZE(_,SOME(_))) then DAE.ET_ARRAY(DAE.ET_INT(),{DAE.DIM_UNKNOWN});
case (DAE.SIZE(_,SOME(_))) then DAE.ET_ARRAY(DAE.ET_INT(),{DAE.DIM_UNKNOWN()});

//MetaModelica extension
case (DAE.LIST(ty = tp)) then DAE.ET_LIST(tp); // was tp, but the type of a LIST is a LIST
Expand Down Expand Up @@ -11081,7 +11081,7 @@ algorithm oint := matchcontinue(insubs)
equation
recursive = subscriptDimensions(subs);
then
DAE.DIM_UNKNOWN :: recursive;
DAE.DIM_UNKNOWN() :: recursive;

case ((ss as DAE.INDEX(exp = e)) :: subs)
equation
Expand Down Expand Up @@ -11710,7 +11710,7 @@ Converts a type into an array type with dimension n as first dim"
algorithm
outTp := matchcontinue(tp,n)
local
Type elt_tp,tp;
Type elt_tp;
list<DAE.Dimension> dims;

case(DAE.ET_ARRAY(elt_tp,dims),n)
Expand Down Expand Up @@ -11915,7 +11915,7 @@ algorithm
Boolean retVal;
case({}) then true;

case (DAE.DIM_UNKNOWN :: iLst)
case (DAE.DIM_UNKNOWN() :: iLst)
equation
retVal = arrayContainZeroDimension(iLst);
then
Expand All @@ -11941,7 +11941,7 @@ algorithm
local
input list<DAE.Dimension> rest_dims;
case ({}) then false;
case (DAE.DIM_UNKNOWN :: rest_dims) then true;
case (DAE.DIM_UNKNOWN() :: rest_dims) then true;
case (_ :: rest_dims) then arrayContainZeroDimension(rest_dims);
end matchcontinue;
end arrayContainWholeDimension;
Expand Down Expand Up @@ -12888,7 +12888,7 @@ algorithm
Integer i;
case DAE.DIM_INTEGER(integer = i) then DAE.INDEX(DAE.ICONST(i));
case DAE.DIM_ENUM(size = i) then DAE.INDEX(DAE.ICONST(i));
case DAE.DIM_UNKNOWN then DAE.WHOLEDIM();
case DAE.DIM_UNKNOWN() then DAE.WHOLEDIM();
end matchcontinue;
end dimensionSubscript;

Expand All @@ -12899,8 +12899,8 @@ public function dimensionsEqual
output Boolean res;
algorithm
res := matchcontinue(dim1, dim2)
case (DAE.DIM_UNKNOWN, _) then true;
case (_, DAE.DIM_UNKNOWN) then true;
case (DAE.DIM_UNKNOWN(), _) then true;
case (_, DAE.DIM_UNKNOWN()) then true;
case (DAE.DIM_EXP(exp = _), _) then true;
case (_, DAE.DIM_EXP(exp = _)) then true;
case (_, _)
Expand Down Expand Up @@ -12937,8 +12937,8 @@ public function dimensionsAdd
output DAE.Dimension res;
algorithm
res := matchcontinue(dim1, dim2)
case (DAE.DIM_UNKNOWN, _) then DAE.DIM_UNKNOWN;
case (_, DAE.DIM_UNKNOWN) then DAE.DIM_UNKNOWN;
case (DAE.DIM_UNKNOWN(), _) then DAE.DIM_UNKNOWN();
case (_, DAE.DIM_UNKNOWN()) then DAE.DIM_UNKNOWN();
case (_, _)
equation
res = intDimension(dimensionSize(dim1) + dimensionSize(dim2));
Expand All @@ -12953,7 +12953,7 @@ public function dimensionKnown
output Boolean known;
algorithm
known := matchcontinue(dim)
case DAE.DIM_UNKNOWN then false;
case DAE.DIM_UNKNOWN() then false;
case DAE.DIM_EXP(exp = DAE.ICONST(integer = _)) then true;
case DAE.DIM_EXP(exp = _) then false;
case _ then true;
Expand Down
4 changes: 2 additions & 2 deletions Compiler/HashTableCG.mo
Expand Up @@ -449,7 +449,7 @@ algorithm
matchcontinue (valueArray,pos,entry)
local
array<Option<tuple<Key,Value>>> arr_1,arr;
Integer n,size,pos;
Integer n,size;
case (VALUE_ARRAY(n,size,arr),pos,entry)
equation
(pos < size) = true;
Expand Down Expand Up @@ -506,7 +506,7 @@ algorithm
local
Key k;
Value v;
Integer n,pos,len;
Integer n,len;
array<Option<tuple<Key,Value>>> arr;
String ps,lens,ns;
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
Expand Down
3 changes: 0 additions & 3 deletions Compiler/Inst.mo
Expand Up @@ -978,7 +978,6 @@ protected function addProgramToEnv
output Env.Cache outCache;
output Env.Env env_1;
output InstanceHierarchy outIH;
list<Env.Frame> env_1;
algorithm
(outCache,env_1,outIH,_) := instClassDecls(inCache,env,inIH, p, path);
end addProgramToEnv;
Expand Down Expand Up @@ -1175,7 +1174,6 @@ algorithm
SCode.Restriction r;
InstDims inst_dims;
CallingScope callscope;
Env.Cache cache;
Option<Absyn.ElementAttributes> oDA;
String str;
ConnectionGraph.ConnectionGraph graph;
Expand Down Expand Up @@ -9947,7 +9945,6 @@ algorithm
Env.Cache cache;
InstanceHierarchy ih;
DAE.ElementSource source "the origin of the element";
DAE.FunctionTree funcs;
list<DAE.Element> daeElts;
list<DAE.Function> resfns;
list<DAE.FunctionDefinition> derFuncs;
Expand Down
23 changes: 12 additions & 11 deletions Compiler/Interactive.mo
Expand Up @@ -2390,7 +2390,7 @@ algorithm

refactoredClass = Refactor.refactorGraphicalAnnotation(p, cls);

resstr = getAnnotationInClass(refactoredClass, ICON_ANNOTATION);
resstr = getAnnotationInClass(refactoredClass, ICON_ANNOTATION());
st = setSymbolTableAST(st, p);
then
(resstr, st);
Expand All @@ -2405,7 +2405,7 @@ algorithm

refactoredClass = Refactor.refactorGraphicalAnnotation(p, cls);

resstr = getAnnotationInClass(refactoredClass, DIAGRAM_ANNOTATION);
resstr = getAnnotationInClass(refactoredClass, DIAGRAM_ANNOTATION());
st = setSymbolTableAST(st, p);
then
(resstr, st);
Expand Down Expand Up @@ -11985,7 +11985,7 @@ algorithm
case (modelpath,p)
equation
cdef = getPathedClassInProgram(modelpath, p);
str = getAnnotationInClass(cdef, DIAGRAM_ANNOTATION);
str = getAnnotationInClass(cdef, DIAGRAM_ANNOTATION());
then
str;
case (_,_) then "get_diagram_annotation failed!";
Expand Down Expand Up @@ -12043,7 +12043,7 @@ algorithm
case (modelpath,p)
equation
cdef = getPathedClassInProgram(modelpath, p);
str = getAnnotationInClass(cdef, ICON_ANNOTATION);
str = getAnnotationInClass(cdef, ICON_ANNOTATION());
then
str;
case (_,_) then "";
Expand Down Expand Up @@ -12871,8 +12871,8 @@ protected function isAnnotationType
input AnnotationType annotationType;
algorithm
_ := matchcontinue(annotationStr, annotationType)
case ("Icon", ICON_ANNOTATION) then ();
case ("Diagram", DIAGRAM_ANNOTATION) then ();
case ("Icon", ICON_ANNOTATION()) then ();
case ("Diagram", DIAGRAM_ANNOTATION()) then ();
end matchcontinue;
end isAnnotationType;

Expand Down Expand Up @@ -14936,7 +14936,8 @@ algorithm
list<Env.Frame> env_1,env;
Absyn.Path envpath,p_1,p;
String tpname,typename;
list<String> names,lst;
list<Absyn.ComponentItem> lst;
list<String> names,strList;
Boolean f;
Option<Absyn.RedeclareKeywords> r;
Absyn.InnerOuter inout;
Expand All @@ -14952,19 +14953,19 @@ algorithm
p_1 = Absyn.joinPaths(envpath, Absyn.IDENT(tpname));
typename = Absyn.pathString(p_1);
names = getComponentitemsName(lst);
lst = prefixTypename(typename, names);
strList = prefixTypename(typename, names);
then
lst;
strList;

case (Absyn.ELEMENT(finalPrefix = f,redeclareKeywords = r,innerOuter = inout,
specification = Absyn.COMPONENTS(attributes = attr,typeSpec = Absyn.TPATH(p, _),components = lst)),
env)
equation
typename = Absyn.pathString(p);
names = getComponentitemsName(lst);
lst = prefixTypename(typename, names);
strList = prefixTypename(typename, names);
then
lst;
strList;

case (_,env) then {};

Expand Down
25 changes: 11 additions & 14 deletions Compiler/Lookup.mo
Expand Up @@ -200,7 +200,7 @@ algorithm
ClassInf.State ci_state;
Boolean encflag;
equation
env_2 = Env.openScope(env_1, encflag, SOME(id), SOME(Env.CLASS_SCOPE));
env_2 = Env.openScope(env_1, encflag, SOME(id), SOME(Env.CLASS_SCOPE()));
ci_state = ClassInf.start(r, Env.getEnvName(env_2));
(cache,env_3,_,_,_,_,_,types,_,_,_,_) =
Inst.instClassIn(
Expand Down Expand Up @@ -1173,8 +1173,7 @@ algorithm
list<Env.Item> items;
Env.Frame f;
Env.Cache cache;
Option<DAE.Const> cnstForRange;
SplicedExpData splicedExpData;
Option<DAE.Const> cnstForRange;
DAE.ComponentRef cr,cr1,cr2;
Absyn.Path path,scope,ep,p,packp;
Option<DAE.ComponentRef> filterCref;
Expand Down Expand Up @@ -1909,7 +1908,6 @@ algorithm
(outCache,outEnv,outClass) :=
matchcontinue (cache,inEnv,inClass)
local
Env.Cache cache;
list<SCode.Element> funcelts,elts;
SCode.Element reselt;
SCode.Class cl;
Expand Down Expand Up @@ -1946,18 +1944,17 @@ protected function buildRecordConstructorClass2
algorithm
(outCache,outEnv,funcelts,elts) := matchcontinue(cache,env,cl,mods)
local
list<SCode.Element> elts,cdefelts,restElts,classExtendsElts,extendsElts,compElts;
list<SCode.Element> cdefelts,restElts,classExtendsElts,extendsElts,compElts;
list<tuple<SCode.Element,DAE.Mod>> eltsMods;
Env.Env env1;
String name;
Absyn.Path fpath;
SCode.Class cl;

/* a class with parts */
case (cache,env,cl as SCode.CLASS(name = name),mods)
equation
(cache,env,_,elts,_,_,_,_) = InstExtends.instDerivedClasses(cache,env,InnerOuter.emptyInstHierarchy,DAE.NOMOD(),cl,true);
env = Env.openScope(env, false, SOME(name), SOME(Env.CLASS_SCOPE));
env = Env.openScope(env, false, SOME(name), SOME(Env.CLASS_SCOPE()));
fpath = Env.getEnvName(env);
(cdefelts,classExtendsElts,extendsElts,compElts) = Inst.splitElts(elts);
(_,env,_,_,eltsMods,_,_,_,_) = InstExtends.instExtendsAndClassExtendsList(Env.emptyCache(), env, InnerOuter.emptyInstHierarchy, DAE.NOMOD(), Prefix.NOPRE(), extendsElts, classExtendsElts, ClassInf.RECORD(fpath), name, true, false);
Expand Down Expand Up @@ -2364,7 +2361,7 @@ algorithm
t_1 = checkSubscripts(t, ys);
then
t_1;
case ((DAE.T_ARRAY(arrayDim = DAE.DIM_UNKNOWN,arrayType = t),_),
case ((DAE.T_ARRAY(arrayDim = DAE.DIM_UNKNOWN(),arrayType = t),_),
(DAE.INDEX(exp = _) :: ys))
equation
t_1 = checkSubscripts(t, ys);
Expand All @@ -2383,7 +2380,7 @@ algorithm
t_1 = checkSubscripts(t, ys);
then
t_1;
case ((DAE.T_ARRAY(arrayDim = DAE.DIM_UNKNOWN,arrayType = t),_),
case ((DAE.T_ARRAY(arrayDim = DAE.DIM_UNKNOWN(),arrayType = t),_),
(DAE.WHOLEDIM() :: ys))
equation
t_1 = checkSubscripts(t, ys);
Expand All @@ -2402,13 +2399,13 @@ algorithm

t_1 = checkSubscripts(t, ys);
then
((DAE.T_ARRAY(DAE.DIM_UNKNOWN,t_1),p));
case ((DAE.T_ARRAY(arrayDim = DAE.DIM_UNKNOWN,arrayType = t),p),
((DAE.T_ARRAY(DAE.DIM_UNKNOWN(),t_1),p));
case ((DAE.T_ARRAY(arrayDim = DAE.DIM_UNKNOWN(),arrayType = t),p),
(DAE.SLICE(exp = _) :: ys))
equation
t_1 = checkSubscripts(t, ys);
then
((DAE.T_ARRAY(DAE.DIM_UNKNOWN,t_1),p));
((DAE.T_ARRAY(DAE.DIM_UNKNOWN(),t_1),p));

case ((DAE.T_ARRAY(arrayDim = dim as DAE.DIM_EXP(exp = _), arrayType = t), p),
(DAE.SLICE(exp = _) :: ys))
Expand Down Expand Up @@ -2640,13 +2637,13 @@ algorithm
// Special case when addressing array[0].
case DAE.DIM_INTEGER(integer = 0)
then
DAE.SLICE(DAE.ARRAY(DAE.ET_INT, true, {DAE.ICONST(0)}));
DAE.SLICE(DAE.ARRAY(DAE.ET_INT(), true, {DAE.ICONST(0)}));
// Array with integer dimension.
case DAE.DIM_INTEGER(integer = sz)
equation
expl = Util.listMap(Util.listIntRange(sz), Exp.makeIntegerExp);
then
DAE.SLICE(DAE.ARRAY(DAE.ET_INT, true, expl));
DAE.SLICE(DAE.ARRAY(DAE.ET_INT(), true, expl));
// Array with enumeration dimension.
case DAE.DIM_ENUM(enumTypeName = enum_name, literals = l, size = sz)
local
Expand Down

0 comments on commit 82122c0

Please sign in to comment.