4 * Revision 1.1 2001/04/04 05:43:39 wang
5 * First commit: compiles on Linux, Amiga, Windows, Windows CE, generic gcc
7 * Revision 1.3 1999/11/26 13:13:47 bnv
8 * Changed: To use the new macros.
9 * Changed: To support 64-bit cpus.
11 * Revision 1.2 1999/03/10 16:55:35 bnv
12 * A bracket addition to keep compiler happy.
14 * Revision 1.1 1998/07/02 17:34:50 bnv
31 /* ---------- function prototypes ------------- */
32 void RxInitInterStr();
34 /* ---------- Extern variables ---------------- */
35 extern Clause
*CompileClause
; /* compile clauses */
36 extern int CompileCurClause
; /* current clause */
37 extern ErrorMsg errortext
[]; /* from lstring/errortxt.c */
38 extern bool _in_nextsymbol
; /* from nextsymb.c */
39 extern int _trace
; /* from interpret.c */
40 extern PLstr RxStck
[]; /* -//- */
41 extern int RxStckTop
; /* -//- */
42 extern Lstr _tmpstr
[]; /* -//- */
44 static char TraceChar
[] = {' ','>','L','V','C','O','F','.'};
46 /* ----------------- TraceCurline ----------------- */
48 TraceCurline( RxFile
**rxf
, int print
)
54 if (symbolptr
==NULL
) { /* we are in intepret */
55 if (CompileClause
==NULL
) {
56 if (rxf
) *rxf
= rxfile
;
60 codepos
= (size_t)((byte huge
*)Rxcip
- (byte huge
*)Rxcodestart
);
61 /* search for clause */
63 while (CompileClause
[cl
].ptr
) {
64 if (CompileClause
[cl
].code
>= codepos
)
69 line
= CompileClause
[cl
].line
;
70 ch
= CompileClause
[cl
].ptr
;
71 chend
= CompileClause
[cl
+1].ptr
;
73 for (chend
=ch
; *chend
!='\n'; chend
++) /*do nothing*/;;
74 _nesting
= _rx_proc
+ CompileClause
[cl
].nesting
;
76 *rxf
= CompileClause
[ cl
].fptr
;
77 } else { /* we are in compile */
78 if (CompileCurClause
==0)
81 cl
= CompileCurClause
-1;
83 _nesting
= CompileClause
[ cl
].nesting
;
85 if (CompileCurClause
==0)
88 *rxf
= CompileClause
[ cl
].fptr
;
93 while (ch
>symbolprevptr
)
94 if (*ch
--=='\n') line
--;
99 ch
= LSTR((*rxf
)->file
);
101 cl
= CompileCurClause
-1;
102 line
= CompileClause
[ cl
].line
;
103 ch
= CompileClause
[ cl
].ptr
;
105 for (chend
=ch
; *chend
!=';' && *chend
!='\n'; chend
++) /*do nothing*/;;
112 fprintf(STDERR
,"%6d *-* ",line
);
113 for (i
=1; i
<_nesting
; i
++) fputc(' ',STDERR
);
115 while (*ch
&& ch
<chend
) {
128 for (i
=1; i
<_nesting
; i
++) PUTCHAR(' ');
130 while (*ch
&& ch
<chend
) {
141 /* ---------------- TraceSet -------------------- */
143 TraceSet( PLstr trstr
)
155 _Proc
[_rx_proc
].interactive_trace
156 = 1 - _Proc
[_rx_proc
].interactive_trace
;
157 if (_Proc
[_rx_proc
].interactive_trace
)
159 fprintf(STDERR
," +++ %s +++\n",errortext
[2].errmsg
);
162 PUTS(errortext
[0].errmsg
);
170 _Proc
[_rx_proc
].trace
= all_trace
;
173 _Proc
[_rx_proc
].trace
= commands_trace
;
176 _Proc
[_rx_proc
].trace
= error_trace
;
180 /// _Proc[_rx_proc].trace = ;
184 _Proc
[_rx_proc
].trace
= intermediates_trace
;
187 _Proc
[_rx_proc
].trace
= labels_trace
;
190 _Proc
[_rx_proc
].trace
= normal_trace
;
193 _Proc
[_rx_proc
].trace
= off_trace
;
194 _Proc
[_rx_proc
].interactive_trace
= FALSE
;
197 _Proc
[_rx_proc
].trace
= results_trace
;
200 _Proc
[_rx_proc
].trace
= scan_trace
;
204 __debug__
= 1-__debug__
;
206 printf("\n\nInternal DEBUG starting...\n");
208 printf("\n\nInternal DEBUG ended\n");
212 Lerror(ERR_INVALID_TRACE
,1,trstr
);
216 /* --------------------- TraceByte -------------------- */
218 TraceByte( int middlechar
)
222 tracebyte
|= (middlechar
& TB_MIDDLECHAR
);
223 tracebyte
|= TB_TRACE
;
225 _CodeAddByte( tracebyte
);
228 /* ------------------ TraceClause ----------------- */
232 if (_Proc
[_rx_proc
].interactive_trace
) {
233 /* return if user specified a string for interactive trace */
234 if (TraceInteractive(TRUE
))
237 TraceCurline(NULL
,TRUE
);
240 /* ------------------ TraceInstruction ----------------- */
242 TraceInstruction( byte inst
)
244 if ((inst
& TB_MIDDLECHAR
) != nothing_middle
)
245 if (_Proc
[_rx_proc
].trace
== intermediates_trace
) {
248 fprintf(STDERR
," >%c> ",TraceChar
[ inst
& TB_MIDDLECHAR
]);
249 for (i
=0; i
<_nesting
; i
++) fputc(' ',STDERR
);
251 Lprint(STDERR
,RxStck
[RxStckTop
]);
252 fprintf(STDERR
,"\"\n");
255 PUTCHAR(TraceChar
[ inst
& TB_MIDDLECHAR
]);
257 for (i
=0; i
<_nesting
; i
++) PUTCHAR(' ');
259 Lprint(NULL
,RxStck
[RxStckTop
]);
263 } /* TraceInstruction */
264 /* ---------------- TraceInteractive ------------------- */
266 TraceInteractive( int frominterpret
)
268 /* Read the interactive string into a tmp var */
270 RxStck
[RxStckTop
] = &(_tmpstr
[RxStckTop
]);
272 Lread(STDIN
,RxStck
[RxStckTop
],LREADLINE
);
273 if (!LLEN(*RxStck
[RxStckTop
])) {
281 _Proc
[_rx_proc
].calltype
= CT_INTERACTIVE
;
283 _Proc
[_rx_proc
].calltype
= CT_INTERACTIVE
;
284 /* lets go again to NEWCLAUSE */
286 _Proc
[_rx_proc
].ip
-=sizeof(dword
);
288 _Proc
[_rx_proc
].ip
--;
292 } /* TraceInteractive */