Module Trace = Begin Require 'bliss.req'; ! G. MACRO TRACE ROUTINES Own blanks : Integer; ! display a stream of lexeme for trace output Routine display_stream(S : Ref Vector) : Novalue = Begin Local X : Ref GT, c : Integer; If .S Eqla 0 Then Begin Print(AZ('NULL\n')); Return End; Do Begin Incr I From 1 To .S[strm_size] Do Begin X = S[strm_data(.I-1)]; C = .X[lex_delim]; OutLexeme(.X[lex_type],.X[lex_addr]); If .DTPF[.c] Neq 0 Then Print(AZ('%p '),.DTPF[.c]) Else If .c Neq 0 Then Print(AZ('%c'),.c) Else Output(' '); End End While (S = .S[strm_next]) Neqa 0; Print(AZ('\n')) End; ! start the tracing of a macro Global Routine trace_begin : Novalue = Begin blanks = .blanks + 4 End; ! append trace_buff to the appropriate trace list in mac_info. ! this allows trace_buff to be reset for tracing the next macro. Global Routine trace_append(m) : Novalue = Begin Local p; p = stream_quit(trace_buff); If .m Then mac_trace2 = stream_concat(.mac_trace2,.p) Else mac_trace1 = stream_concat(.mac_trace1,.p) End; ! called after macro actuals are collected but before the ! actual expansion starts Global Routine trace_expansion(S : Ref ST) : Novalue = Begin Print(AZ(';;%t[%p]: EXPANSION\n'),.blanks,.s) End; ! called after macro actuals are collected and bound to ! their arguments but before trace_expansion is called. Global Routine trace_fixed_formals(S : Ref ST) : Novalue = Begin Incr I From 1 To .S[st_mac_num_fixed] Do Begin Print(AZ(';;%t[%p](%d)= '),.blanks,.s); display_stream(.mac_actuals[strm_data(.I-1)]) End End; Global Routine trace_end_iteration(S : Ref ST) : Novalue = Begin Print(AZ(';;%t[%p](%d)= '),.blanks,.s,.mac_iteration-1); mac_trace2 = stream_concat(.mac_trace2, stream_quit(trace_buff)); display_stream(.mac_trace2); mac_trace1 = stream_concat(.mac_trace1,.mac_trace2); mac_trace2 = 0 End; Global Routine trace_iterated_formals(S : Ref ST) : Novalue = Begin Incr I From 1 To .S[st_mac_num_ited] Do Begin Print(AZ(';;%t[%p](%d)[%d]= '),.blanks,.s, .mac_iteration-1, .i + .s[st_mac_num_fixed]); display_stream(.mac_actuals[strm_data(.I+.S[st_mac_num_fixed]-1)]) End End; Global Routine trace_bindings(S : Ref ST) : Novalue = Begin Print(AZ(';;%t[%p]: PARAMETER BINDING\n'),.blanks,.s) End; Global Routine trace_binding_expansion(S : Ref ST) : Novalue = Begin Print(AZ(';;%t[%p](%d): PARAMETER BINDING / EXPANSION\n'),.blanks,.s, .mac_iteration-1) End; ! called when a separator is about to be generated for an interated ! macro. Global Routine trace_separator(S : Ref ST,C : Integer) : Novalue = Begin Print(AZ(';;%t[%p]: SEPARATOR = %l\n'),.blanks,.s,.C) End; ! called when the end of a macro expansion is reached. save and prints ! all the lexemes collected for this macro. Global Routine trace_end(S : Ref ST) : Novalue = Begin mac_trace1 = stream_concat(.mac_trace1, stream_quit(trace_buff)); Print(AZ(';;%t[%p]= '),.blanks,.s); display_stream(.mac_trace1); Print(AZ('\n')); blanks = .blanks - 4 End; Global Routine trace_null_body(S : Ref ST) : Novalue = Begin Print(AZ(';;%t[%p]= '),.blanks,.s); display_stream(0); Print(AZ('\n')); blanks = .blanks - 4 End; End Eludom