From d43df4ddab6bf405288a8b3f7d58f97dcfc5717b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sj=C3=B6lund?= Date: Tue, 15 Jan 2013 10:19:30 +0000 Subject: [PATCH] - Make the filename prefix of the simulate commands be the actual class if using reflections git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14782 f25d12d1-65f4-0310-ae8a-bbce733d8d8e --- Compiler/BackEnd/SimCodeMain.mo | 1 - Compiler/FrontEnd/Static.mo | 2 +- Compiler/Script/CevalScript.mo | 2 +- Compiler/Script/StaticScript.mo | 18 ++++++++++++------ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Compiler/BackEnd/SimCodeMain.mo b/Compiler/BackEnd/SimCodeMain.mo index 00135d0cd3e..7f0ebcbea59 100644 --- a/Compiler/BackEnd/SimCodeMain.mo +++ b/Compiler/BackEnd/SimCodeMain.mo @@ -541,7 +541,6 @@ algorithm equation // calculate stuff that we need to create SimCode data structure System.realtimeTick(CevalScript.RT_CLOCK_FRONTEND); - //(cache,Values.STRING(filenameprefix),SOME(_)) = Ceval.ceval(cache,env, fileprefix, true, SOME(st),NONE(), msg); (cache,env,dae,st) = CevalScript.runFrontEnd(cache,env,className,st,false); timeFrontend = System.realtimeTock(CevalScript.RT_CLOCK_FRONTEND); System.realtimeTick(CevalScript.RT_CLOCK_BACKEND); diff --git a/Compiler/FrontEnd/Static.mo b/Compiler/FrontEnd/Static.mo index aeda895f8eb..e495694c362 100644 --- a/Compiler/FrontEnd/Static.mo +++ b/Compiler/FrontEnd/Static.mo @@ -13935,7 +13935,7 @@ algorithm res := b and res; end slotAnd; -protected function elabCodeExp +public function elabCodeExp input Absyn.Exp exp; input Env.Cache cache; input Env.Env env; diff --git a/Compiler/Script/CevalScript.mo b/Compiler/Script/CevalScript.mo index 109ad90e6f0..67c2def5a4e 100644 --- a/Compiler/Script/CevalScript.mo +++ b/Compiler/Script/CevalScript.mo @@ -6449,7 +6449,7 @@ algorithm end matchcontinue; end unparseGroupImport; -protected function evalCodeTypeName +public function evalCodeTypeName input Values.Value val; input Env.Env env; output Values.Value res; diff --git a/Compiler/Script/StaticScript.mo b/Compiler/Script/StaticScript.mo index 01c503c9ed4..437bc87f115 100644 --- a/Compiler/Script/StaticScript.mo +++ b/Compiler/Script/StaticScript.mo @@ -9,6 +9,7 @@ public import Prefix; public type Ident = String; +protected import Ceval; protected import CevalScript; protected import ClassInf; protected import Debug; @@ -19,6 +20,7 @@ protected import ExpressionSimplify; protected import Flags; protected import Static; protected import Types; +protected import Values; protected function calculateSimulationTimes @@ -121,6 +123,7 @@ algorithm (outCache, outSimulationArguments) := match (inCache, inEnv, inAbsynExpLst, inAbsynNamedArgLst, inBoolean, inInteractiveInteractiveSymbolTableOption, inPrefix, inInfo) local + Absyn.Exp crexp; Absyn.ComponentRef cr; DAE.ComponentRef cr_1; list args; @@ -130,19 +133,22 @@ algorithm Absyn.Info info; String cname_str; Absyn.Path className; - DAE.Exp startTime,stopTime,numberOfIntervals,tolerance,method,cflags,simflags; + DAE.Exp exp,startTime,stopTime,numberOfIntervals,tolerance,method,cflags,simflags; DAE.Exp fileNamePrefix,storeInTemp,options,noClean,outputFormat,variableFilter,measureTime; CevalScript.SimulationOptions defaulSimOpt; Env.Cache cache; Env.Env env; + Values.Value v; // fill in defaults - case (cache,env,{Absyn.CREF(componentRef = cr)},args,impl,SOME(st),pre,info) + case (cache,env,{crexp},args,impl,SOME(st),pre,info) equation - (cache,cr_1) = Static.elabUntypedCref(cache,env,cr,impl,pre,info); - className = Static.componentRefToPath(cr_1) "this extracts the fileNamePrefix which is used when generating code and init-file" ; + exp = Static.elabCodeExp(crexp,cache,env,DAE.C_TYPENAME(),info); + // We need to force eval in order to get the correct prefix + (cache,v,SOME(st)) = Ceval.ceval(cache,env,exp,true,SOME(st),Ceval.MSG(info)); + Values.CODE(Absyn.C_TYPENAME(className)) = CevalScript.evalCodeTypeName(v,env); + cname_str = Absyn.pathString(Absyn.unqotePathIdents(className)) "easier than checking if the file system supports UTF-8..."; - defaulSimOpt = CevalScript.buildSimulationOptionsFromModelExperimentAnnotation(st, className, cname_str); (cache, startTime, stopTime, numberOfIntervals) = @@ -606,4 +612,4 @@ end elabGraphicsExp; -end StaticScript; \ No newline at end of file +end StaticScript;