Skip to content

Commit

Permalink
- Enable error messages for cevalCallFunction again
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@6259 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Sep 30, 2010
1 parent a895033 commit e2be88a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
39 changes: 13 additions & 26 deletions Compiler/Ceval.mo
Expand Up @@ -91,7 +91,6 @@ protected import Cevalfunc;
protected import InnerOuter;
protected import Prefix;
protected import Connect;
protected import ErrorExt;
protected import OptManager;

public function ceval "
Expand Down Expand Up @@ -146,6 +145,7 @@ algorithm
Exp.Exp expExp;
list<Integer> dims;
list<DAE.Dimension> arrayDims;
DAE.ComponentRef cr;

/* uncomment for debugging
case (cache,env,inExp,_,st,_,_)
Expand Down Expand Up @@ -230,21 +230,17 @@ algorithm
(cache,Values.LIST(es_1),st);

// MetaModelica Partial Function. sjoelund
case (cache,env,DAE.CREF(componentRef = c, ty = DAE.ET_FUNCTION_REFERENCE_VAR()),impl,st,_,msg)
local
DAE.ComponentRef c;
case (cache,env,DAE.CREF(componentRef = cr, ty = DAE.ET_FUNCTION_REFERENCE_VAR()),impl,st,_,MSG())
equation
print(" metamodelica non implemented\n");
Debug.fprintln("failtrace", "Ceval.ceval not working for function references");
str = Exp.crefStr(cr);
Error.addMessage(Error.META_CEVAL_FUNCTION_REFERENCE, {str});
then
fail();

case (cache,env,DAE.CREF(componentRef = c, ty = DAE.ET_FUNCTION_REFERENCE_FUNC(builtin = _)),impl,st,_,msg)
local
DAE.ComponentRef c;
case (cache,env,DAE.CREF(componentRef = cr, ty = DAE.ET_FUNCTION_REFERENCE_FUNC(builtin = _)),impl,st,_,MSG())
equation
print(" metamodelica non implemented\n");
Debug.fprintln("failtrace", "Ceval.ceval not working for function references");
str = Exp.crefStr(cr);
Error.addMessage(Error.META_CEVAL_FUNCTION_REFERENCE, {str});
then
fail();

Expand Down Expand Up @@ -277,20 +273,18 @@ algorithm
(cache,vallst) = cevalList(cache, env, expl, impl, st, msg);
then (cache,Values.TUPLE(vallst),st);

case (cache,env,DAE.CREF(componentRef = c),(impl as false),SOME(st),_,msg)
case (cache,env,DAE.CREF(componentRef = cr),(impl as false),SOME(st),_,msg)
local
DAE.ComponentRef c;
Interactive.InteractiveSymbolTable st;
equation
(cache,v) = cevalCref(cache,env, c, false, msg) "When in interactive mode, always evalutate crefs, i.e non-implicit mode.." ;
(cache,v) = cevalCref(cache,env, cr, false, msg) "When in interactive mode, always evalutate crefs, i.e non-implicit mode.." ;
//Debug.traceln("cevalCref cr: " +& Exp.printComponentRefStr(c) +& " in s: " +& Env.printEnvPathStr(env) +& " v:" +& ValuesUtil.valString(v));
then
(cache,v,SOME(st));

case (cache,env,DAE.CREF(componentRef = c),impl,st,_,msg)
local DAE.ComponentRef c;
case (cache,env,DAE.CREF(componentRef = cr),impl,st,_,msg)
equation
(cache,v) = cevalCref(cache,env, c, impl, msg);
(cache,v) = cevalCref(cache,env, cr, impl, msg);
//Debug.traceln("cevalCref cr: " +& Exp.printComponentRefStr(c) +& " in s: " +& Env.printEnvPathStr(env) +& " v:" +& ValuesUtil.valString(v));
then
(cache,v,st);
Expand All @@ -307,20 +301,14 @@ algorithm
// Call functions FIXME: functions are always generated. Put back the check
// and write another rule for the false case that generates the function
equation
ErrorExt.setCheckpoint("cevalCall");
// do not handle Connection.isRoot here!
false = stringEqual("Connection.isRoot", Absyn.pathString(funcpath));
// do not roll back errors generated by evaluating the arguments
(cache,vallst) = cevalList(cache,env, expl, impl, st, msg);
// do not handle Connection.isRoot here!
(cache,newval,st)= cevalCallFunction(cache, env, e, vallst, impl, st, dimOpt, msg);
ErrorExt.rollBack("cevalCall");
then
(cache,newval,st);

// make rollback for case above
case(_,_,DAE.CALL(path = funcpath,expLst = expl,builtin = builtin),_,_,_,_) equation
ErrorExt.rollBack("cevalCall");
then fail();

// Try Interactive functions last
case (cache,env,(e as DAE.CALL(path = _)),(impl as true),SOME(st),_,msg)
local
Expand Down Expand Up @@ -1478,7 +1466,6 @@ algorithm
Debug.fprint("failtrace", "- codegeneration is turned off. switch \"nogen\" flag off\n");
then
fail();

end matchcontinue;
end cevalCallFunction;

Expand Down
4 changes: 3 additions & 1 deletion Compiler/Error.mo
Expand Up @@ -265,6 +265,7 @@ public constant ErrorID META_MATCH_EQUATION_FORBIDDEN=5004;
public constant ErrorID META_UNIONTYPE_ALIAS_MODS=5005;
public constant ErrorID META_COMPLEX_TYPE_MOD=5006;
public constant ErrorID META_MATCHEXP_RESULT_NUM_ARGS=5007;
public constant ErrorID META_CEVAL_FUNCTION_REFERENCE=5008;

protected constant list<tuple<Integer, MessageType, Severity, String>> errorTable=
{(SYNTAX_ERROR,SYNTAX(),ERROR(),"Syntax error near: %s"),
Expand Down Expand Up @@ -598,7 +599,8 @@ protected constant list<tuple<Integer, MessageType, Severity, String>> errorTabl
(META_UNIONTYPE_ALIAS_MODS,TRANSLATION(),ERROR(),"Uniontype was not generated correctly. One possible cause is modifications, which are not allowed."),
(META_COMPLEX_TYPE_MOD,TRANSLATION(),ERROR(),"MetaModelica complex types may not have modifiers."),
(META_MATCHEXP_RESULT_NUM_ARGS,TRANSLATION(),ERROR(),"Match expression has mismatched number of expected (%s) and actual (%s) outputs. The expressions were %s and %s."),
(GENERATECODE_INVARS_HAS_FUNCTION_PTR,SYMBOLIC(),ERROR(),"%s has a function pointer as input. OpenModelica does not support this feature in the interactive environment. Suggested workaround: Call this function with the arguments you want from another function (that does not have function pointer input). Then call that function from the interactive environment instead.")
(GENERATECODE_INVARS_HAS_FUNCTION_PTR,SYMBOLIC(),ERROR(),"%s has a function pointer as input. OpenModelica does not support this feature in the interactive environment. Suggested workaround: Call this function with the arguments you want from another function (that does not have function pointer input). Then call that function from the interactive environment instead."),
(META_CEVAL_FUNCTION_REFERENCE,TRANSLATION(),ERROR(),"Cannot evaluate function pointers (got %s).")

};

Expand Down

0 comments on commit e2be88a

Please sign in to comment.