Subversion Repositories tendra.SVN

Rev

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

Rev 5 Rev 6
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 60... Line 90...
60
#include "arith_codes.h"
90
#include "arith_codes.h"
61
 
91
 
62
/* PROCEDURES */
92
/* PROCEDURES */
63
 
93
 
64
int arith_type
94
int arith_type
65
    PROTO_N ( (a,b) )
-
 
66
    PROTO_T ( int a X int b )
95
(int a, int b)
67
{
96
{
68
 if(a==(t_long|t_unsigned))return a;
97
 if (a== (t_long|t_unsigned)) return a;
69
 if(b==(t_long|t_unsigned))return b;
98
 if (b== (t_long|t_unsigned)) return b;
70
 if(a==(t_long|t_signed)){
99
 if (a== (t_long|t_signed)) {
71
   if(b==(t_int|t_unsigned))return (t_long|t_unsigned);
100
   if (b== (t_int|t_unsigned)) return(t_long|t_unsigned);
72
   return a;
101
   return a;
73
   }
102
   }
74
 if(b==(t_long|t_signed)){
103
 if (b== (t_long|t_signed)) {
75
   if(a==(t_int|t_unsigned))return (t_long|t_unsigned);
104
   if (a== (t_int|t_unsigned)) return(t_long|t_unsigned);
76
   return b;
105
   return b;
77
   }
106
   }
78
 if(a==(t_int|t_unsigned))return a;
107
 if (a== (t_int|t_unsigned)) return a;
79
 if(b==(t_int|t_unsigned))return b;
108
 if (b== (t_int|t_unsigned)) return b;
80
 return (t_int|t_signed);
109
 return(t_int|t_signed);
81
}
110
}
82
 
111
 
83
int promote
112
int promote
84
    PROTO_N ( (a) )
-
 
85
    PROTO_T ( int a )
113
(int a)
86
{
114
{
87
 if((a&variety_filter)<t_int)return(t_int|t_signed);
115
 if ((a&variety_filter) <t_int) return(t_int|t_signed);
88
 return a;
116
 return a;
89
}
117
}
90
 
118
 
91
int sign_promote
119
int sign_promote
92
    PROTO_N ( (a) )
-
 
93
    PROTO_T ( int a )
120
(int a)
94
{
121
{
95
 if((a&variety_filter)<t_int)a=((a&~variety_filter)|t_int);
122
 if ((a&variety_filter) <t_int)a= ((a&~variety_filter) |t_int);
96
 return a;
123
 return a;
97
}
124
}
98
 
125
 
99
variety convert
126
variety convert
100
    PROTO_N ( (a) )
-
 
101
    PROTO_T ( unsigned a )
127
(unsigned a)
102
{
128
{
103
 switch(a) {
129
 switch (a) {
104
   case (t_char|t_none): return scharsh;
130
   case(t_char|t_none): return scharsh;
105
   case (t_char|t_signed): return scharsh;
131
   case(t_char|t_signed): return scharsh;
106
   case (t_char|t_unsigned): return ucharsh;
132
   case(t_char|t_unsigned): return ucharsh;
107
   case (t_short|t_signed): return swordsh;
133
   case(t_short|t_signed): return swordsh;
108
   case (t_short|t_unsigned): return uwordsh;
134
   case(t_short|t_unsigned): return uwordsh;
109
 
135
 
110
   case (t_int|t_signed): return slongsh;
136
   case(t_int|t_signed): return slongsh;
111
   case (t_int|t_unsigned): return ulongsh;
137
   case(t_int|t_unsigned): return ulongsh;
112
   case (t_long|t_signed): return slongsh;
138
   case(t_long|t_signed): return slongsh;
113
   case (t_long|t_unsigned): return ulongsh;
139
   case(t_long|t_unsigned): return ulongsh;
114
   }
140
   }
115
   return slongsh;
141
   return slongsh;
116
 }
142
 }