Skip to content

Commit

Permalink
Fix DAEUtil.addDaeFunction.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Apr 11, 2016
1 parent 7007bf4 commit e008b58
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 39 deletions.
2 changes: 2 additions & 0 deletions Compiler/FrontEnd/DAE.mo
Expand Up @@ -586,6 +586,8 @@ public
algorithm
outResult := Absyn.pathCompareNoQual(inKey1,inKey2);
end keyCompare;

redeclare function addConflictDefault = addConflictReplace;
end AvlTreePathFunction;

/* -- Algorithm.mo -- */
Expand Down
41 changes: 5 additions & 36 deletions Compiler/FrontEnd/DAEUtil.mo
Expand Up @@ -5568,43 +5568,12 @@ algorithm
end collectFunctionRefVarPaths;

public function addDaeFunction "add functions present in the element list to the function tree"
input list<DAE.Function> ifuncs;
input DAE.FunctionTree itree;
output DAE.FunctionTree outTree;
input list<DAE.Function> functions;
input output DAE.FunctionTree functionTree;
algorithm
outTree := match (ifuncs,itree)
local
DAE.Function func, fOld;
list<DAE.Function> funcs;
DAE.FunctionTree tree;
String msg;

case ({},tree)
equation
//showCacheFuncs(tree);
then
tree;
/*
case (func::funcs,tree)
equation
true = Flags.isSet(Flags.FAILTRACE);
// print("Add to cache [check] : " + Absyn.pathString(functionName(func)) + "\n");
// print("Function added: \n" + DAEDump.dumpFunctionStr(func) + "\n");
fOld = Util.getOption(DAE.AvlTreePathFunction.get(tree, functionName(func)));
failure(equality(fOld = func));
print("Function already in the tree and different (keep the one already in the tree):" +
"\nnew:\n" + DAEDump.dumpFunctionStr(func) +
"\nold:\n" + DAEDump.dumpFunctionStr(fOld) + "\n");
then
fail();
*/
case (func::funcs,tree)
equation
// print("Add to cache: " + Absyn.pathString(functionName(func)) + "\n");
tree = DAE.AvlTreePathFunction.add(tree,functionName(func),SOME(func));
then addDaeFunction(funcs,tree);

end match;
for f in functions loop
functionTree := DAE.AvlTreePathFunction.add(functionTree, functionName(f), SOME(f));
end for;
end addDaeFunction;

public function addFunctionDefinition
Expand Down
9 changes: 6 additions & 3 deletions Compiler/Util/BaseAvlTree.mo
Expand Up @@ -65,6 +65,9 @@ algorithm
end match;
end printNodeStr;

replaceable function addConflictDefault = addConflictFail
"Default conflict resolving function for add.";

function addConflictFail
"Conflict resolving function for add which fails on conflict."
input Value newValue;
Expand Down Expand Up @@ -93,7 +96,7 @@ redeclare function add
input Tree inTree;
input Key inKey;
input Value inValue;
input ConflictFunc conflictFunc = addConflictFail "Used to resolve conflicts.";
input ConflictFunc conflictFunc = addConflictDefault "Used to resolve conflicts.";
output Tree tree=inTree;

partial function ConflictFunc
Expand Down Expand Up @@ -139,7 +142,7 @@ redeclare function addList
"Adds a list of key-value pairs to the tree."
input output Tree tree;
input list<tuple<Key,Value>> inValues;
input ConflictFunc conflictFunc = addConflictFail "Used to resolve conflicts.";
input ConflictFunc conflictFunc = addConflictDefault "Used to resolve conflicts.";

partial function ConflictFunc
input Value newValue "The value given by the caller.";
Expand Down Expand Up @@ -227,7 +230,7 @@ redeclare function join
"Joins two trees by adding the second one to the first."
input output Tree tree;
input Tree treeToJoin;
input ConflictFunc conflictFunc = addConflictFail "Used to resolve conflicts.";
input ConflictFunc conflictFunc = addConflictDefault "Used to resolve conflicts.";

partial function ConflictFunc
input Value newValue "The value given by the caller.";
Expand Down

0 comments on commit e008b58

Please sign in to comment.