summaryrefslogblamecommitdiffstats
path: root/private/windbg/eecan/debwalk.c
blob: a3c3b52c3d36a8b51e77b4ae3cf6c02028efde0e (plain) (tree)
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
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010

















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                   
/***    debwalk.c - walk bound expression tree and perform operations
 *
 */





/*
*
*/
LOCAL   bool_t  NEAR    FASTCALL    Walk (bnode_t);

LOCAL   bool_t  NEAR    FASTCALL    WalkAddrOf (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkArray (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkAssign (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkBang (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkBasePtr (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkBinary (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkBScope (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkByteOps (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkCast (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkCastBin (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkConst (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkContext (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkDMember (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkDot (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkError (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkEmpty (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkFetch (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkFunction (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkLChild (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkRChild (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkPlusMinus (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkPMember (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkPostIncDec (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkPreIncDec (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkPointsTo (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkRelat (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkSegOp (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkSizeOf (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkSymbol (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkTypestr (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkUnary (bnode_t);
LOCAL   bool_t  NEAR    FASTCALL    WalkUScope (bnode_t);

/*
*
*/
LOCAL   bool_t  NEAR PASCAL PushCXT (peval_t);
LOCAL   bool_t  NEAR PASCAL GetCXTL (pnode_t);
LOCAL   bool_t  NEAR PASCAL GetCXTFunction (pnode_t, pnode_t);

// Walk Dispatch table

LOCAL bool_t (NEAR FASTCALL *pWalk[]) (bnode_t) = {
#define OPCNT(name, val)
#define OPCDAT(opc)
#define OPDAT(op, opfprec, opgprec, opclass, opbind, opeval, opwalk) opwalk,
#include "debops.h"
#undef OPDAT
#undef OPCDAT
#undef OPCNT
};
#ifdef WIN32
extern uchar F_level[COPS_EXPR];
#else
extern uchar _based(_segname("_CODE")) F_level[COPS_EXPR];
#endif
#ifdef WIN32
extern uchar G_level[COPS_EXPR];
#else
extern uchar _based(_segname("_CODE")) G_level[COPS_EXPR];
#endif

LOCAL   char *  PchString;
LOCAL   int     CchString;
LOCAL   int     CchStringMax;
LOCAL   bool_t  FPrototype = TRUE;
LOCAL   bool_t  FInScope = FALSE;

typedef struct {
    HDR_TYPE Hdr;
    char Buf[256];
} FORMATBUF;


/**     DoGetCXTL - Gets a list of symbols and contexts for expression
 *
 *      status = DoGetCXTL (phTM, phCXTL)
 *
 *      Entry   phTM = pointer to handle to expression state structure
 *              phCXTL = pointer to handle for CXT list buffer
 *
 *      Exit    *phCXTL = handle for CXT list buffer
 *
 *      Returns EENOERROR if no error
 *              status code if error
 */


ushort PASCAL DoGetCXTL (PHTM phTM, PHCXTL phCXTL)
{
    ushort      retval = EECATASTROPHIC;

    // lock the expression state structure and copy the context package

    DASSERT (*phTM != 0);
    if (*phTM != 0) {
        DASSERT(pExState == NULL);
        pExState = MHMemLock (*phTM);
        if ((pExState->state.parse_ok == TRUE) &&
          (pExState->state.bind_ok == TRUE)) {
            if ((hCxtl = MHMemAllocate (sizeof (CXTL) + 5 * sizeof (HCS))) == 0) {
                pExState->err_num = ERR_NOMEMORY;
                MHMemUnLock (*phTM);
                pExState = NULL;
                *phCXTL = hCxtl;
                return (EEGENERAL);
            }
            else {
                pCxtl = MHMemLock (hCxtl);
                mCxtl = 5;
                pCxtl->CXT = pExState->cxt;
                pCxtl->cHCS = 0;

            }
            pTree = MHMemLock (pExState->hETree);
            if (GetCXTL (pnodeOfbnode(pTree->start_node))) {
                retval = EENOERROR;
            }
            else {
                retval = EEGENERAL;
            }
            *phCXTL = hCxtl;
            MHMemUnLock (hCxtl);
            MHMemUnLock (pExState->hETree);
        }
        MHMemUnLock (*phTM);
        pExState = NULL;
    }
    return (retval);
}





/**     GetCXTL - get CXT list from bound expression tree
 *
 *      fSuccess = GetCXTL (pn)
 *
 *      Entry   pn = pointer to node
 *              hCxtl = handle of CXT list
 *              pCxtl = pointer to CXT list
 *              mCxtl = maximum number of context list entries
 *
 *      Exit    *phCXTL = handle for CXT list
 *
 *      Returns TRUE if no error
 *              FALSEif error
 */


LOCAL bool_t NEAR PASCAL GetCXTL (pnode_t pn)
{
    PCXT        oldCxt;
    bool_t      retval;
    peval_t     pv;

    // Recurse down the tree.

    pv = &pn->v[0];
    switch (NODE_OP (pn)) {
        case OP_typestr:
            return (TRUE);

        case OP_const:
        case OP_ident:
        case OP_this:
        case OP_hsym:
            return (PushCXT (pv));

        case OP_cast:
            return (GetCXTL (pnodeOfbnode(NODE_RCHILD (pn))));

        case OP_function:
            return (GetCXTFunction (
                         pnodeOfbnode(NODE_LCHILD (pn)),
                         pnodeOfbnode(NODE_RCHILD (pn))));

        case OP_context:
            // Set the new context for evaluation of the remainder of this
            // part of the tree

            oldCxt = pCxt;
            pCxt = SHpCXTFrompCXF ((PCXF)&pn->v[0]);
            retval = GetCXTL (pnodeOfbnode(NODE_LCHILD (pn)));
            pCxt = oldCxt;
            return (retval);

        // All other operators come through here.  Recurse down the tree

        default:
            if (!GetCXTL (pnodeOfbnode(NODE_LCHILD (pn))))
                return (FALSE);

            if ((pn->pnRight != 0) && (!GetCXTL (pnodeOfbnode(NODE_RCHILD (pn)))))
                return (FALSE);

            return (TRUE);
    }
}






/**     GetExpr - get expression from bound expression tree
 *
 *      status = GetExpr (radix, phStr, pEnd);
 *
 *      Entry   radix = numeric radix for formatting
 *              phStr = pointer to handle for formatted string
 *              pEnd = pointer to int to receive index of char that ended parse
 *
 *      Exit    *phStr = handle for allocated expression
 *              *pEnd = index of character that terminated parse
 *
 *      Returns EENOERROR if no error
 *              error number if
 */


EESTATUS PASCAL
GetExpr (
         PHTM           phTM,
         EERADIX        radix,
         PEEHSTR        phStr,
         ushort FAR *   pEnd
         )
{
    EESTATUS    retval = EECATASTROPHIC;
    char FAR   *pStr;

    DASSERT (*phTM != 0);
    if (*phTM == 0) {
        return retval;
    }

    DASSERT(pExState == NULL);
    pExState = MHMemLock (*phTM);
    if (pExState->state.bind_ok == TRUE) {
        pTree = MHMemLock(pExState->hETree);
        pExStr = MHMemLock(pExState->hExStr);

        PchString = NULL;
        CchStringMax = CchString = 0;

        retval = Walk((bnode_t)pTree->start_node);

        MHMemUnLock(pExState->hETree);
        MHMemUnLock(pExState->hExStr);
        if (retval == TRUE) {
            retval = EENOERROR;
            if ((*phStr = MHMemAllocate( CchString+1 )) != 0) {
                pStr = MHMemLock( *phStr );
                _fmemcpy(pStr, PchString, CchString);
                *pEnd = CchString;
                MHMemUnLock( *phStr);
            } else {
                retval = EEGENERAL;
                *phStr = 0;
            }
        } else {
            retval = EEGENERAL;
            *phStr = 0;
        }

        if (PchString != NULL) {
            free(PchString);
        }
        PchString = NULL;
    }
    MHMemUnLock (*phTM);
    pExState = NULL;
    return (retval);
}




/**     PushCXT - Push CXT list entry
 *
 *      fSuccess = PushCXT (pv)
 *
 *      Entry   pv = pointer to evaluation
 *              hCxtl = handle of CXT list
 *              pCxtl = pointer to CXT list
 *              mCxtl = maximum number of context list entries
 *
 *      Exit    CXT entry pushed
 *
 *      Returns TRUE if no error
 *              FALSE if error
 */


LOCAL bool_t NEAR PASCAL PushCXT (peval_t pv)
{
    HCXTL   nhCxtl;
    PCXTL   npCxtl;
    uint    lenIn;
    uint    lenOut;

    DASSERT (pCxtl->cHCS <= mCxtl);
    if (mCxtl < pCxtl->cHCS) {
        // this is a catatrosphic error
        return (FALSE);
    }
    if (mCxtl == pCxtl->cHCS) {
        // grow CXT list

        lenIn = sizeof (CXTL) + mCxtl * sizeof (HCS);
        lenOut = sizeof (CXTL) + (mCxtl + 5) * sizeof (HCS);
        if ((nhCxtl = MHMemAllocate (lenOut)) == 0) {
            return (FALSE);
        }
        npCxtl = MHMemLock (nhCxtl);
        _fmemcpy (npCxtl, pCxtl, lenIn);
        mCxtl += 5;
        MHMemUnLock (hCxtl);
        MHMemFree (hCxtl);
        hCxtl = nhCxtl;
        pCxtl = npCxtl;
    }

    // in case of a constant we will return only the context information.
    // anything more than that doesn't make sense and since we
    // need to get context only information in the case of bp {..}.line
    // we needed to make this change.

    pCxtl->rgHCS[pCxtl->cHCS].hSym = pv->hSym;
    pCxtl->rgHCS[pCxtl->cHCS].CXT = *pCxt;
    pCxtl->cHCS++;
    return (TRUE);
}



LOCAL bool_t NEAR PASCAL GetCXTFunction (pnode_t pnLeft, pnode_t pnRight)
{
    Unreferenced( pnLeft );
    Unreferenced( pnRight );

    return (FALSE);
}

LOCAL BOOLEAN
WalkAppendString(
    char * pch,
    int    cch
    )
/*++

Routine Description:


Arguments:


Return Value:



--*/
{
    if (cch > CchStringMax - CchString) {
        PchString = (LPSTR)MHMemReAlloc((HDEP)PchString, CchStringMax + 256);
        if (PchString == NULL) {
            return FALSE;
        }
        CchStringMax += 256;
    }

    _fstrncpy(&PchString[CchString], pch, cch);
    CchString += cch;
    return TRUE;
}                               /* WalkAppendString() */

/*
 *  Functions to build a string from a TM Tree
 */

LOCAL   bool_t NEAR FASTCALL
Walk(
     bnode_t bn
     )
{
    return (*pWalk[NODE_OP(pnodeOfbnode(bn))])(bn);
}

LOCAL bool_t NEAR FASTCALL
WalkLChild (bnode_t bn)
{
    register bnode_t bnL = NODE_LCHILD (pnodeOfbnode(bn));
    BOOL        f = FALSE;

    if (F_level[NODE_OP(pnodeOfbnode(bn))] > F_level[NODE_OP(pnodeOfbnode(bnL))]) {
        if (!WalkAppendString("(", 1)) {
            return FALSE;
        }
        f = TRUE;
    }

   if  (!((*pWalk[NODE_OP(pnodeOfbnode(bnL))])(bnL))) {
       return FALSE;
   }

    if (f) {
        return WalkAppendString(")", 1);
    }

    return TRUE;
}                               /* WalkLChild() */

LOCAL bool_t NEAR FASTCALL
WalkRChild (bnode_t bn)
{
    register bnode_t bnR = NODE_RCHILD (pnodeOfbnode(bn));
    BOOL        f = FALSE;

    if (F_level[NODE_OP(pnodeOfbnode(bn))] > F_level[NODE_OP(pnodeOfbnode(bnR))]) {
        if (!WalkAppendString("(", 1)) {
            return FALSE;
        }
        f = TRUE;
    }

   if  (!((*pWalk[NODE_OP(pnodeOfbnode(bnR))])(bnR))) {
       return FALSE;
   }

    if (f) {
        return WalkAppendString(")", 1);
    }

    return TRUE;
}                               /* WalkRChild() */

/*
*
*/

LOCAL   bool_t  NEAR    FASTCALL
WalkAddrOf (bnode_t bn)
{
    return WalkAppendString("&", 1) && WalkLChild(bn);
}                               /* WalkAddrOf() */

LOCAL   bool_t  NEAR    FASTCALL
WalkArray (bnode_t bn)
{
    return WalkLChild(bn) && WalkAppendString("[", 1) &&
      WalkRChild(bn) && WalkAppendString("]", 1);
}                               /* WalkArray() */

LOCAL   bool_t  NEAR    FASTCALL
WalkAssign (bnode_t bn)
{
    char *      pch;
    int         cch = 2;

    switch( NODE_OP (pnodeOfbnode(bn)) ) {
    case OP_eq:         pch = "=";      cch = 1;        break;
    case OP_multeq:     pch = "*=";                     break;
    case OP_diveq:      pch = "/=";                     break;
    case OP_modeq:      pch = "%=";                     break;
    case OP_pluseq:     pch = "+=";                     break;
    case OP_minuseq:    pch = "-=";                     break;
    case OP_shleq:      pch = "<<=";    cch = 3;        break;
    case OP_shreq:      pch = ">>=";    cch = 3;        break;
    case OP_andeq:      pch = "&=";                     break;
    case OP_xoreq:      pch = "^=";                     break;
    case OP_oreq:       pch = "|=";                     break;
    default:
        DASSERT(FALSE);
        return FALSE;
    }

    return WalkLChild(bn) && WalkAppendString(pch, cch) && WalkRChild(bn);
}                               /* WalkAssign() */

LOCAL   bool_t  NEAR    FASTCALL
WalkBang (bnode_t bn)
{
    return WalkAppendString("!", 1) && WalkLChild(bn);
}                               /* WalkBang() */

LOCAL   bool_t  NEAR    FASTCALL
WalkBasePtr (bnode_t bn)
{
    DASSERT(FALSE);
    return TRUE;
}

LOCAL   bool_t  NEAR    FASTCALL
WalkBinary (bnode_t bn)
{
    char *      pch;
    int         cch = 1;

    switch( NODE_OP (pnodeOfbnode(bn)) ) {
    case OP_mult:   pch = "*"; break;
    case OP_div:    pch = "/"; break;
    case OP_mod:    pch = "%"; break;
    case OP_shl:    pch = "<<"; cch = 2; break;
    case OP_shr:    pch = ">>"; cch = 2; break;
    case OP_and:    pch = "&"; break;
    case OP_xor:    pch = "^"; break;
    case OP_or:     pch = "|"; break;
    case OP_andand: pch = "&&"; cch = 2; break;
    case OP_oror:   pch = "||"; cch = 2; break;
    default:
        DASSERT(FALSE);
        return FALSE;
    }

    return WalkLChild(bn) && WalkAppendString(pch, cch) && WalkRChild(bn);
}                               /* WalkBinary() */

LOCAL   bool_t  NEAR    FASTCALL
WalkBScope (bnode_t bn)
{
    bool_t      fInScope = FInScope;
    bool_t      fResult;

    FInScope = TRUE;
    fResult = WalkLChild(bn) && WalkAppendString("::", 2) && WalkRChild(bn);
    FInScope = fInScope;
    return fResult;
}                               /* WalkBScope() */

LOCAL   bool_t  NEAR    FASTCALL
WalkByteOps (bnode_t bn)
{
    char *      pch;

    switch( NODE_OP (pnodeOfbnode(bn)) ) {
    case OP_by:        pch = "BY ";        break;
    case OP_wo:        pch = "WO ";        break;
    case OP_dw:        pch = "DW ";        break;
    default:
        DASSERT(FALSE);
        return FALSE;
    }

    return WalkAppendString(pch, 2) && WalkLChild(bn);
}

LOCAL   bool_t  NEAR    FASTCALL
WalkCast (bnode_t bn)
{
    peval_t     pv = &pnodeOfbnode(NODE_LCHILD(pnodeOfbnode(bn)))->v[0];
    FORMATBUF   fb;
    char *      pch;
    unsigned int cch;

    pch = fb.Buf;
    cch = sizeof(fb.Buf);
    FormatType(pv, &pch, &cch, NULL, FPrototype, &fb.Hdr);

    do {
        pch--;
    } while (*pch == ' ');

    return WalkAppendString("(", 1) &&
           WalkAppendString(fb.Buf, pch-fb.Buf+1) &&
           WalkAppendString(")", 1) &&
           WalkRChild(bn);
}

LOCAL   bool_t  NEAR    FASTCALL
WalkCastBin (bnode_t bn)
{
    peval_t     pv = &pnodeOfbnode(NODE_LCHILD(pnodeOfbnode(bn)))->v[0];
    FORMATBUF   fb;
    char *      pch;
    unsigned int cch;
    bool_t      f;

    pch = fb.Buf;
    cch = sizeof(fb.Buf);
    FormatType(pv, &pch, &cch, NULL, FPrototype, &fb.Hdr);

    do {
        pch--;
    } while (*pch == ' ');

    f = WalkAppendString("(", 1) &&
        WalkAppendString(fb.Buf, pch-fb.Buf+1) &&
        WalkAppendString(")", 1);

    if (!f) {
        return f;
    }

    switch( NODE_OP (pnodeOfbnode(bn)) ) {
    case OP_caststar:   pch = "*";      break;
    case OP_castplus:   pch = "+";      break;
    case OP_castminus:  pch = "-";      break;
    case OP_castamp:    pch = "&";      break;
    default:
        DASSERT(FALSE);
        return FALSE;
    }

    return WalkAppendString(pch, 1) && WalkRChild(bn);
}

LOCAL   bool_t  NEAR    FASTCALL
WalkConst (bnode_t bn)
{
    peval_t     pv = &pnodeOfbnode(bn)->v[0];

    return WalkAppendString(pExStr + EVAL_ITOK(pv), EVAL_CBTOK(pv));
}                               /* WalkConst() */

LOCAL   bool_t  NEAR    FASTCALL
WalkContext (bnode_t bn)
{
    peval_t     pv = &pnodeOfbnode(bn)->v[0];

    return WalkAppendString(pExStr + EVAL_ITOK(pv), EVAL_CBTOK(pv)) &&
      WalkLChild(bn);
}                               /* WalkContext() */

LOCAL   bool_t  NEAR    FASTCALL
WalkDMember (bnode_t bn)
{
    DASSERT(FALSE);
    return TRUE;
}

LOCAL   bool_t  NEAR    FASTCALL
WalkDot (bnode_t bn)
{
    return WalkLChild(bn) && WalkAppendString(".", 1) && WalkRChild(bn);
}                               /* WalkDot() */

LOCAL   bool_t  NEAR    FASTCALL
WalkEmpty (register bnode_t bn)
{
    return TRUE;
}                               /* WalkEmpty */

LOCAL   bool_t  NEAR    FASTCALL
WalkError (register bnode_t bn)
{
    DASSERT(FALSE);
    return TRUE;
}

LOCAL   bool_t  NEAR    FASTCALL
WalkFetch (bnode_t bn)
{
    return WalkAppendString("*", 1) && WalkLChild(bn);
}                               /* WalkFetch() */

LOCAL   bool_t  NEAR    FASTCALL
WalkFunction (bnode_t bn)
{
    bnode_t     bnT;
    BOOLEAN     f = FALSE;
    bool_t      fPrototype = FPrototype;

    FPrototype = FALSE;

    if (!WalkLChild(bn) || !WalkAppendString("(", 1)) {
        FPrototype = fPrototype;
        return FALSE;
    }

    FPrototype = fPrototype;
    for (bnT = NODE_RCHILD( pnodeOfbnode(bn) );
         NODE_OP(pnodeOfbnode(bnT)) != OP_endofargs;
         bnT = NODE_RCHILD( pnodeOfbnode(bnT) )) {
        if (f) {
            if (!WalkAppendString(", ", 2)) {
                return FALSE;
            }
        } else {
            f = TRUE;
        }
        if (!WalkLChild(bnT)) {
            return FALSE;
        }
    }

    return WalkAppendString(")", 1);
}                               /* WalkFunction() */

LOCAL   bool_t  NEAR    FASTCALL
WalkPlusMinus (bnode_t bn)
{
    char *  pch;

    switch( NODE_OP(pnodeOfbnode(bn)) ) {
    case OP_plus:
        pch = "+";
        break;

    case OP_minus:
        pch = "-";
        break;

    default:
        DASSERT(FALSE);
        return FALSE;
    }

    if (WalkLChild(bn) && WalkAppendString(pch, 1) && WalkRChild(bn)) {
        return TRUE;
    }
    return FALSE;
}                               /* WalkPlusMinus() */

LOCAL   bool_t  NEAR    FASTCALL
WalkPMember (bnode_t bn)
{
    DASSERT(FALSE);
    return TRUE;
}

LOCAL   bool_t  NEAR    FASTCALL
WalkPostIncDec (bnode_t bn)
{
    char *      pch;
    int         cch = 2;

    switch( NODE_OP (pnodeOfbnode(bn)) ) {
    case OP_postinc:     pch = "++"; break;
    case OP_postdec:     pch = "--"; break;
    default:
        DASSERT(FALSE);
        return FALSE;
    }

    return WalkLChild(bn) && WalkAppendString(pch, cch);
}                               /* WalkPostIncDec() */

LOCAL   bool_t  NEAR    FASTCALL
WalkPreIncDec (bnode_t bn)
{
    char *      pch;
    int         cch = 2;

    switch( NODE_OP (pnodeOfbnode(bn)) ) {
    case OP_preinc:     pch = "++"; break;
    case OP_predec:     pch = "--"; break;
    default:
        DASSERT(FALSE);
        return FALSE;
    }

    return WalkAppendString(pch, cch) && WalkLChild(bn);
}                               /* WalkPreIncDec() */

LOCAL   bool_t  NEAR    FASTCALL
WalkPointsTo (bnode_t bn)
{
    return WalkLChild(bn) && WalkAppendString("->", 2) && WalkRChild(bn);
}                               /* WalkPointsTo() */

LOCAL   bool_t  NEAR    FASTCALL
WalkRelat (bnode_t bn)
{
    char *      pch;
    int         cch = 2;

    switch( NODE_OP (pnodeOfbnode(bn)) ) {
    case OP_lt:         pch = "<";      cch = 1;        break;
    case OP_lteq:       pch = "<=";                     break;
    case OP_gt:         pch = ">";      cch = 1;        break;
    case OP_gteq:       pch = ">=";                     break;
    case OP_eqeq:       pch = "==";                     break;
    case OP_bangeq:     pch = "!=";                     break;

    default:
        DASSERT(FALSE);
        return FALSE;
    }

    return WalkLChild(bn) && WalkAppendString(pch, cch) && WalkRChild(bn);
}                               /* WalkRelat() */

LOCAL   bool_t  NEAR    FASTCALL
WalkSegOp (bnode_t bn)
{
    return WalkLChild(bn) && WalkAppendString(":", 1) && WalkRChild(bn);
}

LOCAL   bool_t  NEAR    FASTCALL
WalkSizeOf (bnode_t bn)
{
    return WalkAppendString("sizeof(", 7) && WalkLChild(bn) &&
      WalkAppendString(")", 1);
}                               /* WalkSizeOf() */

LOCAL   bool_t  NEAR    FASTCALL
WalkSymbol (bnode_t bn)
{
    peval_t     pv = &pnodeOfbnode(bn)->v[0];
    SYMPTR      pSym;
    int         len;
    EEHSTR      hStr = 0;
    FORMATBUF   fb;
    CV_typ_t    rvtype;
    CV_typ_t    mclass;
    CV_typ_t    call;
    ushort      cparam;
    CV_typ_t    paramtype;
    HTYPE       hType;
    plfEasy     pType;
    char *      pch;
    int         cch;
    char *      pch2;
    char *      pch3;
    char        ch;

    if (EVAL_HSYM(pv) == 0) {
        return WalkAppendString(pExStr + EVAL_ITOK(pv), EVAL_CBTOK(pv));
    }

    switch((pSym = MHOmfLock( (HDEP)EVAL_HSYM (pv) ))->rectyp) {
    case S_BPREL16:
        len =  ((BPRELPTR16) pSym)->name[0];
        pch = &((BPRELPTR16) pSym)->name[1];
        break;

    case S_BPREL32:
        len =  ((BPRELPTR32) pSym)->name[0];
        pch = &((BPRELPTR32) pSym)->name[1];
        break;

    case S_LDATA16:
    case S_GDATA16:
    case S_PUB16:
        len =  ((DATAPTR16) pSym)->name[0];
        pch = &((DATAPTR16) pSym)->name[1];
        break;

    case S_LDATA32:
    case S_GDATA32:
    case S_PUB32:
        len =  ((DATAPTR32) pSym)->name[0];
        pch = &((DATAPTR32) pSym)->name[1];
        break;

    case S_REGISTER:
        len = ((REGPTR) pSym)->name[0];
        pch = &((REGPTR) pSym)->name[1];
        break;

    case S_REGREL16:
        len =  ((REGREL16 *) pSym)->name[0];
        pch = &((REGREL16 *) pSym)->name[1];
        break;

    case S_REGREL32:
        len =  ((LPREGREL32) pSym)->name[0];
        pch = &((LPREGREL32) pSym)->name[1];
        break;

    case S_LPROC16:
    case S_GPROC16:
        len =  ((PROCPTR16) pSym)->name[0];
        pch = &((PROCPTR16) pSym)->name[1];
        break;

    case S_LPROC32:
    case S_GPROC32:
        len = ((PROCPTR32) pSym)->name[0];
        pch = &((PROCPTR32) pSym)->name[1];
        break;

    case S_LPROCMIPS:
    case S_GPROCMIPS:
        len =  ((PROCPTRMIPS) pSym)->name[0];
        pch = &((PROCPTRMIPS) pSym)->name[1];
        break;

    case S_UDT:
        len =  ((UDTSYM *) pSym)->name[0];
        pch = &((UDTSYM *) pSym)->name[1];
        break;

    default:
        DASSERT(FALSE);
        return FALSE;
    }

    if ((FPrototype) &&
        (hType = THGetTypeFromIndex( EVAL_MOD(pv), EVAL_TYP(pv) )) != 0) {
        pType = (plfEasy) (&((TYPPTR)(MHOmfLock ((HDEP)hType)))->leaf);
        switch( pType->leaf ) {
        case LF_PROCEDURE:
            mclass = 0;
            rvtype = ((plfProc)pType)->rvtype;
            call = ((plfProc)pType)->calltype;
            cparam = ((plfProc)pType)->parmcount;
            paramtype = ((plfProc)pType)->arglist;
            MHOmfUnLock((HDEP)hType);
            pch2 = fb.Buf;
            pch3 = pch + len;
            ch = *pch3;
            *pch3 = 0;
            cch = sizeof(fb.Buf);
            FormatProc(pv, &pch2, &cch, &pch, rvtype, mclass, call,
                       cparam, paramtype, 1, &fb.Hdr);
            len = pch2 - fb.Buf;
            pch = fb.Buf;
            *pch3 = ch;
            break;

#if !defined (C_ONLY)
        case LF_MFUNCTION:
            rvtype = ((plfMFunc)pType)->rvtype;
            mclass = ((plfMFunc)pType)->classtype;
            call = ((plfMFunc)pType)->calltype;
            cparam = ((plfMFunc)pType)->parmcount;
            paramtype = ((plfMFunc)pType)->arglist;
            MHOmfUnLock ((HDEP)hType);
            pch3 = pch + len;
            ch = *pch3;
            *pch3 = 0;
            if (FInScope) {
                pch2 = strrchr(pch, ':');
                if (pch2 == NULL) {
                    pch2 = pch;
                } else {
                    pch2++;
                }
            } else {
                pch2 = pch;
            }
            pch = fb.Buf;
            cch = sizeof(fb.Buf);
            FormatProc (pv, &pch, &cch, &pch2, rvtype, mclass, call,
                        cparam, paramtype, 1, &fb.Hdr);
            len = pch - fb.Buf;
            pch = fb.Buf;
            *pch3 = ch;
            break;
#endif


          default:
            MHOmfUnLock((HDEP)hType);
        }
    }

    return WalkAppendString(pch, len);
}                               /* WalkSymbol() */

LOCAL   bool_t  NEAR    FASTCALL
WalkTypestr (bnode_t bn)
{
    peval_t     pv = &pnodeOfbnode(NODE_LCHILD(pnodeOfbnode(bn)))->v[0];
    FORMATBUF   fb;
    char *      pch;
    unsigned int cch;

    pch = fb.Buf;
    cch = sizeof(fb.Buf);
    FormatType(pv, &pch, &cch, NULL, FPrototype, &fb.Hdr);

    return WalkAppendString(fb.Buf, pch-fb.Buf);
}                               /* WalkTypestr() */

LOCAL   bool_t  NEAR    FASTCALL
WalkUnary (bnode_t bn)
{
    char *      pch;
    int         cch = 1;

    switch( NODE_OP (pnodeOfbnode(bn)) ) {
    case OP_negate:     pch = "-"; break;
    case OP_tilde:      pch = "~"; break;
    case OP_uplus:      pch = "+"; break;
    default:
        DASSERT(FALSE);
        return FALSE;
    }

    return WalkAppendString(pch, cch) && WalkLChild(bn);
}                               /* WalkUnary() */

LOCAL   bool_t  NEAR    FASTCALL
WalkUScope (bnode_t bn)
{
    bool_t      fInScope = FInScope;
    bool_t      fResult;

    FInScope = TRUE;
    fResult = WalkAppendString("::", 2) && WalkLChild(bn);
    FInScope = fInScope;
    return fResult;
}                               /* WalkUScope() */