Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit aefe4fd

Browse files
runrevmarkpeter-b
authored andcommitted
[[ VarAccess ]] Remove 'evalvar()' method
This patch removes the 'evalvar()' virtual method from MCExpression replacing all uses with 'evalcontainer()'.
1 parent 50d9f62 commit aefe4fd

12 files changed

Lines changed: 284 additions & 416 deletions

engine/src/cmdsm.cpp

Lines changed: 39 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,8 @@ void MCAdd::exec_ctxt(MCExecContext &ctxt)
100100
MCContainer t_dst_container;
101101
if (destvar != nil)
102102
{
103-
bool t_success;
104-
if (destvar -> needsContainer())
105-
t_success = destvar -> evalcontainer(ctxt, t_dst_container)
106-
&& t_dst_container.eval_ctxt(ctxt, t_dst);
107-
else
108-
{
109-
destvar -> eval_ctxt(ctxt, t_dst);
110-
t_success = !ctxt . HasError();
111-
}
112-
113-
if (!t_success)
103+
if (!destvar->evalcontainer(ctxt, t_dst_container) ||
104+
!t_dst_container.eval_ctxt(ctxt, t_dst))
114105
{
115106
ctxt . LegacyThrow(EE_ADD_BADDEST);
116107
MCExecTypeRelease(t_src);
@@ -162,13 +153,7 @@ void MCAdd::exec_ctxt(MCExecContext &ctxt)
162153
{
163154
if (destvar != nil)
164155
{
165-
bool t_success;
166-
if (destvar -> needsContainer())
167-
t_success = t_dst_container.give_value(ctxt, t_result);
168-
else
169-
t_success = destvar -> give_value(ctxt, t_result);
170-
171-
if (!t_success)
156+
if (!t_dst_container.give_value(ctxt, t_result))
172157
ctxt . Throw();
173158
}
174159
else
@@ -257,22 +242,13 @@ void MCDivide::exec_ctxt(MCExecContext &ctxt)
257242
ctxt.LegacyThrow(EE_DIVIDE_BADSOURCE);
258243
return;
259244
}
260-
261-
MCExecValue t_dst;
262-
MCContainer t_dst_container;
263-
if (destvar != nil)
264-
{
265-
bool t_success;
266-
if (destvar -> needsContainer())
267-
t_success = destvar -> evalcontainer(ctxt, t_dst_container)
268-
&& t_dst_container.eval_ctxt(ctxt, t_dst);
269-
else
270-
{
271-
destvar -> eval_ctxt(ctxt, t_dst);
272-
t_success = !ctxt.HasError();
273-
}
274-
275-
if (!t_success)
245+
246+
MCExecValue t_dst;
247+
MCContainer t_dst_container;
248+
if (destvar != nil)
249+
{
250+
if (!destvar->evalcontainer(ctxt, t_dst_container) ||
251+
!t_dst_container.eval_ctxt(ctxt, t_dst))
276252
{
277253
ctxt . LegacyThrow(EE_DIVIDE_BADDEST);
278254
MCExecTypeRelease(t_src);
@@ -320,19 +296,12 @@ void MCDivide::exec_ctxt(MCExecContext &ctxt)
320296
MCExecTypeRelease(t_dst);
321297

322298
if (!ctxt . HasError())
323-
{
324-
if (destvar != nil)
325-
{
326-
bool t_success;
327-
328-
if (destvar -> needsContainer())
329-
t_success = t_dst_container.give_value(ctxt, t_result);
330-
else
331-
t_success = destvar -> give_value(ctxt, t_result);
332-
333-
if (!t_success)
299+
{
300+
if (destvar != nil)
301+
{
302+
if (!t_dst_container.give_value(ctxt, t_result))
334303
ctxt . Throw();
335-
}
304+
}
336305
else
337306
{
338307
if (dest->set(ctxt, PT_INTO, t_result))
@@ -423,22 +392,13 @@ void MCMultiply::exec_ctxt(MCExecContext &ctxt)
423392
ctxt.LegacyThrow(EE_MULTIPLY_BADSOURCE);
424393
return;
425394
}
426-
427-
MCExecValue t_dst;
428-
MCContainer t_dst_container;
429-
if (destvar != nil)
430-
{
431-
bool t_success;
432-
if (destvar -> needsContainer())
433-
t_success = destvar -> evalcontainer(ctxt, t_dst_container)
434-
&& t_dst_container.eval_ctxt(ctxt, t_dst);
435-
else
436-
{
437-
destvar -> eval_ctxt(ctxt, t_dst);
438-
t_success = !ctxt . HasError();
439-
}
440-
441-
if (!t_success)
395+
396+
MCExecValue t_dst;
397+
MCContainer t_dst_container;
398+
if (destvar != nil)
399+
{
400+
if (!destvar->evalcontainer(ctxt, t_dst_container) ||
401+
!t_dst_container.eval_ctxt(ctxt, t_dst))
442402
{
443403
ctxt . LegacyThrow(EE_MULTIPLY_BADDEST);
444404
MCExecTypeRelease(t_src);
@@ -486,19 +446,12 @@ void MCMultiply::exec_ctxt(MCExecContext &ctxt)
486446
MCExecTypeRelease(t_dst);
487447

488448
if (!ctxt . HasError())
489-
{
490-
if (destvar != nil)
491-
{
492-
bool t_success;
493-
494-
if (destvar -> needsContainer())
495-
t_success = t_dst_container.give_value(ctxt, t_result);
496-
else
497-
t_success = destvar -> give_value(ctxt, t_result);
498-
499-
if (!t_success)
449+
{
450+
if (destvar != nil)
451+
{
452+
if (!t_dst_container.give_value(ctxt, t_result))
500453
ctxt . Throw();
501-
}
454+
}
502455
else
503456
{
504457
if (dest->set(ctxt, PT_INTO, t_result))
@@ -589,22 +542,13 @@ void MCSubtract::exec_ctxt(MCExecContext &ctxt)
589542
ctxt.LegacyThrow(EE_SUBTRACT_BADSOURCE);
590543
return;
591544
}
592-
593-
MCExecValue t_dst;
594-
MCContainer t_dst_container;
595-
if (destvar != nil)
596-
{
597-
bool t_success;
598-
if (destvar -> needsContainer())
599-
t_success = destvar -> evalcontainer(ctxt, t_dst_container)
600-
&& t_dst_container.eval_ctxt(ctxt, t_dst);
601-
else
602-
{
603-
destvar -> eval_ctxt(ctxt, t_dst);
604-
t_success = !ctxt . HasError();
605-
}
606-
607-
if (!t_success)
545+
546+
MCExecValue t_dst;
547+
MCContainer t_dst_container;
548+
if (destvar != nil)
549+
{
550+
if (!destvar->evalcontainer(ctxt, t_dst_container) ||
551+
!t_dst_container.eval_ctxt(ctxt, t_dst))
608552
{
609553
ctxt . LegacyThrow(EE_SUBTRACT_BADDEST);
610554
MCExecTypeRelease(t_src);
@@ -652,19 +596,12 @@ void MCSubtract::exec_ctxt(MCExecContext &ctxt)
652596
MCExecTypeRelease(t_dst);
653597

654598
if (!ctxt . HasError())
655-
{
656-
if (destvar != nil)
657-
{
658-
bool t_success;
659-
660-
if (destvar -> needsContainer())
661-
t_success = t_dst_container.give_value(ctxt, t_result);
662-
else
663-
t_success = destvar -> give_value(ctxt, t_result);
664-
665-
if (!t_success)
599+
{
600+
if (destvar != nil)
601+
{
602+
if (!t_dst_container.give_value(ctxt, t_result))
666603
ctxt . Throw();
667-
}
604+
}
668605
else
669606
{
670607
if (dest->set(ctxt, PT_INTO, t_result))

engine/src/exec-keywords.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ void MCKeywordsExecTry(MCExecContext& ctxt, MCStatement *trystatements, MCStatem
778778
{
779779
MCAutoStringRef t_error;
780780
MCeerror -> copyasstringref(&t_error);
781-
errorvar->evalvar(ctxt)->setvalueref(*t_error);
781+
errorvar->set(ctxt, *t_error);
782782
}
783783

784784
// MW-2007-09-04: At this point we need to clear the execution error
@@ -808,13 +808,16 @@ void MCKeywordsExecTry(MCExecContext& ctxt, MCStatement *trystatements, MCStatem
808808
case ES_PASS:
809809
if (state == TS_CATCH)
810810
{
811+
MCAutoValueRef t_value;
811812
MCAutoStringRef t_string;
812-
if (ctxt . ConvertToString(errorvar->evalvar(ctxt)->getvalueref(), &t_string))
813+
if ((errorvar->eval(ctxt, &t_value), !ctxt.HasError()) &&
814+
ctxt . ConvertToString(*t_value, &t_string))
813815
{
814816
MCeerror->copystringref(*t_string, False);
815-
MCeerror->add(EE_TRY_BADSTATEMENT, line, pos);
816-
stat = ES_ERROR;
817817
}
818+
819+
MCeerror->add(EE_TRY_BADSTATEMENT, line, pos);
820+
stat = ES_ERROR;
818821
}
819822
default:
820823
if (state == TS_FINALLY)

engine/src/express.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ MCVarref *MCExpression::getrootvarref(void)
6060
return NULL;
6161
}
6262

63-
MCVariable *MCExpression::evalvar(MCExecContext& ctxt)
64-
{
65-
return NULL;
66-
}
67-
6863
bool MCExpression::evalcontainer(MCExecContext& ctxt, MCContainer& r_container)
6964
{
7065
return false;

engine/src/express.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class MCExpression
5959
// the container's value in r_ref.
6060
// EP-less version of evaluation functions
6161
virtual bool evalcontainer(MCExecContext& ctxt, MCContainer& r_container);
62-
virtual MCVariable *evalvar(MCExecContext& ctxt);
6362

6463
// Return the var-ref which lies at the root of this expression.
6564
// A return value of NULL means that there is no root variable.

0 commit comments

Comments
 (0)