1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
|
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>nevrax.org : docs</TITLE>
<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF='/'><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF='/'><b>nevrax.com</B></FONT></A> </TD>
</TR>
</TABLE>
<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
<TR><TD BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG SRC="/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>
<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!------ Begin Box ------>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
<TABLE cellspacing=0 cellpadding=1 border=0>
<tr><td ALIGN=middle><a class='linkbox' href="/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
</TABLE>
</TD></TR></TABLE></TD></TR></TABLE>
<!------ End Box ------>
</TD>
<TD WIDTH=15><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD ALIGN=left valign=top><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!-- title -->
<TABLE background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
<!-- block -->
<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
<TD><B>Documentation</B></TD>
<TD ALIGN=RIGHT> </td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>code_branche_run_debug.cpp</h1><a href="code__branche__run__debug_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
00006 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font>
00007 <font class="comment"> *</font>
00008 <font class="comment"> * This file is part of NEVRAX NEL.</font>
00009 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
00010 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00011 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00012 <font class="comment"> * any later version.</font>
00013 <font class="comment"></font>
00014 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
00015 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00016 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00017 <font class="comment"> * General Public License for more details.</font>
00018 <font class="comment"></font>
00019 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00020 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
00021 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00022 <font class="comment"> * MA 02111-1307, USA.</font>
00023 <font class="comment"> */</font>
00024
00025 <font class="preprocessor">#include "<a class="code" href="code__branche__run__debug_8h.html">nel/ai/script/code_branche_run_debug.h</a>"</font>
00026 <font class="preprocessor">#include "<a class="code" href="varstack_8h.html">nel/ai/script/varstack.h</a>"</font>
00027
00028 <font class="preprocessor">#ifdef NL_DEBUG</font>
00029 <font class="preprocessor"></font><font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
00030 <font class="preprocessor"></font><font class="preprocessor">#include "windows.h"</font>
00031 <font class="preprocessor">#endif</font>
00032 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
00033 <font class="preprocessor"></font>
00034 <font class="keyword">namespace </font>NLAISCRIPT
00035 {
00036 <font class="comment">/*</font>
00037 <font class="comment"> * Constructor</font>
00038 <font class="comment"> */</font>
00039
<a name="l00040"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#c0">00040</a> <font class="keywordtype">void</font> CCodeBrancheRunDebug::initCBRD()
00041 {
00042 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a> = <font class="keyword">new</font> <font class="keywordtype">int</font>[<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n2">_Count</a>];
00043 <font class="keywordflow">for</font>(sint32 i = 0 ;i < <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n2">_Count</a>; i ++)
00044 {
00045 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a>[i] = 0; <font class="comment">// It's a mark, because 0 could'nt be a true value.</font>
00046 }
00047 }
00048
<a name="l00049"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a0">00049</a> CCodeBrancheRunDebug::CCodeBrancheRunDebug(sint32 N,<font class="keyword">const</font> IOpCode &op):
00050 CCodeBrancheRun(N, op), _SourceCode(NULL)
00051 {
00052 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#c0">initCBRD</a>();
00053 }
00054
<a name="l00055"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a1">00055</a> CCodeBrancheRunDebug::CCodeBrancheRunDebug(sint32 N, IScriptDebugSource* sourceCode):
00056 CCodeBrancheRun(N),
00057 _SourceCode(sourceCode)
00058 {
00059 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o1">_SourceCode</a>->incRef();
00060 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#c0">initCBRD</a>();
00061 }
00062
<a name="l00063"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a2">00063</a> CCodeBrancheRunDebug::CCodeBrancheRunDebug(<font class="keyword">const</font> <a class="code" href="classstd_1_1list.html">tListCode</a> &<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>):
00064 CCodeBrancheRun(<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>),
00065 _SourceCode(NULL)
00066 {
00067 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#c0">initCBRD</a>();
00068 }
00069
<a name="l00070"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a3">00070</a> CCodeBrancheRunDebug::CCodeBrancheRunDebug(<font class="keyword">const</font> CCodeBrancheRunDebug &<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>):
00071 CCodeBrancheRun(<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>),
00072 _LineInSourceCodeArray(NULL),
00073 _SourceCode(<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>._SourceCode)
00074 {
00075 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o1">_SourceCode</a>->incRef();
00076 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#c0">initCBRD</a>();
00077 <font class="keywordflow">for</font>(sint32 i = 0 ;i < <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n2">_Count</a>; i ++)
00078 {
00079 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a>[i] = <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>._LineInSourceCodeArray[i];
00080 }
00081 }
00082
<a name="l00083"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a4">00083</a> CCodeBrancheRunDebug::~CCodeBrancheRunDebug()
00084 {
00085 <font class="keyword">delete</font> []<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a>;
00086 <font class="keywordflow">if</font> (_SourceCode) <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o1">_SourceCode</a>->release();
00087 }
00088
<a name="l00089"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#z213_1">00089</a> <font class="keyword">const</font> <a class="code" href="classNLAIC_1_1IBasicType.html">NLAIC::IBasicType</a>* CCodeBrancheRunDebug::clone()<font class="keyword"> const </font>
00090 <font class="keyword"> </font>{
00091 <a class="code" href="classNLAIC_1_1IBasicType.html">NLAIC::IBasicType</a> *<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> = <font class="keyword">new</font> <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a0">CCodeBrancheRunDebug</a>(*<font class="keyword">this</font>);
00092 <font class="keywordflow">return</font> x;
00093 }
00094
<a name="l00095"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#z213_2">00095</a> <font class="keyword">const</font> <a class="code" href="classNLAIC_1_1IBasicType.html">NLAIC::IBasicType</a> *CCodeBrancheRunDebug::newInstance()<font class="keyword"> const </font>
00096 <font class="keyword"> </font>{
00097 <a class="code" href="classNLAIC_1_1IBasicType.html">NLAIC::IBasicType</a> *<a class="code" href="driver__opengl__extension__def_8h.html#a364">x</a> = <font class="keyword">new</font> <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a0">CCodeBrancheRunDebug</a>(1,CHaltOpCode());
00098 <font class="keywordflow">return</font> x;
00099 }
00100
<a name="l00101"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#z213_3">00101</a> <font class="keywordtype">void</font> CCodeBrancheRunDebug::save(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &os)
00102 {
00103 CCodeBrancheRun::save(os);
00104
00105 <font class="keywordflow">for</font>(<font class="keywordtype">int</font> i = 0 ;i < <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n2">_Count</a>; i ++)
00106 {
00107 sint32 n = <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a>[i];
00108 os.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>( n );
00109 }
00110 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o1">_SourceCode</a>->save(os);
00111
00112 }
00113
<a name="l00114"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#z213_4">00114</a> <font class="keywordtype">void</font> CCodeBrancheRunDebug::load(<a class="code" href="classNLMISC_1_1IStream.html">NLMISC::IStream</a> &is)
00115 {
00116 <font class="keywordtype">int</font> i;
00117 CCodeBrancheRun::load(is);
00118 <font class="keyword">delete</font>[] <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a>;
00119 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a> = <font class="keyword">new</font> <font class="keywordtype">int</font>[<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n2">_Count</a>];
00120 <font class="keywordflow">for</font>(i = 0 ;i < <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n2">_Count</a>; i ++)
00121 {
00122 sint32 n;
00123 is.<a class="code" href="classNLMISC_1_1IStream.html#a5">serial</a>( n );
00124 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a>[i] = (int)n;
00125 }
00126 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o1">_SourceCode</a>->load(is);
00127 }
00128
<a name="l00129"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a8">00129</a> <font class="keyword">const</font> <a class="code" href="structNLAIAGENT_1_1IObjectIA_1_1CProcessResult.html">NLAIAGENT::IObjectIA::CProcessResult</a>& CCodeBrancheRunDebug::run(<a class="code" href="classNLAIAGENT_1_1IObjectIA.html">NLAIAGENT::IObjectIA</a> &self)
00130 {
00131 CStackPointer stack,heap;
00132 CCodeContext p(stack,heap,<font class="keyword">this</font>,&self,<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>);
00133 CVarPStack::_LocalTableRef = &heap[0];
00134 stack --;
00135
00136 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#z212_0">run</a>(p);
00137
00138 stack -= (sint32)stack;
00139 heap -= (sint32)heap;
00140 <font class="keywordflow">return</font> <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n3">_RunState</a>;
00141 }
00142
<a name="l00143"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a9">00143</a> <font class="keyword">const</font> <a class="code" href="structNLAIAGENT_1_1IObjectIA_1_1CProcessResult.html">NLAIAGENT::IObjectIA::CProcessResult</a> &CCodeBrancheRunDebug::run(CCodeContext &p)
00144 {
00145 NLAIAGENT::TProcessStatement i = NLAIAGENT::processIdle;
00146
00147 p.ContextDebug.Active = <font class="keyword">true</font>; <font class="comment">// We are in Debug mode.</font>
00148 p.ContextDebug.callStackPush(<font class="keyword">this</font>);
00149
00150 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n3">_RunState</a>.<a class="code" href="structNLAIAGENT_1_1IObjectIA_1_1CProcessResult.html#m1">Result</a> = NULL;
00151 <font class="keywordflow">while</font>(i != NLAIAGENT::processEnd)
00152 {
00153 i = <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a10">runOpCode</a>(p);
00154 }
00155
00156 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n3">_RunState</a>.<a class="code" href="structNLAIAGENT_1_1IObjectIA_1_1CProcessResult.html#m0">ResultState</a> = NLAIAGENT::processIdle;
00157 <font class="keywordflow">return</font> <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n3">_RunState</a>;
00158 }
00159 <font class="preprocessor">#ifdef NL_DEBUG</font>
00160 <font class="preprocessor"></font> <font class="keyword">extern</font> <font class="keywordtype">bool</font> NL_AI_DEBUG_SERVER;
00161 <font class="preprocessor">#endif</font>
<a name="l00162"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a10">00162</a> <font class="preprocessor"></font> NLAIAGENT::TProcessStatement CCodeBrancheRunDebug::runOpCode(CCodeContext &p)
00163 {
00164 std::string buf;
00165 p.ContextDebug.Active = <font class="keyword">true</font>; <font class="comment">// We are in Debug mode.</font>
00166
00167 <a class="code" href="classNLAISCRIPT_1_1IOpCode.html#a0">IOpCode</a> &op = <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#a13">nextCode</a>();
00168
00169 <font class="preprocessor">#ifdef NL_DEBUG</font>
00170 <font class="preprocessor"></font> <font class="keywordflow">if</font>(NL_AI_DEBUG_SERVER)
00171 {
00172 std::string chaine;
00173 op.getDebugResult(chaine,p);
00174 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
00175 <font class="preprocessor"></font> OutputDebugString(chaine.c_str());
00176 OutputDebugString(<font class="stringliteral">"\n"</font>);
00177 <font class="preprocessor">#endif</font>
00178 <font class="preprocessor"></font> }
00179 <font class="preprocessor">#endif</font>
00180 <font class="preprocessor"></font> <font class="keywordflow">if</font> (<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a>[<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n1">_Ip</a>-1] != 0)
00181 {
00182 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#c1">fixContextDebugMode</a>(p);
00183
00184 <font class="comment">// We print info debug only if we are running the stepByStep codeBrancheRun.</font>
00185 <font class="keywordflow">if</font> ( p.ContextDebug.getDebugMode() == <a class="code" href="namespaceNLAISCRIPT.html#a52a13">stepByStepMode</a>
00186 && p.ContextDebug.getCallStackTopIndex() == p.ContextDebug.getStepIndex())
00187 {
00188 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a14">printCurrentSourceCodeLine</a>();
00189
00190 <font class="keywordtype">bool</font> executOpcode = <font class="keyword">false</font>;
00191
00192 <font class="keywordflow">while</font> (!executOpcode)
00193 {
00194 <font class="comment">// Wait command</font>
00195 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"(db) "</font>);
00196 buf = <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a2">InPut</a>();
00197 executOpcode = <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#c2">readCommandLine</a>(p, buf.c_str());
00198 <font class="keywordflow">if</font> (0 != buf.c_str()[0]) p.ContextDebug.setLastCommandLine(buf.c_str());
00199 }
00200 }
00201 }
00202
00203 <font class="keywordflow">if</font> (p.ContextDebug.getDebugMode() == <a class="code" href="namespaceNLAISCRIPT.html#a52a16">stopMode</a>)
00204 {
00205 <font class="keywordflow">return</font> NLAIAGENT::processEnd;
00206 }
00207 <font class="keywordflow">else</font>
00208 {
00209 <font class="keywordflow">return</font> op.runOpCode(p);
00210 }
00211 }
00212
<a name="l00213"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a7">00213</a> <font class="keywordtype">void</font> CCodeBrancheRunDebug::getDebugResult(std::string &str,CCodeContext &p)<font class="keyword"> const</font>
00214 <font class="keyword"> </font>{
00215 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n0">_TableCode</a>[<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n1">_Ip</a>]->getDebugResult(str,p);
00216 }
00217
<a name="l00218"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#z213_0">00218</a> <font class="keyword">const</font> <a class="code" href="classNLAIC_1_1CIdentType.html">NLAIC::CIdentType</a>& CCodeBrancheRunDebug::getType()<font class="keyword"> const</font>
00219 <font class="keyword"> </font>{
00220 <font class="keywordflow">return</font> <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#p0">IdCodeBrancheRunDebug</a>;
00221 }
00222
<a name="l00223"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a5">00223</a> <font class="keywordtype">void</font> CCodeBrancheRunDebug::initCode(<font class="keyword">const</font> <a class="code" href="classstd_1_1list.html">tListCode</a> &<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>)
00224 {
00225 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#b0">del</a>();
00226 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n2">_Count</a> = l.size();
00227
00228 tListCode::const_iterator i;
00229 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n0">_TableCode</a> = <font class="keyword">new</font> <a class="code" href="classNLAISCRIPT_1_1IOpCode.html#a0">IOpCode</a> * [l.size()];
00230 i = l.begin();
00231 sint32 k = 0;
00232 <font class="keywordflow">while</font>(i != l.end())
00233 {
00234 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n0">_TableCode</a>[k ++] = (<a class="code" href="classNLAISCRIPT_1_1IOpCode.html#a0">IOpCode</a> *)*i++;
00235 }
00236 }
00237
<a name="l00238"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a6">00238</a> <font class="keywordtype">void</font> CCodeBrancheRunDebug::initCode(<font class="keyword">const</font> CCodeBrancheRunDebug &<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>)
00239 {
00240 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#b0">del</a>();
00241
00242 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n1">_Ip</a> = 0;
00243 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n2">_Count</a> = <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>._Count;
00244
00245 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n0">_TableCode</a> = <font class="keyword">new</font> <a class="code" href="classNLAISCRIPT_1_1IOpCode.html#a0">IOpCode</a> * [<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n2">_Count</a>];
00246 <font class="keywordflow">for</font>(sint32 i = 0; i < <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n2">_Count</a>;i ++)
00247 {
00248 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n0">_TableCode</a>[i] = (<a class="code" href="classNLAISCRIPT_1_1IOpCode.html#a0">IOpCode</a> *)<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>._TableCode[i]->clone();
00249 }
00250 }
00251
<a name="l00252"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a11">00252</a> <font class="keywordtype">void</font> CCodeBrancheRunDebug::setLineCode(<font class="keywordtype">int</font> ligne, <font class="keywordtype">int</font> <a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>)
00253 {
00254 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a>[<a class="code" href="driver__opengl__extension__def_8h.html#a358">index</a>] = ligne;
00255 }
00256
<a name="l00257"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a12">00257</a> std::string CCodeBrancheRunDebug::getSourceFileName()<font class="keyword"> const</font>
00258 <font class="keyword"> </font>{
00259 <font class="keywordflow">return</font> <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o1">_SourceCode</a>->getSourceName().c_str();
00260 }
00261
<a name="l00262"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#c1">00262</a> <font class="keywordtype">void</font> CCodeBrancheRunDebug::fixContextDebugMode(CCodeContext &P)<font class="keyword"> const</font>
00263 <font class="keyword"> </font>{
00264 <font class="comment">// We are in step by step mode on the current CCodeBrancheRun :</font>
00265 <font class="keywordflow">if</font> ( P.ContextDebug.getBreakPointValue(<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a>[<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n1">_Ip</a>-1],<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a12">getSourceFileName</a>().c_str()) <font class="comment">// After a BreakPoint.</font>
00266 || P.ContextDebug.getDebugMode() == <a class="code" href="namespaceNLAISCRIPT.html#a52a14">stepInMode</a> <font class="comment">// After a stepInMode.</font>
00267 || P.ContextDebug.getDebugMode() == <a class="code" href="namespaceNLAISCRIPT.html#a52a15">stepOutMode</a> && (P.ContextDebug.getCallStackTopIndex() < P.ContextDebug.getStepIndex()) <font class="comment">// After leaving a branche in stepOutMode.</font>
00268 || P.ContextDebug.getDebugMode() == <a class="code" href="namespaceNLAISCRIPT.html#a52a13">stepByStepMode</a> && P.ContextDebug.getCallStackTopIndex() < P.ContextDebug.getStepIndex()) <font class="comment">// If we reach a higer level branch in stepBySteplMode.</font>
00269 {
00270 P.ContextDebug.setDebugMode(<a class="code" href="namespaceNLAISCRIPT.html#a52a13">stepByStepMode</a>);
00271 P.ContextDebug.setStepIndex(P.ContextDebug.getCallStackTopIndex());
00272 }
00273 }
00274
<a name="l00275"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a15">00275</a> <font class="keywordtype">void</font> CCodeBrancheRunDebug::printSourceCodeLine(<font class="keywordtype">int</font> first, <font class="keywordtype">int</font> last)<font class="keyword"> const</font>
00276 <font class="keyword"> </font>{
00277 sint32 i, j, k, size, lineNumber;
00278 <font class="keyword">const</font> <font class="keywordtype">char</font>* buf;
00279 <font class="keywordtype">char</font>* lineTxt;
00280 std::string code;
00281
00282 lineNumber = this-><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a13">getCurrentSourceCodeLineNumber</a>();
00283 code = <font class="stringliteral">" "</font>;
00284 code += <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o1">_SourceCode</a>->getSourceBuffer();
00285 code +=<font class="stringliteral">"\n"</font>;
00286 size = code.size();
00287 buf = code.c_str();
00288
00289 <font class="comment">// first should be lowest than last.</font>
00290 <font class="keywordflow">if</font> (first > last) last = first;
00291
00292 <font class="comment">// Seek the good line</font>
00293 i = 0; <font class="comment">// Line start</font>
00294 j = 0; <font class="comment">// Line end</font>
00295 k = 0; <font class="comment">// Line number</font>
00296 lineTxt = <font class="keyword">new</font> <font class="keywordtype">char</font>[1024];
00297
00298 <font class="comment">// Seek the first line</font>
00299 <font class="keywordflow">while</font> (k != first && j < size)
00300 {
00301 j++;
00302 i = j;
00303 <font class="keywordflow">while</font> (buf[j] != <font class="charliteral">'\n'</font>)
00304 {
00305 j++;
00306 }
00307 k++;
00308 }
00309
00310 <font class="comment">// Print until the last line</font>
00311 <font class="keywordflow">while</font> (k != last+1 && j < size)
00312 {
00313 strncpy (lineTxt, buf+i,j-i);
00314 lineTxt[j-i] = 0;
00315
00316 <font class="comment">// Print debug informations</font>
00317 <font class="keywordflow">if</font> ( k == lineNumber)
00318 {
00319 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"%d ->\t %s\n"</font>, k, lineTxt);
00320 }
00321 <font class="keywordflow">else</font>
00322 {
00323 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"%d \t %s\n"</font>, k, lineTxt);
00324 }
00325
00326 j++;
00327 i = j;
00328 <font class="keywordflow">while</font> (buf[j] != <font class="charliteral">'\n'</font>)
00329 {
00330 j++;
00331 }
00332 k++;
00333 }
00334 <font class="keyword">delete</font>[] lineTxt;
00335 }
00336
<a name="l00337"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a14">00337</a> <font class="keywordtype">void</font> CCodeBrancheRunDebug::printCurrentSourceCodeLine()<font class="keyword"> const</font>
00338 <font class="keyword"> </font>{
00339 uint16 lineNumber = <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a13">getCurrentSourceCodeLineNumber</a>();
00340 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a15">printSourceCodeLine</a>(lineNumber, lineNumber);
00341 }
00342
<a name="l00343"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a13">00343</a> uint16 CCodeBrancheRunDebug::getCurrentSourceCodeLineNumber()<font class="keyword"> const</font>
00344 <font class="keyword"> </font>{
00345 <font class="keywordflow">if</font> (<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n1">_Ip</a> ==0)
00346 <font class="keywordflow">return</font> 0; <font class="comment">// This shouldn't appen.</font>
00347
00348 <font class="keywordflow">if</font> (<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a>[<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n1">_Ip</a>-1] != 0)
00349 {
00350 <font class="keywordflow">return</font> (<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a>[<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n1">_Ip</a>-1]);
00351 }
00352 <font class="keywordflow">else</font>
00353 {
00354 sint32 i = 2;
00355 <font class="keywordflow">while</font> (<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a>[<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n1">_Ip</a>-i] == 0)
00356 {
00357 i++;
00358 }
00359 <font class="keywordflow">return</font> <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#o0">_LineInSourceCodeArray</a>[<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#n1">_Ip</a>-i];
00360 }
00361 }
00362
<a name="l00363"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#c3">00363</a> <font class="keywordtype">void</font> CCodeBrancheRunDebug::printVariable (CCodeContext &P, <font class="keyword">const</font> <font class="keywordtype">char</font>* c)<font class="keyword"> const</font>
00364 <font class="keyword"> </font>{
00365 sint32 begin;
00366 <font class="keyword">const</font> <a class="code" href="classNLAIAGENT_1_1IObjectIA.html">NLAIAGENT::IObjectIA</a>* base;
00367 <font class="keyword">const</font> <a class="code" href="classNLAIAGENT_1_1IVarName.html">NLAIAGENT::IVarName</a>* ivn;
00368 <a class="code" href="classNLAIAGENT_1_1CStringType.html">NLAIAGENT::CStringType</a>* st;
00369 <a class="code" href="classNLAIAGENT_1_1CStringVarName.html">NLAIAGENT::CStringVarName</a>* svn;
00370 <font class="keywordtype">char</font>* buf = <font class="keyword">new</font> <font class="keywordtype">char</font>[1024*8];
00371 <font class="keywordtype">char</font>* bufA = <font class="keyword">new</font> <font class="keywordtype">char</font>[1024*8];
00372 <font class="keywordtype">char</font>* bufX = <font class="keyword">new</font> <font class="keywordtype">char</font>[1024*8];
00373 <font class="keywordtype">int</font> i;
00374 <font class="keywordtype">int</font> j;
00375 <font class="keywordtype">char</font>* dotPos;
00376 buf[0] = 0;
00377 bufA[0] = 0;
00378 bufX[0] = 0;
00379
00380 <font class="comment">// Wee look if it's a composed varaible. If so, we just store the first part in buf and the second in bufX.</font>
00381 strcpy (buf, c);
00382 dotPos = strchr(buf,<font class="charliteral">'.'</font>);
00383 <font class="keywordflow">if</font>(dotPos != NULL)
00384 {
00385 strcpy(bufX, dotPos+1);
00386 strchr(buf,<font class="charliteral">'.'</font>)[0]= <font class="charliteral">'\0'</font>;
00387 }
00388
00389 <font class="comment">// Seek in the heap from the bottom the buf in order to know if it's a local variable.</font>
00390 begin = (int)P.ContextDebug.HeapDebug;
00391 <font class="keywordflow">for</font> (i = begin; i>=0; i--)
00392 {
00393 base = P.ContextDebug.HeapDebug[i];
00394 <font class="keywordflow">if</font> (base)
00395 {
00396 <font class="keywordflow">if</font> (base-><a class="code" href="classNLAIC_1_1IBasicType.html#a2">getType</a>() == <a class="code" href="classNLAIAGENT_1_1CStringType.html#p0">NLAIAGENT::CStringType::IdStringType</a>)
00397 {
00398 st = (<a class="code" href="classNLAIAGENT_1_1CStringType.html">NLAIAGENT::CStringType</a>*) base;
00399 ivn = &(st-><a class="code" href="classNLAIAGENT_1_1CStringType.html#a10">getStr</a>());
00400 <font class="keywordflow">if</font> (ivn-><a class="code" href="classNLAIC_1_1IBasicType.html#a2">getType</a>() == <a class="code" href="classNLAIAGENT_1_1CStringVarName.html#p0">NLAIAGENT::CStringVarName::IdStringVarName</a>)
00401 {
00402 svn = (<a class="code" href="classNLAIAGENT_1_1CStringVarName.html">NLAIAGENT::CStringVarName</a>*) ivn;
00403 <font class="keywordflow">if</font> (strcmp(svn-><a class="code" href="classNLAIAGENT_1_1CStringVarName.html#a4">getString</a>(), buf) == 0)
00404 {
00405 <font class="keywordflow">break</font>;
00406 }
00407 }
00408 }
00409 }
00410 }
00411
00412 base = NULL;
00413 <font class="keywordflow">if</font> (i>=0)
00414 {
00415 <font class="comment">// It's a local variable</font>
00416 base = P.Heap[i];
00417 }
00418 <font class="keywordflow">else</font>
00419 {
00420 j = P.Self-><a class="code" href="classNLAIAGENT_1_1IObjectIA.html#a6">getStaticMemberIndex</a>(<a class="code" href="classNLAIAGENT_1_1CStringVarName.html">NLAIAGENT::CStringVarName</a>(buf));
00421 <font class="keywordflow">if</font> (j >= 0)
00422 {
00423 <font class="comment">// It's a static member.</font>
00424 base = P.Self-><a class="code" href="classNLAIAGENT_1_1IObjectIA.html#a7">getStaticMember</a>(j);
00425 }
00426 }
00427
00428 <font class="keywordflow">if</font> (base != NULL)
00429 {
00430 <font class="comment">// We found a reference.</font>
00431 <font class="keywordflow">if</font> (bufX[0] == 0)
00432 {
00433 <font class="comment">// The variable wasn't composit.</font>
00434 std::string buf;
00435 base-><a class="code" href="classNLAIC_1_1IBasicType.html#a5">getDebugString</a>(buf);
00436 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"%s\n"</font>,buf.c_str());
00437 }
00438 <font class="keywordflow">else</font>
00439 {
00440 <font class="comment">// The variable was composit.</font>
00441 dotPos = strchr(bufX,<font class="charliteral">'.'</font>);
00442 <font class="keywordflow">while</font> (dotPos != NULL)
00443 {
00444 strcpy(buf,bufX);
00445 strcpy(bufX, dotPos+1);
00446 strcpy(bufA,buf);
00447 strchr(bufA,<font class="charliteral">'.'</font>)[0]= <font class="charliteral">'\0'</font>;
00448 j = base-><a class="code" href="classNLAIAGENT_1_1IObjectIA.html#a6">getStaticMemberIndex</a>(<a class="code" href="classNLAIAGENT_1_1CStringVarName.html">NLAIAGENT::CStringVarName</a>(bufA));
00449 <font class="keywordflow">if</font> (j >= 0)
00450 {
00451 base = base-><a class="code" href="classNLAIAGENT_1_1IObjectIA.html#a7">getStaticMember</a>(j);
00452 }
00453 dotPos = strchr(bufX,<font class="charliteral">'.'</font>);
00454 }
00455 j = base-><a class="code" href="classNLAIAGENT_1_1IObjectIA.html#a6">getStaticMemberIndex</a>(<a class="code" href="classNLAIAGENT_1_1CStringVarName.html">NLAIAGENT::CStringVarName</a>(bufX));
00456 <font class="keywordflow">if</font> (j >= 0)
00457 {
00458 std::string buf;
00459 base-><a class="code" href="classNLAIAGENT_1_1IObjectIA.html#a7">getStaticMember</a>(j)->getDebugString(buf);
00460 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"%s\n"</font>,buf.c_str());
00461 }
00462 }
00463 }
00464
00465 <font class="keyword">delete</font>[] buf;
00466 <font class="keyword">delete</font>[] bufA;
00467 <font class="keyword">delete</font>[] bufX;
00468 }
<a name="l00469"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#c4">00469</a> <font class="keywordtype">void</font> CCodeBrancheRunDebug::printArgs (CCodeContext &P)<font class="keyword"> const</font>
00470 <font class="keyword"> </font>{
00471 <font class="keywordflow">if</font> (P.Param.size() >0 )
00472 {
00473 <a class="code" href="classNLAIAGENT_1_1CIteratorContener.html">NLAIAGENT::CIteratorContener</a> Ita = ((<a class="code" href="classNLAIAGENT_1_1CGroupType.html">NLAIAGENT::CGroupType</a> *) P.ContextDebug.Param.back())->getIterator();
00474 <a class="code" href="classNLAIAGENT_1_1CIteratorContener.html">NLAIAGENT::CIteratorContener</a> Itb = ((<a class="code" href="classNLAIAGENT_1_1CGroupType.html">NLAIAGENT::CGroupType</a> *) P.Param.back())->getIterator();;
00475 <font class="keywordflow">while</font>(!Ita.<a class="code" href="classNLAIAGENT_1_1CConstIteratorContener.html#a6">isInEnd</a>())
00476 {
00477 std::string buf;
00478 Ita++;
00479 <a class="code" href="classNLAIAGENT_1_1CStringType.html">NLAIAGENT::CStringType</a> *p = (<a class="code" href="classNLAIAGENT_1_1CStringType.html">NLAIAGENT::CStringType</a> *)Itb++;
00480 p-><a class="code" href="classNLAIAGENT_1_1CStringType.html#a9">getDebugString</a>(buf);
00481 <font class="comment">// InputOutput->Echo("%s = %s\n", o->getStr().getString(), buf);</font>
00482 }
00483 }
00484 }
00485
<a name="l00486"></a><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#c2">00486</a> <font class="keywordtype">bool</font> CCodeBrancheRunDebug::readCommandLine(CCodeContext &P, <font class="keyword">const</font> <font class="keywordtype">char</font>* buf)
00487 {
00488 <font class="keywordtype">char</font>* sourceFileName;
00489 <font class="keywordtype">char</font>* varName;
00490 uint32 lineNumber;
00491 sint32 first, last;
00492 <font class="keywordtype">bool</font> ret = <font class="keyword">false</font>;
00493
00494 <font class="keywordflow">switch</font> (buf[0])
00495 {
00496 <font class="keywordflow">case</font> <font class="charliteral">'p'</font> :
00497 <font class="comment">// p(rint) expression | Inspect variables / attributes, evaluate expressions, call functions/methods.</font>
00498 varName = <font class="keyword">new</font> <font class="keywordtype">char</font>[1024];
00499 sscanf(buf+1, <font class="stringliteral">"%s"</font>, varName);
00500 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#c3">printVariable</a>(P,varName);
00501 <font class="keyword">delete</font>[] varName;
00502 <font class="keywordflow">break</font>;
00503 <font class="keywordflow">case</font> <font class="charliteral">'w'</font> :
00504 <font class="comment">// w(here) | Dump the call stack : the context of the current program location.</font>
00505 P.ContextDebug.callStackPrint(<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>);
00506 <font class="keywordflow">break</font>;
00507 <font class="keywordflow">case</font> <font class="charliteral">'u'</font> :
00508 <font class="comment">// u(p) | Travel up (to newer) frames in the call stack.</font>
00509 P.ContextDebug.stepIndexUp();
00510 <font class="keywordflow">break</font>;
00511 <font class="keywordflow">case</font> <font class="charliteral">'d'</font> :
00512 <font class="comment">// d(own) | Travel down (to older) frames in the call stack.</font>
00513 P.ContextDebug.stepIndexDown();
00514 <font class="keywordflow">break</font>;
00515 <font class="keywordflow">case</font> <font class="charliteral">'l'</font> :
00516 <font class="comment">// l(ist) first?, last? | List the current context's source code file : 11 lines, or around lines numbers.</font>
00517 first = last = 0;
00518 sscanf(buf+1, <font class="stringliteral">"%d %d"</font>,&first, &last);
00519 <font class="keywordflow">if</font> (0 == first) first = this-><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a13">getCurrentSourceCodeLineNumber</a>() - 6;
00520 <font class="keywordflow">if</font> (0 > first) first = 0;
00521 <font class="keywordflow">if</font> (0 == last) last = first + 11;
00522 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a15">printSourceCodeLine</a>(first, last);
00523 <font class="keywordflow">break</font>;
00524 <font class="keywordflow">case</font> <font class="charliteral">'b'</font> :
00525 <font class="comment">// b(reak) line? | Set more breakpoints on functions or line numbers, or list active breaks.</font>
00526 sourceFileName = <font class="keyword">new</font> <font class="keywordtype">char</font>[1024];
00527 sourceFileName[0] = 0;
00528 lineNumber = 0;
00529 sscanf(buf+1,<font class="stringliteral">"%d %s"</font>,&lineNumber,sourceFileName);
00530 <font class="keywordflow">if</font> (0 == lineNumber)
00531 {
00532 P.ContextDebug.printActiveBeaks(<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>);
00533 }
00534 <font class="keywordflow">else</font>
00535 {
00536 <font class="keywordflow">if</font> (sourceFileName[0])
00537 {
00538 P.ContextDebug.addBreakPoint((uint16)lineNumber,sourceFileName);
00539 }
00540 <font class="keywordflow">else</font>
00541 {
00542 P.ContextDebug.addBreakPoint((uint16)lineNumber,<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a12">getSourceFileName</a>().c_str());
00543 }
00544 }
00545 <font class="keyword">delete</font>[] sourceFileName;
00546 <font class="keywordflow">break</font>;
00547 <font class="keywordflow">case</font> <font class="charliteral">'e'</font> :
00548 <font class="comment">// e(rase) line? | Erase a specific breakpoint (or all of them)</font>
00549 sourceFileName = <font class="keyword">new</font> <font class="keywordtype">char</font>[1024];
00550 sourceFileName[0] = 0;
00551 sscanf(buf+1,<font class="stringliteral">"%d %s"</font>,&lineNumber,sourceFileName);
00552 <font class="keywordflow">if</font> (sourceFileName[0])
00553 {
00554 P.ContextDebug.eraseBreakPoint((uint16)lineNumber,sourceFileName);
00555 }
00556 <font class="keywordflow">else</font>
00557 {
00558 P.ContextDebug.eraseBreakPoint((uint16)lineNumber,<a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#a12">getSourceFileName</a>().c_str());
00559 }
00560 <font class="keyword">delete</font>[] sourceFileName;
00561 <font class="keywordflow">break</font>;
00562 <font class="keywordflow">case</font> <font class="charliteral">'s'</font> :
00563 <font class="comment">// s(tep) | Run the next line and stop; stop in called functions.</font>
00564 P.ContextDebug.setDebugMode(<a class="code" href="namespaceNLAISCRIPT.html#a52a14">stepInMode</a>);
00565 ret = <font class="keyword">true</font>;
00566 <font class="keywordflow">break</font>;
00567 <font class="keywordflow">case</font> <font class="charliteral">'n'</font> :
00568 <font class="comment">// n(ext) | Run the next line and stop, but don't stop in functions it calls.</font>
00569 P.ContextDebug.setDebugMode(<a class="code" href="namespaceNLAISCRIPT.html#a52a13">stepByStepMode</a>);
00570 ret = <font class="keyword">true</font>;
00571 <font class="keywordflow">break</font>;
00572 <font class="keywordflow">case</font> <font class="charliteral">'r'</font> :
00573 <font class="comment">// r(eturn) | Continue silently until the current function returns.</font>
00574 P.ContextDebug.setDebugMode(<a class="code" href="namespaceNLAISCRIPT.html#a52a15">stepOutMode</a>);
00575 ret = <font class="keyword">true</font>;
00576 <font class="keywordflow">break</font>;
00577 <font class="keywordflow">case</font> <font class="charliteral">'c'</font> :
00578 <font class="comment">// c(ontinue) | Continue programm execution until an error, breakpoint, or exit.</font>
00579 P.ContextDebug.setDebugMode(<a class="code" href="namespaceNLAISCRIPT.html#a52a12">runMode</a>);
00580 ret = <font class="keyword">true</font>;
00581 <font class="keywordflow">break</font>;
00582 <font class="keywordflow">case</font> <font class="charliteral">'a'</font> :
00583 <font class="comment">// a(rgs) | Print arguments passed to the current context's function.</font>
00584 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#c4">printArgs</a>(P);
00585 <font class="keywordflow">break</font>;
00586 <font class="keywordflow">case</font> <font class="charliteral">'q'</font> :
00587 <font class="comment">// q(uit) | Quit the debugger; also terminates the code being debugged.</font>
00588 P.ContextDebug.setDebugMode(<a class="code" href="namespaceNLAISCRIPT.html#a52a16">stopMode</a>);
00589 ret = <font class="keyword">true</font>;
00590 <font class="keywordflow">break</font>;
00591 <font class="keywordflow">case</font> 0 :
00592 <font class="comment">// <enter-key> | Repeat the last command.</font>
00593 ret = this-><a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRunDebug.html#c2">readCommandLine</a>(P, P.ContextDebug.getLastCommandLine());
00594 <font class="keywordflow">break</font>;
00595 <font class="keywordflow">case</font> <font class="charliteral">'h'</font> :
00596 <font class="comment">// h(elp) command ? | Get command help; you can forget the rest if you remember 'h'.</font>
00597
00598 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"p(rint) expr.\t| Inspect variables / attributes.\n"</font>);
00599 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"w(here)\t\t| Dump the call stack.\n"</font>);
00600 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"u(p)\t\t| Travel up (to newer) frames in the call stack.\n"</font>);
00601 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"d(own)\t\t| Travel down (to older) frames in the call stack.\n"</font>);
00602 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"l(ist) f?, l?\t| List the current context's source code file.\n"</font>);
00603 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"b(reak) line?\t| Set more breakpoints on line numbers, or list active breaks.\n"</font>);
00604 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"e(rase) line?\t| Erase a specific breakpoint (or all of them)\n"</font>);
00605 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"s(tep)\t\t| Run the next line and stop; stop in called functions.\n"</font>);
00606 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"n(ext)\t\t| Run the next line and stop, don't stop in functions it calls.\n"</font>);
00607 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"r(eturn)\t| Continue silently until the current function returns.\n"</font>);
00608 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"c(ontinue)\t| Continue programm execution until breakpoint, or exit.\n"</font>);
00609 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"a(rgs)\t\t| Print arguments passed to the current context's function.\n"</font>);
00610 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"q(uit)\t\t| Quit the debugger; also terminates the code being debugged.\n"</font>);
00611 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"<enter-key>\t| Repeat the last command.\n"</font>);
00612 <a class="code" href="classNLAISCRIPT_1_1CCodeBrancheRun.html#p0">InputOutput</a>-><a class="code" href="classNLAIC_1_1IIO.html#a1">Echo</a>(<font class="stringliteral">"h(elp) command ?| Get command help; you can forget the rest if you remember 'h'.\n"</font>);
00613 <font class="keywordflow">break</font>;
00614 }
00615
00616 <font class="keywordflow">return</font> ret;
00617 }
00618 }
</pre></div>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|