/[eiffelstudio]/branches/eth/eve/Src/Eiffel/API/evaluated_type/integer_a.e
ViewVC logotype

Contents of /branches/eth/eve/Src/Eiffel/API/evaluated_type/integer_a.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 89347 - (show annotations)
Fri Aug 10 15:09:25 2012 UTC (7 years, 4 months ago) by jasonw
File size: 4451 byte(s)
<<Merged from trunk#89346.>>
1 note
2 description: "Actual type for integer type."
3 legal: "See notice at end of class."
4 status: "See notice at end of class."
5 date: "$Date$"
6 revision: "$Revision$"
7
8 class
9 INTEGER_A
10
11 inherit
12 BASIC_A
13 rename
14 make as cl_make
15 redefine
16 is_integer, base_class,
17 same_as, is_numeric, process,
18 minimum_interval_value,
19 maximum_interval_value,
20 heaviest
21 end
22
23 create
24 make
25
26 feature {NONE} -- Initialization
27
28 make (n: INTEGER)
29 -- Create instance of INTEGER_A represented by `n' bits.
30 require
31 valid_n: n = 8 or n = 16 or n = 32 or n = 64
32 do
33 size := n.to_integer_8
34 cl_make (base_class.class_id)
35 ensure
36 size_set: size = n
37 end
38
39 feature -- Visitor
40
41 process (v: TYPE_A_VISITOR)
42 -- Process current element.
43 do
44 v.process_integer_a (Current)
45 end
46
47 feature -- Property
48
49 is_integer: BOOLEAN = True
50 -- Is the current type an integer type ?
51
52 size: INTEGER_8
53 -- Current is stored on `size' bits.
54
55 feature -- Access
56
57 same_as (other: TYPE_A): BOOLEAN
58 -- Is the current type the same as `other' ?
59 do
60 Result := attached {INTEGER_A} other as i and then size = i.size
61 end
62
63 base_class: CLASS_C
64 -- Class INTEGER
65 do
66 inspect size
67 when 8 then Result := System.integer_8_class.compiled_class
68 when 16 then Result := System.integer_16_class.compiled_class
69 when 32 then Result := System.integer_32_class.compiled_class
70 when 64 then Result := System.integer_64_class.compiled_class
71 end
72 end
73
74 feature -- IL code generation
75
76 minimum_interval_value: INTERVAL_VAL_B
77 -- Minimum value in inspect interval for current type
78 do
79 inspect size
80 when 8 then
81 create {INT_VAL_B} Result.make ({INTEGER_8}.min_value)
82 when 16 then
83 create {INT_VAL_B} Result.make ({INTEGER_16}.min_value)
84 when 32 then
85 create {INT_VAL_B} Result.make ({INTEGER_32}.min_value)
86 when 64 then
87 create {INT64_VAL_B} Result.make ({INTEGER_64}.min_value)
88 end
89 end
90
91 maximum_interval_value: INTERVAL_VAL_B
92 -- Maximum value in inspect interval for current type
93 do
94 inspect size
95 when 8 then
96 create {INT_VAL_B} Result.make ({INTEGER_8}.max_value)
97 when 16 then
98 create {INT_VAL_B} Result.make ({INTEGER_16}.max_value)
99 when 32 then
100 create {INT_VAL_B} Result.make ({INTEGER_32}.max_value)
101 when 64 then
102 create {INT64_VAL_B} Result.make ({INTEGER_64}.max_value)
103 end
104 end
105
106 heaviest (other: TYPE_A): TYPE_A
107 local
108 l_long: like Current
109 do
110 if other.is_real_64 or other.is_real_32 then
111 Result := other
112 else
113 if other.is_integer then
114 l_long ?= other
115 if size >= l_long.size then
116 Result := Current
117 else
118 Result := other
119 end
120 else
121 Result := Current
122 end
123 end
124 end
125
126 feature {COMPILER_EXPORTER}
127
128 is_numeric: BOOLEAN = True
129 -- Is the current type a numeric type ?
130
131 c_type: INTEGER_I
132 -- C type
133 do
134 inspect size
135 when 8 then Result := int8_c_type
136 when 16 then Result := int16_c_type
137 when 32 then Result := int32_c_type
138 when 64 then Result := int64_c_type
139 end
140 end
141
142 invariant
143 correct_size: size = 8 or size = 16 or size = 32 or size = 64
144
145 note
146 copyright: "Copyright (c) 1984-2007, Eiffel Software"
147 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
148 licensing_options: "http://www.eiffel.com/licensing"
149 copying: "[
150 This file is part of Eiffel Software's Eiffel Development Environment.
151
152 Eiffel Software's Eiffel Development Environment is free
153 software; you can redistribute it and/or modify it under
154 the terms of the GNU General Public License as published
155 by the Free Software Foundation, version 2 of the License
156 (available at the URL listed under "license" above).
157
158 Eiffel Software's Eiffel Development Environment is
159 distributed in the hope that it will be useful, but
160 WITHOUT ANY WARRANTY; without even the implied warranty
161 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
162 See the GNU General Public License for more details.
163
164 You should have received a copy of the GNU General Public
165 License along with Eiffel Software's Eiffel Development
166 Environment; if not, write to the Free Software Foundation,
167 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
168 ]"
169 source: "[
170 Eiffel Software
171 356 Storke Road, Goleta, CA 93117 USA
172 Telephone 805-685-1006, Fax 805-685-6869
173 Website http://www.eiffel.com
174 Customer support http://support.eiffel.com
175 ]"
176
177 end -- class INTEGER_A

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23