note description: "Constants needed for generating JVM Byte Code" legal: "See notice at end of class." status: "See notice at end of class." date: "$Date$" revision: "$Revision$" class JVM_CONSTANTS inherit IL_CONST feature {ANY} -- Access flags for Java Byte code files Acc_public: INTEGER = 0x0001 Acc_final: INTEGER = 0x0010 Acc_super: INTEGER = 0x0020 Acc_interface: INTEGER = 0x0200 Acc_abstract: INTEGER = 0x0400 Acc_static: INTEGER = 0x0008 Acc_transient: INTEGER = 0x0080 Acc_volatile: INTEGER = 0x0040 Acc_protected: INTEGER = 0x0004 Acc_private: INTEGER = 0x0002 feature {ANY} -- Type sizes Int_8_size: INTEGER = 1 Int_16_size: INTEGER = 2 Int_32_size: INTEGER = 4 Int_64_size: INTEGER = 8 Double_size: INTEGER = 8 Float_size: INTEGER = 4 feature {ANY} -- JVM types void_type: INTEGER = 0 object_type: INTEGER = 1 int_type: INTEGER = 2 long_type: INTEGER = 3 float_type: INTEGER = 4 double_type: INTEGER = 5 short_type: INTEGER = 6 bool_type: INTEGER = 7 char_type: INTEGER = 8 byte_type: INTEGER = 9 valid_jvm_type (a_jvm_type: INTEGER): BOOLEAN -- is `a_jvm_type' a valid jvm type ? do Result := a_jvm_type >= 0 and a_jvm_type <= 9 end jvm_type_to_stack_size (a_jvm_type: INTEGER): INTEGER -- takes a *_type from above and gives you the number of -- words a value of this type would take on the stack. -- note: unfortunatly the JVM has an untyped stack. that -- means that the compiler (we) need to make sure i.e. what -- add instructino (iadd, ladd, fadd, dadd) needs to be -- applied. on the jvm some types take two words on the -- stack and some take one (same goes for local variables -- and slots). have a look at the jvm specs. for details. do inspect a_jvm_type when void_type then Result := 1 when object_type then Result := 1 when int_type then Result := 1 when long_type then Result := 2 when float_type then check False end -- FIXME when double_type then Result := 2 when short_type then when bool_type then Result := 1 when char_type then check False end -- FIXME when byte_type then check False end -- FIXME else check False end end end il_kind_to_jvm_type (il_kind: INTEGER): INTEGER -- converts a il kind constant (see il_* in IL_CONST) to jvm type ids -- (see in Current *_type) require valid_type_kind: valid_type_kind (il_kind) do inspect il_kind when il_i1 then Result := byte_type when il_i2 then Result := short_type when il_i4 then Result := int_type when il_i8 then Result := long_type when il_r4 then Result := float_type when il_r8 then Result := double_type when il_ref then Result := object_type else check dead_end: False end end end note copyright: "Copyright (c) 1984-2006, Eiffel Software" license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)" licensing_options: "http://www.eiffel.com/licensing" copying: "[ This file is part of Eiffel Software's Eiffel Development Environment. Eiffel Software's Eiffel Development Environment is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2 of the License (available at the URL listed under "license" above). Eiffel Software's Eiffel Development Environment is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Eiffel Software's Eiffel Development Environment; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ]" source: "[ Eiffel Software 356 Storke Road, Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end -- class JVM_CONSTANTS