diff --git a/OMCompiler/Compiler/FrontEnd/AbsynUtil.mo b/OMCompiler/Compiler/FrontEnd/AbsynUtil.mo index c1f0d88629e..8da618decf9 100644 --- a/OMCompiler/Compiler/FrontEnd/AbsynUtil.mo +++ b/OMCompiler/Compiler/FrontEnd/AbsynUtil.mo @@ -6111,5 +6111,25 @@ algorithm end match; end isElementRedeclare; +function isModel + input Absyn.Class cls; + output Boolean res; +algorithm + res := match cls + case Absyn.Class.CLASS(restriction = Absyn.Restriction.R_MODEL()) then true; + else false; + end match; +end isModel; + +function isBlock + input Absyn.Class cls; + output Boolean res; +algorithm + res := match cls + case Absyn.Class.CLASS(restriction = Absyn.Restriction.R_BLOCK()) then true; + else false; + end match; +end isBlock; + annotation(__OpenModelica_Interface="frontend"); end AbsynUtil; diff --git a/OMCompiler/Compiler/FrontEnd/ModelicaBuiltin.mo b/OMCompiler/Compiler/FrontEnd/ModelicaBuiltin.mo index 95ad6b30666..ec6db291a43 100644 --- a/OMCompiler/Compiler/FrontEnd/ModelicaBuiltin.mo +++ b/OMCompiler/Compiler/FrontEnd/ModelicaBuiltin.mo @@ -3890,7 +3890,7 @@ function isExperiment output Boolean res; external "builtin"; annotation(Documentation(info=" -
An experiment is defined as having annotation experiment(StopTime=...)
+An experiment is defined as a non-partial model or block having annotation experiment(StopTime=...)
")); end isExperiment; diff --git a/OMCompiler/Compiler/NFFrontEnd/NFModelicaBuiltin.mo b/OMCompiler/Compiler/NFFrontEnd/NFModelicaBuiltin.mo index dd271c88fe0..421ca0ebe78 100644 --- a/OMCompiler/Compiler/NFFrontEnd/NFModelicaBuiltin.mo +++ b/OMCompiler/Compiler/NFFrontEnd/NFModelicaBuiltin.mo @@ -4143,7 +4143,7 @@ function isExperiment output Boolean res; external "builtin"; annotation(Documentation(info=" -An experiment is defined as having annotation experiment(StopTime=...)
+An experiment is defined as a non-partial model or block having annotation experiment(StopTime=...)
")); end isExperiment; diff --git a/OMCompiler/Compiler/Script/CevalScriptBackend.mo b/OMCompiler/Compiler/Script/CevalScriptBackend.mo index 33efe9d0a8c..b711a7d7190 100644 --- a/OMCompiler/Compiler/Script/CevalScriptBackend.mo +++ b/OMCompiler/Compiler/Script/CevalScriptBackend.mo @@ -2149,13 +2149,7 @@ algorithm then Values.BOOL(false); case ("isExperiment",{Values.CODE(Absyn.C_TYPENAME(classpath))}) - equation - b = Interactive.getNamedAnnotation(classpath, SymbolTable.getAbsyn(), Absyn.IDENT("experiment"), SOME(false), hasStopTime); - then - Values.BOOL(b); - - case ("isExperiment",_) - then Values.BOOL(false); + then Values.BOOL(isExperiment(classpath, SymbolTable.getAbsyn())); case ("getInheritedClasses",{Values.CODE(Absyn.C_TYPENAME(classpath))}) equation @@ -7355,6 +7349,23 @@ algorithm end matchcontinue; end isShortDefinition; +protected function isExperiment + input Absyn.Path path; + input Absyn.Program program; + output Boolean res; +protected + Absyn.Class cdef; +algorithm + try + cdef := InteractiveUtil.getPathedClassInProgram(path, program); + false := AbsynUtil.isPartial(cdef); + true := AbsynUtil.isModel(cdef) or AbsynUtil.isBlock(cdef); + SOME(res) := AbsynUtil.getNamedAnnotationInClass(cdef, Absyn.Path.IDENT("experiment"), hasStopTime); + else + res := false; + end try; +end isExperiment; + protected function hasStopTime "For use with getNamedAnnotation" input Option