Skip to content

Commit

Permalink
Instantiate functions fully even when not in function context (to get…
Browse files Browse the repository at this point in the history
… the full type; previously we returned an empty DAE which seemed weird)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15555 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Mar 13, 2013
1 parent fe922ff commit 3ef9680
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
26 changes: 16 additions & 10 deletions Compiler/FrontEnd/Inst.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,6 @@ algorithm
//System.stopTimer();
//print("\nConnect and Overconstrained: " +& realString(System.getTimerIntervalTime()));


ty = mktype(fq_class, ci_state_1, tys, bc_ty, equalityConstraint, c);
dae = updateDeducedUnits(callscope_1,store,dae);

Expand Down Expand Up @@ -1956,6 +1955,7 @@ algorithm
SCode.Partial partialPrefix;
SCode.Encapsulated encapsulatedPrefix;
UnitAbsyn.InstStore store;
Boolean b;

/* Real class */
case (cache,env,ih,store,mods,pre, ci_state,
Expand Down Expand Up @@ -2050,20 +2050,12 @@ algorithm
then
(cache,env_3,ih,store,DAEUtil.emptyDae,csets,ci_state_1,tys2,bc /* NONE() */,NONE(),NONE(),graph);

/* Ignore functions if not implicit instantiation */
case (cache,env,ih,store,mods,pre,ci_state,cls,_,_,(impl as false),_,graph,_,_)
equation
true = SCode.isFunction(cls);
clsname = SCode.className(cls);
//print("Ignore function" +& clsname +& "\n");
then
(cache,env,ih,store,DAEUtil.emptyDae, inSets,ci_state,{},NONE(),NONE(),NONE(),graph);

/* Instantiate a class definition made of parts */
case (cache,env,ih,store,mods,pre,ci_state,
c as SCode.CLASS(name = n,restriction = r,classDef = d,info=info,partialPrefix = partialPrefix,encapsulatedPrefix = encapsulatedPrefix),
vis,inst_dims,impl,callscope,graph,_,_)
equation
ErrorExt.setCheckpoint("instClassParts");
false = isBuiltInClass(n) "If failed above, no need to try again";
// Debug.fprint(Flags.INSTTR, "ICLASS [");
implstr = Util.if_(impl, "impl] ", "expl] ");
Expand All @@ -2080,9 +2072,23 @@ algorithm
// s = realString(time);
// Debug.fprintln(Flags.INSTTR, " -> ICLASS " +& n +& " inst time: " +& s +& " in env: " +& Env.printEnvPathStr(env) +& " mods: " +& Mod.printModStr(mods));
cache = Env.addCachedEnv(cache,n,env_1);
dae = Util.if_(SCode.isFunction(c) and not impl, DAE.DAE({}), dae);
ErrorExt.delCheckpoint("instClassParts");
then
(cache,env_1,ih,store,dae,csets,ci_state_1,tys,bc,oDA,eqConstraint,graph);

/* Ignore functions if not implicit instantiation, and doing checkModel - some dimensions might not be complete... */
case (cache,env,ih,store,mods,pre,ci_state,c as SCode.CLASS(name = _),_,_,impl,_,graph,_,_)
equation
b = Flags.getConfigBool(Flags.CHECK_MODEL) and (not impl) and SCode.isFunction(c);
Debug.bcall1(not b, ErrorExt.delCheckpoint, "instClassParts");
Debug.bcall1(b, ErrorExt.rollBack, "instClassParts");
true = b;
// clsname = SCode.className(cls);
// print("Ignore function" +& clsname +& "\n");
then
(cache,env,ih,store,DAEUtil.emptyDae, inSets,ci_state,{},NONE(),NONE(),NONE(),graph);

// failure
else
equation
Expand Down
4 changes: 3 additions & 1 deletion Compiler/FrontEnd/Types.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ algorithm
l1 = unparseType(t1);
l2 = unparseType(t2);
l1 = stringAppendList({"- Types.subtype failed:\n t1=",l1,"\n t2=",l2});
Debug.fprintln(Flags.FAILTRACE, l1);
print(l1);
*/
then false;
end matchcontinue;
Expand Down Expand Up @@ -2228,6 +2228,8 @@ algorithm
case (DAE.T_UNKNOWN(_)) then "#T_UNKNOWN#";
case (DAE.T_ANYTYPE(anyClassType = _)) then "#ANYTYPE#";
case (DAE.T_CODE(ty = codeType)) then printCodeTypeStr(codeType);
case (DAE.T_FUNCTION_REFERENCE_VAR(functionType=ty)) then "#FUNCTION_REFERENCE_VAR#" +& unparseType(ty);
case (DAE.T_FUNCTION_REFERENCE_FUNC(functionType=ty)) then "#FUNCTION_REFERENCE_FUNC#" +& unparseType(ty);
case (ty) then "Internal error Types.unparseType: not implemented yet\n";
end match;
end unparseType;
Expand Down

0 comments on commit 3ef9680

Please sign in to comment.