Skip to content

Commit

Permalink
- Interactive.buildEnvFromSymboltable now caches its result
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10737 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Dec 16, 2011
1 parent 3019510 commit 2383a51
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions Compiler/Script/Interactive.mo
Expand Up @@ -421,7 +421,7 @@ algorithm
// Type check the function
case (Absyn.PROGRAM(classes = {absyn_class}),st)
equation
env = buildEnvFromSymboltable(st);
(env,st) = buildEnvFromSymboltable(st);
scode_class = SCodeUtil.translateClass(absyn_class);
scode_class = SCodeFlatten.flattenClass(scode_class);

Expand Down Expand Up @@ -534,7 +534,7 @@ algorithm
functionArgs = Absyn.FUNCTIONARGS(args = {cond,msg}))),
(st as SYMBOLTABLE(ast = p)))
equation
env = buildEnvFromSymboltable(st);
(env,st) = buildEnvFromSymboltable(st);
(cache,econd,prop,SOME(st_1)) = Static.elabExp(Env.emptyCache(),env, cond, true, SOME(st),true,Prefix.NOPRE(),info);
(_,Values.BOOL(true),SOME(st_2)) = Ceval.ceval(cache,env, econd, true,SOME(st_1),Ceval.MSG(info));
then
Expand All @@ -544,15 +544,15 @@ algorithm
functionArgs = Absyn.FUNCTIONARGS(args = {cond,msg}))),
(st as SYMBOLTABLE(ast = p)))
equation
env = buildEnvFromSymboltable(st);
(env,st) = buildEnvFromSymboltable(st);
(cache,msg_1,prop,SOME(st_1)) = Static.elabExp(Env.emptyCache(),env, msg, true, SOME(st),true,Prefix.NOPRE(),info);
(_,Values.STRING(str),SOME(st_2)) = Ceval.ceval(cache,env, msg_1, true,SOME(st_1),Ceval.MSG(info));
then
(str,st_2);

case (Absyn.ALGORITHMITEM(info=info,algorithm_ = Absyn.ALG_NORETCALL(functionCall = cr,functionArgs = fargs)),st)
equation
env = buildEnvFromSymboltable(st);
(env,st) = buildEnvFromSymboltable(st);
exp = Absyn.CALL(cr,fargs);
(cache,sexp,prop,SOME(st_1)) = Static.elabExp(Env.emptyCache(), env, exp, true, SOME(st),true,Prefix.NOPRE(),info);
(_,_,SOME(st_2)) = Ceval.ceval(cache, env, sexp, true,SOME(st_1),Ceval.MSG(info));
Expand All @@ -578,7 +578,7 @@ algorithm
Absyn.CREF(Absyn.CREF_IDENT(name = ident,subscripts = {})),value = exp)),
(st as SYMBOLTABLE(ast = p)))
equation
env = buildEnvFromSymboltable(st);
(env,st) = buildEnvFromSymboltable(st);
(cache,sexp,DAE.PROP(_,_),SOME(st_1)) = Static.elabExp(Env.emptyCache(),env, exp, true, SOME(st),true,Prefix.NOPRE(),info);
(_,value,SOME(st_2)) = Ceval.ceval(cache,env, sexp, true,SOME(st_1),Ceval.MSG(info));
t = Types.typeOfValue(value) "This type can be more specific than the elaborated type; if the dimensions are unknown...";
Expand All @@ -593,7 +593,7 @@ algorithm
Absyn.TUPLE(expressions = crefexps),value = rexp)),
(st as SYMBOLTABLE(ast = p))) /* Since expressions cannot be tuples an empty string is returned */
equation
env = buildEnvFromSymboltable(st);
(env,st) = buildEnvFromSymboltable(st);
(cache,srexp,rprop,SOME(st_1)) = Static.elabExp(Env.emptyCache(),env, rexp, true, SOME(st),true,Prefix.NOPRE(),info);
DAE.T_TUPLE(tupleType = types) = Types.getPropType(rprop);
idents = List.map(crefexps, getIdentFromTupleCrefexp);
Expand Down Expand Up @@ -909,7 +909,7 @@ algorithm

