~ubuntu-branches/ubuntu/vivid/inform/vivid

« back to all changes in this revision

Viewing changes to inform-6.31.1/lib/infix.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Christoph Nordholz
  • Date: 2008-05-26 22:09:44 UTC
  • mfrom: (2.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080526220944-ba7phz0d1k4vo7wx
Tags: 6.31.1+dfsg-1
* Remove a considerable number of files from the package
  due to unacceptable licensing terms.
* Repair library symlinks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
! ==============================================================================
 
2
!   INFIX:  Support for the optional library debugger extension "Infix".
 
3
!
 
4
!   Supplied for use with Inform 6 -- Release 6/11 -- Serial number 040227
 
5
!
 
6
!   Copyright Graham Nelson 1993-2004 but freely usable (see manuals)
 
7
!
 
8
!   This file is automatically Included in your game file by "Grammar" if you
 
9
!   supply the -X compiler switch.
 
10
! ==============================================================================
 
11
 
 
12
System_file;
 
13
 
 
14
! ------------------------------------------------------------------------------
 
15
 
 
16
#Ifdef DEBUG;
 
17
 
 
18
Constant INFIXTT_NUMBER          0;
 
19
Constant INFIXTT_ARRAY           1;
 
20
Constant INFIXTT_ROUTINE         2;
 
21
Constant INFIXTT_CONSTANT        3;
 
22
Constant INFIXTT_DWORD           4;
 
23
Constant INFIXTT_ACTION          5;
 
24
Constant INFIXTT_ATTRIBUTE       6;
 
25
Constant INFIXTT_PROPERTY        7;
 
26
Constant INFIXTT_GLOBAL          8;
 
27
Constant INFIXTT_NAMEDOBJECT     9;
 
28
Constant INFIXTT_SYSFUN         10;
 
29
Constant INFIXTT_STATICSTRING   11;
 
30
Constant INFIXTT_LOGICAL        12;
 
31
 
 
32
Global infix_term_type;
 
33
Global infix_data1;
 
34
Global infix_data2;
 
35
Global infix_lvalue;
 
36
Global infix_parsed_lvalue;
 
37
Array  infix_tolowercase -> 256;
 
38
#Ifdef VN_1630;
 
39
Array  infix_text buffer 126;
 
40
#Ifnot;
 
41
Array  infix_text -> 128;
 
42
#Endif; ! VN_
 
43
 
 
44
 
 
45
[ InfixPrintAttribute x; print (string) #attribute_names_array-->x; ];
 
46
 
 
47
[ InfixPrintProperty x;  print (property) x; ];
 
48
 
 
49
[ InfixPrintGlobal x;    print (string) #global_names_array-->x; ];
 
50
 
 
51
[ InfixPrintAction x;    print (string) #action_names_array-->(x-#lowest_action_number); ];
 
52
 
 
53
[ InfixPrintRoutine x;   print (string) #routine_names_array-->(x-#lowest_routine_number); ];
 
54
 
 
55
[ InfixPrintConstant x;  print (string) #constant_names_array-->(x-#lowest_constant_number); ];
 
56
 
 
57
[ InfixPrintArray x;     print (string) #array_names_array-->(x-#lowest_array_number); ];
 
58
 
 
59
[ InfixPrintFakeAction x;
 
60
                        print (string) #fake_action_names_array-->(x-#lowest_fake_action_number); ];
 
61
 
 
62
[ InfixPrintPA x n;
 
63
    for (n=#lowest_routine_number : n<=#highest_routine_number : n++) {
 
64
        if (x == Symb__Tab(INFIXTT_ROUTINE, n)) {
 
65
            print (InfixPrintRoutine) n; return;
 
66
        }
 
67
    }
 
68
    print "Routine(", x, ")";
 
69
];
 
70
 
 
71
[ InfixMatchPrule PrintingRule range1 range2 wa wl t i i2 it2 itlc j k plus;
 
72
    itlc = infix_tolowercase;
 
73
    if (itlc->255 == 0) {
 
74
        for (j=0 : j<256 : j++) itlc->j = j;
 
75
        itlc->'A' = 'a';    itlc->'B' = 'b';
 
76
        itlc->'C' = 'c';    itlc->'D' = 'd';
 
77
        itlc->'E' = 'e';    itlc->'F' = 'f';
 
78
        itlc->'G' = 'g';    itlc->'H' = 'h';
 
79
        itlc->'I' = 'i';    itlc->'J' = 'j';
 
80
        itlc->'K' = 'k';    itlc->'L' = 'l';
 
81
        itlc->'M' = 'm';    itlc->'N' = 'n';
 
82
        itlc->'O' = 'o';    itlc->'P' = 'p';
 
83
        itlc->'Q' = 'q';    itlc->'R' = 'r';
 
84
        itlc->'S' = 's';    itlc->'T' = 't';
 
85
        itlc->'U' = 'u';    itlc->'V' = 'v';
 
86
        itlc->'W' = 'w';    itlc->'X' = 'x';
 
87
        itlc->'Y' = 'y';    itlc->'Z' = 'z';
 
88
    }
 
89
    switch(PrintingRule) {
 
90
      InfixPrintAttribute:
 
91
        if (wa->0 == '~') { wl--; wa++; plus = 100; } ! A tilde
 
92
        t = #attribute_names_array;
 
93
      InfixPrintProperty:   t = #property_names_array;
 
94
      InfixPrintAction:     t = #action_names_array;
 
95
      InfixPrintFakeAction: t = #fake_action_names_array;
 
96
      InfixPrintGlobal:     t = #global_names_array;
 
97
      InfixPrintRoutine:    t = #routine_names_array;
 
98
      InfixPrintAction:     t = #constant_names_array;
 
99
      InfixPrintArray:      t = #array_names_array;
 
100
    }
 
101
 
 
102
    i2 = range2-range1; it2 = infix_text+2;
 
103
    for (i=0 : i<=i2 : i++) {
 
104
        infix_text-->0 = 62; @output_stream 3 infix_text;
 
105
        if (t) print (string) t-->i; else PrintingRule(i+range1);
 
106
        @output_stream -3;
 
107
        k = infix_text-->0;
 
108
        if (k ~= wl) jump XL;
 
109
        if (itlc->(it2->0) ~= wa->0) jump XL;
 
110
        for (j=1 : j<k : j++)
 
111
            if (itlc->(it2->j) ~= wa->j) jump XL;
 
112
        parsed_number = i + range1 + plus;
 
113
        rtrue;
 
114
      .XL;
 
115
    }
 
116
    rfalse;
 
117
];
 
118
 
 
119
[ InfixActionToken;
 
120
    if (InfixMatchPrule(InfixPrintAction, #lowest_action_number,
 
121
        #highest_action_number, WordAddress(wn), WordLength(wn))) {
 
122
        wn++; infix_lvalue = parsed_number; return 0;
 
123
    }
 
124
    if (InfixMatchPrule(InfixPrintFakeAction, #lowest_fake_action_number,
 
125
        #highest_fake_action_number, WordAddress(wn), WordLength(wn))) {
 
126
        wn++; infix_lvalue = parsed_number; return 0;
 
127
    }
 
128
    return -1;
 
129
];
 
130
 
 
131
[ InfixRvalueTerm n w i initial_wn wa wl sign base digit dcount;
 
132
 
 
133
    initial_wn = wn;
 
134
 
 
135
    infix_parsed_lvalue = -1;
 
136
    infix_term_type = INFIXTT_NUMBER;
 
137
 
 
138
    w = NextWordStopped();
 
139
    if (w == -1) return -1;
 
140
 
 
141
    wa = WordAddress(wn-1);
 
142
    wl = WordLength(wn-1);
 
143
    if (wa->0 == '-' or '$' or '0' or '1' or '2' or '3'
 
144
              or '4' or '5' or '6' or '7' or '8' or '9') {
 
145
        ! Parse decimal, hex or binary number
 
146
 
 
147
        sign = 1; base = 10; dcount = 0;
 
148
        if (wa->0 == '-') { sign = -1; wl--; wa++; }
 
149
        else {
 
150
            if (wa->0 == '$') { base = 16; wl--; wa++; }
 
151
            if (wa->0 == '$') { base = 2; wl--; wa++; }
 
152
        }
 
153
        if (wl == 0) return -1;
 
154
        n = 0;
 
155
        while (wl > 0) {
 
156
            if (wa->0 >= 'a') digit = wa->0 - 'a' + 10;
 
157
            else digit = wa->0 - '0';
 
158
            dcount++;
 
159
            switch (base) {
 
160
              2:
 
161
                if (dcount == 17) return -1;
 
162
              10:
 
163
                if (dcount == 6) return -1;
 
164
                if (dcount == 5) {
 
165
                    if (n > 3276) return -1;
 
166
                    if (n == 3276) {
 
167
                        if (sign == 1 && digit > 7) return -1;
 
168
                        if (sign == -1 && digit > 8) return -1;
 
169
                    }
 
170
                }
 
171
              16:
 
172
                if (dcount == 5) return -1;
 
173
            }
 
174
            if (digit >= 0 && digit < base) n = base*n + digit;
 
175
            else return -1;
 
176
            wl--; wa++;
 
177
        }
 
178
        parsed_number = n*sign; return 1;
 
179
    }
 
180
 
 
181
    ! Parse character constant 'a'
 
182
 
 
183
    if (wl == 3 && wa->0 == ''' && wa->2 == ''') {
 
184
        parsed_number = wa->1; return 1;
 
185
    }
 
186
 
 
187
    ! ##Action, 'dword'
 
188
 
 
189
    switch (w) {
 
190
      '##':
 
191
        infix_term_type = INFIXTT_ACTION;
 
192
        w = NextWordStopped(); if (w == -1) return -1;
 
193
        wn--;
 
194
        if (InfixActionToken() == 0) return 1;
 
195
        return -1;
 
196
      '^^':
 
197
        infix_term_type = INFIXTT_DWORD;
 
198
        w = NextWordStopped(); if (w == -1) return -1;
 
199
        parsed_number = w; return 1;
 
200
    }
 
201
 
 
202
    ! Test for attribute, property, class name, variable name, array name, routine
 
203
    ! name, constant name
 
204
 
 
205
    wn--;
 
206
    if ((wa->0 >= 'a' && wa->0 <= 'z') ||
 
207
        (wa->0 >= 'A' && wa->0 <= 'Z') ||
 
208
         wa->0 == '_') {
 
209
 
 
210
 
 
211
        infix_term_type = INFIXTT_ATTRIBUTE;
 
212
        if (InfixMatchPrule(InfixPrintAttribute, #lowest_attribute_number,
 
213
            #highest_attribute_number, wa, wl)) {
 
214
            wn++; return 1; }
 
215
 
 
216
        infix_term_type = INFIXTT_PROPERTY;
 
217
        if (InfixMatchPrule(InfixPrintProperty, #lowest_property_number,
 
218
            #highest_property_number, wa, wl)) {
 
219
            wn++; return 1; }
 
220
 
 
221
        infix_term_type = INFIXTT_GLOBAL;
 
222
        if (InfixMatchPrule(InfixPrintGlobal, #lowest_global_number,
 
223
            #highest_global_number, wa, wl)) {
 
224
            infix_parsed_lvalue = parsed_number-16;
 
225
            parsed_number = #globals_array-->infix_parsed_lvalue;
 
226
            wn++; return 1;
 
227
        }
 
228
 
 
229
        infix_term_type = INFIXTT_ARRAY;
 
230
        if (InfixMatchPrule(InfixPrintArray, #lowest_array_number,
 
231
            #highest_array_number, wa, wl)) {
 
232
            infix_parsed_lvalue = parsed_number;
 
233
            parsed_number = Symb__Tab(INFIXTT_ARRAY,parsed_number);
 
234
            infix_data1 = temp__global3;
 
235
            infix_data2 = temp__global2;
 
236
            wn++; return 1;
 
237
        }
 
238
 
 
239
        infix_term_type = INFIXTT_ROUTINE;
 
240
        if (InfixMatchPrule(InfixPrintRoutine, #lowest_routine_number,
 
241
            #highest_routine_number, wa, wl)) {
 
242
            infix_parsed_lvalue = parsed_number;
 
243
            parsed_number = Symb__Tab(INFIXTT_ROUTINE,parsed_number);
 
244
            infix_data1 = temp__global3;
 
245
            infix_data2 = temp__global2;
 
246
            wn++; return 1;
 
247
        }
 
248
 
 
249
        infix_term_type = INFIXTT_CONSTANT;
 
250
        if (InfixMatchPrule(InfixPrintConstant, #lowest_constant_number,
 
251
            #highest_constant_number, wa, wl)) {
 
252
            infix_parsed_lvalue = parsed_number;
 
253
            parsed_number = Symb__Tab(INFIXTT_CONSTANT,parsed_number);
 
254
            infix_data1 = temp__global3;
 
255
            infix_data2 = temp__global2;
 
256
            wn++; return 1;
 
257
        }
 
258
 
 
259
        switch (w) {
 
260
          'parent', 'child', 'children',
 
261
          'random', 'metaclass', 'sibling':
 
262
            parsed_number = w;
 
263
            infix_parsed_lvalue = INFIXTT_SYSFUN;
 
264
            wn++; return 1;
 
265
        }
 
266
    }
 
267
 
 
268
    infix_term_type = INFIXTT_NAMEDOBJECT;
 
269
 
 
270
    wn = initial_wn; i = ParseToken(SCOPE_TT, InfixBigScope);
 
271
 
 
272
    if (i == GPR_REPARSE) return i;
 
273
    if (i > GPR_MULTIPLE) {
 
274
        print "(", (name) i, " (", i, "))^";
 
275
        parsed_number = i; return 1;
 
276
    }
 
277
    return -1;
 
278
]; ! end of InfixRvalueTerm
 
279
 
 
280
[ InfixBigScope x;
 
281
    if (scope_stage == 1) return false;  ! No multiples here
 
282
    if (scope_stage == 2) {
 
283
        objectloop (x ofclass Object) PlaceInScope(x);
 
284
        return true; ! That's the whole scope
 
285
    }
 
286
    print "; I'm unable to make any sense of that term.^";
 
287
];
 
288
 
 
289
[ InfixCheckLineSpaced wa wl i force altered;
 
290
    for (i=1 : i<=parse->1 : i++) {
 
291
        wa = WordAddress(i);
 
292
        wl = WordLength(i);
 
293
        if (wl > 3 && wa->0 == ''' && wa->(wl-1) == ''') {
 
294
            wa->(wl-1) = ' ';
 
295
            if (wa->(wl-2) == '/' && wa->(wl-3) == '/') {
 
296
                wa->(wl-2) = ' ';
 
297
                wa->(wl-3) = ' ';
 
298
            }
 
299
            LTI_Insert(wa-buffer, ''');
 
300
            LTI_Insert(wa-buffer + 2, ' ');
 
301
            altered = true; break;
 
302
        }
 
303
    }
 
304
    for (i=2 : i<buffer->1 + 2 : i++) {
 
305
        force = false;
 
306
        if (buffer->i == '-' && buffer->(i+1) == '-' && buffer->(i+2) == '>')
 
307
            force = true;
 
308
        if (force) {
 
309
            if (i>2 && buffer->(i-1) ~= ' ') {
 
310
                LTI_Insert(i++, ' '); altered = true;
 
311
            }
 
312
            if (buffer->(i+3) ~= ' ') {
 
313
                LTI_Insert(i+3, ' '); i++; altered = true;
 
314
            }
 
315
            i = i + 2; continue;
 
316
        }
 
317
 
 
318
        if (buffer->i == ':' && buffer->(i+1) == ':') force = true;
 
319
        if (buffer->i == '-' && buffer->(i+1) == '>') force = true;
 
320
        if (buffer->i == '.' && buffer->(i+1) == '&') {
 
321
            buffer->i = ']'; force = true;
 
322
        }
 
323
        if (buffer->i == '.' && buffer->(i+1) == '#') {
 
324
            buffer->i = ']'; force = true;
 
325
        }
 
326
        if (buffer->i == ']' && buffer->(i+1) == '&') force = true;
 
327
        if (buffer->i == ']' && buffer->(i+1) == '#') force = true;
 
328
        if (buffer->i == '+' && buffer->(i+1) == '+') force = true;
 
329
        if (buffer->i == '-' && buffer->(i+1) == '-') force = true;
 
330
        if (buffer->i == '&' && buffer->(i+1) == '&') force = true;
 
331
        if (buffer->i == '|' && buffer->(i+1) == '|') force = true;
 
332
        if (buffer->i == '~' && buffer->(i+1) == '~') force = true;
 
333
 
 
334
        if (buffer->i == '=' && buffer->(i+1) == '=') force = true;
 
335
        if (buffer->i == '~' && buffer->(i+1) == '=') force = true;
 
336
        if (buffer->i == '>' && buffer->(i+1) == '=') force = true;
 
337
        if (buffer->i == '<' && buffer->(i+1) == '=') force = true;
 
338
        if (buffer->i == '#' && buffer->(i+1) == '#') force = true;
 
339
 
 
340
        if (force) {
 
341
            if (i > 2 && buffer->(i-1) ~= ' ') {
 
342
                LTI_Insert(i++, ' '); altered = true;
 
343
            }
 
344
            if (buffer->(i+2) ~= ' ') {
 
345
                LTI_Insert(i+2, ' '); i++; altered = true;
 
346
            }
 
347
            i = i + 1; continue;
 
348
        }
 
349
 
 
350
        if (buffer->i == '+') force = true;
 
351
        if (buffer->i == '-') force = true;
 
352
        if (buffer->i == '*') force = true;
 
353
        if (buffer->i == '/') force = true;
 
354
        if (buffer->i == '%') force = true;
 
355
        if (buffer->i == '(') force = true;
 
356
        if (buffer->i == ')') force = true;
 
357
        if (buffer->i == '<' && buffer->(i-1) ~= ';') force = true;
 
358
        if (buffer->i == '>') force = true;
 
359
        if (buffer->i == ',') force = true;
 
360
        if (buffer->i == '.') force = true;
 
361
        if (buffer->i == '&') force = true;
 
362
        if (buffer->i == '|') force = true;
 
363
        if (buffer->i == '~') force = true;
 
364
        if (buffer->i == '=') force = true;
 
365
        if (force) {
 
366
            if (i > 2 && buffer->(i-1) ~= ' ') {
 
367
                LTI_Insert(i++, ' '); altered = true;
 
368
            }
 
369
            if (buffer->(i+1) ~= ' ') {
 
370
                LTI_Insert(i+1, ' '); i++; altered = true;
 
371
            }
 
372
        }
 
373
    }
 
374
    for (i=2 : i<buffer->1 + 2 : i++)
 
375
        if (buffer->i == '~') { buffer->i = '['; altered = true; }
 
376
    return altered;
 
377
]; ! end of InfixCheckLineSpaced
 
378
 
 
379
Array InfixRV_rvals --> 32;
 
380
Array InfixRV_lvals --> 32;
 
381
Array InfixRV_op --> 32;
 
382
Array InfixRV_lop --> 32;
 
383
Array InfixRV_rop --> 32;
 
384
Array InfixRV_types --> 32;
 
385
Array InfixRV_commas --> 32;
 
386
 
 
387
[ InfixInBounds addr index n;
 
388
    if (addr < #array__start || addr > #array__end)
 
389
        rtrue;
 
390
    for (n=#lowest_array_number : n<=#highest_array_number : n++) {
 
391
        if (addr == Symb__Tab(INFIXTT_ARRAY, n)) {
 
392
            if (temp__global3 == 1 or 3)
 
393
                temp__global2=temp__global2*WORDSIZE+WORDSIZE-1;
 
394
            if (index > temp__global2) {
 
395
                print "Array index out of range";
 
396
                rfalse;
 
397
            }
 
398
        }
 
399
    }
 
400
    rtrue;
 
401
];
 
402
 
 
403
[ InfixRvalue acc w i n flag base expecting_term max maxi lop rop lvalside
 
404
              a b sysfun_f;
 
405
 
 
406
    if (InfixCheckLineSpaced()) return GPR_REPARSE;
 
407
 
 
408
!   w = wn; for (i=0 : i<10 : i++) { wn = w; InfixRvalueTerm(); print i, "^"; }
 
409
!   wn = w;
 
410
 
 
411
    expecting_term = true; base = 0;
 
412
    do {
 
413
        w = NextWordStopped();
 
414
        if (expecting_term) {
 
415
            switch (w) {
 
416
              '-//':
 
417
                InfixRV_rvals-->n = 'unary-'; InfixRV_types-->n = base + 8;
 
418
              '[//':
 
419
                InfixRV_rvals-->n = w; InfixRV_types-->n = base + 6;
 
420
              '[[':
 
421
                InfixRV_rvals-->n = w; InfixRV_types-->n = base + 2;
 
422
              '++':
 
423
                InfixRV_rvals-->n = 'pre++'; InfixRV_types-->n = base + 9;
 
424
              '--':
 
425
                InfixRV_rvals-->n = 'pre--'; InfixRV_types-->n = base + 9;
 
426
              '(//':
 
427
                InfixRV_rvals-->n = w; InfixRV_types-->n = -3; base=base+100;
 
428
              ')//':
 
429
                InfixRV_rvals-->n = w; InfixRV_types-->n = -3; base=base-100;
 
430
                if (base < 0) { wn--; flag = true; }
 
431
              -1:
 
432
                flag = true;
 
433
              default:
 
434
                wn--;
 
435
                if (InfixRValueTerm() == 1) {
 
436
                    InfixRV_rvals-->n = parsed_number;
 
437
                    InfixRV_lvals-->n = infix_parsed_lvalue;
 
438
                    InfixRV_types-->n = -1;
 
439
                    expecting_term = false;
 
440
                }
 
441
                else flag = true;
 
442
            }
 
443
        }
 
444
        else {
 
445
            expecting_term = true;
 
446
            switch (w) {
 
447
              comma_word:
 
448
                InfixRV_rvals-->n = w; InfixRV_types-->n = base;
 
449
              '=//':
 
450
                InfixRV_rvals-->n = w; InfixRV_types-->n = base + 1;
 
451
              '&&', '||':
 
452
                InfixRV_rvals-->n = w; InfixRV_types-->n = base + 2;
 
453
              '==', '[=', '>//', '>=', '<//', '<=', 'has', 'hasnt',
 
454
              'in', 'notin', 'ofclass', 'provides':
 
455
                InfixRV_rvals-->n = w; InfixRV_types-->n = base + 3;
 
456
              'or':
 
457
                InfixRV_rvals-->n = w; InfixRV_types-->n = base + 4;
 
458
              '+//', '-//':
 
459
                InfixRV_rvals-->n = w; InfixRV_types-->n = base + 5;
 
460
              '*//', '@{2f}//', '%//', '&//', '|//':
 
461
                InfixRV_rvals-->n = w; InfixRV_types-->n = base + 6;
 
462
              '->', '-->':
 
463
                InfixRV_rvals-->n = w; InfixRV_types-->n = base + 7;
 
464
              ']&', ']#':
 
465
                InfixRV_rvals-->n = w; InfixRV_types-->n = base + 10;
 
466
              THEN1__WD:
 
467
                InfixRV_rvals-->n = w; InfixRV_types-->n = base + 12;
 
468
              '::':
 
469
                InfixRV_rvals-->n = w; InfixRV_types-->n = base + 13;
 
470
              '(//':
 
471
                InfixRV_rvals-->n = '(rcall';
 
472
                InfixRV_types-->n = base + 11; base = base + 100;
 
473
              ')//':
 
474
                InfixRV_rvals-->n = w; InfixRV_types-->n = -3;
 
475
                base = base - 100;
 
476
                if (base < 0) { wn--; flag = true; }
 
477
                expecting_term = false;
 
478
              '++':
 
479
                InfixRV_rvals-->n = 'post++'; InfixRV_types-->n = base + 9;
 
480
                expecting_term = false;
 
481
              '--':
 
482
                InfixRV_rvals-->n = 'post--'; InfixRV_types-->n = base + 9;
 
483
                expecting_term = false;
 
484
              default:
 
485
                flag = true;
 
486
            }
 
487
        }
 
488
        n++;
 
489
    } until (flag || n == 32);
 
490
    if (base > 0) return -1;
 
491
    n--; if (n == 0) return -1;
 
492
    wn--;
 
493
 
 
494
    for (i=0 : i<n : i++) {
 
495
        acc = 0; if (InfixRV_types-->i ~= -3) acc = InfixRV_rvals-->i;
 
496
        InfixRV_op-->i = acc;
 
497
    }
 
498
 
 
499
    for (::) {
 
500
 
 
501
!       for (i=0 : i<n : i++) {
 
502
!           if (InfixRV_types-->i == -1) print InfixRV_rvals-->i, " ";
 
503
!           else if (InfixRV_types-->i == -3) print " # ";
 
504
!           else if (InfixRV_types-->i == -2) print " ## ";
 
505
!           else print (address) InfixRV_rvals-->i, "_", InfixRV_types-->i, " ";
 
506
!       }
 
507
!       new_line;
 
508
 
 
509
        max = -2;
 
510
        for (i=0 : i<n : i++) if (InfixRV_types-->i > max) {
 
511
                            max = InfixRV_types-->i; maxi = i; }
 
512
        if (max == -1) { parsed_number = InfixRV_rvals-->maxi; return 1; }
 
513
 
 
514
        lop = maxi-1; rop = maxi+1;
 
515
        while (lop >= 0 && InfixRV_types-->lop < -1) lop--;
 
516
        while (rop < n && InfixRV_types-->rop < -1) rop++;
 
517
        if (lop >= 0) InfixRV_lop-->maxi = InfixRV_rvals-->lop;
 
518
        if (rop < n) InfixRV_rop-->maxi = InfixRV_rvals-->rop;
 
519
        flag = false;
 
520
        infix_term_type = INFIXTT_NUMBER;
 
521
        switch (InfixRV_rvals-->maxi) {
 
522
          comma_word:
 
523
            acc = (InfixRV_rvals-->rop);
 
524
          '=//', 'pre++', 'post++', 'pre--', 'post--':
 
525
            lvalside = lop;
 
526
            switch (InfixRV_rvals-->maxi) {
 
527
              '=//':        acc = (InfixRV_rvals-->rop);
 
528
              'pre++':      acc = (InfixRV_rvals-->rop) + 1; lvalside = rop;
 
529
              'pre--':      acc = (InfixRV_rvals-->rop) - 1; lvalside = rop;
 
530
              'post++':     acc = (InfixRV_rvals-->lop) + 1;
 
531
              'post--':     acc = (InfixRV_rvals-->lop) - 1;
 
532
            }
 
533
            switch (InfixRV_op-->lvalside) {
 
534
              THEN1__WD:
 
535
                (InfixRV_lop-->lvalside).(InfixRV_rop-->lvalside) = acc;
 
536
              '->':
 
537
                if (InfixInBounds(InfixRV_lop-->lvalside, InfixRV_rop-->lvalside))
 
538
                    (InfixRV_lop-->lvalside)->(InfixRV_rop-->lvalside) = acc;
 
539
              '-->':
 
540
                if (InfixInBounds(InfixRV_lop-->lvalside, WORDSIZE * InfixRV_rop-->lvalside))
 
541
                    (InfixRV_lop-->lvalside)-->(InfixRV_rop-->lvalside) = acc;
 
542
              default:
 
543
                w = InfixRV_lvals-->lvalside; if (w == -1) return -1;
 
544
                @storew #globals_array w acc;
 
545
            }
 
546
            switch(InfixRV_rvals-->maxi) {
 
547
              'post++': acc--;
 
548
              'post--': acc++;
 
549
            }
 
550
          '(rcall':
 
551
            sysfun_f = false;
 
552
            switch (InfixRV_op-->lop) {
 
553
              THEN1__WD:
 
554
                a = InfixRV_lop-->lop; b = InfixRV_rop-->lop;
 
555
              default:
 
556
                a = InfixRV_rvals-->lop; b = call;
 
557
                if (InfixRV_lvals-->lop == INFIXTT_SYSFUN)
 
558
                    sysfun_f = true;
 
559
            }
 
560
            w = 0;
 
561
            i = maxi + 1; base = 100;
 
562
            if (InfixRV_types-->i == -1 && InfixRV_rvals-->i == ')//') {
 
563
                if (sysfun_f) return -1;
 
564
                acc = a.b();
 
565
            }
 
566
            else {
 
567
                while (base > 0) {
 
568
                    if (InfixRV_types-->i == -3 && InfixRV_rvals-->i == ')//') base = base - 100;
 
569
                    if (InfixRV_types-->i == -3 && InfixRV_rvals-->i == '(//') base = base + 100;
 
570
                    if (InfixRV_op-->i == '(rcall') base = base + 100;
 
571
                    if (base == 100 && InfixRV_op-->i == comma_word) {
 
572
                        InfixRV_commas-->(w++) = i;
 
573
!                       print "Comma found at ", i, "^";
 
574
                    }
 
575
                    i++;
 
576
                }
 
577
!               print "Num args = ", w + 1, "^";
 
578
!               for (i=0 : i<w : i++)
 
579
!                   print "arg: ", InfixRV_lop-->(InfixRV_commas-->i), "^";
 
580
!               print "arg: ", InfixRV_rvals-->rop, "^";
 
581
                switch (w+1) {
 
582
                  1:
 
583
                    if (sysfun_f) {
 
584
                        b = InfixRV_rvals-->rop;
 
585
                        infix_term_type = INFIXTT_NAMEDOBJECT;
 
586
                        switch(a) {
 
587
                          'metaclass':
 
588
                            acc = metaclass(b);
 
589
                          'parent':
 
590
                            acc = parent(b);
 
591
                          'child':
 
592
                            acc = child(b);
 
593
                          'children':
 
594
                            acc = children(b);
 
595
                            infix_term_type = INFIXTT_NUMBER;
 
596
                          'random':
 
597
                            acc = random(b);
 
598
                            infix_term_type = INFIXTT_NUMBER;
 
599
                          'sibling':
 
600
                            acc = sibling(b);
 
601
                        }
 
602
                    }
 
603
                    else
 
604
                        acc = a.b(InfixRV_rvals-->rop);
 
605
                  2:
 
606
                    if (sysfun_f) return -1;
 
607
                    acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
 
608
                              InfixRV_rvals-->rop);
 
609
                  3:
 
610
                    if (sysfun_f) return -1;
 
611
                    acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
 
612
                              InfixRV_lop-->(InfixRV_commas-->1),
 
613
                              InfixRV_rvals-->rop);
 
614
                  4:
 
615
                    if (sysfun_f) return -1;
 
616
                    acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
 
617
                              InfixRV_lop-->(InfixRV_commas-->1),
 
618
                              InfixRV_lop-->(InfixRV_commas-->2),
 
619
                              InfixRV_rvals-->rop);
 
620
                  5:
 
621
                    if (sysfun_f) return -1;
 
622
                    acc = a.b(InfixRV_lop-->(InfixRV_commas-->0),
 
623
                              InfixRV_lop-->(InfixRV_commas-->1),
 
624
                              InfixRV_lop-->(InfixRV_commas-->2),
 
625
                              InfixRV_lop-->(InfixRV_commas-->3),
 
626
                              InfixRV_rvals-->rop);
 
627
                  default:
 
628
                    return -1;
 
629
                }
 
630
            }
 
631
          '+//':        acc = (InfixRV_rvals-->lop) + (InfixRV_rvals-->rop);
 
632
          '-//':        acc = (InfixRV_rvals-->lop) - (InfixRV_rvals-->rop);
 
633
          '*//':        acc = (InfixRV_rvals-->lop) * (InfixRV_rvals-->rop);
 
634
          '@{2f}//':    acc = (InfixRV_rvals-->lop) / (InfixRV_rvals-->rop);
 
635
          '%//':        acc = (InfixRV_rvals-->lop) % (InfixRV_rvals-->rop);
 
636
          THEN1__WD:    acc = (InfixRV_rvals-->lop) . (InfixRV_rvals-->rop);
 
637
          '->':         acc = (InfixRV_rvals-->lop) -> (InfixRV_rvals-->rop);
 
638
          '-->':        acc = (InfixRV_rvals-->lop) --> (InfixRV_rvals-->rop);
 
639
          ']&':         acc = (InfixRV_rvals-->lop) .& (InfixRV_rvals-->rop);
 
640
          ']#':         acc = (InfixRV_rvals-->lop) .# (InfixRV_rvals-->rop);
 
641
          '::':         acc = (InfixRV_rvals-->lop) :: (InfixRV_rvals-->rop);
 
642
          '&//':        acc = (InfixRV_rvals-->lop) & (InfixRV_rvals-->rop);
 
643
          '|//':        acc = (InfixRV_rvals-->lop) | (InfixRV_rvals-->rop);
 
644
          '&&':         acc = (InfixRV_rvals-->lop) && (InfixRV_rvals-->rop);
 
645
                        infix_term_type = INFIXTT_LOGICAL;
 
646
          '||':         acc = (InfixRV_rvals-->lop) || (InfixRV_rvals-->rop);
 
647
                        infix_term_type = INFIXTT_LOGICAL;
 
648
          '<//':        acc = (InfixRV_rvals-->lop) < (InfixRV_rvals-->rop);
 
649
                        infix_term_type = INFIXTT_LOGICAL;
 
650
          '<=':         acc = (InfixRV_rvals-->lop) <= (InfixRV_rvals-->rop);
 
651
                        infix_term_type = INFIXTT_LOGICAL;
 
652
          '>//':        acc = (InfixRV_rvals-->lop) > (InfixRV_rvals-->rop);
 
653
                        infix_term_type = INFIXTT_LOGICAL;
 
654
          '>=':         acc = (InfixRV_rvals-->lop) >= (InfixRV_rvals-->rop);
 
655
                        infix_term_type = INFIXTT_LOGICAL;
 
656
          '==':         acc = (InfixRV_rvals-->lop) == (InfixRV_rvals-->rop);
 
657
                        infix_term_type = INFIXTT_LOGICAL;
 
658
          '[=':         acc = (InfixRV_rvals-->lop) ~= (InfixRV_rvals-->rop);
 
659
                        infix_term_type = INFIXTT_LOGICAL;
 
660
          'has':        acc = (InfixRV_rvals-->lop) has (InfixRV_rvals-->rop);
 
661
                        infix_term_type = INFIXTT_LOGICAL;
 
662
          'hasnt':      acc = (InfixRV_rvals-->lop) hasnt (InfixRV_rvals-->rop);
 
663
                        infix_term_type = INFIXTT_LOGICAL;
 
664
          'in':         acc = (InfixRV_rvals-->lop) in (InfixRV_rvals-->rop);
 
665
                        infix_term_type = INFIXTT_LOGICAL;
 
666
          'notin':      acc = (InfixRV_rvals-->lop) notin (InfixRV_rvals-->rop);
 
667
                        infix_term_type = INFIXTT_LOGICAL;
 
668
          'provides':   acc = (InfixRV_rvals-->lop) provides (InfixRV_rvals-->rop);
 
669
                        infix_term_type = INFIXTT_LOGICAL;
 
670
          'ofclass':    acc = (InfixRV_rvals-->lop) ofclass (InfixRV_rvals-->rop);
 
671
                        infix_term_type = INFIXTT_LOGICAL;
 
672
          '[[':         acc = ~~ (InfixRV_rvals-->rop); flag = true;
 
673
          '[//':        acc = ~ (InfixRV_rvals-->rop); flag = true;
 
674
          'unary-':     acc = - (InfixRV_rvals-->rop); flag = true;
 
675
        } ! end of switch(InfixRV_rvals-->maxi)
 
676
        InfixRV_rvals-->maxi = acc;
 
677
        InfixRV_types-->maxi = -1;
 
678
        if (rop < n) InfixRV_types-->rop = -2;
 
679
        if (flag == false && lop >= 0) InfixRV_types-->lop = -2;
 
680
    } ! end of for (::)
 
681
]; ! end of InfixRvalue
 
682
 
 
683
! ------------------------------------------------------------------------
 
684
 
 
685
[ InfixWelcomeSub;
 
686
    print "; Welcome to the ~Infix~ debugger (1/990428), which makes the
 
687
        following verbs available:^^
 
688
        ~; <expression>~: evaluates this Inform expression: e.g.
 
689
        ~; location~ will print the value of the variable ~location~,
 
690
        ~; 3*5+1~ will print 16, ~; children(old cloth bag)~ will tell you
 
691
        how many items are in it. (You can name objects either by their
 
692
        names inside the source code, such as ~n_obj~, or by typing the
 
693
        names by which the game's parser would normally know them, such
 
694
        as ~north wall~: the effect is the same.)^
 
695
        Any expression is allowed except that you can't use double-quoted
 
696
        strings of text: but you can send messages, call routines or
 
697
        assign values to variables, properties and array entries.
 
698
        ^   ~; score++~ is one way to get on in the world.
 
699
        ^   ~; deadflag = true~ is one way to get out of it.
 
700
        ^   ~; StopDaemon(nasty little dwarf)~ will keep you from being pestered.^
 
701
        Conditions like ~; score>20~ are also allowed and print
 
702
        either 1 (if true) or 0 (if false).^^";
 
703
    print "~;examine <something>~ or ~;x <something>~ gives full details
 
704
        of whatever it is. For instance, ~;x ##Take~ describes the Take
 
705
        action; ~;x Class~ the class Class; ~;x 'drop'~ the dictionary
 
706
        word ~drop~ and so on for numbers, routines, arrays and of course
 
707
        objects.  ~;xo~ examines something as an object, so for instance
 
708
        ~;x location~ tells you about the variable ~location~, but ~;xo
 
709
        location~ tells you what object it refers to.^^";
 
710
    print "~;give~, ~;remove~ and ~;move~ work like the corresponding
 
711
        Inform statements.^^";
 
712
    print "~;<~ causes an action: for instance, ~;< Eat cheese~.^^";
 
713
    print "~;watch~ or ~;w~ can set a watch on various activities:
 
714
        type just ~;w~ for details.^^";
 
715
    print "~;inventory~ or ~;i~ describes the contents of this story file.^";
 
716
];
 
717
 
 
718
[ InfixEvalSub; InfixExamineP(true); ];
 
719
 
 
720
[ InfixActionSub;
 
721
    print "; <", (InfixPrintAction) infix_lvalue;
 
722
    if (noun) print " (", (the) noun, ")";
 
723
    if (second) print " (", (the) second, ")";
 
724
    print ">^";
 
725
    if (second) <<(infix_lvalue) noun second>>;
 
726
    if (noun) <<(infix_lvalue) noun>>;
 
727
    <<(infix_lvalue)>>;
 
728
];
 
729
 
 
730
[ InfixGiveSub f;
 
731
    print "; give (", (the) noun, ") ";
 
732
    if (second < 0) { second = ~second; f=true; }
 
733
    if (second < 0 || second >= 48) "<No such attribute>";
 
734
    if (f) print "@@126";
 
735
    print (DebugAttribute) second;
 
736
    if (f) @clear_attr noun second;
 
737
    else @set_attr noun second;
 
738
];
 
739
 
 
740
[ InfixMoveSub;
 
741
    print "; move (", (the) noun, ") to (", (the) second, ")";
 
742
    move noun to second;
 
743
];
 
744
 
 
745
[ InfixRemoveSub;
 
746
    print "; remove (", (the) noun, ")";
 
747
    remove noun;
 
748
];
 
749
 
 
750
[ InfixHex x y;
 
751
    y = (x & $7f00) / $100;
 
752
    if (x < 0) y = y + $80;
 
753
    x = x & $ff;
 
754
    print (Infixhexdigit) y/$10, (Infixhexdigit) y, (Infixhexdigit) x/$10, (Infixhexdigit) x;
 
755
];
 
756
 
 
757
[ Infixhexdigit x; x = x % $10; if (x < 10) print x; else print (char) 'a'+x-10; ];
 
758
 
 
759
[ InfixExamineOSub;
 
760
    infix_data1 = metaclass(noun);
 
761
    infix_term_type = INFIXTT_CONSTANT;
 
762
    InfixExamineP(false);
 
763
];
 
764
 
 
765
[ InfixExamineSSub;
 
766
    infix_term_type = INFIXTT_STATICSTRING;
 
767
    InfixExamineP(false);
 
768
];
 
769
 
 
770
[ InfixExamineSub;     InfixExamineP(false); ];
 
771
 
 
772
[ InfixExamineP brief x a b w flag lines;
 
773
    switch (infix_term_type) {
 
774
      INFIXTT_NUMBER:
 
775
        if (brief) "; == ", noun;
 
776
        print "; The number ", noun, " == $", (InfixHex) noun;
 
777
        if (noun >= 32 && noun < 127) print " == '", (char) noun, "'";
 
778
        new_line;
 
779
      INFIXTT_NAMEDOBJECT:
 
780
        print "~", (name) noun, "~ (", noun, ")^"; if (brief) return;
 
781
        <<Showobj noun>>;
 
782
      INFIXTT_CONSTANT:
 
783
        if (brief) "; == ", noun;
 
784
        switch (infix_data1 & 15) {
 
785
            nothing:
 
786
                print "; Constant ", (InfixPrintConstant) infix_parsed_lvalue,
 
787
                " == ", noun, "^";
 
788
            Object: <<Showobj noun>>;
 
789
            Class:
 
790
                print "Class ", (name) noun, "^";
 
791
                objectloop (a ofclass noun) {
 
792
                    if (flag) print ", "; else print "Contains: ";
 
793
                    print (name) a, " (", a, ")"; flag=true;
 
794
                }
 
795
                if (flag == false) "No object is of this class";
 
796
        }
 
797
        new_line;
 
798
      INFIXTT_ATTRIBUTE:
 
799
        if (brief) "; == ", noun;
 
800
        if (noun >= 48 || noun < 0) "; No such attribute";
 
801
        print "; Attribute ", (InfixPrintAttribute) noun,
 
802
            " (numbered ", noun, ")^";
 
803
        objectloop (x has noun) {
 
804
            if (flag) print ", ";
 
805
            else print "Each of these ~has ", (InfixPrintAttribute) noun, "~: ";
 
806
            print (name) x, " (", x, ")"; flag = true;
 
807
        }
 
808
        if (flag == false) "No object ~has ", (InfixPrintAttribute) noun, "~";
 
809
        new_line;
 
810
      INFIXTT_PROPERTY:
 
811
        if (brief) "; == ", noun;
 
812
        print "; Property ", (property) noun, " (numbered ", noun, ")^";
 
813
        objectloop (x provides noun) {
 
814
            if (flag) print ", "; else print "Provided by: ";
 
815
            print (name) x, " (", x, ")"; flag = true;
 
816
        }
 
817
        if (flag == false) "Which is not provided by any object";
 
818
        new_line;
 
819
      INFIXTT_DWORD:
 
820
        if (brief) "; == ", noun;
 
821
        if (noun == 0) "; This word is not in the dictionary";
 
822
        a = noun->#dict_par1;
 
823
        print "; Dictionary word '", (address) noun;
 
824
        if (a & 4) print "//p";
 
825
        print "' (address ", noun, ")";
 
826
        if (a) {
 
827
            print ": ";
 
828
            if (a & 2)   print "meta ";
 
829
            if (a & 1)   print "verb   ";
 
830
            if (a & 8)   print "preposition   ";
 
831
            if (a & 4)   print "pluralising ";
 
832
            if (a & 128) print "noun ";
 
833
        }
 
834
        new_line;
 
835
        if (a & 1) <<Showverb noun>>;
 
836
      INFIXTT_ROUTINE:
 
837
        if (brief) "; == ", noun;
 
838
        print "; Routine ", (InfixPrintRoutine) infix_parsed_lvalue, " (number ",
 
839
          infix_parsed_lvalue, ", packed address ", noun, ")^";
 
840
      INFIXTT_GLOBAL:
 
841
        if (brief) "; == ", noun;
 
842
        print "; Global ", (InfixPrintGlobal) infix_parsed_lvalue, " == ", noun, "^";
 
843
      INFIXTT_ARRAY:
 
844
        if (brief) "; == ", noun;
 
845
        print "; Array ", (InfixPrintArray) infix_parsed_lvalue, " ";
 
846
        infix_data1 = infix_data1 % 16;
 
847
        switch (infix_data1) {
 
848
          0:    print "->"; a=0;
 
849
          1:    print "-->"; a=0;
 
850
          2:    print "string"; a=1;
 
851
          3:    print "table"; a=1;
 
852
          4:    print "buffer"; a=WORDSIZE;
 
853
        }
 
854
        print " ", infix_data2 + 1 - a, "^; == "; b = infix_data2;
 
855
        for (w=b : w>=a : w--)
 
856
            if (infix_data1 == 0 or 2 or 4) { if (noun->w) break; }
 
857
            else { if (noun-->w) break; }
 
858
        if (b-w < 5) w=b;
 
859
        for (: x<=w : x++) {
 
860
            if (infix_data1 == 0 or 2 or 4) print noun->x, " ";
 
861
            else print noun-->x, " ";
 
862
            if (x+1 == a) print ": ";
 
863
            }
 
864
        if (w < b) print "(then ", b-w, " zero entries)";
 
865
        new_line;
 
866
      INFIXTT_ACTION:
 
867
        if (brief) "; == ", noun;
 
868
        if (noun >= #lowest_fake_action_number && noun <= #highest_fake_action_number)
 
869
           "; Fake action ", (InfixPrintFakeAction) noun,
 
870
            " (numbered ", noun, ")^Is not generated by any grammar";
 
871
        print "; Action ", (InfixPrintAction) noun,
 
872
            " (numbered ", noun, ")^";
 
873
        w = HDR_DICTIONARY-->0;
 
874
        for (b=0 : b<(HDR_DICTIONARY-->0 + 5)-->0 : b++) {
 
875
            w = HDR_DICTIONARY-->0 + 7 + b*9;
 
876
            if ((w->#dict_par1) & 1) {
 
877
                a = (HDR_STATICMEMORY-->0)-->($ff-(w->#dict_par2));
 
878
                lines = a->0; a++;
 
879
                for (: lines>0 : lines--) {
 
880
                    a = UnpackGrammarLine(a);
 
881
                    if (action_to_be == noun) {
 
882
                        print "'", (address) w, "' "; DebugGrammarLine();
 
883
                        new_line;
 
884
                        flag = true;
 
885
                    }
 
886
                }
 
887
            }
 
888
        }
 
889
        if (flag == 0) "Is not generated by any grammar";
 
890
      INFIXTT_SYSFUN:
 
891
        if (brief) "; == ", noun;
 
892
        "; System function ~", (address) infix_parsed_lvalue, "~ has
 
893
        not been overridden by any routine and so has its standard definition.";
 
894
      INFIXTT_STATICSTRING:
 
895
        if (brief) "; == ", noun;
 
896
        if (metaclass(noun) ~= String) "; ", noun, " is not a string.";
 
897
        print "~", (string) noun, "~^";
 
898
      INFIXTT_LOGICAL:
 
899
        if (noun == true) "; true"; if (noun == false) "; false";
 
900
        "; ", noun;
 
901
    }
 
902
]; ! end of InfixExamineP
 
903
 
 
904
[ InfixDescribeWatchSub x y z s flag aflag;
 
905
    print "; The Infix ~;watch~ verb allows you to set a watch on any named
 
906
        routine(s) or objects: for instance ~;watch ScoreSub~ or
 
907
        ~;watch silver bars~. You can also:
 
908
        ^    ~;watch objects~: changes to attribute or property settings";
 
909
    if (debug_flag & 8) print " (on)"; else print " (off)";
 
910
 
 
911
    print ";^    ~;watch timers~: the running of timers and daemons each turn";
 
912
    if (debug_flag & 4) print " (on)"; else print " (off)";
 
913
 
 
914
    print ";^    ~;watch messages~: all messages sent";
 
915
    if (debug_flag & 1) print " (on)"; else print " (off)";
 
916
 
 
917
    print ";^    ~;watch actions~: all actions generated";
 
918
    if (debug_flag & 2) print " (on)"; else print " (off)";
 
919
 
 
920
    print ".^~~;watch~ can be abbreviated to ~;w~ and use ~off~ to stop
 
921
        watching: for instance ~;w location off~.^";
 
922
    aflag = debug_flag;
 
923
    objectloop (x has infix__watching) flag = true; aflag = aflag || flag;
 
924
    if (flag) print "The following objects are currently being watched: ";
 
925
    flag = false;
 
926
    objectloop (x has infix__watching) {
 
927
        if (flag) print ", "; flag = true;
 
928
        print (name) x, " (", x, ")";
 
929
    }
 
930
    if (flag) new_line;
 
931
    s = (#highest_routine_number - #lowest_routine_number);
 
932
    if (s%8 == 0) s=s/8; else s=s/8+1;
 
933
    for (flag=false,x=0 : x<s : x++) if (#routine_flags_array->x) flag = true;
 
934
    aflag = aflag || flag;
 
935
    if (flag) print "The following routines are currently being watched: ";
 
936
    for (x=0,flag=false : x<s : x++) {
 
937
        for (y=1,z=0 : y<256 : z++,y=y*2) {
 
938
            if ((#routine_flags_array->x) & y) {
 
939
                if (flag) print ", "; flag = true;
 
940
                print (InfixPrintRoutine)
 
941
                    #lowest_routine_number + x*8 + z;
 
942
            }
 
943
        }
 
944
    }
 
945
    if (flag) new_line;
 
946
    if (aflag == false) "At present, nothing is being watched.";
 
947
];
 
948
 
 
949
[ InfixWatchOnSub i j k l;
 
950
    if (noun == 0) return InfixDescribeWatchSub();
 
951
    if (infix_term_type == INFIXTT_ROUTINE) {
 
952
        i = infix_parsed_lvalue/8;
 
953
        for (j=0,k=1 : j<infix_parsed_lvalue%8 : j++) k=k*2;
 
954
        l = #routine_flags_array->i;
 
955
        l = l | k;
 
956
        @storeb #routine_flags_array i l;
 
957
       "; Watching routine ", (InfixPrintRoutine) infix_parsed_lvalue, ".";
 
958
    }
 
959
    if (metaclass(noun) == Object) {
 
960
        give noun infix__watching;
 
961
       "; Watching object ~", (name) noun, "~ (", noun, ").";
 
962
    }
 
963
    InfixDescribeWatchSub();
 
964
  ];
 
965
 
 
966
[ InfixWatchOffSub i j k l;
 
967
    if (noun == 0) return InfixDescribeWatchSub();
 
968
    if (infix_term_type == INFIXTT_ROUTINE) {
 
969
        i = infix_parsed_lvalue/8;
 
970
        for (j=0,k=1 : j<infix_parsed_lvalue%8 : j++) k=k*2;
 
971
        l = #routine_flags_array->i;
 
972
        l = l & (~k);
 
973
        @storeb #routine_flags_array i l;
 
974
       "; Not watching ", (InfixPrintRoutine) infix_parsed_lvalue, ".";
 
975
    }
 
976
    if (metaclass(noun) == Object) {
 
977
        @clear_attr noun infix__watching;
 
978
       "; Not watching object ~", (name) noun, "~ (", noun, ").";
 
979
    }
 
980
    InfixDescribeWatchSub();
 
981
];
 
982
 
 
983
[ InfixList from to tab filter i flag;
 
984
    print "^    ";
 
985
    for (i=from : i<=to : i++)
 
986
        if (tab-->(i-from)) {
 
987
            flag = true;
 
988
            if (tab == #array_names_array) {
 
989
                Symb__Tab(INFIXTT_ARRAY, i);
 
990
                flag = ~~(temp__global3 & 16);
 
991
            }
 
992
            if (tab == #routine_names_array) {
 
993
                Symb__Tab(INFIXTT_ROUTINE,i);
 
994
                flag = ~~(temp__global3 & 16);
 
995
            }
 
996
            if (tab == #constant_names_array) {
 
997
                Symb__Tab(INFIXTT_CONSTANT,i);
 
998
                flag = (~~(temp__global3 & 16)) && (temp__global3 % 16 == filter);
 
999
            }
 
1000
            if (flag) print (string) tab-->(i-from), " ";
 
1001
        }
 
1002
    new_line;
 
1003
];
 
1004
 
 
1005
[ InfixInvSub i;
 
1006
 
 
1007
    print (string) Story, (string) Headline;
 
1008
    print "  ", (number) #highest_object_number - #lowest_object_number + 1,
 
1009
        " objects;^";
 
1010
 
 
1011
    print "  non-library object-name constants:";
 
1012
    InfixList(#lowest_constant_number, #highest_constant_number, #constant_names_array, 2);
 
1013
 
 
1014
    print "  ", (number) #highest_class_number - #lowest_class_number + 1, "  classes:^    ";
 
1015
    for (i=#lowest_class_number : i<=#highest_class_number : i++)
 
1016
        print (name) #class_objects_array-->i, " ";
 
1017
    new_line;
 
1018
 
 
1019
    print "  non-library arrays:";
 
1020
    InfixList(#lowest_array_number, #highest_array_number, #array_names_array);
 
1021
 
 
1022
    print "  non-library routines:";
 
1023
    InfixList(#lowest_routine_number, #highest_routine_number, #routine_names_array);
 
1024
 
 
1025
    print "  non-library constants:";
 
1026
    InfixList(#lowest_constant_number, #highest_constant_number, #constant_names_array, 0);
 
1027
 
 
1028
    print "  (common) properties:";
 
1029
    InfixList(#lowest_property_number, 63, #property_names_array);
 
1030
 
 
1031
    print "  (individual) properties:";
 
1032
    InfixList(64, #highest_property_number, #property_names_array + 126);
 
1033
 
 
1034
    print "  attributes:";
 
1035
    InfixList(#lowest_attribute_number, #highest_attribute_number, #attribute_names_array);
 
1036
 
 
1037
    if (true) return;
 
1038
 
 
1039
    print "  variables:";
 
1040
    InfixList(#lowest_global_number, #highest_global_number, #global_names_array);
 
1041
 
 
1042
    print "  actions:";
 
1043
    InfixList(#lowest_action_number, #highest_action_number, #action_names_array);
 
1044
 
 
1045
    print "  fake actions:";
 
1046
    InfixList(#lowest_fake_action_number, #highest_fake_action_number, #fake_action_names_array);
 
1047
];
 
1048
 
 
1049
Verb meta ';i' ';inv' ';inventory'
 
1050
    *                                           -> InfixInv;
 
1051
Verb meta ';x' ';examine'
 
1052
    * InfixRvalue                               -> InfixExamine;
 
1053
Verb meta ';xo' ';examineo'
 
1054
    * InfixRvalue                               -> InfixExamineO;
 
1055
Verb meta ';xs' ';examines'
 
1056
    * InfixRvalue                               -> InfixExamineS;
 
1057
Verb meta ';<'
 
1058
    * InfixActionToken                          -> InfixAction
 
1059
    * InfixActionToken InfixRvalue              -> InfixAction
 
1060
    * InfixActionToken InfixRvalue InfixRvalue  -> InfixAction;
 
1061
Verb meta ';//'
 
1062
    *                                           -> InfixWelcome
 
1063
    * InfixRvalue                               -> InfixEval;
 
1064
Verb meta ';give'
 
1065
    * InfixRvalue InfixRvalue                   -> InfixGive;
 
1066
Verb meta ';move'
 
1067
    * InfixRvalue "to" InfixRvalue              -> InfixMove;
 
1068
Verb meta ';remove'
 
1069
    * InfixRvalue                               -> InfixRemove;
 
1070
Verb meta ';watch' ';w'
 
1071
    *                                           -> InfixWatchOn
 
1072
    * "timers"/"daemons"                        -> TimersOn
 
1073
    * "timers"/"daemons" "off"                  -> TimersOff
 
1074
    * "actions"                                 -> ActionsOn
 
1075
    * "actions" "off"                           -> ActionsOff
 
1076
    * "messages"                                -> RoutinesOn
 
1077
    * "messages" "off"                          -> RoutinesOff
 
1078
    * "objects"                                 -> ChangesOn
 
1079
    * "objects" "off"                           -> ChangesOff
 
1080
    * InfixRvalueTerm                           -> InfixWatchOn
 
1081
    * InfixRvalueTerm "off"                     -> InfixWatchOff;
 
1082
 
 
1083
#Endif; ! DEBUG
 
1084
 
 
1085
! ==============================================================================