Skip to content

Commit

Permalink
* Implemented support for instantiate a single constant in a package
Browse files Browse the repository at this point in the history
* Improved getTotalProgram to decrease instantiation time 

git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/MathCoreOSMC@3993 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Björn Zachrisson committed Apr 2, 2009
1 parent 84b019d commit f6e4d72
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 46 deletions.
4 changes: 2 additions & 2 deletions Compiler/CevalScript.mo
Expand Up @@ -3351,7 +3351,7 @@ algorithm
env3 = Env.openScope(env_1, encflag, SOME(n));
ci_state = ClassInf.start(r, n);
(cache,dae1,env4,csets_1,ci_state_1,tys,_,_,_,_) = Inst.instClassIn(cache,env3, Types.NOMOD(), Prefix.NOPRE(), Connect.emptySet,
ci_state, c, false, {}, false, ConnectionGraph.EMPTY);
ci_state, c, false, {}, false, ConnectionGraph.EMPTY,NONE);
cref_1 = Exp.joinCrefs(cref, Exp.CREF_IDENT("stateSelect",Exp.OTHER(),{}));
(cache,attr,ty,Types.EQBOUND(exp,_,_),_,_) = Lookup.lookupVar(cache,env4, cref_1);
ic_1 = Interactive.addInstantiatedClass(ic, Interactive.INSTCLASS(classname_1,dae1,env4));
Expand Down Expand Up @@ -3390,7 +3390,7 @@ algorithm
env3 = Env.openScope(env_1, encflag, SOME(n));
ci_state = ClassInf.start(r, n);
(cache,dae1,env4,csets_1,ci_state_1,tys,_,_,_,_) = Inst.instClassIn(cache,env3, Types.NOMOD(), Prefix.NOPRE(), Connect.emptySet,
ci_state, c, false, {}, false, ConnectionGraph.EMPTY);
ci_state, c, false, {}, false, ConnectionGraph.EMPTY,NONE);
cref_1 = Exp.joinCrefs(cref, Exp.CREF_IDENT(attribute,Exp.OTHER(),{}));
(cache,attr,ty,Types.VALBOUND(v),_,_) = Lookup.lookupVar(cache,env4, cref_1);
ic_1 = Interactive.addInstantiatedClass(ic, Interactive.INSTCLASS(classname_1,dae1,env4));
Expand Down
232 changes: 200 additions & 32 deletions Compiler/Inst.mo

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Compiler/Interactive.mo
Expand Up @@ -18259,7 +18259,7 @@ algorithm
env2 = Env.openScope(env_1, encflag, SOME(id));
ci_state = ClassInf.start(restr, id);
(_,_,env_2,_,_,_,_,_,_,_) = Inst.instClassIn(Env.emptyCache,env2, Types.NOMOD(), Prefix.NOPRE(), Connect.emptySet,
ci_state, cl, false, {},false, ConnectionGraph.EMPTY);
ci_state, cl, false, {},false, ConnectionGraph.EMPTY,NONE);
then env_2;
end matchcontinue;
end getClassEnvNoElaboration;
Expand Down
29 changes: 23 additions & 6 deletions Compiler/Lookup.mo
Expand Up @@ -588,7 +588,7 @@ algorithm
env2 = Env.openScope(env_1, encflag, SOME(id));
ci_state = ClassInf.start(restr, id);
(cache,_,(f :: _),_,_,_,_,_,_,_) = Inst.instClassIn(cache,env2, Types.NOMOD(), Prefix.NOPRE(), Connect.emptySet,
ci_state, c, false, {}, false, ConnectionGraph.EMPTY);
ci_state, c, false, {}, false, ConnectionGraph.EMPTY,NONE);
(cache,p_env,attr,ty,bind) = lookupVarInPackages(cache,{f}, Exp.CREF_IDENT(ident,Exp.OTHER(),{}));
(cache,more) = moreLookupUnqualifiedImportedVarInFrame(cache,fs, env, ident);
unique = boolNot(more);
Expand Down Expand Up @@ -1033,7 +1033,7 @@ algorithm
env3 = Env.openScope(env2, encflag, SOME(n));
ci_state = ClassInf.start(r, n);
(cache,_,env5,_,_,types,_,_,_,_) = Inst.instClassIn(cache,env3, Types.NOMOD(), Prefix.NOPRE(), Connect.emptySet,
ci_state, c, false, {}, false, ConnectionGraph.EMPTY);
ci_state, c, false, {}, false, ConnectionGraph.EMPTY,NONE);
(cache,p_env,attr,ty,bind) = lookupVarInPackages(cache,env5, id2);
then
(cache,p_env,attr,ty,bind);
Expand Down Expand Up @@ -1069,13 +1069,15 @@ algorithm
(cache,p_env,attr,ty,bind);

