Skip to content

Commit

Permalink
- Refactoring Values.mo into Values.mo (AST with minimal dependencies…
Browse files Browse the repository at this point in the history
…) and ValuesUtil.mo

- Removed Exp.Value and part of the workaround in Convert.mo


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4521 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 16, 2009
1 parent 2bf8021 commit 2392e33
Show file tree
Hide file tree
Showing 15 changed files with 191 additions and 2,426 deletions.
162 changes: 84 additions & 78 deletions Compiler/Ceval.mo

Large diffs are not rendered by default.

49 changes: 25 additions & 24 deletions Compiler/CevalScript.mo
Expand Up @@ -91,6 +91,7 @@ protected import UnitParserExt;
protected import UnitAbsynBuilder;
protected import Inline;
protected import SimulationResults;
protected import ValuesUtil;

public function cevalInteractiveFunctions
"function cevalInteractiveFunctions
Expand Down Expand Up @@ -787,7 +788,7 @@ algorithm
plotCmd = Util.stringAppendList({cit,omhome_1,pd,"bin",pd,"doPlot",cit});
uniqueStr = intString(tick());
tmpPlotFile = Util.stringAppendList({pwd,pd,"tmpPlot_",uniqueStr,".plt"});
res = Values.writePtolemyplotDataset(tmpPlotFile, value, vars_2, "Plot by OpenModelica");
res = ValuesUtil.writePtolemyplotDataset(tmpPlotFile, value, vars_2, "Plot by OpenModelica");
call = Util.stringAppendList({cit,plotCmd," \"",tmpPlotFile,"\"",cit});

