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

http://github.com/tybor/Liberty · Specman e · 75 lines · 28 code · 11 blank · 36 comment · 0 complexity · 63122c510f82941db0080219529bc3ca MD5 · raw file

  1. deferred class LLVM_CONSTANT
  2. -- LLVM Constant Representation.
  3. -- This is an important base class in LLVM. It provides the common
  4. -- facilities of all constant values in an LLVM program. A constant is a
  5. -- value that is immutable at runtime. Functions are constants because
  6. -- their address is immutable. Same with global variables.
  7. -- All constants share the capabilities provided in this class. All
  8. -- constants can have a null value. They can have an operand list.
  9. -- Constants can be simple (integer and floating point values), complex
  10. -- (arrays and structures), or expression based (computations yielding a
  11. -- constant value composed of only certain operators and other constant
  12. -- values).
  13. -- Note that Constants are immutable (once created they never change) and
  14. -- are fully shared by structural equivalence. This means that two
  15. -- structurally equivalent constants will always have the same address.
  16. -- Constants are created on demand as needed and never deleted: thus
  17. -- clients don't have to worry about the lifetime of the objects.
  18. inherit LLVM_USER
  19. insert CORE_EXTERNALS
  20. feature {ANY}
  21. null_from (a_type: LLVM_TYPE)
  22. -- Create a null constant of `a_type'
  23. require a_type/=Void
  24. do
  25. handle:=llvmconst_null(a_type.handle)
  26. end
  27. undef_from (a_type: LLVM_TYPE)
  28. -- Create an undefined constant of `a_type'
  29. require a_type/=Void
  30. do
  31. handle:=llvmget_undef(a_type.handle)
  32. end
  33. feature {ANY} -- Queries
  34. is_constant: BOOLEAN
  35. -- TODO: as far as I understand this feature shall belong to LLVM_VALUE.
  36. do
  37. Result := llvmis_constant(handle).to_boolean
  38. end
  39. is_null: BOOLEAN
  40. -- Is Current constant null?
  41. do
  42. Result := llvmis_null(handle).to_boolean
  43. end
  44. is_undefined: BOOLEAN
  45. -- Is Current constant not defined?
  46. do
  47. Result := llvmis_undef(handle).to_boolean
  48. end
  49. end -- class LLVM_CONSTANT
  50. -- Copyright (C) 2009-2017: ,2010,2013 Paolo Redaelli - 2013 Cyril Adrian
  51. -- This file is part of LLVM wrappers for Liberty Eiffel.
  52. --
  53. -- This library is free software: you can redistribute it and/or modify
  54. -- it under the terms of the GNU Lesser General Public License as published by
  55. -- the Free Software Foundation, version 3 of the License.
  56. --
  57. -- Liberty Eiffel is distributed in the hope that it will be useful,
  58. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  59. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  60. -- GNU General Public License for more details.
  61. --
  62. -- You should have received a copy of the GNU General Public License
  63. -- along with Liberty Eiffel. If not, see <http://www.gnu.org/licenses/>.
  64. --