1 /* ***********************************************************
 2    *                                                         *
 3    * Copyright, (C) Honeywell Information Systems Inc., 1982 *
 4    *                                                         *
 5    * Copyright (c) 1972 by Massachusetts Institute of        *
 6    * Technology and Honeywell Information Systems, Inc.      *
 7    *                                                         *
 8    *********************************************************** */
 9 
10 
11 need_temp:          proc(pt,bit2);
12 
13 /*        Modified: 9 April 1977 by RAB to remove mod_word operator   */
14 
15 dcl       (o,p,pt,q) ptr;
16 dcl       bit2 bit(2) aligned;
17 dcl       (check_length, check_qual_and_off) bit(1) aligned;
18 dcl       (null,substr) builtin;
19 
20 %include operator;
21 %include reference;
22 %include nodes;
23 
24 
25 /* need_temp is called by expmac when pt has a reference count of 1 to try to prevent
26    unnecessary saving of temporary values whose reference counts are momentarily to be
27    counted down to zero */
28 
29           p = pt;
30           check_qual_and_off = substr(bit2,1,1);
31           check_length = substr(bit2,2,1);
32 
33           if check_length
34           then do;
35                if p ->reference.value_in.string_aq
36                     then p -> reference.dont_save = "1"b;
37                q = p -> reference.length;
38                if q ^= null
39                then do;
40                     if q -> node.type = operator_node
41                          then q = q -> operand(1);
42                     call check;
43                     end;
44                end;
45 
46           if ^ check_qual_and_off then return;
47 
48           q = p -> reference.qualifier;
49           if q ^= null
50           then do;
51                if q -> node.type = operator_node
52                     then q = q -> operand(1);
53                if q -> node.type = reference_node
54                     then call check;
55                end;
56 
57           q = p -> reference.offset;
58           if q = null then return;
59 
60           if q -> node.type = operator_node
61                then q = q -> operand(1);
62 
63           call check;
64 
65 check:    proc;
66 
67           if q -> reference.shared then return;
68           if q -> reference.dont_save then return;
69           if q -> reference.ref_count ^= 1 then return;
70           q -> reference.dont_save = "1"b;
71           call need_temp(q,"11"b);
72 end;
73 
74 end;