From d9d4df52a193236dba186dcfd72c5a2a5683ff1b Mon Sep 17 00:00:00 2001 From: Adrian Pop Date: Wed, 8 Feb 2017 18:33:32 +0100 Subject: [PATCH] fixes for ticket:4248 - properly revert flag Flags.CHECK_MODEL to the previous state --- Compiler/Script/CevalScript.mo | 21 ++++++++--------- Compiler/Script/Interactive.mo | 41 +++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/Compiler/Script/CevalScript.mo b/Compiler/Script/CevalScript.mo index 14c26d282c9..4063ab4fe0f 100644 --- a/Compiler/Script/CevalScript.mo +++ b/Compiler/Script/CevalScript.mo @@ -1700,17 +1700,18 @@ end getVariableNames; public function getPackageVersion input Absyn.Path path; input Absyn.Program p; - output String version; + output String version = ""; +protected + Boolean evalParamAnn; algorithm - version := matchcontinue (path,p) - case (_,_) - equation - Config.setEvaluateParametersInAnnotations(true); - Absyn.STRING(version) = Interactive.getNamedAnnotation(path, p, Absyn.IDENT("version"), SOME(Absyn.STRING("")), Interactive.getAnnotationExp); - Config.setEvaluateParametersInAnnotations(false); - then version; - else ""; - end matchcontinue; + evalParamAnn := Config.getEvaluateParametersInAnnotations(); + Config.setEvaluateParametersInAnnotations(true); + try + Absyn.STRING(version) := Interactive.getNamedAnnotation(path, p, Absyn.IDENT("version"), SOME(Absyn.STRING("")), Interactive.getAnnotationExp); + else + version := ""; + end try; + Config.setEvaluateParametersInAnnotations(evalParamAnn); end getPackageVersion; protected function errorToValue diff --git a/Compiler/Script/Interactive.mo b/Compiler/Script/Interactive.mo index 88f2bf92b18..84184d67e98 100644 --- a/Compiler/Script/Interactive.mo +++ b/Compiler/Script/Interactive.mo @@ -1004,7 +1004,7 @@ protected Absyn.Class cls; list lf; Absyn.Modification mod; - Boolean finalPrefix, flowPrefix, streamPrefix, protected_, repl, dref1, dref2; + Boolean finalPrefix, flowPrefix, streamPrefix, protected_, repl, dref1, dref2, evalParamAnn; Boolean addFunctions; FCore.Graph env; Absyn.Exp exp; @@ -1126,9 +1126,10 @@ algorithm algorithm {Absyn.CREF(componentRef = cr)} := args; ErrorExt.setCheckpoint("getComponentAnnotations"); + evalParamAnn := Config.getEvaluateParametersInAnnotations(); Config.setEvaluateParametersInAnnotations(true); outResult := getComponentAnnotations(cr, p); - Config.setEvaluateParametersInAnnotations(false); + Config.setEvaluateParametersInAnnotations(evalParamAnn); ErrorExt.rollBack("getComponentAnnotations"); then outResult; @@ -1137,9 +1138,10 @@ algorithm algorithm {Absyn.CREF(componentRef = cr), Absyn.INTEGER(value = n)} := args; ErrorExt.setCheckpoint("getNthComponentAnnotation"); + evalParamAnn := Config.getEvaluateParametersInAnnotations(); Config.setEvaluateParametersInAnnotations(true); outResult := getNthComponentAnnotation(cr, p, n); - Config.setEvaluateParametersInAnnotations(false); + Config.setEvaluateParametersInAnnotations(evalParamAnn); ErrorExt.rollBack("getNthComponentAnnotation"); then outResult; @@ -1226,9 +1228,10 @@ algorithm {Absyn.CREF(componentRef = cr), Absyn.INTEGER(value = n)} := args; ErrorExt.setCheckpoint("getNthConnectionAnnotation"); path := Absyn.crefToPath(cr); + evalParamAnn := Config.getEvaluateParametersInAnnotations(); Config.setEvaluateParametersInAnnotations(true); outResult := getNthConnectionAnnotation(path, p, n); - Config.setEvaluateParametersInAnnotations(false); + Config.setEvaluateParametersInAnnotations(evalParamAnn); ErrorExt.rollBack("getNthConnectionAnnotation"); then outResult; @@ -1249,9 +1252,10 @@ algorithm algorithm {Absyn.CREF(componentRef = cr), Absyn.INTEGER(value = n)} := args; ErrorExt.setCheckpoint("getNthConnectorIconAnnotation"); + evalParamAnn := Config.getEvaluateParametersInAnnotations(); Config.setEvaluateParametersInAnnotations(true); outResult := getNthConnectorIconAnnotation(Absyn.crefToPath(cr), p, n); - Config.setEvaluateParametersInAnnotations(false); + Config.setEvaluateParametersInAnnotations(evalParamAnn); ErrorExt.rollBack("getNthConnectorIconAnnotation"); then outResult; @@ -1260,9 +1264,10 @@ algorithm algorithm {Absyn.CREF(componentRef = cr)} := args; ErrorExt.setCheckpoint("getIconAnnotation"); + evalParamAnn := Config.getEvaluateParametersInAnnotations(); Config.setEvaluateParametersInAnnotations(true); outResult := getIconAnnotation(Absyn.crefToPath(cr), p); - Config.setEvaluateParametersInAnnotations(false); + Config.setEvaluateParametersInAnnotations(evalParamAnn); ErrorExt.rollBack("getIconAnnotation"); then outResult; @@ -1271,9 +1276,10 @@ algorithm algorithm {Absyn.CREF(componentRef = cr)} := args; ErrorExt.setCheckpoint("getDiagramAnnotation"); + evalParamAnn := Config.getEvaluateParametersInAnnotations(); Config.setEvaluateParametersInAnnotations(true); outResult := getDiagramAnnotation(Absyn.crefToPath(cr), p); - Config.setEvaluateParametersInAnnotations(false); + Config.setEvaluateParametersInAnnotations(evalParamAnn); ErrorExt.rollBack("getDiagramAnnotation"); then outResult; @@ -1282,9 +1288,10 @@ algorithm algorithm {Absyn.CREF(componentRef = cr), Absyn.INTEGER(value = n)} := args; ErrorExt.setCheckpoint("getNthInheritedClassIconMapAnnotation"); + evalParamAnn := Config.getEvaluateParametersInAnnotations(); Config.setEvaluateParametersInAnnotations(true); outResult := getNthInheritedClassMapAnnotation(Absyn.crefToPath(cr), n, p, "IconMap"); - Config.setEvaluateParametersInAnnotations(false); + Config.setEvaluateParametersInAnnotations(evalParamAnn); ErrorExt.rollBack("getNthInheritedClassIconMapAnnotation"); then outResult; @@ -1293,9 +1300,10 @@ algorithm algorithm {Absyn.CREF(componentRef = cr), Absyn.INTEGER(value = n)} := args; ErrorExt.setCheckpoint("getNthInheritedClassDiagramMapAnnotation"); + evalParamAnn := Config.getEvaluateParametersInAnnotations(); Config.setEvaluateParametersInAnnotations(true); outResult := getNthInheritedClassMapAnnotation(Absyn.crefToPath(cr), n, p, "DiagramMap"); - Config.setEvaluateParametersInAnnotations(false); + Config.setEvaluateParametersInAnnotations(evalParamAnn); ErrorExt.rollBack("getNthInheritedClassDiagramMapAnnotation"); then outResult; @@ -1305,10 +1313,11 @@ algorithm {Absyn.CREF(componentRef = cr), Absyn.CREF(componentRef = Absyn.CREF_IDENT(name, {}))} := args; ErrorExt.setCheckpoint("getNamedAnnotation"); + evalParamAnn := Config.getEvaluateParametersInAnnotations(); Config.setEvaluateParametersInAnnotations(true); outResult := getNamedAnnotation(Absyn.crefToPath(cr), p, Absyn.IDENT(name), SOME("{}"), getAnnotationValue); - Config.setEvaluateParametersInAnnotations(false); + Config.setEvaluateParametersInAnnotations(evalParamAnn); ErrorExt.rollBack("getNamedAnnotation"); then outResult; @@ -13752,7 +13761,7 @@ protected function buildEnvForGraphicProgramFull output FCore.Graph outEnv; output Absyn.Program outProgram; protected - Boolean check_model, eval_param; + Boolean check_model, eval_param, failed = false; Absyn.Program graphic_program; SCode.Program scode_program; algorithm @@ -13765,11 +13774,17 @@ algorithm Flags.setConfigBool(Flags.CHECK_MODEL, true); Config.setEvaluateParametersInAnnotations(true); - (outCache, outEnv) := Inst.instantiateClass(FCore.emptyCache(), - InnerOuter.emptyInstHierarchy, scode_program, inModelPath); + try + (outCache, outEnv) := Inst.instantiateClass(FCore.emptyCache(), InnerOuter.emptyInstHierarchy, scode_program, inModelPath); + else + failed := true; + end try; Config.setEvaluateParametersInAnnotations(eval_param); Flags.setConfigBool(Flags.CHECK_MODEL, check_model); + if failed then + fail(); + end if; end buildEnvForGraphicProgramFull; protected function getAnnotationString