1 /* ******************************************************
 2    *                                                    *
 3    *                                                    *
 4    * Copyright (c) 1972 by Massachusetts Institute of   *
 5    * Technology and Honeywell Information Systems, Inc. *
 6    *                                                    *
 7    *                                                    *
 8    ****************************************************** */
 9 
10 /* Procedure to search for a symbol block
11 
12    Initial Version: 15 May 1970 by BLW
13           Modified: 25 September 1972 by BLW for std obj segments */
14 
15 find_block: proc(pt,name) returns(ptr);
16 
17 dcl       pt        ptr,                /* points at symbol header */
18           name      char(*) aligned;    /* name of block to look up */
19 
20 dcl       (hp,bp) ptr,
21           root bit(18) aligned,
22           (addrel,length,null) builtin;
23 
24 %include symbol_header;
25 %include symbol_node;
26 %include std_symbol_header;
27 %include pl1_symbol_block;
28 
29           hp = pt;
30 
31           if hp -> std_symbol_header.identifier ^= "symbtree"
32           then root = hp -> symbol_header.root;             /* non-std symbol header */
33           else do;
34 
35                /* have std symbol header, look for pl1 symbol block */
36 
37                if hp -> std_symbol_header.area_pointer = (18)"0"b then return(null);
38 
39                bp = addrel(hp,hp -> std_symbol_header.area_pointer);
40                if bp -> pl1_symbol_block.identifier ^= "pl1info" then return(null);
41 
42                root = bp -> pl1_symbol_block.root;
43                end;
44 
45           if root = (18)"0"b then return(null);
46 
47           return(search(addrel(hp,root)));
48 
49 search:        proc(block_pt) returns(ptr);
50 
51 dcl            (block_pt,p,bp) ptr,
52                n fixed bin;
53 
54 dcl            1 acc          aligned based,
55                2 size         unal bit(9),
56                2 string       unal char(n);
57 
58                bp = block_pt;
59 
60 check:         if bp -> symbol_block.name = (18)"0"b then goto step;
61 
62                p = addrel(bp,bp -> symbol_block.name);
63                n = fixed(p -> acc.size,9);
64                if n ^= length(name) then goto step;
65 
66                if name = p -> acc.string then return(bp);
67 
68 step:          if bp -> symbol_block.son
69                then do;
70                     p = search(addrel(bp,bp -> symbol_block.son));
71                     if p ^= null then return(p);
72                     end;
73 
74                if bp -> symbol_block.brother
75                then do;
76                     bp = addrel(bp,bp -> symbol_block.brother);
77                     goto check;
78                     end;
79 
80                return(null);
81 
82                end;
83 
84           end;