Skip to content

Commit

Permalink
Fix bug: #2854 (do scope versioning also in the top scope, but not fo…
Browse files Browse the repository at this point in the history
…r builtin classes and builtin types)

- note that flattening/modelica/declarations/Constant12.mo is actually correct now,
  see m:#1397, well, except for the fact that it should tell that A.y does not have a binding


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22515 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Sep 30, 2014
1 parent 61e34ac commit ed133b8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
22 changes: 20 additions & 2 deletions Compiler/FFrontEnd/FGraph.mo
Expand Up @@ -1645,11 +1645,11 @@ algorithm
case (_, _, _, DAE.NOMOD(), _, _, _) then (inTargetClassEnv, inTargetClass, inIH);
case (_, _, _, DAE.MOD(subModLst={},eqModOption=_), _, _, _) then (inTargetClassEnv, inTargetClass, inIH);

// don't do this for MetaModelica, top scope, functions
// don't do this for MetaModelica, target class is builtin or builtin type, functions
case (_, _, _, _, _, _, _)
equation
true = Config.acceptMetaModelicaGrammar() or
isTopScope(inTargetClassEnv) or
isTargetClassBuiltin(inTargetClassEnv, inTargetClass) or
inFunctionScope(inSourceEnv);
then
(inTargetClassEnv, inTargetClass, inIH);
Expand All @@ -1671,6 +1671,24 @@ algorithm
end matchcontinue;
end createVersionScope;

public function isTargetClassBuiltin
input Graph inGraph;
input SCode.Element inClass;
output Boolean yes;
algorithm
yes := matchcontinue(inGraph, inClass)
local Ref r;
case (_, _)
equation
r = FNode.child(lastScopeRef(inGraph), SCode.elementName(inClass));
yes = FNode.isRefBasicType(r) or FNode.isRefBuiltin(r);
then
yes;

else false;
end matchcontinue;
end isTargetClassBuiltin;

public function mkVersionName
input Graph inSourceEnv;
input Name inSourceName;
Expand Down
13 changes: 9 additions & 4 deletions Compiler/FrontEnd/Inst.mo
Expand Up @@ -5785,13 +5785,16 @@ algorithm
Prefix.Prefix pre1, pre2;
SCode.Element e1, e2;
Boolean b1, b2, b3;
SCode.Encapsulated encflag;
SCode.Restriction restr;

case (cache, _, _, _)
equation
true = Flags.isSet(Flags.CACHE);
instHash = getGlobalRoot(Global.instHashIndex);
FCore.CL(e2, pre2, m2, _, _) = FNode.refData(inRef);
fullEnvPathPlusClass = generateCachePath(inEnv, e2, pre2, InstTypes.INNER_CALL());
FCore.CL(e2 as SCode.CLASS(restriction = restr, encapsulatedPrefix=encflag), pre2, m2, _, _) = FNode.refData(inRef);
env = FGraph.openScope(inEnv, encflag, SOME(inName), FGraph.restrictionToScopeType(restr));
fullEnvPathPlusClass = generateCachePath(env, e2, pre2, InstTypes.INNER_CALL());

// print("Try cached instance: " +& Absyn.pathString(fullEnvPathPlusClass) +& "\n");
{SOME(FUNC_instClassIn(inputs, outputs as (ft, env, _, _, _, _, _, _, _, _))),_} = BaseHashTable.get(fullEnvPathPlusClass, instHash);
Expand All @@ -5817,8 +5820,10 @@ algorithm
equation
true = Flags.isSet(Flags.CACHE);
instHash = getGlobalRoot(Global.instHashIndex);
FCore.CL(e2, pre2, m2, _, _) = FNode.refData(inRef);
fullEnvPathPlusClass = generateCachePath(inEnv, e2, pre2, InstTypes.INNER_CALL());
FCore.CL(e2 as SCode.CLASS(restriction = restr, encapsulatedPrefix=encflag), pre2, m2, _, _) = FNode.refData(inRef);
env = FGraph.openScope(inEnv, encflag, SOME(inName), FGraph.restrictionToScopeType(restr));
fullEnvPathPlusClass = generateCachePath(env, e2, pre2, InstTypes.INNER_CALL());

// print("Could not get the cached instance: " +& Absyn.pathString(fullEnvPathPlusClass) +& "\n");
env = FGraph.pushScopeRef(inEnv, inRef);
then
Expand Down

0 comments on commit ed133b8

Please sign in to comment.