Skip to content

Commit

Permalink
- val() is now part of the builtin environment
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7844 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Feb 2, 2011
1 parent 5d8d0ec commit 2d7a8ce
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/Inst.mo
Expand Up @@ -1290,7 +1290,7 @@ algorithm
then Util.assoc(name,{
("TypeName",(DAE.T_CODE(DAE.C_TYPENAME()),NONE())),
("VariableName",(DAE.T_CODE(DAE.C_VARIABLENAME()),NONE()))
});
});
case (ty,false) then ty;
case (ty,true) then Types.makeFunctionPolymorphicReference(ty);
end matchcontinue;
Expand Down
18 changes: 18 additions & 0 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -857,6 +857,12 @@ function readSimulationResultSize
external "builtin";
end readSimulationResultSize;

function codeToString
input Code className;
output String string;
external "builtin";
end codeToString;

function dumpXMLDAE
input TypeName className;
input String translationLevel := "flat";
Expand All @@ -870,5 +876,17 @@ function dumpXMLDAE
external "builtin";
end dumpXMLDAE;

function listVariables
output TypeName variables[:];
external "builtin";
end listVariables;

function val
input VariableName exp;
input Real time;
output Real valAtTime;
external "builtin";
end val;

end Scripting;
end OpenModelica;
15 changes: 2 additions & 13 deletions Compiler/FrontEnd/Static.mo
Expand Up @@ -7120,15 +7120,6 @@ protected function elabCallInteractive "function: elabCallInteractive
(cache,Expression.makeBuiltinCall("plot",{DAE.ARRAY(DAE.ET_OTHER(),false,vars_1), interpolation, title, legend, grid, logX, logY, xLabel, yLabel, points, xRange, yRange},
DAE.ET_BOOL()),DAE.PROP(DAE.T_BOOL_DEFAULT,DAE.C_VAR()),SOME(st));

case (cache,env,Absyn.CREF_IDENT(name = "val"),{e1,e2},{},impl,SOME(st),pre,_)
equation
{e1_1} = elabVariablenames({e1});
(cache,e2_1,ptop,st_1) = elabExp(cache, env, e2, false, SOME(st),true,pre,info);
Types.integerOrReal(Types.arrayElementType(Types.getPropType(ptop)));
then
(cache,Expression.makeBuiltinCall("val",{e1_1,e2_1},
DAE.ET_REAL()),DAE.PROP(DAE.T_REAL_DEFAULT,DAE.C_VAR()),SOME(st));

case (cache,env,Absyn.CREF_IDENT(name = "plotParametric2"),vars,{},impl,SOME(st),_,_) /* PlotParametric is similar to plot but does not allow a single CREF as an
argument as you are plotting at least one variable as a function of another.
Thus, plotParametric has to take an array as an argument, or two componentRefs. */
Expand Down Expand Up @@ -7260,10 +7251,6 @@ protected function elabCallInteractive "function: elabCallInteractive
then
(cache,Expression.makeBuiltinCall("timing",{exp_1},DAE.ET_REAL()),DAE.PROP(DAE.T_REAL_DEFAULT,DAE.C_VAR()),st_1);

case (cache,env,Absyn.CREF_IDENT(name = "listVariables"),{},{},impl,SOME(st),_,_)
then (cache, Expression.makeBuiltinCall("listVariables",{},DAE.ET_OTHER()),
DAE.PROP((DAE.T_ARRAY(DAE.DIM_UNKNOWN(),(DAE.T_NOTYPE(),NONE())),NONE()),DAE.C_VAR()),SOME(st)); /* Returns an array of \"component references\" */

case (cache,env,Absyn.CREF_IDENT(name = "getUnit"),{Absyn.CREF(componentRef = cr),Absyn.CREF(componentRef = cr2)},{},impl,SOME(st),pre,_)
equation
(cache,cr_1) = elabUntypedCref(cache,env,cr,impl,pre,info);
Expand Down Expand Up @@ -13279,6 +13266,8 @@ algorithm
then DAE.CODE(Absyn.C_TYPENAME(path),DAE.ET_OTHER());
case (Absyn.CREF(componentRef=cr),DAE.C_VARIABLENAME(),_)
then DAE.CODE(Absyn.C_VARIABLENAME(cr),DAE.ET_OTHER());
case (Absyn.CALL(Absyn.CREF_IDENT("der",{}),Absyn.FUNCTIONARGS(args={Absyn.CREF(componentRef=cr)},argNames={})),DAE.C_VARIABLENAME(),_)
then DAE.CODE(Absyn.C_EXPRESSION(exp),DAE.ET_OTHER());
case (exp,ct,info)
equation
s1 = Dump.printExpStr(exp);
Expand Down
6 changes: 6 additions & 0 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -662,6 +662,7 @@ algorithm
list<Real> timeStamps;
list<DAE.Exp> expLst;
list<tuple<String,list<String>>> deps;
Absyn.CodeNode codeNode;

/* Does not exist in the env...
case (cache,env,"lookupClass",{Values.CODE(Absyn.C_TYPENAME(path))},(st as Interactive.SYMBOLTABLE(ast = p)),msg)
Expand All @@ -679,6 +680,11 @@ algorithm
then
(cache,Values.STRING(str),st);
*/

case (cache,env,"codeToString",{Values.CODE(codeNode)},st,msg)
equation
str = Dump.printCodeStr(codeNode);
then (cache,Values.STRING(str),st);

case (cache,env,"typeOf",{Values.CODE(Absyn.C_VARIABLENAME(Absyn.CREF_IDENT(name = varid)))},(st as Interactive.SYMBOLTABLE(lstVarVal = iv)),msg)
equation
Expand Down

0 comments on commit 2d7a8ce

Please sign in to comment.