Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
 
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
Line 68... Line 98...
68
#include "is_worth.h"
98
#include "is_worth.h"
69
 
99
 
70
/* PROCEDURES */
100
/* PROCEDURES */
71
 
101
 
72
int is_worth
102
int is_worth
73
    PROTO_N ( (c) )
-
 
74
    PROTO_T ( exp c )
103
(exp c)
75
{
104
{
76
				/* decide if constant c is worth declaring
105
				/* decide if constant c is worth declaring
77
				   separately */
106
				   separately */
78
  unsigned char cnam = name (c);
107
  unsigned char cnam = name(c);
79
 
108
 
80
  if (name(sh(c)) == realhd && cnam == cont_tag &&
109
  if (name(sh(c)) == realhd && cnam == cont_tag &&
81
	name(son(c)) == name_tag && isvar(son(son(c))) &&
110
	name(son(c)) == name_tag && isvar(son(son(c))) &&
82
	isglob(son(son(c))))
111
	isglob(son(son(c))))
83
    return 1;
112
    return 1;
Line 85... Line 114...
85
  if (cnam == cont_tag && name(son(c)) == name_tag &&
114
  if (cnam == cont_tag && name(son(c)) == name_tag &&
86
       !isvar(son(son(c)))) {
115
       !isvar(son(son(c)))) {
87
    return 1;
116
    return 1;
88
  }
117
  }
89
 
118
 
90
  return ((!is_o (cnam) && cnam != clear_tag &&
119
  return((!is_o(cnam) && cnam != clear_tag &&
91
	   cnam != int_to_bitf_tag && cnam != bitf_to_int_tag) ||
120
	   cnam != int_to_bitf_tag && cnam != bitf_to_int_tag) ||
92
  /* ignore simple things unless ... */
121
  /* ignore simple things unless ... */
93
      (cnam == cont_tag && name (son (c)) == cont_tag &&
122
     (cnam == cont_tag && name(son(c)) == cont_tag &&
94
	name (son (son (c))) == name_tag)
123
	name(son(son(c))) == name_tag)
95
      || (cnam == name_tag &&
124
      || (cnam == name_tag &&
96
          (isloadparam(son(c)) || isparam(son(c))) &&
125
         (isloadparam(son(c)) || isparam(son(c))) &&
97
          !isvar(son(c)) &&
126
          !isvar(son(c)) &&
98
          shape_size(sh(c)) <= 32
127
          shape_size(sh(c)) <= 32
99
 
128
 
100
          && name(sh(c)) != shrealhd
129
          && name(sh(c))!= shrealhd
101
 
130
 
102
         )
131
        )
103
      ||  (cnam == cont_tag && name(son(c)) == name_tag &&
132
      || (cnam == cont_tag && name(son(c)) == name_tag &&
104
	   isvar(son(son(c))) && isglob(son(son(c))) &&
133
	   isvar(son(son(c))) && isglob(son(son(c))) &&
105
	   ((last(c) && bro(c) != nilexp) ||
134
	  ((last(c) && bro(c)!= nilexp) ||
106
		(!last(c) && last(bro(c)) && bro(bro(c)) != nilexp)) &&
135
		(!last(c) && last(bro(c)) && bro(bro(c))!= nilexp)) &&
107
	   name(father(c)) == test_tag)
136
	   name(father(c)) == test_tag)
108
    );
137
   );
109
}
138
}