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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 92408 - (show annotations)
Fri Apr 5 09:22:00 2013 UTC (6 years, 8 months ago) by jasonw
File size: 4819 byte(s)
<<Merged from trunk#92407.>>
1 note
2 description: "Actual type for integer constant types."
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 MANIFEST_INTEGER_A
10
11 inherit
12 INTEGER_A
13 redefine
14 convert_to, intrinsic_type, process
15 end
16 INTEGER_TYPE_MASKS
17 SHARED_TYPES
18
19 create
20 make_for_constant
21
22 feature {NONE} -- Initialization
23
24 make_for_constant (n: like size; possible_types: INTEGER)
25 -- Create instance of INTEGER_A represented by `n' bits
26 -- whose value can also be of a type taken from `possible_types'.
27 require
28 valid_n: n = 32 or n = 64
29 valid_possible_types:
30 possible_types & (
31 integer_8_mask | integer_16_mask | integer_32_mask | integer_64_mask |
32 natural_8_mask | natural_16_mask | natural_32_mask | natural_64_mask
33 ).bit_not = 0
34 consistent_integer_32: n = 32 implies (possible_types & integer_32_mask) /= 0
35 consistent_integer_64: n = 64 implies (possible_types & integer_64_mask) /= 0
36 do
37 make (n)
38 integer_types := possible_types
39 ensure
40 size_set: size = n
41 types_set: integer_types = possible_types
42 end
43
44 feature -- Visitor
45
46 process (v: TYPE_A_VISITOR)
47 -- Process current element.
48 do
49 v.process_manifest_integer_a (Current)
50 end
51
52 feature -- Property
53
54 intrinsic_type: INTEGER_A
55 -- Real type of current manifest integer.
56 -- To preserve compatibility with ETL2, a manifest
57 -- integer is always at least 32 bits wide.
58 do
59 inspect size
60 when 32 then Result := integer_type
61 when 64 then Result := integer_64_type
62 end
63 end
64
65 feature {COMPILER_EXPORTER} -- Implementation
66
67 convert_to (a_context_class: CLASS_C; a_target_type: TYPE_A): BOOLEAN
68 -- Does current convert to `a_target_type' in `a_context_class'?
69 -- Update `last_conversion_info' of AST_CONTEXT.
70 local
71 l_int: INTEGER_A
72 l_nat: NATURAL_A
73 l_info: CONVERSION_INFO
74 l_feat: FEATURE_I
75 do
76 if a_target_type.is_integer then
77 l_int ?= a_target_type
78 if (integer_types & integer_mask (l_int.size)) /= 0 then
79 l_feat := base_class.feature_table.
80 item ("to_integer_" + l_int.size.out)
81 -- We protect ourself in case the `to_integer_xx' routines
82 -- would have been removed from the INTEGER_XX classes
83 if l_feat /= Void then
84 create {FEATURE_CONVERSION_INFO} l_info.make_to (Current, l_int, base_class, l_feat)
85 Result := True
86 end
87 end
88 context.set_last_conversion_info (l_info)
89 elseif a_target_type.is_natural then
90 l_nat ?= a_target_type
91 if (integer_types & natural_mask (l_nat.size)) /= 0 then
92 l_feat := base_class.feature_table.
93 item ("to_natural_" + l_nat.size.out)
94 -- We protect ourself in case the `to_natural_xx' routines
95 -- would have been removed from the INTEGER_XX classes
96 if l_feat /= Void then
97 create {FEATURE_CONVERSION_INFO} l_info.make_to (Current, l_nat, base_class, l_feat)
98 Result := True
99 end
100 end
101 context.set_last_conversion_info (l_info)
102 else
103 Result := Precursor {INTEGER_A} (a_context_class, a_target_type)
104 end
105 end
106
107 feature {NONE} -- Implementation
108
109 integer_types: INTEGER
110 -- Possible types of integer constant
111 -- (Combination of bit masks `integer_..._mask' and `natural_..._mask')
112
113 invariant
114 correct_size: size = 32 or size = 64
115 valid_types:
116 integer_types & (
117 integer_8_mask | integer_16_mask | integer_32_mask | integer_64_mask |
118 natural_8_mask | natural_16_mask | natural_32_mask | natural_64_mask
119 ).bit_not = 0
120
121 note
122 copyright: "Copyright (c) 1984-2006, Eiffel Software"
123 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
124 licensing_options: "http://www.eiffel.com/licensing"
125 copying: "[
126 This file is part of Eiffel Software's Eiffel Development Environment.
127
128 Eiffel Software's Eiffel Development Environment is free
129 software; you can redistribute it and/or modify it under
130 the terms of the GNU General Public License as published
131 by the Free Software Foundation, version 2 of the License
132 (available at the URL listed under "license" above).
133
134 Eiffel Software's Eiffel Development Environment is
135 distributed in the hope that it will be useful, but
136 WITHOUT ANY WARRANTY; without even the implied warranty
137 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
138 See the GNU General Public License for more details.
139
140 You should have received a copy of the GNU General Public
141 License along with Eiffel Software's Eiffel Development
142 Environment; if not, write to the Free Software Foundation,
143 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
144 ]"
145 source: "[
146 Eiffel Software
147 356 Storke Road, Goleta, CA 93117 USA
148 Telephone 805-685-1006, Fax 805-685-6869
149 Website http://www.eiffel.com
150 Customer support http://support.eiffel.com
151 ]"
152
153 end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23