Skip to content

Commit

Permalink
Remove some error-messages when viewing icons
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Feb 10, 2017
1 parent e53eddf commit ed7a5af
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
10 changes: 7 additions & 3 deletions Compiler/FrontEnd/Inst.mo
Expand Up @@ -342,7 +342,9 @@ algorithm
stackOverflow = setStackOverflowSignal(false);

cname_str = Absyn.pathString(path) + (if stackOverflow then ". The compiler got into Stack Overflow!" else "");
Error.addMessage(Error.ERROR_FLATTENING, {cname_str});
if not Config.getGraphicsExpMode() then
Error.addMessage(Error.ERROR_FLATTENING, {cname_str});
end if;

// let the GC collect these as they are used only by Inst!
releaseInstHashTable();
Expand Down Expand Up @@ -418,6 +420,7 @@ algorithm
(cache,env_2,ih,dae);

case (_,_,_,path) /* error instantiating */
guard not Config.getGraphicsExpMode()
equation
cname_str = Absyn.pathString(path);
//print(" Error flattening partial, errors: " + ErrorExt.printMessagesStr() + "\n");
Expand Down Expand Up @@ -600,7 +603,6 @@ algorithm

ci_state = ClassInf.start(r,FGraph.getGraphName(env_1));
csets = ConnectUtil.newSet(pre, inSets);

(cache,env_3,ih,store,dae1,csets,ci_state_1,tys,bc_ty,oDA,equalityConstraint, graph)
= instClassIn(cache, env_1, ih, store, mod, pre, ci_state, c, SCode.PUBLIC(), inst_dims, impl, callscope, graph, csets, NONE());
csets = ConnectUtil.addSet(inSets, csets);
Expand Down Expand Up @@ -631,7 +633,9 @@ algorithm
// Classes with the keyword partial can not be instantiated. They can only be inherited
case (cache,_,_,_,_,_,SCode.CLASS(name = n,partialPrefix = SCode.PARTIAL(), info = info),_,(false),_,_,_)
equation
Error.addSourceMessage(Error.INST_PARTIAL_CLASS, {n}, info);
if not Config.getGraphicsExpMode() then
Error.addSourceMessage(Error.INST_PARTIAL_CLASS, {n}, info);
end if;
then
fail();

Expand Down
12 changes: 7 additions & 5 deletions Compiler/FrontEnd/InstUtil.mo
Expand Up @@ -6808,12 +6808,14 @@ algorithm

outIsConditional := match(val)
case Values.BOOL(b) then b;
case Values.EMPTY(__) // Print an error if the expression has no value.
case Values.EMPTY() // Print an error if the expression has no value.
equation
Error.addSourceMessage(Error.CONDITIONAL_EXP_WITHOUT_VALUE,
{Dump.printExpStr(inCondition)}, inInfo);
then
fail();
if not Config.getGraphicsExpMode() then
Error.addSourceMessage(Error.CONDITIONAL_EXP_WITHOUT_VALUE,
{Dump.printExpStr(inCondition)}, inInfo);
fail();
end if;
then true; // Randomly pick a default for graphics mode...
else
equation
Error.addInternalError("InstUtil.instConditionalDeclaration got unexpected value " + ValuesUtil.valString(val), sourceInfo());
Expand Down
2 changes: 2 additions & 0 deletions Compiler/FrontEnd/Lookup.mo
Expand Up @@ -1299,6 +1299,8 @@ algorithm
then
(cache,attr,ty,binding,cnstForRange,splicedExpData,classEnv,componentEnv,name);

case (cache,env,cref) guard Config.getGraphicsExpMode() then (cache,DAE.dummyAttrConst,DAE.T_UNKNOWN_DEFAULT,DAE.UNBOUND(),NONE(),InstTypes.SPLICEDEXPDATA(NONE(),DAE.T_UNKNOWN_DEFAULT),env,env,"#varNotFound#");

/*/ fail if we couldn't find it
case (_,env,cref)
equation
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/Static.mo
Expand Up @@ -11879,7 +11879,7 @@ algorithm
end if;

// If the types are not matching, print an error and fail.
if not ty_match then
if (not ty_match) and not Config.getGraphicsExpMode() then
e1_str := ExpressionDump.printExpStr(inTrueBranch);
e2_str := ExpressionDump.printExpStr(inFalseBranch);
ty1_str := Types.unparseTypeNoAttr(true_ty);
Expand Down
14 changes: 12 additions & 2 deletions Compiler/Script/Interactive.mo
Expand Up @@ -13762,7 +13762,7 @@ protected function buildEnvForGraphicProgramFull
output FCore.Graph outEnv;
output Absyn.Program outProgram;
protected
Boolean check_model, eval_param, failed = false;
Boolean check_model, eval_param, failed = false, graphics_mode;
Absyn.Program graphic_program;
SCode.Program scode_program;
algorithm
Expand All @@ -13772,8 +13772,10 @@ algorithm

check_model := Flags.getConfigBool(Flags.CHECK_MODEL);
eval_param := Config.getEvaluateParametersInAnnotations();
graphics_mode := Config.getGraphicsExpMode();
Flags.setConfigBool(Flags.CHECK_MODEL, true);
Config.setEvaluateParametersInAnnotations(true);
Config.setGraphicsExpMode(true);

try
(outCache, outEnv) := Inst.instantiateClass(FCore.emptyCache(), InnerOuter.emptyInstHierarchy, scode_program, inModelPath);
Expand All @@ -13783,6 +13785,7 @@ algorithm

Config.setEvaluateParametersInAnnotations(eval_param);
Flags.setConfigBool(Flags.CHECK_MODEL, check_model);
Config.setGraphicsExpMode(graphics_mode);
if failed then
fail();
end if;
Expand Down Expand Up @@ -13821,10 +13824,17 @@ algorithm
algorithm
is_icon := ann_name == "Icon";
is_diagram := ann_name == "Diagram";
(stripped_mod, graphic_mod) := stripGraphicsAndInteractionModification(mod);

(stripped_mod, graphic_mod) := stripGraphicsAndInteractionModification(mod);
ErrorExt.setCheckpoint("buildEnvForGraphicProgram");
try
(cache, env, graphic_prog) :=
buildEnvForGraphicProgram(GRAPHIC_ENV_NO_CACHE(inFullProgram, inModelPath), mod);
else
ErrorExt.delCheckpoint("buildEnvForGraphicProgram");
fail();
end try;
ErrorExt.rollBack("buildEnvForGraphicProgram");

smod := SCodeUtil.translateMod(SOME(Absyn.CLASSMOD(stripped_mod, Absyn.NOMOD())),
SCode.NOT_FINAL(), SCode.NOT_EACH(), info);
Expand Down

0 comments on commit ed7a5af

Please sign in to comment.