_ = System.systemCall(call);
Expand Down Expand Up @@ -883,7 +884,7 @@ algorithm
then
(cache,Values.STRING("Error reading the simulation result."),st);
// res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
// res = ValuesUtil.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
// then
// (cache,Values.BOOL(true),st);
Expand Down Expand Up @@ -923,7 +924,7 @@ algorithm
value = SimulationResults.readPtolemyplotDataset(filename2, vars_2, 0);
res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
res = ValuesUtil.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
then
(cache,Values.BOOL(true),st);
Expand Down Expand Up @@ -985,7 +986,7 @@ algorithm
vars_2 = Util.stringSplitAtChar(str, " ");
value = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0);
res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
res = ValuesUtil.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
then
(cache,Values.BOOL(true),st);
Expand Down Expand Up @@ -1021,7 +1022,7 @@ algorithm
value = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0);
res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
res = ValuesUtil.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
then
(cache,Values.BOOL(true),st);
Expand Down Expand Up @@ -1082,7 +1083,7 @@ algorithm
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg);
value = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0);
res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
res = ValuesUtil.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
then
(cache,Values.BOOL(true),st);
Expand Down Expand Up @@ -1203,7 +1204,7 @@ algorithm
//print(Util.stringAppendList(vars_2));
//print(Util.stringDelimitList(vars_2, ", "));
value = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0);
res = Values.sendPtolemyplotDataset2(value, vars_2, visvar_str, "Plot by OpenModelica");
res = ValuesUtil.sendPtolemyplotDataset2(value, vars_2, visvar_str, "Plot by OpenModelica");
then
(cache,Values.BOOL(true),st);
Expand Down Expand Up @@ -1265,8 +1266,8 @@ algorithm
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg);
print("tjo\n");
value = SimulationResults.readPtolemyplotDataset(filename, vars_2, 0);
print("value = " +& Values.valString(value));
res = Values.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, title, title);
print("value = " +& ValuesUtil.valString(value));
res = ValuesUtil.sendPtolemyplotDataset(value, vars_2, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, title, title);
then
(cache,Values.BOOL(true),st);
Expand Down Expand Up @@ -1376,8 +1377,8 @@ algorithm
Values.ARRAY({Values.ARRAY(timeValues)}) = SimulationResults.readPtolemyplotDataset(filename, {"time"}, 0);
tV = Values.valueReals(timeValues);
vV = Values.valueReals(varValues);
tV = ValuesUtil.valueReals(timeValues);
vV = ValuesUtil.valueReals(varValues);
val = System.getVariableValue(timeStamp, tV, vV);
then
(cache,Values.REAL(val),st);
Expand Down Expand Up @@ -1413,8 +1414,8 @@ algorithm
Values.ARRAY({Values.ARRAY(timeValues)}) = SimulationResults.readPtolemyplotDataset(filename, {"time"}, 0);
tV = Values.valueReals(timeValues);
vV = Values.valueReals(varValues);
tV = ValuesUtil.valueReals(timeValues);
vV = ValuesUtil.valueReals(varValues);
val = System.getVariableValue(intReal(timeStamp), tV, vV);
then
(cache,Values.REAL(val),st);
Expand Down Expand Up @@ -1484,7 +1485,7 @@ algorithm
varName = Exp.CodeVarToCref(varName);
varNameStr = Exp.printExpStr(varName);
(cache,Values.ARRAY(vals),SOME(st)) = Ceval.ceval(cache,env, varTimeStamp, true, SOME(st), NONE, msg);
timeStamps = Util.listMap(vals,Values.valueReal);
timeStamps = Util.listMap(vals,ValuesUtil.valueReal);
(cache,val) = cevalValArray(cache,env,SOME(st),timeStamps,varNameStr);
then
(cache,val,st);
Expand Down Expand Up @@ -1532,7 +1533,7 @@ algorithm
plotCmd = Util.stringAppendList({cit,omhome_1,pd,"bin",pd,"doPlot",cit});
uniqueStr = intString(tick());
tmpPlotFile = Util.stringAppendList({pwd,pd,"tmpPlot_",uniqueStr,".plt"});
res = Values.writePtolemyplotDataset(tmpPlotFile, value, vars_1, "Plot by OpenModelica");
res = ValuesUtil.writePtolemyplotDataset(tmpPlotFile, value, vars_1, "Plot by OpenModelica");
call = Util.stringAppendList({cit,plotCmd," \"",tmpPlotFile,"\"",cit});
_ = System.systemCall(call);
then
Expand Down Expand Up @@ -1631,7 +1632,7 @@ algorithm
plotCmd = Util.stringAppendList({cit,omhome_1,pd,"bin",pd,"doPlot",cit});
uniqueStr = intString(tick());
tmpPlotFile = Util.stringAppendList({pwd,pd,"tmpPlot_",uniqueStr,".plt"});
res = Values.sendPtolemyplotDataset(value, vars_1, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
res = ValuesUtil.sendPtolemyplotDataset(value, vars_1, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
then
(cache,Values.BOOL(true),st);

Expand Down Expand Up @@ -1661,7 +1662,7 @@ algorithm
(cache,Values.RECORD(orderd={Values.STRING(filename)}),_) = Ceval.ceval(cache,env,
Exp.CREF(Exp.CREF_IDENT("currentSimulationResult",Exp.OTHER(),{}),Exp.OTHER()), true, SOME(st), NONE, msg);
value = SimulationResults.readPtolemyplotDataset(filename, vars_1, 0);
res = Values.sendPtolemyplotDataset(value, vars_1, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));
res = ValuesUtil.sendPtolemyplotDataset(value, vars_1, "Plot by OpenModelica", interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, Exp.printExpStr(xRange), Exp.printExpStr(yRange));

then
(cache,Values.BOOL(true),st);
Expand Down Expand Up @@ -1770,7 +1771,7 @@ algorithm
// print("setVariableFilter\n");
// print(Util.stringAppendList(vars_1));
// print("\n");
// _ = Values.setVariableFilter(vars_1);
// _ = ValuesUtil.setVariableFilter(vars_1);
_=System.setVariableFilter(Util.stringAppendList(vars_1));
then
(cache,Values.BOOL(true),st);
Expand Down Expand Up @@ -2198,8 +2199,8 @@ algorithm
Values.ARRAY({Values.ARRAY(varValues)}) = SimulationResults.readPtolemyplotDataset(filename, {varName}, 0);
Values.ARRAY({Values.ARRAY(timeValues)}) = SimulationResults.readPtolemyplotDataset(filename, {"time"}, 0);
tV = Values.valueReals(timeValues);
vV = Values.valueReals(varValues);
tV = ValuesUtil.valueReals(timeValues);
vV = ValuesUtil.valueReals(varValues);
val = System.getVariableValue(timeStamp, tV, vV);
then (cache,val);
end matchcontinue;
Expand Down Expand Up @@ -2474,10 +2475,10 @@ algorithm
(cache,tolerance_v,SOME(st)) = Ceval.ceval(cache,env, toleranceExp, true, SOME(st), NONE, msg);
(cache,Values.STRING(method_str),SOME(st)) = Ceval.ceval(cache,env, method, true, SOME(st), NONE, msg);
(cache,Values.STRING(options_str),SOME(st)) = Ceval.ceval(cache,env, options, true, SOME(st), NONE, msg);
starttime_r = Values.valueReal(starttime_v);
stoptime_r = Values.valueReal(stoptime_v);
starttime_r = ValuesUtil.valueReal(starttime_v);
stoptime_r = ValuesUtil.valueReal(stoptime_v);
interval_r = intReal(interval_i);
tolerance_r = Values.valueReal(tolerance_v);
tolerance_r = ValuesUtil.valueReal(tolerance_v);
init_filename = Util.stringAppendList({prefix_str,"_init.txt"});
then
(cache,init_filename,starttime_r,stoptime_r,interval_r,tolerance_r,method_str,options_str);
Expand Down Expand Up @@ -4002,7 +4003,7 @@ algorithm ostring := matchcontinue( e1)
String ret;
equation
(_,val,_) = Ceval.ceval(Env.emptyCache(),Env.emptyEnv, e1,true,NONE,NONE,Ceval.MSG());
ret = Values.printValStr(val);
ret = ValuesUtil.printValStr(val);
then
ret;

Expand Down
3 changes: 2 additions & 1 deletion Compiler/CevalScript_stub.mo
Expand Up @@ -79,6 +79,7 @@ protected import Print;
protected import System;
protected import Error;
protected import Static;
protected import ValuesUtil;

public function cevalInteractiveFunctions
"function cevalInteractiveFunctions
Expand Down Expand Up @@ -653,7 +654,7 @@ algorithm ostring := matchcontinue( e1)
String ret;
equation
(_,val,_) = Ceval.ceval(Env.emptyCache,Env.emptyEnv, e1,true,NONE,NONE,Ceval.MSG());
ret = Values.printValStr(val);
ret = ValuesUtil.printValStr(val);
then
ret;

Expand Down
9 changes: 5 additions & 4 deletions Compiler/Cevalfunc.mo
Expand Up @@ -30,6 +30,7 @@ protected import Static;
protected import Inst;
protected import InstanceHierarchy;
protected import UnitAbsyn;
protected import ValuesUtil;

protected constant String forScopeName="$for loop scope$";

Expand Down Expand Up @@ -669,16 +670,16 @@ algorithm oenv:= matchcontinue(env,varName,statements,start,step,stop)
Env.Env env1,env2,env3;
case(env,varName,statements,start,step,stop)
equation
true = Values.safeLessEq(start,stop);
true = ValuesUtil.safeLessEq(start,stop);
env1 = setValue(start,env,Absyn.CREF(Absyn.CREF_IDENT(varName,{})));
env2 = evaluateConditionalStatement2(statements,env1);
newVal = Values.safeIntRealOp(start,step,Values.ADDOP);
newVal = ValuesUtil.safeIntRealOp(start,step,Values.ADDOP);
env3 = evaluateForLoopRange(env2,varName,statements,newVal,step,stop);
then
env3;
case(env,_,_,start,step,stop)
equation
false = Values.safeLessEq(start,stop);
false = ValuesUtil.safeLessEq(start,stop);
then env;
end matchcontinue;
end evaluateForLoopRange;
Expand Down Expand Up @@ -1115,7 +1116,7 @@ algorithm oval := matchcontinue(inType)
Integer idx;
Absyn.Path path;
list<String> names;
then Values.ENUM(Exp.CREF_IDENT("",Exp.ENUMERATION(SOME(idx),path,names,{}),{}),0);
then Values.ENUM(idx,path,names);
// then Values.ENUM(Exp.CREF_IDENT("",Exp.ENUM(),{}),0);
// case((Types.T_ENUM,_)) then Values.ENUM(Exp.CREF_IDENT("",Exp.ENUM(),{}),0);
case((Types.T_COMPLEX(ClassInf.RECORD(str), typesVar,_,_),_))
Expand Down

0 comments on commit 2392e33

Please sign in to comment.