case (exp,(st as SYMBOLTABLE(ast = p)),info)
equation
env = buildEnvFromSymboltable(st);
(env,st) = buildEnvFromSymboltable(st);
(cache,sexp,prop,SOME(st_1)) = Static.elabExp(Env.emptyCache(), env, exp, true, SOME(st),true,Prefix.NOPRE(),info);
(_,value,SOME(st_2)) = Ceval.ceval(cache,env, sexp, true,
SOME(st_1),Ceval.MSG(info));
Expand All @@ -931,7 +931,7 @@ protected
DAE.Properties prop;
SymbolTable st_1;
algorithm
env := buildEnvFromSymboltable(st);
(env,st) := buildEnvFromSymboltable(st);
(_,sexp,prop,SOME(st_1)) := Static.elabExp(Env.emptyCache(),env, exp, true, SOME(st),true,Prefix.NOPRE(),Absyn.dummyInfo);
(_, sexp, prop) := Ceval.cevalIfConstant(Env.emptyCache(), env, sexp, prop, true, Absyn.dummyInfo);
estr := ExpressionDump.printExpStr(sexp);
Expand Down Expand Up @@ -1228,29 +1228,25 @@ public function buildEnvFromSymboltable
interactive variables and their bindings to the environment."
input SymbolTable inSymbolTable;
output Env.Env outEnv;
output SymbolTable st;
algorithm
outEnv := match (inSymbolTable)
(outEnv,st) := match (inSymbolTable)
local
list<SCode.Element> p_1,sp;
list<Env.Frame> env,env_1;
Absyn.Program p;
list<InstantiatedClass> ic;
list<Variable> vars;
list<CompiledCFunction> cf;
case (SYMBOLTABLE(explodedAst = SOME(p_1), lstVarVal = vars))
equation
(_,env) = Inst.makeEnvFromProgram(Env.emptyCache(),p_1, Absyn.IDENT(""));
env_1 = addVarsToEnv(vars, env);
then
env_1;

case (SYMBOLTABLE(ast = p, lstVarVal = vars))
list<LoadedFile> loadedFiles;
AbsynDep.Depends depends;
case (st as SYMBOLTABLE(lstVarVal = vars))
equation
p_1 = SCodeUtil.translateAbsyn2SCode(p);
(p_1,st) = symbolTableToSCode(st);
(_,env) = Inst.makeEnvFromProgram(Env.emptyCache(),p_1, Absyn.IDENT(""));
env_1 = addVarsToEnv(vars, env);
then
env_1;
(env_1,st);
end match;
end buildEnvFromSymboltable;

Expand Down Expand Up @@ -2324,7 +2320,7 @@ algorithm
b1 = useQuotes(nargs);
path = Absyn.crefToPath(cr);
cls = getPathedClassInProgram(path, p);
env = buildEnvFromSymboltable(st);
(env,st) = buildEnvFromSymboltable(st);
resstr = getLocalVariables(cls, b1, env);
then
(resstr,st);
Expand Down Expand Up @@ -2365,7 +2361,7 @@ algorithm
{Absyn.CREF(componentRef = cr), Absyn.ARRAY(arrayExp = exp_list),Absyn.INTEGER(value = n)} = getApiFunctionArgs(istmts);
modelpath = Absyn.crefToPath(cr);
filenameprefix = Absyn.pathLastIdent(modelpath);
env = buildEnvFromSymboltable(st);
(env,st) = buildEnvFromSymboltable(st);
Config.setRemoveTerms(true);
Config.setGenerateLabeledDAE(false);
(_,{_,_,_,_,_,DAE.SCONST(method),_,_,_,_,_,_,_,_}) = Static.getSimulationArguments(Env.emptyCache(),{},{Absyn.CREF(cr)},{},false,SOME(st),Prefix.NOPRE(),Absyn.dummyInfo);
Expand Down

0 comments on commit 2383a51

Please sign in to comment.