@@ -63,7 +63,7 @@ uint2 MCnbreakpoints = 0;
6363Watchvar *MCwatchedvars = nil;
6464uint2 MCnwatchedvars = 0 ;
6565
66- MCExecPoint *MCexecutioncontexts[MAX_CONTEXTS ];
66+ MCExecContext *MCexecutioncontexts[MAX_CONTEXTS ];
6767uint2 MCnexecutioncontexts = 0 ;
6868uint2 MCdebugcontext = MAXUINT2 ;
6969Boolean MCmessagemessages = False;
@@ -76,12 +76,8 @@ static int2 depth;
7676
7777#include " srvdebug.h"
7878
79- void MCB_setmsg (MCStringRef p_msg)
80- {
81-
82- }
8379
84- void MCB_setmsg (MCExecPoint& ep )
80+ void MCB_setmsg (MCExecContext& ctxt, MCStringRef p_string )
8581{
8682 // At some point we will add the ability to manipulate/look at the 'message box' in a
8783 // remote debugging session.
@@ -110,38 +106,25 @@ void MCB_done(MCExecPoint &ep)
110106{
111107}
112108
113- void MCB_setvar (MCExecPoint &ep, MCNameRef name)
114- {
115- MCServerDebugVariableChanged (ep, name);
116- }
117-
118109void MCB_setvar (MCExecContext &ctxt, MCValueRef p_value, MCNameRef name)
119110{
120-
111+ MCServerDebugVariableChanged (ctxt, p_value, name);
121112}
122113
123114#else
124115
125- void MCB_setmsg (MCStringRef p_msg)
126- {
127- MCExecPoint ep (nil, nil, nil);
128- ep . setvalueref (p_msg);
129- MCB_setmsg (ep);
130- }
131-
132- void MCB_setmsg (MCExecPoint &ep)
116+ void MCB_setmsg (MCExecContext &ctxt, MCStringRef p_string)
133117{
134118 if (MCnoui)
135119 {
136- MCS_write (ep.getsvalue ().getstring (), sizeof (char ),
137- ep.getsvalue ().getlength (), IO_stdout);
138- uint4 length = ep.getsvalue ().getlength ();
139- if (length && ep.getsvalue ().getstring ()[length - 1 ] != ' \n ' )
120+ MCS_write (MCStringGetCString (p_string), sizeof (char ), MCStringGetLength (p_string), IO_stdout);
121+ uint4 length = MCStringGetLength (p_string);
122+ if (length && MCStringGetCharAtIndex (p_string, length - 1 ) != ' \n ' )
140123 MCS_write (" \n " , sizeof (char ), 1 , IO_stdout);
141124 return ;
142125 }
143126
144- if (!MCModeHandleMessageBoxChanged (ep ))
127+ if (!MCModeHandleMessageBoxChanged (ctxt, p_string ))
145128 {
146129 // MW-2004-11-17: Now use global 'MCmbstackptr' instead
147130 if (MCmbstackptr == NULL )
@@ -163,12 +146,12 @@ void MCB_setmsg(MCExecPoint &ep)
163146 MCCard *cptr = MCmbstackptr->getchild (CT_THIS , kMCEmptyString , CT_CARD );
164147 MCField *fptr = (MCField *)cptr->getchild (CT_FIRST , kMCEmptyString , CT_FIELD , CT_CARD );
165148 if (fptr != NULL )
166- fptr->settext_oldstring (0 , ep. getsvalue () , False);
149+ fptr->settext (0 , p_string , False);
167150 }
168151 }
169152}
170153
171- void MCB_message (MCExecPoint &ep , MCNameRef mess, MCParameter *p)
154+ void MCB_message (MCExecContext &ctxt , MCNameRef mess, MCParameter *p)
172155{
173156 Boolean exitall = MCexitall;
174157 MCSaveprops sp;
@@ -179,7 +162,7 @@ void MCB_message(MCExecPoint &ep, MCNameRef mess, MCParameter *p)
179162 if (MCtracestackptr != NULL )
180163 MCtracewindow = MCtracestackptr->getw ();
181164 else
182- MCtracewindow = ep. getobj ()->getw ();
165+ MCtracewindow = ctxt. GetObject ()->getw ();
183166 MCVariable *oldresult = MCresult;
184167 /* UNCHECKED */ MCVariable::createwithname (MCNAME (" MCdebugresult" ), MCresult);
185168 MCtracereturn = False;
@@ -194,7 +177,7 @@ void MCB_message(MCExecPoint &ep, MCNameRef mess, MCParameter *p)
194177
195178 // OK-2008-11-28: [[Bug 7491]] - It seems that using the "send" parameter causes problems with the MetaCard debugger
196179 // So instead of doing that, I've added a new optional parameter to MCObject::send, called p_force, and used this instead.
197- if (ep . getobj () -> message (mess, p, True, False, True) == ES_NORMAL )
180+ if (ctxt. GetObject () -> message (mess, p, True, False, True) == ES_NORMAL )
198181 {
199182 MCcheckstack = oldcheck;
200183 // if (depth++ > 1)
@@ -206,7 +189,7 @@ void MCB_message(MCExecPoint &ep, MCNameRef mess, MCParameter *p)
206189 }
207190 // depth--;
208191 if (MCtracedobject == NULL )
209- MCtracedobject = ep. getobj ();
192+ MCtracedobject = ctxt. GetObject ();
210193 if (MCtraceabort)
211194 {
212195 MCtraceabort = False;
@@ -224,17 +207,17 @@ void MCB_message(MCExecPoint &ep, MCNameRef mess, MCParameter *p)
224207 MCexitall = exitall;
225208}
226209
227- void MCB_prepmessage (MCExecPoint &ep , MCNameRef mess, uint2 line, uint2 pos, uint2 id, MCStringRef p_info)
210+ void MCB_prepmessage (MCExecContext &ctxt , MCNameRef mess, uint2 line, uint2 pos, uint2 id, MCStringRef p_info)
228211{
229212 Boolean added = False;
230213 if (MCnexecutioncontexts < MAX_CONTEXTS )
231214 {
232- ep .setline (line);
233- MCexecutioncontexts[MCnexecutioncontexts++] = &ep ;
215+ ctxt. GetEP () .setline (line);
216+ MCexecutioncontexts[MCnexecutioncontexts++] = &ctxt ;
234217 added = True;
235218 }
236219 MCParameter p1, p2, p3, p4;
237- p1.setvalueref_argument (ep. gethandler ()->getname ());
220+ p1.setvalueref_argument (ctxt. GetHandler ()->getname ());
238221 p1.setnext (&p2);
239222 p2.setn_argument ((real8)line);
240223 p2.setnext (&p3);
@@ -244,30 +227,31 @@ void MCB_prepmessage(MCExecPoint &ep, MCNameRef mess, uint2 line, uint2 pos, uin
244227 p3.setnext (&p4);
245228 MCeerror->add (id, line, pos);
246229
247- ep.getobj ()->getprop (0 , P_LONG_ID , ep, False);
248- MCeerror->add (EE_OBJECT_NAME , 0 , 0 , ep.getsvalue ());
230+ MCAutoValueRef t_val;
231+ ctxt.GetObject ()->getvariantprop (ctxt, 0 , P_LONG_ID , False, &t_val);
232+ MCeerror->add (EE_OBJECT_NAME , 0 , 0 , *t_val);
249233 p4.sets_argument (MCeerror->getsvalue ());
250234 }
251235 else if (!MCStringIsEmpty (p_info))
252236 {
253237 p3.setnext (&p4);
254238 p4.setvalueref_argument (p_info);
255239 }
256- MCB_message (ep , mess, &p1);
240+ MCB_message (ctxt , mess, &p1);
257241 if (id != 0 )
258242 MCeerror->clear ();
259243 if (added)
260244 MCnexecutioncontexts--;
261245}
262246
263- void MCB_trace (MCExecPoint &ep , uint2 line, uint2 pos)
247+ void MCB_trace (MCExecContext &ctxt , uint2 line, uint2 pos)
264248{
265249 uint2 i;
266250
267251 if (MCtrace && (MCtraceuntil == MAXUINT2 || MCnexecutioncontexts == MCtraceuntil))
268252 {
269253 MCtraceuntil = MAXUINT2 ;
270- MCB_prepmessage (ep , MCM_trace, line, pos, 0 );
254+ MCB_prepmessage (ctxt , MCM_trace, line, pos, 0 );
271255 }
272256 else
273257 {
@@ -278,75 +262,55 @@ void MCB_trace(MCExecPoint &ep, uint2 line, uint2 pos)
278262 if (MCbreakpoints[i].line == line)
279263 {
280264 MCParentScriptUse *t_parentscript;
281- t_parentscript = ep . getparentscript ();
282- if (t_parentscript == NULL && MCbreakpoints[i].object == ep. getobj () ||
265+ t_parentscript = ctxt . GetParentScript ();
266+ if (t_parentscript == NULL && MCbreakpoints[i].object == ctxt. GetObject () ||
283267 t_parentscript != NULL && MCbreakpoints[i].object == t_parentscript -> GetParent () -> GetObject ())
284- MCB_prepmessage (ep , MCM_trace_break, line, pos, 0 , MCbreakpoints[i].info );
268+ MCB_prepmessage (ctxt , MCM_trace_break, line, pos, 0 , MCbreakpoints[i].info );
285269 }
286270 }
287271}
288272
289- void MCB_break (MCExecPoint &ep , uint2 line, uint2 pos)
273+ void MCB_break (MCExecContext &ctxt , uint2 line, uint2 pos)
290274{
291- MCB_prepmessage (ep , MCM_trace_break, line, pos, 0 );
275+ MCB_prepmessage (ctxt , MCM_trace_break, line, pos, 0 );
292276}
293277
294278bool s_in_trace_error = false ;
295279
296- void MCB_error (MCExecPoint &ep , uint2 line, uint2 pos, uint2 id)
280+ void MCB_error (MCExecContext &ctxt , uint2 line, uint2 pos, uint2 id)
297281{
298282 // OK-2009-03-25: [[Bug 7517]] - The crash described in this bug report is probably caused by a stack overflow. This overflow is due to
299283 // errors being thrown in the IDE (or in this case GLX2) component of the debugger. This should prevent traceError from recursing.
300284 if (s_in_trace_error)
301285 return ;
302286
303287 s_in_trace_error = true ;
304- MCB_prepmessage (ep , MCM_trace_error, line, pos, id);
288+ MCB_prepmessage (ctxt , MCM_trace_error, line, pos, id);
305289 MCerrorlock++; // suppress errors as stack unwinds
306290 s_in_trace_error = false ;
307291}
308292
309- void MCB_done (MCExecPoint &ep )
293+ void MCB_done (MCExecContext &ctxt )
310294{
311- MCB_message (ep, MCM_trace_done, NULL );
312- }
313-
314- void MCB_setvar (MCExecPoint &ep, MCNameRef name)
315- {
316- Boolean added = False;
317- if (MCnexecutioncontexts < MAX_CONTEXTS )
318- {
319- MCexecutioncontexts[MCnexecutioncontexts++] = &ep;
320- added = True;
321- }
322- MCParameter p1, p2, p3;
323- p1.setn_argument (ep.getline ());
324- p1.setnext (&p2);
325- p2.setvalueref_argument (name);
326- p2.setnext (&p3);
327- p3.sets_argument (ep.getsvalue ());
328- MCB_message (ep, MCM_update_var, &p1);
329- if (added)
330- MCnexecutioncontexts--;
295+ MCB_message (ctxt, MCM_trace_done, NULL );
331296}
332297
333298void MCB_setvar (MCExecContext &ctxt, MCValueRef p_value, MCNameRef name)
334299{
335- MCExecPoint& ep = ctxt . GetEP ();
336-
337300 Boolean added = False;
338301 if (MCnexecutioncontexts < MAX_CONTEXTS )
339302 {
340- MCexecutioncontexts[MCnexecutioncontexts++] = &ep ;
303+ MCexecutioncontexts[MCnexecutioncontexts++] = &ctxt ;
341304 added = True;
342305 }
306+
343307 MCParameter p1, p2, p3;
344- p1.setn_argument (ep .getline ());
308+ p1.setn_argument (ctxt. GetEP () .getline ());
345309 p1.setnext (&p2);
346310 p2.setvalueref_argument (name);
347311 p2.setnext (&p3);
348312 p3.setvalueref_argument (p_value);
349- MCB_message (ep , MCM_update_var, &p1);
313+ MCB_message (ctxt , MCM_update_var, &p1);
350314 if (added)
351315 MCnexecutioncontexts--;
352316}
0 commit comments