Skip to content

Commit

Permalink
Refactor some more things away
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23238 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 6, 2014
1 parent 79faad1 commit 1be83ab
Show file tree
Hide file tree
Showing 31 changed files with 109 additions and 213 deletions.
24 changes: 2 additions & 22 deletions Compiler/BackEnd/DAEQuery.mo
Expand Up @@ -296,18 +296,8 @@ algorithm
DAE.ElementSource source;

case ({},_) then "";
case (((BackendDAE.VAR(varName = cr,

varDirection = dir,





connectorType = _)) :: {}),varno)
case (((BackendDAE.VAR(varName = cr, varDirection = dir)) :: {}),varno)
equation
_ = intString(varno);
_ = DAEDump.dumpDirectionStr(dir);
str1 = ComponentReference.printComponentRefStr(cr);
/*
paths_lst = List.map(paths, Absyn.pathString);
Expand All @@ -331,18 +321,8 @@ algorithm
then
str;

case (((BackendDAE.VAR(varName = cr,

varDirection = dir,





connectorType = _)) :: xs),varno)
case (((BackendDAE.VAR(varName = cr, varDirection = dir)) :: xs),varno)
equation
_ = intString(varno);
_ = DAEDump.dumpDirectionStr(dir);
str1 = ComponentReference.printComponentRefStr(cr);
/*
paths_lst = List.map(paths, Absyn.pathString);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/EvaluateFunctions.mo
Expand Up @@ -577,7 +577,7 @@ algorithm
DAE.FunctionTree funcTree;
DAE.Type ty;
BackendVarTransform.VariableReplacements repl;
case(DAE.CALL(expLst=expLst,attr=DAE.CALL_ATTR(ty=ty)),FUNCINFO(idx=_))
case(DAE.CALL(expLst=expLst,attr=DAE.CALL_ATTR(ty=ty)),FUNCINFO())
equation
true = Expression.isCall(inExp);
true = listLength(expLst) == 1;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/InlineArrayEquations.mo
Expand Up @@ -167,7 +167,7 @@ algorithm
((_, eqns)) = List.threadFold4(ea1, ea2, generateScalarArrayEqns2, source, differentiated, eqKind, DAE.EQUALITY_EXPS(lhs, rhs), (1, inAccEqnLst));
then (eqns,true);

case (BackendDAE.ARRAY_EQUATION(left=lhs as DAE.CREF(),right=rhs as DAE.CREF(componentRef=_), source=source, attr=BackendDAE.EQUATION_ATTRIBUTES(differentiated=differentiated, kind=eqKind)), _) equation
case (BackendDAE.ARRAY_EQUATION(left=lhs as DAE.CREF(),right=rhs as DAE.CREF(), source=source, attr=BackendDAE.EQUATION_ATTRIBUTES(differentiated=differentiated, kind=eqKind)), _) equation
(e1_1, _) = Expression.extendArrExp(lhs, false);
(e2_1, _) = Expression.extendArrExp(rhs, false);
ea1 = Expression.flattenArrayExpToList(e1_1);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/SymbolicJacobian.mo
Expand Up @@ -255,7 +255,7 @@ algorithm
true = Flags.getConfigBool(Flags.GENERATE_SYMBOLIC_LINEARIZATION);
System.realtimeTick(ClockIndexes.RT_CLOCK_EXECSTAT_JACOBIANS);
BackendDAE.DAE(eqs=eqs,shared=shared) = inBackendDAE;
BackendDAE.SHARED(constraints=_) = shared;
BackendDAE.SHARED() = shared;
(linearModelMatrixes, funcs) = createLinearModelMatrixes(inBackendDAE, Config.acceptOptimicaGrammar());
shared = addBackendDAESharedJacobians(linearModelMatrixes, shared);
functionTree = BackendDAEUtil.getFunctions(shared);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/Tearing.mo
Expand Up @@ -105,7 +105,7 @@ algorithm
BackendDAE.SHARED(backendDAEType=DAEtype) = shared;
false = stringEqual(methodString, "shuffleTearing") and stringEq("simulation",BackendDump.printBackendDAEType2String(DAEtype));
method = getTearingMethod(methodString);
BackendDAE.DAE(shared=_) = inDAE;
BackendDAE.DAE() = inDAE;
if Flags.isSet(Flags.TEARING_DUMP) then
print("\n\n\n\n" + UNDERLINE + UNDERLINE + "\nCalling Tearing for ");
BackendDump.printBackendDAEType(DAEtype);
Expand Down
5 changes: 1 addition & 4 deletions Compiler/BackEnd/Uncertainties.mo
Expand Up @@ -2053,10 +2053,7 @@ algorithm
BackendDAE.ExtraInfo ei;

case(BackendDAE.DAE(
(syst as BackendDAE.EQSYSTEM(orderedVars=orderedVars,m=m,mT=mT,matching=matching,stateSets=stateSets,partitionKind=partitionKind))::systList,
(shared as BackendDAE.SHARED(

info=_))),_,false)
(syst as BackendDAE.EQSYSTEM(orderedVars=orderedVars,m=m,mT=mT,matching=matching,stateSets=stateSets,partitionKind=partitionKind))::systList, shared),_,false)
equation
syst = BackendDAE.EQSYSTEM(orderedVars,eqns,m,mT,matching,stateSets,partitionKind);
then
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/Unit.mo
Expand Up @@ -169,7 +169,7 @@ algorithm
true = intEq(i7, j7);
then true;

case (MASTER(lcr), MASTER(_)) //equation
case (MASTER(), MASTER()) //equation
// lcr comparison????
then true;

Expand Down
2 changes: 0 additions & 2 deletions Compiler/BackEnd/XMLDump.mo
Expand Up @@ -3601,7 +3601,6 @@ algorithm
varType = var_type,
bindExp = e,
bindValue = b,

source = source,
values = dae_var_attr,
comment = comment,
Expand Down Expand Up @@ -3665,7 +3664,6 @@ algorithm
varType = var_type,
bindExp = e,
bindValue = b,

source = source,
values = dae_var_attr,
comment = comment,
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FFrontEnd/FMod.mo
Expand Up @@ -222,7 +222,7 @@ algorithm
SCode.NAMEMOD(id, SCode.MOD(fp, ep, submods1, binding, info2));

// The first modifier has no binding, use the binding from the second.
case (SCode.NAMEMOD(ident = _, mod = mod1), SCode.NAMEMOD(mod = mod2), _, _)
case (SCode.NAMEMOD(mod = mod1), SCode.NAMEMOD(mod = mod2), _, _)
equation
info1 = SCode.getModifierInfo(mod1);
info2 = SCode.getModifierInfo(mod2);
Expand Down
4 changes: 1 addition & 3 deletions Compiler/FrontEnd/CevalFunction.mo
Expand Up @@ -140,7 +140,6 @@ algorithm
case (_, _, DAE.FUNCTION(
path = p,
functions = _ :: _,

partialPrefix = partialPrefix), _, _)
equation
true = Flags.isSet(Flags.FAILTRACE);
Expand Down Expand Up @@ -208,8 +207,7 @@ algorithm

case (_, _, _, DAE.FUNCTION_EXT(body = body, externalDecl =
DAE.EXTERNALDECL(name = ext_fun_name,
args = ext_fun_args,
returnArg = _)), _, _, _, st)
args = ext_fun_args)), _, _, _, st)
equation
// Get all variables from the function. Ignore everything else, since
// external functions shouldn't have statements.
Expand Down
4 changes: 2 additions & 2 deletions Compiler/FrontEnd/ConnectUtil.mo
Expand Up @@ -2760,7 +2760,7 @@ algorithm
// One inside, one outside:
// cr1 = cr2;
case ({Connect.CONNECTOR_ELEMENT(name = cr1, source = src1),
Connect.CONNECTOR_ELEMENT(name = cr2, face = _, source = src2)})
Connect.CONNECTOR_ELEMENT(name = cr2, source = src2)})
equation
src = DAEUtil.mergeSources(src1, src2);
e1 = Expression.crefExp(cr1);
Expand Down Expand Up @@ -3686,7 +3686,7 @@ algorithm
// determined by the size of the return value of that function.
case (DAE.T_COMPLEX(equalityConstraint = SOME((_, n, _)))) then n;
// The size of a basic subtype with equality constraint is ZERO.
case (DAE.T_SUBTYPE_BASIC(complexType = _, equalityConstraint = SOME(_))) then 0;
case (DAE.T_SUBTYPE_BASIC(equalityConstraint = SOME(_))) then 0;
// The size of a basic subtype is the size of the extended type.
case (DAE.T_SUBTYPE_BASIC(complexType = t)) then sizeOfVariable2(t);
// Anything we forgot?
Expand Down
4 changes: 1 addition & 3 deletions Compiler/FrontEnd/ConnectionGraph.mo
Expand Up @@ -257,9 +257,7 @@ algorithm
GRAPH(updateGraph,definiteRoots,potentialRoots,(root,inMessage)::uniqueRoots,branches,connections);

// array of component references, empty case
case (GRAPH(
connections = connections),
DAE.ARRAY(_, _, {}), _)
case (GRAPH(), DAE.ARRAY(_, _, {}), _)
then
inGraph;

Expand Down
2 changes: 0 additions & 2 deletions Compiler/FrontEnd/DAEDump.mo
Expand Up @@ -1988,7 +1988,6 @@ algorithm
list<DAE.Element> l;
case DAE.VAR(componentRef = cr,
kind = vk,

binding = NONE(),
variableAttributesOption = dae_var_attr,
comment = comment)
Expand All @@ -2007,7 +2006,6 @@ algorithm
();
case DAE.VAR(componentRef = cr,
kind = vk,

binding = SOME(e),
variableAttributesOption = dae_var_attr,
comment = comment)
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/Expression.mo
Expand Up @@ -1714,7 +1714,7 @@ algorithm
ty = Types.unliftArray(ty);
es = List.map2(matrix,makeArray,ty,not Types.arrayType(ty));
then es;
case DAE.CREF(componentRef=DAE.CREF_IDENT(),ty=DAE.T_ARRAY(ty,dims=DAE.DIM_INTEGER(istop)::_))
case DAE.CREF(componentRef=DAE.CREF_IDENT(),ty=DAE.T_ARRAY(dims=DAE.DIM_INTEGER(istop)::_))
equation
es = List.map(ExpressionSimplify.simplifyRange(1,1,istop), makeIntegerExp);
es = List.map1r(es, makeASUBSingleSub, e);
Expand Down
4 changes: 2 additions & 2 deletions Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -1224,7 +1224,7 @@ algorithm
tp = DAE.T_ARRAY(tp,{DAE.DIM_INTEGER(i)},source);
then DAE.ARRAY(tp,true,es);

case DAE.CALL(path=Absyn.IDENT("vector"),expLst=(e as DAE.ARRAY(scalar=true))::{},attr=DAE.CALL_ATTR(ty=_))
case DAE.CALL(path=Absyn.IDENT("vector"),expLst=(e as DAE.ARRAY(scalar=true))::{},attr=DAE.CALL_ATTR())
then e;

case DAE.CALL(path=Absyn.IDENT("vector"),expLst=DAE.MATRIX(matrix=mexpl)::{},attr=DAE.CALL_ATTR(ty=tp))
Expand Down Expand Up @@ -5206,7 +5206,7 @@ algorithm
true = stringEq(name,id);
exp = DAE.CREF(DAE.CREF_QUAL(replName,ty1,ss,cr),ty);
then (exp,tpl);
case (DAE.CREF(DAE.CREF_QUAL(id,_,{},DAE.CREF_IDENT(id2,_,{})),ty),tpl as (name,DAE.CALL(expLst=exps,path=callPath,attr=DAE.CALL_ATTR(ty=DAE.T_COMPLEX(varLst=varLst,complexClassType=ClassInf.RECORD(recordPath)))),_))
case (DAE.CREF(componentRef=DAE.CREF_QUAL(id,_,{},DAE.CREF_IDENT(id2,_,{}))),tpl as (name,DAE.CALL(expLst=exps,path=callPath,attr=DAE.CALL_ATTR(ty=DAE.T_COMPLEX(varLst=varLst,complexClassType=ClassInf.RECORD(recordPath)))),_))
equation
true = stringEq(name,id);
true = Absyn.pathEqual(callPath,recordPath);
Expand Down
36 changes: 7 additions & 29 deletions Compiler/FrontEnd/Inst.mo
Expand Up @@ -971,8 +971,7 @@ algorithm
(cache,env,ih,store,dae,csets,ci_state,tys,bc,oDA,equalityConstraint,graph);

// failure
case (_, env, _, _, _, _, _, SCode.CLASS(name = n,
classDef = _), _, _, _, _, _, _, _)
case (_, env, _, _, _, _, _, SCode.CLASS(name = n), _, _, _, _, _, _, _)
equation
//print("instClassIn(");print(n);print(") failed\n");
true = Flags.isSet(Flags.FAILTRACE);
Expand Down Expand Up @@ -2974,15 +2973,10 @@ algorithm
FCore.Ref lastRef;

// long class definition, the normal case, a class with parts
case (cache,env,ih,mods,pre,ci_state,parentClass,
SCode.PARTS(elementLst = els,

initialAlgorithmLst = _),
_,inst_dims,_)
case (cache,env,ih,mods,pre,ci_state,parentClass,SCode.PARTS(elementLst = els),_,inst_dims,_)
equation
isPartialInst = true;

_ = SCode.getClassRestriction(parentClass);
partialPrefix = SCode.getClassPartialPrefix(parentClass);
className = SCode.getElementName(parentClass);

Expand Down Expand Up @@ -3461,7 +3455,7 @@ algorithm
// these are treated in a similar way. Lookup the class name, apply
// modifications and add the variable to the current frame in the
// environment. Then instantiate the class with an extended prefix.
case (cache, env, ih, store, mods, pre, ci_state, ((el as SCode.COMPONENT(name = name, typeSpec = Absyn.TPATH(_, _))), cmod),
case (cache, env, ih, store, mods, pre, ci_state, ((el as SCode.COMPONENT(name = name, typeSpec = Absyn.TPATH())), cmod),
inst_dims, impl, _, graph, csets)
equation
//print(" instElement: A component: " + name + "\n");
Expand All @@ -3472,7 +3466,6 @@ algorithm
SCode.COMPONENT(
name = name,
prefixes = prefixes as SCode.PREFIXES(

finalPrefix = final_prefix,
innerOuter = io
),
Expand Down Expand Up @@ -3971,23 +3964,15 @@ algorithm

// constraining type on the component
case (cache,env,ih,(DAE.REDECL(tplSCodeElementModLst = ((( redComp as SCode.COMPONENT(name = n1,
prefixes = SCode.PREFIXES(
finalPrefix = finalPrefix,


redeclarePrefix = _),
prefixes = SCode.PREFIXES(finalPrefix = finalPrefix),
modifications = mod,
info = info
)),rmod) :: _))),
// adrpo: always take the inner outer from the component, not the redeclaration!!!!
comp as SCode.COMPONENT(name = n2,
prefixes = SCode.PREFIXES(
finalPrefix = SCode.NOT_FINAL(),
replaceablePrefix = SCode.REPLACEABLE((cc as SOME(_))),

visibility = _),


replaceablePrefix = SCode.REPLACEABLE((cc as SOME(_)))),
modifications = old_mod),
pre,ci_state,impl,cmod)
equation
Expand Down Expand Up @@ -4015,22 +4000,15 @@ algorithm
case (cache,env,ih,(DAE.REDECL(tplSCodeElementModLst = (((redComp as
SCode.COMPONENT(name = n1,
prefixes = SCode.PREFIXES(
finalPrefix = finalPrefix,


redeclarePrefix = _),
finalPrefix = finalPrefix),
modifications = mod,
info = info
)),rmod) :: _))),
// adrpo: always take the inner outer from the component, not the redeclaration!!!!
comp as SCode.COMPONENT(name = n2,
prefixes = SCode.PREFIXES(
finalPrefix = SCode.NOT_FINAL(),
replaceablePrefix = SCode.REPLACEABLE(NONE()),

visibility = _),


replaceablePrefix = SCode.REPLACEABLE(NONE())),
modifications = old_mod),
pre,ci_state,impl,cmod)
equation
Expand Down
4 changes: 1 addition & 3 deletions Compiler/FrontEnd/InstExtends.mo
Expand Up @@ -236,9 +236,7 @@ algorithm
case (cache,env,ih,mod,pre,
(elt as SCode.COMPONENT(attributes =
SCode.ATTR(variability = var),

prefixes = SCode.PREFIXES(),
comment = _)) :: rest,elsExtendsScope,
prefixes = SCode.PREFIXES())) :: rest,elsExtendsScope,
ci_state,className,impl,_)
equation
(cache,env_1,ih,mods,compelts2,eq2,initeq2,alg2,ialg2) =
Expand Down
7 changes: 1 addition & 6 deletions Compiler/FrontEnd/InstFunction.mo
Expand Up @@ -791,12 +791,7 @@ algorithm

case (cache,env,ih,
SCode.COMPONENT(name = id,
prefixes = prefixes as SCode.PREFIXES(

visibility = vis,

innerOuter = _
),
prefixes = prefixes as SCode.PREFIXES(visibility = vis),
attributes = (attr as
SCode.ATTR(arrayDims = dim, connectorType = ct,
parallelism = prl,variability = var,direction = dir)),
Expand Down
23 changes: 5 additions & 18 deletions Compiler/FrontEnd/InstUtil.mo
Expand Up @@ -1758,8 +1758,7 @@ algorithm
(l1, l2);

// redeclare long class, investigate cc
case (SCode.REDECL(element = SCode.CLASS(prefixes = SCode.PREFIXES(replaceablePrefix = rp),
classDef = _)))
case SCode.REDECL(element = SCode.CLASS(prefixes = SCode.PREFIXES(replaceablePrefix = rp)))
equation
(l1, l2) = getExpsFromConstrainClass(rp);
then
Expand Down Expand Up @@ -1861,9 +1860,7 @@ algorithm
deps;

// For input and output variables in function scope return no dependencies so they stay in order!
case ((SCode.COMPONENT(
attributes = SCode.ATTR(direction = direction),
modifications = _), _), (_, true))
case ((SCode.COMPONENT(attributes = SCode.ATTR(direction = direction)), _), (_, true))
equation
true = Absyn.isInputOrOutput(direction);
then
Expand Down Expand Up @@ -3894,8 +3891,7 @@ algorithm
//------------------------
// MetaModelica extension
case (cache, env, _, pre, cl as SCode.CLASS(name = id, info=info,
classDef = SCode.DERIVED(Absyn.TCOMPLEX(Absyn.IDENT(_),_,arrayDim = ad),
modifications = _)),
classDef = SCode.DERIVED(Absyn.TCOMPLEX(Absyn.IDENT(),_,arrayDim = ad))),
dims,impl)
equation
true=Config.acceptMetaModelicaGrammar();
Expand Down Expand Up @@ -3956,8 +3952,7 @@ algorithm
normalEquationLst = {},
initialEquationLst = {},
normalAlgorithmLst = {},
initialAlgorithmLst = {},
externalDecl = _)),
initialAlgorithmLst = {})),
_, impl)
equation
(_,_,{SCode.EXTENDS(path, _, mod,_, info)},{}) = splitElts(els); // ONLY ONE extends!
Expand Down Expand Up @@ -5724,15 +5719,7 @@ algorithm
Absyn.TypeSpec path;
SCode.Mod mod;

case SCode.COMPONENT(
name = id,
prefixes = SCode.PREFIXES(


visibility = _),
attributes = SCode.ATTR(arrayDims = dims),

modifications = _)
case SCode.COMPONENT(name = id, attributes = SCode.ATTR(arrayDims = dims))
equation
sizelist = instExtMakeCrefs2(id, dims, 1);
crlist = (Absyn.CREF(Absyn.CREF_IDENT(id,{})) :: sizelist);
Expand Down

0 comments on commit 1be83ab

Please sign in to comment.