Skip to content

Commit

Permalink
Fixed bug in lookup of classes from inside functions. Cleaned up some…
Browse files Browse the repository at this point in the history
… comments.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2344 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Apr 25, 2006
1 parent 5354494 commit b6b3411
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 170 deletions.
6 changes: 3 additions & 3 deletions Compiler/Ceval.mo
Expand Up @@ -2708,7 +2708,7 @@ algorithm
env3 = Env.openScope(env_1, encflag, SOME(n));
ci_state = ClassInf.start(r, n);
(dae1,env4,csets_1,ci_state_1,tys,_) = Inst.instClassIn(env3, Types.NOMOD(), Prefix.NOPRE(), Connect.emptySet,
ci_state, c, false, {}, false, false);
ci_state, c, false, {}, false);
cref_1 = Exp.joinCrefs(cref, Exp.CREF_IDENT("stateSelect",{}));
(attr,ty,Types.EQBOUND(exp,_,_)) = Lookup.lookupVar(env4, cref_1);
ic_1 = Interactive.addInstantiatedClass(ic, Interactive.INSTCLASS(classname_1,dae1,env4));
Expand All @@ -2732,7 +2732,7 @@ algorithm
env3 = Env.openScope(env_1, encflag, SOME(n));
ci_state = ClassInf.start(r, n);
(dae1,env4,csets_1,ci_state_1,tys,_) = Inst.instClassIn(env3, Types.NOMOD(), Prefix.NOPRE(), Connect.emptySet,
ci_state, c, false, {}, false, false);
ci_state, c, false, {}, false);
cref_1 = Exp.joinCrefs(cref, Exp.CREF_IDENT(attribute,{}));
(attr,ty,Types.VALBOUND(v)) = Lookup.lookupVar(env4, cref_1);
ic_1 = Interactive.addInstantiatedClass(ic, Interactive.INSTCLASS(classname_1,dae1,env4));
Expand Down Expand Up @@ -4417,7 +4417,7 @@ algorithm
(cls,env_1) = Lookup.lookupClass(env, path, false);
Debug.fprintln("ceval", "/*- ceval_generate_function_str instantiating*/");
(env_2,d) = Inst.implicitFunctionInstantiation(env_1, Types.NOMOD(), Prefix.NOPRE(), Connect.emptySet,
cls, {}, false);
cls, {});
Debug.fprint("ceval",
"/*- ceval_generate_function_str getting functions: ");
calledfuncs = SimCodegen.getCalledFunctionsInFunction(path, DAE.DAE(d));
Expand Down
29 changes: 28 additions & 1 deletion Compiler/Env.mo
Expand Up @@ -469,10 +469,37 @@ algorithm
list<Exp.ComponentRef> crs;
Boolean encflag;
Absyn.Import imp;
case ((FRAME(class_1 = sid,list_2 = ht,list_3 = httypes,list_4 = imps,list_5 = bcframes,current6 = crs,encapsulated_7 = encflag) :: fs),imp) then (FRAME(sid,ht,httypes,(IMPORT(imp) :: imps),bcframes,crs,encflag) :: fs);
Env env;
case ((FRAME(class_1 = sid,list_2 = ht,list_3 = httypes,list_4 = imps,list_5 = bcframes,current6 = crs,encapsulated_7 = encflag) :: fs),imp)
equation
false = memberImportList(imps,imp);
then (FRAME(sid,ht,httypes,(IMPORT(imp) :: imps),bcframes,crs,encflag) :: fs);
case (env,imp) then env;
end matchcontinue;
end extendFrameI;

protected function memberImportList "Returns true if import exist in imps"
input list<Item> imps;
input Absyn.Import imp;
output Boolean res "true if import exist in imps, false otherwise";
algorithm
res := matchcontinue (imps,imp)
local
list<Item> ims;
Absyn.Import imp2;
Boolean res;
case (IMPORT(imp2)::ims,imp)
equation
equality(imp2 = imp);
then true;

case (_::ims,imp) equation
res=memberImportList(ims,imp);
then res;
case (_,_) then false;
end matchcontinue;
end memberImportList;

public function addBcFrame "function: addBcFrame
author: PA
Expand Down
4 changes: 2 additions & 2 deletions Compiler/Error.mo
Expand Up @@ -279,7 +279,7 @@ protected constant list<tuple<Integer, MessageType, Severity, String>> errorTabl
(LOOKUP_ERROR_COMPNAME,TRANSLATION(),ERROR(),
"Class %s not found in scope %s while instantiating %s."),
(LOOKUP_VARIABLE_ERROR,TRANSLATION(),ERROR(),
"Variable %s not found in scope %s\n"),
"Variable %s not found in scope %s"),
(LOOKUP_BASECLASS_ERROR,TRANSLATION(),ERROR(),
"Base class %s not found in scope %s"),
(ASSIGN_CONSTANT_ERROR,TRANSLATION(),ERROR(),
Expand Down Expand Up @@ -383,7 +383,7 @@ protected constant list<tuple<Integer, MessageType, Severity, String>> errorTabl
(IMPORT_PACKAGES_ONLY,TRANSLATION(),ERROR(),
"%s is not a package, imports is only allowed for packages."),
(IMPORT_SEVERAL_NAMES,TRANSLATION(),ERROR(),
"% found in several unqualified import statements."),
"%s found in several unqualified import statements."),
(LOOKUP_TYPE_FOUND_COMP,TRANSLATION(),ERROR(),
"Found a component with same name when looking for type %s"),
(LOOKUP_ENCAPSULATED_RESTRICTION_VIOLATION,TRANSLATION(),
Expand Down

0 comments on commit b6b3411

Please sign in to comment.