@@ -56,6 +56,7 @@ import NFTyping.ExpOrigin;
5656import SCode ;
5757import NFPrefixes.Variability ;
5858import EvalFunctionExt = NFEvalFunctionExt ;
59+ import NFCeval.EvalTarget ;
5960
6061encapsulated package ReplTree
6162 import BaseAvlTree ;
@@ -163,7 +164,7 @@ algorithm
163164
164165 if lang == "builtin" then
165166 // Functions defined as 'external "builtin"', delegate to Ceval.
166- result := Ceval . evalBuiltinCall(fn, args, NFCeval . EvalTarget . IGNORE_ERRORS ());
167+ result := Ceval . evalBuiltinCall(fn, args, EvalTarget . IGNORE_ERRORS ());
167168 elseif isKnownExternalFunc(name, ann) then
168169 // External functions that we know how to evaluate without generating code.
169170 // TODO: Move this to EvalFunctionExt and unify evaluateKnownExternal and
@@ -491,11 +492,11 @@ algorithm
491492 // adrpo: we really need some error handling here to detect which statement cannot be evaluated
492493 // try
493494 ctrl := match stmt
494- case Statement . ASSIGNMENT () then evaluateAssignment(stmt. lhs, stmt. rhs);
495+ case Statement . ASSIGNMENT () then evaluateAssignment(stmt. lhs, stmt. rhs, stmt . source );
495496 case Statement . FOR () then evaluateFor(stmt. iterator, stmt. range, stmt. body, stmt. source);
496- case Statement . IF () then evaluateIf(stmt. branches);
497+ case Statement . IF () then evaluateIf(stmt. branches, stmt . source );
497498 case Statement . ASSERT () then evaluateAssert(stmt. condition, stmt);
498- case Statement . NORETCALL () then evaluateNoRetCall(stmt. exp);
499+ case Statement . NORETCALL () then evaluateNoRetCall(stmt. exp, stmt . source );
499500 case Statement . WHILE () then evaluateWhile(stmt. condition, stmt. body, stmt. source);
500501 case Statement . RETURN () then FlowControl . RETURN ;
501502 case Statement . BREAK () then FlowControl . BREAK ;
@@ -515,9 +516,10 @@ end evaluateStatement;
515516function evaluateAssignment
516517 input Expression lhsExp;
517518 input Expression rhsExp;
519+ input DAE . ElementSource source;
518520 output FlowControl ctrl = FlowControl . NEXT ;
519521algorithm
520- assignVariable(lhsExp, Ceval . evalExp(rhsExp));
522+ assignVariable(lhsExp, Ceval . evalExp(rhsExp, EvalTarget . STATEMENT (source) ));
521523end evaluateAssignment;
522524
523525public
@@ -715,7 +717,7 @@ protected
715717 list< Statement > body = forBody;
716718 Integer i = 0 , limit = Flags . getConfigInt(Flags . EVAL_LOOP_LIMIT );
717719algorithm
718- range_exp := Ceval . evalExp(Util . getOption(range));
720+ range_exp := Ceval . evalExp(Util . getOption(range), EvalTarget . STATEMENT (source) );
719721 range_iter := RangeIterator . fromExp(range_exp);
720722
721723 if RangeIterator . hasNext(range_iter) then
@@ -748,6 +750,7 @@ end evaluateFor;
748750
749751function evaluateIf
750752 input list< tuple< Expression , list< Statement >>> branches;
753+ input DAE . ElementSource source;
751754 output FlowControl ctrl;
752755protected
753756 Expression cond;
@@ -756,7 +759,7 @@ algorithm
756759 for branch in branches loop
757760 (cond, body) := branch;
758761
759- if Expression . isTrue(Ceval . evalExp(cond)) then
762+ if Expression . isTrue(Ceval . evalExp(cond, EvalTarget . STATEMENT (source) )) then
760763 ctrl := evaluateStatements(body);
761764 return ;
762765 end if ;
@@ -770,13 +773,14 @@ function evaluateAssert
770773 input Statement assertStmt;
771774 output FlowControl ctrl = FlowControl . NEXT ;
772775protected
773- Expression msg, lvl;
776+ Expression cond, msg, lvl;
774777 DAE . ElementSource source;
778+ EvalTarget target = EvalTarget . STATEMENT (Statement . source(assertStmt));
775779algorithm
776- if Expression . isFalse(Ceval . evalExp(condition)) then
780+ if Expression . isFalse(Ceval . evalExp(condition, target )) then
777781 Statement . ASSERT (message = msg, level = lvl, source = source) := assertStmt;
778- msg := Ceval . evalExp(msg);
779- lvl := Ceval . evalExp(lvl);
782+ msg := Ceval . evalExp(msg, target );
783+ lvl := Ceval . evalExp(lvl, target );
780784
781785 () := match (msg, lvl)
782786 case (Expression . STRING (), Expression . ENUM_LITERAL (name = "warning" ))
@@ -804,9 +808,10 @@ end evaluateAssert;
804808
805809function evaluateNoRetCall
806810 input Expression callExp;
811+ input DAE . ElementSource source;
807812 output FlowControl ctrl = FlowControl . NEXT ;
808813algorithm
809- Ceval . evalExp(callExp);
814+ Ceval . evalExp(callExp, EvalTarget . STATEMENT (source) );
810815end evaluateNoRetCall;
811816
812817function evaluateWhile
@@ -816,8 +821,9 @@ function evaluateWhile
816821 output FlowControl ctrl = FlowControl . NEXT ;
817822protected
818823 Integer i = 0 , limit = Flags . getConfigInt(Flags . EVAL_LOOP_LIMIT );
824+ EvalTarget target = EvalTarget . STATEMENT (source);
819825algorithm
820- while Expression . isTrue(Ceval . evalExp(condition)) loop
826+ while Expression . isTrue(Ceval . evalExp(condition, target )) loop
821827 ctrl := evaluateStatements(body);
822828
823829 if ctrl <> FlowControl . NEXT then
0 commit comments