Skip to content

Commit

Permalink
- remove Compiler/FrontEnd/Env.mo (bye bye, you served us well for qu…
Browse files Browse the repository at this point in the history
…ite some years now)

  (replaced everywhere by Compiler/FrontEnd/FGraph.mo and Compiler/FrontEnd/FCore.mo)
- other minor changes
- let's see how it goes and a 1.9.1 Beta3 will come next

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22628 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Oct 6, 2014
1 parent 8648950 commit 4e3b149
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 3,750 deletions.
4 changes: 4 additions & 0 deletions Compiler/FFrontEnd/FCore.mo
Expand Up @@ -233,6 +233,10 @@ uniontype Data
String message;
end ASSERT;

record STATUS "status node"
Boolean isInstantiating;
end STATUS;

end Data;

type Refs = list<Ref>;
Expand Down
89 changes: 89 additions & 0 deletions Compiler/FFrontEnd/FGraph.mo
Expand Up @@ -1827,5 +1827,94 @@ algorithm
end matchcontinue;
end graphPrefixOf2;

public function setStatus
input Graph inEnv;
input Name inName;
input FCore.Data inStatus;
output Graph outEnv;
algorithm
outEnv := matchcontinue(inEnv, inName, inStatus)
local
Graph g;
Node n;
Ref ref, refParent;

// child does not exist, do nothing, is an import or extends
case (g, _, _)
equation
refParent = lastScopeRef(g);
false = FNode.refHasChild(refParent, inName);
then
g;

// child exists and has a status node
case (g, _, _)
equation
refParent = lastScopeRef(g);
true = FNode.refHasChild(refParent, inName);
ref = FNode.child(refParent, inName);
true = FNode.refHasChild(ref, FNode.statusNodeName);
ref = FNode.child(ref, FNode.statusNodeName);
n = FNode.setData(FNode.fromRef(ref), inStatus);
ref = FNode.updateRef(ref, n);
then
g;

// child exists but has no status node
case (g, _, _)
equation
refParent = lastScopeRef(g);
true = FNode.refHasChild(refParent, inName);
ref = FNode.child(refParent, inName);
false = FNode.refHasChild(ref, FNode.statusNodeName);
(g, n) = node(g, FNode.statusNodeName, {ref}, inStatus);
FNode.addChildRef(ref, FNode.statusNodeName, FNode.toRef(n));
then
g;

// did we fail for some weird reson?
case (g, _, _)
equation
print("FGraph.setStatus failed on: " +& getGraphNameStr(g) +& " element: " +& inName +& "\n");
then
g;

end matchcontinue;
end setStatus;

public function getStatus
input Graph inEnv;
input Name inName;
output FCore.Data outStatus;
algorithm
outStatus := matchcontinue(inEnv, inName)
local
Graph g;
Node n;
Ref ref, refParent;
FCore.Data s;

// child exists and has a status node
case (g, _)
equation
refParent = lastScopeRef(g);
true = FNode.refHasChild(refParent, inName);
ref = FNode.child(refParent, inName);
true = FNode.refHasChild(ref, FNode.statusNodeName);
ref = FNode.child(ref, FNode.statusNodeName);
s = FNode.refData(ref);
then
s;

// we can fail here with no problem, there is no status node!
case (g, _)
equation
// print("FGraph.getStatus failed on: " +& getGraphNameStr(g) +& " element: " +& inName +& "\n");
then
fail();

end matchcontinue;
end getStatus;

end FGraph;

1 change: 1 addition & 0 deletions Compiler/FFrontEnd/FNode.mo
Expand Up @@ -112,6 +112,7 @@ constant Name veNodeName = "$ve" "a node for storing references to instance
constant Name imNodeName = "$imp" "an node holding the import table";
constant Name itNodeName = "$it" "an node holding the instance information DAE.Var";
constant Name assertNodeName = "$assert" "an assersion node";
constant Name statusNodeName = "$status" "an status node";

public function toRef
"@author: adrpo
Expand Down

0 comments on commit 4e3b149

Please sign in to comment.