/test/language/unclassified/position/aux_position.e

http://github.com/tybor/Liberty · Specman e · 121 lines · 77 code · 8 blank · 36 comment · 5 complexity · 41510e1bfb757e7890eefc9e7b568818 MD5 · raw file

  1. -- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries.
  2. -- See the Copyright notice at the end of this file.
  3. --
  4. expanded class AUX_POSITION
  5. --
  6. -- To test the True POSITION class of the compiler.
  7. --
  8. insert
  9. PLATFORM
  10. ANY
  11. feature {ANY}
  12. line: INTEGER
  13. -- The corresponding `line' number in the source file or 0
  14. -- when `is_unknown'.
  15. local
  16. bit: INTEGER_32
  17. do
  18. if mangling.bit_test(0) then
  19. bit := mangling |>> 1
  20. bit := bit.bit_and(0x00007fff)
  21. else
  22. bit := mangling |>> 8
  23. bit := bit.bit_and(0x00001fff)
  24. end
  25. Result := bit
  26. ensure
  27. not is_unknown implies Result >= 0
  28. end
  29. column: INTEGER
  30. -- The `column' number in the source file or 0 when `is_unknown' or
  31. -- when there is not enough space in `mangling' for the `column'.
  32. local
  33. bit: INTEGER_32
  34. do
  35. if mangling.bit_test(0) then
  36. -- Result is 0 because `column' is not memorized.
  37. else
  38. bit := mangling |>> 1 -- To drop the flag.
  39. bit := bit.bit_and(0x0000007f)
  40. Result := bit
  41. end
  42. ensure
  43. Result >= 0
  44. end
  45. is_unknown: BOOLEAN
  46. -- True when the `eiffel_parser' as called `set'.
  47. do
  48. Result := mangling = 0
  49. end
  50. set (li, co: INTEGER; class_id: INTEGER_16)
  51. require
  52. li >= 1
  53. co >= 1
  54. class_id >= 0
  55. local
  56. l, c, i: INTEGER
  57. do
  58. check
  59. Integer_bits >= 32
  60. end
  61. if class_id <= 2047 and then li <= 8191 and then co <= 127 then
  62. mangling := class_id.to_integer_32 |<< 21 -- 11 bits for `id'
  63. mangling := mangling | (li |<< 8) -- 13 bits for `line'
  64. mangling := mangling | (co |<< 1) -- 7 bits for `column'
  65. else
  66. -- The `column' is not memorized.
  67. mangling := class_id.to_integer_32 |<< 17 -- 15 bits for `id'
  68. mangling := mangling | (li |<< 1) -- 16 bits for `line'
  69. mangling := mangling | 1 -- forget `column'.
  70. end
  71. l := line
  72. c := column
  73. i := id
  74. ensure
  75. line = li
  76. id = class_id
  77. column = 0 or else column = co
  78. end
  79. mangling: INTEGER_32
  80. -- In order to save memory (there are a lot of objects like `Current'),
  81. -- the `id' of the class, the `line' and the `column' are saved in this
  82. -- BIT sequence. Two mangling are used, and the `column' may be
  83. -- dropped (not memorized, see `set'). This implementation assume
  84. -- that `Integer_bits' is greater or equal to 32.
  85. id: INTEGER_16
  86. do
  87. if mangling.bit_test(0) then
  88. Result := (mangling |>>> 17).low_16
  89. else
  90. Result := (mangling |>>> 21).low_16
  91. end
  92. ensure
  93. Result >= 0
  94. end
  95. end -- class AUX_POSITION
  96. --
  97. -- ------------------------------------------------------------------------------------------------------------------------------
  98. -- Copyright notice below. Please read.
  99. --
  100. -- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
  101. -- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
  102. -- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
  103. -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
  104. -- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
  105. -- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  106. --
  107. -- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE
  108. -- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
  109. --
  110. -- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
  111. --
  112. -- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
  113. -- ------------------------------------------------------------------------------------------------------------------------------