Skip to content

Commit

Permalink
Some minor changes to inst->deriveing function and Exp functions.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4992 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Björn Zachrisson committed Feb 18, 2010
1 parent fff335c commit c37a5cf
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
22 changes: 20 additions & 2 deletions Compiler/Exp.mo
Expand Up @@ -3546,8 +3546,8 @@ algorithm
end matchcontinue;
end allTerms;

public function terms
"function: terms
public function terms "
function: terms
author: PA
Returns the terms of the expression if any as a list of expressions"
input Exp inExp;
Expand Down Expand Up @@ -8574,6 +8574,24 @@ algorithm
end matchcontinue;
end solve;

protected function printExpIfDiff ""
input Exp e1,e2;
output String s;
algorithm s := matchcontinue(e1,e2)
case(e1,e2)
equation
true = expEqual(e1,e2);
then
"";
case(e1,e2)
equation
false = expEqual(e1,e2);
s = printExpStr(e1) +& " =!= " +& printExpStr(e2) +& "\n";
then
s;
end matchcontinue;
end printExpIfDiff;

protected function solve2
"function: solve2
This function solves an equation e1 = e2 with
Expand Down
13 changes: 7 additions & 6 deletions Compiler/Inst.mo
Expand Up @@ -9474,8 +9474,8 @@ algorithm element := matchcontinue(subs,elemDecl,baseFunc,inCache,inEnv,inPrefix
conditionRefs = Util.sort(conditionRefs,DAEUtil.derivativeOrder);
defaultDerivative = getDerivativeSubModsOptDefault(subs,inCache,inEnv,inPrefix);


/*print(" adding conditions on derivative count: " +& intString(listLength(conditionRefs)) +& "\n");
/*
print("\n adding conditions on derivative count: " +& intString(listLength(conditionRefs)) +& "\n");
dbgString = Absyn.optPathString(defaultDerivative);
dbgString = Util.if_(stringEqual(dbgString,""),"", "**** Default Derivative: " +& dbgString +& "\n");
print("**** Function derived: " +& Absyn.pathString(baseFunc) +& " \n");
Expand Down Expand Up @@ -9519,23 +9519,23 @@ algorithm outconds := matchcontinue(subs,elemDecl,inCache,inEnv,inPrefix)
equation
name = Absyn.printComponentRefStr(acr);
outconds = getDeriveCondition(subs,elemDecl,inCache,inEnv,inPrefix);
varPos = setFunctionInputIndex(elemDecl,name,0);
varPos = setFunctionInputIndex(elemDecl,name,1);
then
(varPos,DAE.NO_DERIVATIVE(DAE.ICONST(99)))::outconds;

case(SCode.NAMEMOD("zeroDerivative",(m as SCode.MOD(absynExpOption = SOME(((Absyn.CREF(acr)),_)) )))::subs,elemDecl,inCache,inEnv,inPrefix)
equation
name = Absyn.printComponentRefStr(acr);
outconds = getDeriveCondition(subs,elemDecl,inCache,inEnv,inPrefix);
varPos = setFunctionInputIndex(elemDecl,name,0);
varPos = setFunctionInputIndex(elemDecl,name,1);
then
(varPos,DAE.ZERO_DERIVATIVE)::outconds;
case(SCode.NAMEMOD("noDerivative",(m as SCode.MOD(absynExpOption=_)))::subs,elemDecl,inCache,inEnv,inPrefix)
equation
(inCache,(elabedMod as DAE.MOD(subModLst={sub})),_) = Mod.elabMod(inCache,inEnv, inPrefix, m, false);
(name,cond) = extractNameAndExp(sub);
outconds = getDeriveCondition(subs,elemDecl,inCache,inEnv,inPrefix);
varPos = setFunctionInputIndex(elemDecl,name,0);
varPos = setFunctionInputIndex(elemDecl,name,1);
then
(varPos,cond)::outconds;

Expand Down Expand Up @@ -11911,10 +11911,11 @@ algorithm
local DAE.AvlTree dav;
equation
elabedType = Types.elabType(tt);
true = Exp.equalTypes(elabedType,ty);
true = Exp.equalTypes(elabedType,ty);
(_,value,_) = Ceval.ceval(Env.emptyCache(),Env.emptyEnv, e2, false, NONE, NONE, Ceval.MSG());
dael = assignComplexConstantConstruct(value,assignedCr,source);
dav = DAEUtil.avlTreeNew();
//print(" SplitComplex \n ");DAEUtil.printDAE(DAE.DAE(dael,dav));
then DAE.DAE(dael,dav);

/* all other COMPLEX equations */
Expand Down
1 change: 0 additions & 1 deletion Compiler/SCodeUtil.mo
Expand Up @@ -56,7 +56,6 @@ protected import Error;
protected import System;
protected import ExpandableConnectors;
protected import Inst;
protected import Ceval;
protected import InstanceHierarchy;

public function translateAbsyn2SCode
Expand Down

0 comments on commit c37a5cf

Please sign in to comment.