// lookup of constants on form A.B in packages. instantiate package and look inside.
case (cache,env,cr as Exp.CREF_QUAL(ident = id,subscriptLst = {},componentRef = cref)) /* First part of name is a class. */
case (cache,env,cr as Exp.CREF_QUAL(ident = id,subscriptLst = {},componentRef = cref)) /* First part of name is a class. */
local Option<Exp.ComponentRef> filterCref;
equation
(cache,(c as SCode.CLASS(n,_,encflag,r,_)),env2) = lookupClass2(cache,env, Absyn.IDENT(id), false);
env3 = Env.openScope(env2, encflag, SOME(n));
ci_state = ClassInf.start(r, n);
filterCref = makeOptIdentOrNone(cref);
(cache,_,env5,_,_,types,_,_,_,_) = Inst.instClassIn(cache,env3, Types.NOMOD(), Prefix.NOPRE(), Connect.emptySet,
ci_state, c, false, {}, /*true*/false, ConnectionGraph.EMPTY);
ci_state, c, false, {}, /*true*/false, ConnectionGraph.EMPTY,filterCref);
(cache,p_env,attr,ty,bind) = lookupVarInPackages(cache,env5, cref);
then
(cache,p_env,attr,ty,bind);
Expand All @@ -1100,7 +1102,7 @@ algorithm
/* Search among qualified imports, e.g. import A.B; or import D=A.B; */
case (cache,(env as (Env.FRAME(optName = sid,imports = items) :: _)),(cr as Exp.CREF_IDENT(ident = id,subscriptLst = sb)))
equation
(cache,p_env,attr,ty,bind) = lookupQualifiedImportedVarInFrame(cache,items, env, id);
(cache,p_env,attr,ty,bind) = lookupQualifiedImportedVarInFrame(cache,items, env, id);
then
(cache,p_env,attr,ty,bind);

Expand All @@ -1119,12 +1121,27 @@ algorithm
then
(cache,p_env,attr,ty,bind);

case (cache,env,cr) /* Debug.fprint(\"failtrace\", \"lookup_var_in_packages failed\\n exp:\" ) &
case (cache,env,cr)
/* Debug.fprint(\"failtrace\", \"lookup_var_in_packages failed\\n exp:\" ) &
Debug.fcall(\"failtrace\", Exp.print_component_ref, cr) &
Debug.fprint(\"failtrace\", \"\\n\") */ then fail();
end matchcontinue;
end lookupVarInPackages;

protected function makeOptIdentOrNone "
Author: BZ, 2009-04
Helper function for lookupVarInPackages
Makes an optional Exp.ComponentRef if the input Exp.ComponentRef is a Exp.CREF_IDENT otherwise
'NONE' is returned
"
input Exp.ComponentRef incr;
output Option<Exp.ComponentRef> ocR;
algorithm ocR := matchcontinue(incr)
case(incr as Exp.CREF_IDENT(_,_,_)) then SOME(incr);
case(_) then NONE;
end matchcontinue;
end makeOptIdentOrNone;

public function lookupVarLocal "function: lookupVarLocal
This function is very similar to `lookup_var\', but it only looks
Expand Down
8 changes: 4 additions & 4 deletions Compiler/SCode.mo
Expand Up @@ -301,7 +301,7 @@ uniontype Element "- Elements
Option<Path> baseClassPath "the base class path if this component originates from a base class" ;
Option<Absyn.Comment> comment "this if for extraction of comments and annotations from Absyn" ;
Option<Absyn.Exp> condition "the conditional declaration of a component";
Option<Absyn.Info> info "this is for line and column numbers, also file name.";
Option<Absyn.Info> info "this is for line and column numbers, also file name.";
end COMPONENT;
end Element;

Expand Down Expand Up @@ -1664,7 +1664,7 @@ algorithm
str := matchcontinue (optPath)
local Absyn.Path path;
case (SOME(path)) then Absyn.pathString(path);
case (SOME(path)) then "<nothing>";
case (NONE) then "<nothing>";
end matchcontinue;
end unparseOptPath;

Expand Down Expand Up @@ -1727,7 +1727,7 @@ algorithm
then
res;
case CLASSDEF(name = n,finalPrefix = finalPrefix,replaceablePrefix = repl,classDef = cl,baseClassPath = pathOpt)
equation
equation
str = printClassStr(cl);
res = Util.stringAppendList({"CLASSDEF(",n,",...,",str,")"});
then
Expand Down Expand Up @@ -2008,7 +2008,7 @@ algorithm
end matchcontinue;
end componentNames;

protected function componentNamesFromElts
public function componentNamesFromElts
"function: componentNamesFromElts
Helper function to componentNames."
input list<Element> inElementLst;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Util.mo
Expand Up @@ -4145,7 +4145,7 @@ end listFilter_tail;

public function listFilter1_tail
"function: listFilter_tail
@author adrpo
@author bz
tail recursive implementation of listFilter"
input list<Type_a> inTypeALst;
input FuncTypeType_aTo inFuncTypeTypeATo;
Expand Down
1 change: 1 addition & 0 deletions Compiler/runtime/optmanager.cpp
Expand Up @@ -66,6 +66,7 @@ extern "C"
options.insert(std::pair<std::string,bool>("noCse",false));
options.insert(std::pair<std::string,bool>("evaluatingSystem",false));
options.insert(std::pair<std::string,bool>("MOOSEScaleEquations",true));
options.insert(std::pair<std::string,bool>("dummyOption",false));
//options.insert(std::pair<std::string,bool>("dummy",false));

/* for(stringMap::const_iterator it = options.begin(); it != options.end(); ++it)
Expand Down

0 comments on commit f6e4d72

Please sign in to comment.