/src/wrappers/llvm/library/values/llvm_constant_int.e
Specman e | 54 lines | 23 code | 9 blank | 22 comment | 0 complexity | 57c0c68a4fe7f690d71ebf7252d13054 MD5 | raw file
1class LLVM_CONSTANT_INT 2 -- An integer constant 3 4inherit LLVM_CONSTANT 5create {ANY} integer_32, from_integer, from_string 6create {WRAPPER, WRAPPER_HANDLER} from_external_pointer 7 8feature {ANY} -- Creation 9 integer_32 (a_value: INTEGER_32) 10 -- Creates a 32-bit integer constant with `a_value'. 11 12 -- Note: sign-extend is assumed to be 1. See `from_integer' 13 require non_negative: a_value>=0 14 do 15 handle:=llvmconst_int(llvmint32type,a_value.to_natural_64,1) 16 end 17 18 from_integer (a_type: LLVM_INTEGER_TYPE; a_value: NATURAL_64; a_sign_extend: INTEGER_32) 19 -- Create an integer constant of `a_type' with `a_value'; TODO: what's `a_sign_extend'? 20 require a_type/=Void 21 do 22 handle:=llvmconst_int(a_type.handle,a_value,a_sign_extend) 23 end 24 25 from_string (a_type: LLVM_INTEGER_TYPE; a_text: ABSTRACT_STRING; a_radix: CHARACTER) 26 -- Create an integer constant of `a_type' from `a_text' with `a_radix'. 27 28 -- TODO: C API also offers "llvmconst_int_of_string_and_size" that could be better suited to Eiffel STRINGs. 29 require 30 a_type/=Void; 31 a_text/=Void 32 -- Note: an eventual "a_text.is_integer" or "a_text.is_number" does NOT hold because those are limited to 32-64 bits while LLVM integers may be far greater. 33 do 34 handle := llvmconst_int_of_string(a_type.handle,a_text.to_external,a_radix) 35 end 36 37end -- class LLVM_CONSTANT_INT 38-- Copyright (C) 2009-2017: Paolo Redaelli 39 40-- This file is part of LLVM wrappers for Liberty Eiffel. 41-- 42-- This library is free software: you can redistribute it and/or modify 43-- it under the terms of the GNU Lesser General Public License as published by 44-- the Free Software Foundation, version 3 of the License. 45-- 46-- Liberty Eiffel is distributed in the hope that it will be useful, 47-- but WITHOUT ANY WARRANTY; without even the implied warranty of 48-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 49-- GNU General Public License for more details. 50-- 51-- You should have received a copy of the GNU General Public License 52-- along with Liberty Eiffel. If not, see <http://www.gnu.org/licenses/>. 53-- 54