/src/wrappers/llvm/library/values/llvm_constant_int.e

http://github.com/tybor/Liberty · Specman e · 54 lines · 23 code · 9 blank · 22 comment · 0 complexity · 57c0c68a4fe7f690d71ebf7252d13054 MD5 · raw file

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