adlint 2.6.14 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) hide show
  1. data/AUTHORS +1 -3
  2. data/ChangeLog +511 -0
  3. data/INSTALL +1 -1
  4. data/MANIFEST +57 -37
  5. data/NEWS +36 -7
  6. data/README +2 -2
  7. data/Rakefile +6 -6
  8. data/TODO +1 -1
  9. data/bin/adlint +25 -16
  10. data/bin/adlint_chk +22 -12
  11. data/bin/adlint_cma +17 -12
  12. data/bin/adlint_sma +22 -12
  13. data/bin/adlintize +98 -17
  14. data/etc/conf.d/fallback/cinit.erb +1 -1
  15. data/etc/conf.d/fallback/traits.erb +37 -37
  16. data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +1 -1
  17. data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +41 -41
  18. data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +1 -1
  19. data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +40 -40
  20. data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +1 -1
  21. data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +40 -40
  22. data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +1 -1
  23. data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +40 -40
  24. data/etc/conf.d/noarch/GNUmakefile.erb +1 -1
  25. data/etc/conf.d/noarch/adlint_all_bat.erb +1 -1
  26. data/etc/conf.d/noarch/adlint_all_sh.erb +1 -1
  27. data/etc/conf.d/noarch/pinit.erb +1 -1
  28. data/etc/conf.d/x86_64-ubuntu_12.04/cinit-gcc_4.6.3.erb +1 -1
  29. data/etc/conf.d/x86_64-ubuntu_12.04/traits-gcc_4.6.3.erb +42 -42
  30. data/etc/mesg.d/c_builtin/en_US/messages.yml +33 -33
  31. data/etc/mesg.d/c_builtin/ja_JP/messages.yml +5 -5
  32. data/etc/mesg.d/core/en_US/messages.yml +2 -2
  33. data/etc/mesg.d/core/ja_JP/messages.yml +2 -2
  34. data/features/code_check/W0018.feature +197 -0
  35. data/features/code_check/W0019.feature +79 -0
  36. data/features/code_check/W0021.feature +81 -0
  37. data/features/code_check/W0023.feature +203 -0
  38. data/features/code_check/W0024.feature +226 -0
  39. data/features/code_check/W0025.feature +5 -0
  40. data/features/code_check/W0088.feature +2 -2
  41. data/features/code_check/W0109.feature +2 -2
  42. data/features/code_check/W0477.feature +0 -3
  43. data/features/code_check/W0478.feature +0 -1
  44. data/features/code_check/W0582.feature +3 -3
  45. data/features/code_check/W0583.feature +4 -7
  46. data/features/code_check/W0646.feature +0 -1
  47. data/features/code_check/W0695.feature +0 -1
  48. data/features/code_check/W0705.feature +8 -0
  49. data/features/code_check/W0723.feature +0 -1
  50. data/features/code_check/W0745.feature +1 -0
  51. data/features/code_check/W0781.feature +1 -0
  52. data/features/code_check/W1057.feature +141 -0
  53. data/features/code_check/W1058.feature +93 -0
  54. data/features/code_check/W1059.feature +86 -0
  55. data/features/code_check/W1060.feature +77 -0
  56. data/features/code_check/W1061.feature +143 -0
  57. data/features/code_check/W1062.feature +162 -0
  58. data/features/code_check/W1063.feature +123 -0
  59. data/features/code_check/W1064.feature +83 -0
  60. data/features/code_check/W1065.feature +82 -0
  61. data/features/code_check/W9003.feature +2 -0
  62. data/features/step_definitions/code_check_steps.rb +1 -0
  63. data/features/support/env.rb +16 -13
  64. data/lib/adlint.rb +7 -4
  65. data/lib/adlint/analyzer.rb +131 -157
  66. data/lib/adlint/annot.rb +149 -0
  67. data/lib/adlint/cc1.rb +57 -0
  68. data/lib/adlint/{c → cc1}/branch.rb +74 -62
  69. data/lib/adlint/{c → cc1}/builtin.rb +21 -21
  70. data/lib/adlint/{c → cc1}/const.rb +119 -117
  71. data/lib/adlint/{c → cc1}/conv.rb +76 -78
  72. data/lib/adlint/{c → cc1}/ctrlexpr.rb +69 -86
  73. data/lib/adlint/cc1/domain.rb +8103 -0
  74. data/lib/adlint/{c → cc1}/enum.rb +3 -3
  75. data/lib/adlint/{c → cc1}/environ.rb +21 -21
  76. data/lib/adlint/{c → cc1}/expr.rb +232 -218
  77. data/lib/adlint/{c → cc1}/format.rb +305 -342
  78. data/lib/adlint/{c → cc1}/interp.rb +269 -220
  79. data/lib/adlint/cc1/lexer.rb +246 -0
  80. data/lib/adlint/{c → cc1}/mediator.rb +78 -84
  81. data/lib/adlint/{c → cc1}/object.rb +261 -264
  82. data/lib/adlint/{c → cc1}/operator.rb +7 -7
  83. data/lib/adlint/{c → cc1}/option.rb +4 -3
  84. data/lib/adlint/{c → cc1}/parser.rb +274 -506
  85. data/lib/adlint/{c → cc1}/parser.y +69 -301
  86. data/lib/adlint/cc1/phase.rb +138 -0
  87. data/lib/adlint/{c → cc1}/resolver.rb +66 -78
  88. data/lib/adlint/{c → cc1}/scanner.rb +57 -49
  89. data/lib/adlint/{c → cc1}/scope.rb +3 -3
  90. data/lib/adlint/{c → cc1}/seqp.rb +13 -5
  91. data/lib/adlint/{c → cc1}/syntax.rb +819 -1122
  92. data/lib/adlint/{c → cc1}/type.rb +1498 -1479
  93. data/lib/adlint/{c → cc1}/util.rb +20 -12
  94. data/lib/adlint/{c → cc1}/value.rb +699 -642
  95. data/lib/adlint/code.rb +163 -164
  96. data/lib/adlint/cpp.rb +2 -2
  97. data/lib/adlint/cpp/asm.rb +13 -14
  98. data/lib/adlint/cpp/constexpr.rb +42 -38
  99. data/lib/adlint/cpp/constexpr.y +44 -40
  100. data/lib/adlint/cpp/eval.rb +435 -435
  101. data/lib/adlint/cpp/lexer.rb +343 -340
  102. data/lib/adlint/cpp/macro.rb +188 -190
  103. data/lib/adlint/cpp/phase.rb +66 -45
  104. data/lib/adlint/cpp/scanner.rb +14 -17
  105. data/lib/adlint/cpp/source.rb +49 -55
  106. data/lib/adlint/cpp/subst.rb +65 -65
  107. data/lib/adlint/cpp/syntax.rb +155 -275
  108. data/lib/adlint/cpp/util.rb +22 -19
  109. data/lib/adlint/driver.rb +86 -93
  110. data/lib/adlint/error.rb +33 -52
  111. data/lib/adlint/exam.rb +158 -24
  112. data/lib/adlint/exam/c_builtin.rb +7 -7
  113. data/lib/adlint/exam/c_builtin/cc1_check.rb +20522 -0
  114. data/lib/adlint/exam/c_builtin/cc1_check_shima.rb +957 -0
  115. data/lib/adlint/exam/c_builtin/cc1_code.rb +459 -0
  116. data/lib/adlint/exam/c_builtin/cc1_metric.rb +794 -0
  117. data/lib/adlint/exam/c_builtin/cpp_check.rb +486 -441
  118. data/lib/adlint/exam/c_builtin/cpp_check_shima.rb +36 -39
  119. data/lib/adlint/exam/c_builtin/cpp_code.rb +63 -65
  120. data/lib/adlint/exam/c_builtin/ld_check.rb +136 -129
  121. data/lib/adlint/exam/c_builtin/ld_metric.rb +11 -11
  122. data/lib/adlint/lang.rb +25 -25
  123. data/lib/adlint/ld.rb +2 -2
  124. data/lib/adlint/ld/object.rb +220 -188
  125. data/lib/adlint/ld/phase.rb +94 -63
  126. data/lib/adlint/ld/typedef.rb +22 -11
  127. data/lib/adlint/ld/util.rb +43 -35
  128. data/lib/adlint/lexer.rb +59 -56
  129. data/lib/adlint/location.rb +140 -0
  130. data/lib/adlint/memo.rb +157 -0
  131. data/lib/adlint/message.rb +207 -156
  132. data/lib/adlint/metric.rb +139 -217
  133. data/lib/adlint/monitor.rb +45 -43
  134. data/lib/adlint/phase.rb +56 -29
  135. data/lib/adlint/prelude.rb +66 -54
  136. data/lib/adlint/report.rb +253 -332
  137. data/lib/adlint/source.rb +26 -27
  138. data/lib/adlint/supp.rb +131 -0
  139. data/lib/adlint/symbol.rb +14 -16
  140. data/lib/adlint/token.rb +19 -91
  141. data/lib/adlint/traits.rb +242 -226
  142. data/lib/adlint/util.rb +116 -205
  143. data/lib/adlint/version.rb +8 -8
  144. data/share/HEADER +2 -2
  145. data/share/doc/developers_guide_ja.html +148 -19
  146. data/share/doc/developers_guide_ja.texi +141 -11
  147. data/share/doc/samples/GNUmakefile +1 -1
  148. data/share/doc/samples/adlint_traits.yml +45 -36
  149. data/share/doc/users_guide_en.html +1321 -1252
  150. data/share/doc/users_guide_en.texi +475 -408
  151. data/share/doc/users_guide_ja.html +1932 -1878
  152. data/share/doc/users_guide_ja.texi +324 -273
  153. data/share/sample/bison-2.5/adlint/GNUmakefile +5 -1
  154. data/share/sample/bison-2.5/adlint/adlint_traits.yml +38 -38
  155. data/share/sample/bison-2.5/adlint/lib/GNUmakefile +1 -1
  156. data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +1 -1
  157. data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +1 -1
  158. data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +50 -42
  159. data/share/sample/bison-2.5/adlint/src/GNUmakefile +1 -1
  160. data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +1 -1
  161. data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +1 -1
  162. data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +50 -42
  163. data/share/sample/ctags-5.8/adlint/GNUmakefile +1 -1
  164. data/share/sample/ctags-5.8/adlint/adlint_cinit.h +1 -1
  165. data/share/sample/ctags-5.8/adlint/adlint_pinit.h +1 -1
  166. data/share/sample/ctags-5.8/adlint/adlint_traits.yml +50 -42
  167. data/share/sample/flex-2.5.35/adlint/GNUmakefile +1 -1
  168. data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +1 -1
  169. data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +1 -1
  170. data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +50 -42
  171. data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +1 -1
  172. data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +46 -38
  173. data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +1 -1
  174. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +1 -1
  175. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +1 -1
  176. data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +50 -42
  177. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +1 -1
  178. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +1 -1
  179. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +1 -1
  180. data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +50 -42
  181. data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +1 -1
  182. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +1 -1
  183. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +1 -1
  184. data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +50 -42
  185. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +1 -1
  186. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +1 -1
  187. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +1 -1
  188. data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +50 -42
  189. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +1 -1
  190. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +1 -1
  191. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +1 -1
  192. data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +50 -42
  193. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +1 -1
  194. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +1 -1
  195. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +1 -1
  196. data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +50 -42
  197. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +1 -1
  198. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +1 -1
  199. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +1 -1
  200. data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +50 -42
  201. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +1 -1
  202. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +1 -1
  203. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +1 -1
  204. data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +50 -42
  205. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +1 -1
  206. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +1 -1
  207. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +1 -1
  208. data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +50 -42
  209. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +1 -1
  210. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +1 -1
  211. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +1 -1
  212. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +50 -42
  213. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +1 -1
  214. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +1 -1
  215. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +1 -1
  216. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +50 -42
  217. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +1 -1
  218. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +1 -1
  219. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +1 -1
  220. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +50 -42
  221. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +1 -1
  222. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +1 -1
  223. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +1 -1
  224. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +50 -42
  225. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +1 -1
  226. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +1 -1
  227. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +1 -1
  228. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +50 -42
  229. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +1 -1
  230. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +1 -1
  231. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +1 -1
  232. data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +50 -42
  233. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +1 -1
  234. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +1 -1
  235. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +1 -1
  236. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +50 -42
  237. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +1 -1
  238. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +1 -1
  239. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +1 -1
  240. data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +50 -42
  241. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +1 -1
  242. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +1 -1
  243. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +1 -1
  244. data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +50 -42
  245. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +1 -1
  246. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +1 -1
  247. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +1 -1
  248. data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +50 -42
  249. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +1 -1
  250. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +1 -1
  251. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +1 -1
  252. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +50 -42
  253. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +1 -1
  254. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +1 -1
  255. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +1 -1
  256. data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +50 -42
  257. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +1 -1
  258. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +1 -1
  259. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +1 -1
  260. data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +50 -42
  261. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +1 -1
  262. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +1 -1
  263. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +1 -1
  264. data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +50 -42
  265. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +1 -1
  266. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +1 -1
  267. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +1 -1
  268. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +50 -42
  269. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +1 -1
  270. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +1 -1
  271. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +1 -1
  272. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +50 -42
  273. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +1 -1
  274. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +1 -1
  275. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +1 -1
  276. data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +50 -42
  277. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +1 -1
  278. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +1 -1
  279. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +1 -1
  280. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +50 -42
  281. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +1 -1
  282. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +1 -1
  283. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +1 -1
  284. data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +50 -42
  285. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +1 -1
  286. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +1 -1
  287. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +1 -1
  288. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +50 -42
  289. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +1 -1
  290. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +1 -1
  291. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +1 -1
  292. data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +50 -42
  293. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +1 -1
  294. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +1 -1
  295. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +1 -1
  296. data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +50 -42
  297. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +1 -1
  298. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +1 -1
  299. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +1 -1
  300. data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +50 -42
  301. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +1 -1
  302. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +1 -1
  303. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +1 -1
  304. data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +50 -42
  305. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +1 -1
  306. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +1 -1
  307. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +1 -1
  308. data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +50 -42
  309. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +1 -1
  310. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +1 -1
  311. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +1 -1
  312. data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +50 -42
  313. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +1 -1
  314. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +1 -1
  315. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +1 -1
  316. data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +50 -42
  317. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +1 -1
  318. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +1 -1
  319. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +1 -1
  320. data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +50 -42
  321. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +1 -1
  322. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +1 -1
  323. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +1 -1
  324. data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +50 -42
  325. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +1 -1
  326. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +1 -1
  327. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +1 -1
  328. data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +50 -42
  329. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +1 -1
  330. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +1 -1
  331. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +1 -1
  332. data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +50 -42
  333. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +1 -1
  334. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +1 -1
  335. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +1 -1
  336. data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +50 -42
  337. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +1 -1
  338. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +1 -1
  339. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +1 -1
  340. data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +50 -42
  341. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +1 -1
  342. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +1 -1
  343. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +1 -1
  344. data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +50 -42
  345. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +1 -1
  346. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +1 -1
  347. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +1 -1
  348. data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +50 -42
  349. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +1 -1
  350. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +1 -1
  351. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +1 -1
  352. data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +50 -42
  353. data/share/sample/screen-4.0.3/adlint/GNUmakefile +1 -1
  354. data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +1 -1
  355. data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +1 -1
  356. data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +50 -42
  357. data/share/sample/vim-7.3/adlint/vim/GNUmakefile +1 -1
  358. data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +1 -1
  359. data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +1 -1
  360. data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +50 -42
  361. data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +1 -1
  362. data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +1 -1
  363. data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +1 -1
  364. data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +49 -41
  365. data/share/sample/zsh-4.3.15/adlint/GNUmakefile +1 -1
  366. data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +46 -38
  367. data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +1 -1
  368. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +1 -1
  369. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +1 -1
  370. data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +50 -42
  371. data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +1 -1
  372. data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +1 -1
  373. data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +1 -1
  374. data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +50 -42
  375. data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +1 -1
  376. data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +1 -1
  377. data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +1 -1
  378. data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +50 -42
  379. data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +1 -1
  380. data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +1 -1
  381. data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +1 -1
  382. data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +50 -42
  383. data/spec/adlint/{c → cc1}/ctrlexpr_spec.rb +51 -49
  384. data/spec/adlint/{c → cc1}/domain_spec.rb +210 -179
  385. data/spec/adlint/{c → cc1}/operator_spec.rb +3 -3
  386. data/spec/adlint/{c → cc1}/syntax_spec.rb +10 -12
  387. data/spec/adlint/{c → cc1}/type_spec.rb +61 -68
  388. data/{lib/adlint/c.rb → spec/adlint/location_spec.rb} +24 -29
  389. data/spec/conf.d/default_traits.yml +38 -37
  390. data/spec/conf.d/empty_cinit.h +1 -1
  391. data/spec/conf.d/empty_pinit.h +1 -1
  392. data/spec/conf.d/project/foo.c +0 -0
  393. data/spec/spec_helper.rb +2 -2
  394. metadata +60 -40
  395. data/lib/adlint/c/domain.rb +0 -7931
  396. data/lib/adlint/c/lexer.rb +0 -252
  397. data/lib/adlint/c/phase.rb +0 -135
  398. data/lib/adlint/exam/c_builtin/c_check.rb +0 -20745
  399. data/lib/adlint/exam/c_builtin/c_check_shima.rb +0 -983
  400. data/lib/adlint/exam/c_builtin/c_code.rb +0 -477
  401. data/lib/adlint/exam/c_builtin/c_metric.rb +0 -818
@@ -1,7 +1,7 @@
1
1
  # Miscellaneous utilities for C language.
2
2
  #
3
3
  # Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
4
- # Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
4
+ # Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
5
5
  # License:: GPLv3+: GNU General Public License version 3 or later
6
6
  #
7
7
  # Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
@@ -11,7 +11,7 @@
11
11
  # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
12
12
  # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
13
13
  # / __ |/ /_/ / /___/ / /| / / /
14
- # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
14
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
15
15
  #
16
16
  # This file is part of AdLint.
17
17
  #
@@ -30,7 +30,7 @@
30
30
  #++
31
31
 
32
32
  module AdLint #:nodoc:
33
- module C #:nodoc:
33
+ module Cc1 #:nodoc:
34
34
 
35
35
  class EscapeSequence
36
36
  def initialize(str)
@@ -66,21 +66,29 @@ module C #:nodoc:
66
66
  end
67
67
 
68
68
  module DebugUtil
69
- def dump_syntax_tree(context)
70
- return unless $DEBUG
69
+ def dump_syntax_tree(phase_ctxt)
70
+ if $DEBUG
71
+ ast_fname = phase_ctxt[:sources].first.fpath.basename.add_ext(".ast")
72
+ ast_fpath = ast_fname.expand_path(phase_ctxt.msg_fpath.dirname)
71
73
 
72
- File.open(context[:sources].first.fpath.add_ext(".ast"), "w") do |io|
73
- PP.pp(context[:c_syntax_tree], io)
74
+ File.open(ast_fpath, "w") do |io|
75
+ if phase_ctxt[:cc1_syntax_tree]
76
+ PP.pp(phase_ctxt[:cc1_syntax_tree], io)
77
+ end
78
+ end
74
79
  end
75
80
  end
76
81
  module_function :dump_syntax_tree
77
82
 
78
- def dump_token_array(context)
79
- return unless $DEBUG
83
+ def dump_token_array(phase_ctxt)
84
+ if $DEBUG
85
+ tok_fname = phase_ctxt[:sources].first.fpath.basename.add_ext(".tok")
86
+ tok_fpath = tok_fname.expand_path(phase_ctxt.msg_fpath.dirname)
80
87
 
81
- File.open(context[:sources].first.fpath.add_ext(".tok"), "w") do |io|
82
- if context[:c_token_array]
83
- context[:c_token_array].each { |t| io.puts(t.inspect) }
88
+ File.open(tok_fpath, "w") do |io|
89
+ if phase_ctxt[:cc1_token_array]
90
+ phase_ctxt[:cc1_token_array].each { |tok| io.puts(tok.inspect) }
91
+ end
84
92
  end
85
93
  end
86
94
  end
@@ -1,7 +1,7 @@
1
1
  # Values associated with memory blocks.
2
2
  #
3
3
  # Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
4
- # Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
4
+ # Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
5
5
  # License:: GPLv3+: GNU General Public License version 3 or later
6
6
  #
7
7
  # Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
@@ -11,7 +11,7 @@
11
11
  # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
12
12
  # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
13
13
  # / __ |/ /_/ / /___/ / /| / / /
14
- # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
14
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
15
15
  #
16
16
  # This file is part of AdLint.
17
17
  #
@@ -29,11 +29,11 @@
29
29
  #
30
30
  #++
31
31
 
32
- require "adlint/c/domain"
33
- require "adlint/c/operator"
32
+ require "adlint/cc1/domain"
33
+ require "adlint/cc1/operator"
34
34
 
35
35
  module AdLint #:nodoc:
36
- module C #:nodoc:
36
+ module Cc1 #:nodoc:
37
37
 
38
38
  module BuggyValueSampler
39
39
  def unique_sample
@@ -46,12 +46,12 @@ module C #:nodoc:
46
46
  # == DESCRIPTION
47
47
  # === Value class hierarchy
48
48
  # Value
49
- # <--- SingleValue
50
- # <--- ScalarValue
51
- # <--- ArrayValue
52
- # <--- CompositeValue
53
- # <--- MultipleValue
54
- # <--- VersionedValue
49
+ # <-- SingleValue
50
+ # <-- ScalarValue
51
+ # <-- ArrayValue
52
+ # <-- CompositeValue
53
+ # <-- MultipleValue
54
+ # <-- VersionedValue
55
55
  class Value
56
56
  include BuggyValueSampler
57
57
 
@@ -83,7 +83,7 @@ module C #:nodoc:
83
83
  subclass_responsibility
84
84
  end
85
85
 
86
- def contain?(value)
86
+ def contain?(val)
87
87
  subclass_responsibility
88
88
  end
89
89
 
@@ -91,15 +91,15 @@ module C #:nodoc:
91
91
  subclass_responsibility
92
92
  end
93
93
 
94
- def overwrite!(value)
94
+ def overwrite!(val)
95
95
  subclass_responsibility
96
96
  end
97
97
 
98
- def narrow_domain!(operator, operand_value)
98
+ def narrow_domain!(op, ope_val)
99
99
  subclass_responsibility
100
100
  end
101
101
 
102
- def widen_domain!(operator, operand_value)
102
+ def widen_domain!(op, ope_val)
103
103
  subclass_responsibility
104
104
  end
105
105
 
@@ -107,7 +107,7 @@ module C #:nodoc:
107
107
  subclass_responsibility
108
108
  end
109
109
 
110
- def single_value_unified_with(rhs_value)
110
+ def single_value_unified_with(rhs_val)
111
111
  subclass_responsibility
112
112
  end
113
113
 
@@ -123,43 +123,43 @@ module C #:nodoc:
123
123
  subclass_responsibility
124
124
  end
125
125
 
126
- def +(rhs_value)
126
+ def +(rhs_val)
127
127
  subclass_responsibility
128
128
  end
129
129
 
130
- def -(rhs_value)
130
+ def -(rhs_val)
131
131
  subclass_responsibility
132
132
  end
133
133
 
134
- def *(rhs_value)
134
+ def *(rhs_val)
135
135
  subclass_responsibility
136
136
  end
137
137
 
138
- def /(rhs_value)
138
+ def /(rhs_val)
139
139
  subclass_responsibility
140
140
  end
141
141
 
142
- def %(rhs_value)
142
+ def %(rhs_val)
143
143
  subclass_responsibility
144
144
  end
145
145
 
146
- def &(rhs_value)
146
+ def &(rhs_val)
147
147
  subclass_responsibility
148
148
  end
149
149
 
150
- def |(rhs_value)
150
+ def |(rhs_val)
151
151
  subclass_responsibility
152
152
  end
153
153
 
154
- def ^(rhs_value)
154
+ def ^(rhs_val)
155
155
  subclass_responsibility
156
156
  end
157
157
 
158
- def <<(rhs_value)
158
+ def <<(rhs_val)
159
159
  subclass_responsibility
160
160
  end
161
161
 
162
- def >>(rhs_value)
162
+ def >>(rhs_val)
163
163
  subclass_responsibility
164
164
  end
165
165
 
@@ -167,69 +167,69 @@ module C #:nodoc:
167
167
  subclass_responsibility
168
168
  end
169
169
 
170
- def <(rhs_value)
170
+ def <(rhs_val)
171
171
  subclass_responsibility
172
172
  end
173
173
 
174
- def >(rhs_value)
174
+ def >(rhs_val)
175
175
  subclass_responsibility
176
176
  end
177
177
 
178
- def ==(rhs_value)
178
+ def ==(rhs_val)
179
179
  subclass_responsibility
180
180
  end
181
181
 
182
- def !=(rhs_value)
182
+ def !=(rhs_val)
183
183
  subclass_responsibility
184
184
  end
185
185
 
186
- def <=(rhs_value)
186
+ def <=(rhs_val)
187
187
  subclass_responsibility
188
188
  end
189
189
 
190
- def >=(rhs_value)
190
+ def >=(rhs_val)
191
191
  subclass_responsibility
192
192
  end
193
193
 
194
- def logical_and(rhs_value)
194
+ def logical_and(rhs_val)
195
195
  # NOTE: Operator && cannot be defined as a method in Ruby.
196
196
  subclass_responsibility
197
197
  end
198
198
 
199
- def logical_or(rhs_value)
199
+ def logical_or(rhs_val)
200
200
  # NOTE: Operator || cannot be defined as a method in Ruby.
201
201
  subclass_responsibility
202
202
  end
203
203
 
204
- def must_be_equal_to?(value)
204
+ def must_be_equal_to?(val)
205
205
  subclass_responsibility
206
206
  end
207
207
 
208
- def may_be_equal_to?(value)
208
+ def may_be_equal_to?(val)
209
209
  subclass_responsibility
210
210
  end
211
211
 
212
- def must_not_be_equal_to?(value)
212
+ def must_not_be_equal_to?(val)
213
213
  subclass_responsibility
214
214
  end
215
215
 
216
- def may_not_be_equal_to?(value)
216
+ def may_not_be_equal_to?(val)
217
217
  subclass_responsibility
218
218
  end
219
219
 
220
- def must_be_less_than?(value)
220
+ def must_be_less_than?(val)
221
221
  subclass_responsibility
222
222
  end
223
223
 
224
- def may_be_less_than?(value)
224
+ def may_be_less_than?(val)
225
225
  subclass_responsibility
226
226
  end
227
227
 
228
- def must_be_greater_than?(value)
228
+ def must_be_greater_than?(val)
229
229
  subclass_responsibility
230
230
  end
231
231
 
232
- def may_be_greater_than?(value)
232
+ def may_be_greater_than?(val)
233
233
  subclass_responsibility
234
234
  end
235
235
 
@@ -273,7 +273,7 @@ module C #:nodoc:
273
273
  subclass_responsibility
274
274
  end
275
275
 
276
- def eql?(rhs_value)
276
+ def eql?(rhs_val)
277
277
  subclass_responsibility
278
278
  end
279
279
 
@@ -305,58 +305,87 @@ module C #:nodoc:
305
305
  def to_single_value
306
306
  self
307
307
  end
308
+
309
+ private
310
+ def scalar_value_of_true
311
+ ScalarValue.of_true(logical_shr?)
312
+ end
313
+
314
+ def scalar_value_of_false
315
+ ScalarValue.of_false(logical_shr?)
316
+ end
317
+
318
+ def scalar_value_of_nil
319
+ ScalarValue.of_nil(logical_shr?)
320
+ end
321
+
322
+ def logical_shr?
323
+ subclass_responsibility
324
+ end
308
325
  end
309
326
 
310
- class ScalarValue < SingleValue
311
- def self.of(numeric_or_range)
327
+ module ScalarValueFactory
328
+ def of(numeric_or_range, logical_shr)
312
329
  case numeric_or_range
313
330
  when Numeric
314
- new(ValueDomain.equal_to(numeric_or_range))
331
+ new(ValueDomain.equal_to(numeric_or_range, logical_shr))
315
332
  when Range
316
- lower = ValueDomain.greater_than_or_equal_to(numeric_or_range.first)
317
- higher = ValueDomain.less_than_or_equal_to(numeric_or_range.last)
318
- new(lower.intersection(higher))
333
+ new(ValueDomain.greater_than_or_equal_to(
334
+ numeric_or_range.first, logical_shr
335
+ ).intersection(ValueDomain.less_than_or_equal_to(
336
+ numeric_or_range.last, logical_shr
337
+ )))
319
338
  else
320
339
  raise TypeError, "argument must be a Numeric or a Range."
321
340
  end
322
341
  end
323
342
 
324
- def self.not_of(numeric_or_range)
343
+ def not_of(numeric_or_range, logical_shr)
325
344
  case numeric_or_range
326
345
  when Numeric
327
- new(ValueDomain.not_equal_to(numeric_or_range))
346
+ new(ValueDomain.not_equal_to(numeric_or_range, logical_shr))
328
347
  when Range
329
- lower = ValueDomain.less_than(numeric_or_range.first)
330
- higher = ValueDomain.greater_than(numeric_or_range.last)
331
- new(lower.union(higher))
348
+ new(ValueDomain.less_than(
349
+ numeric_or_range.first, logical_shr
350
+ ).union(ValueDomain.greater_than(
351
+ numeric_or_range.last, logical_shr
352
+ )))
332
353
  else
333
354
  raise TypeError, "argument must be a Numeric or a Range."
334
355
  end
335
356
  end
336
357
 
337
- def self.of_true
338
- not_of(0)
358
+ def of_true(logical_shr)
359
+ not_of(0, logical_shr)
339
360
  end
340
361
 
341
- def self.of_false
342
- of(0)
362
+ def of_false(logical_shr)
363
+ of(0, logical_shr)
343
364
  end
344
365
 
345
- def self.of_arbitrary
346
- new(ValueDomain.of_unlimited)
366
+ def of_arbitrary(logical_shr)
367
+ new(ValueDomain.of_unlimited(logical_shr))
347
368
  end
348
369
 
349
- def self.of_undefined(range)
350
- new(ValueDomain.of_undefined(range))
370
+ def of_undefined(range, logical_shr)
371
+ new(ValueDomain.of_undefined(ValueDomain.greater_than_or_equal_to(
372
+ range.first, logical_shr
373
+ ).intersection(ValueDomain.less_than_or_equal_to(
374
+ range.last, logical_shr
375
+ ))))
351
376
  end
352
377
 
353
- def self.of_nil
354
- new(ValueDomain.of_nil)
378
+ def of_nil(logical_shr)
379
+ new(ValueDomain.of_nil(logical_shr))
355
380
  end
356
381
 
357
- def self.of_nan
358
- new(ValueDomain.of_nan)
382
+ def of_nan(logical_shr)
383
+ new(ValueDomain.of_nan(logical_shr))
359
384
  end
385
+ end
386
+
387
+ class ScalarValue < SingleValue
388
+ extend ScalarValueFactory
360
389
 
361
390
  def initialize(domain)
362
391
  @domain = domain
@@ -382,10 +411,10 @@ module C #:nodoc:
382
411
  @domain.kind_of?(EqualToValueDomain)
383
412
  end
384
413
 
385
- def contain?(value)
386
- case single_value = value.to_single_value
414
+ def contain?(val)
415
+ case single_val = val.to_single_value
387
416
  when ScalarValue
388
- @domain.contain?(single_value.domain)
417
+ @domain.contain?(single_val.domain)
389
418
  else
390
419
  false
391
420
  end
@@ -399,32 +428,32 @@ module C #:nodoc:
399
428
  @domain.ambiguous?
400
429
  end
401
430
 
402
- def overwrite!(value)
403
- case single_value = value.to_single_value
431
+ def overwrite!(val)
432
+ case single_val = val.to_single_value
404
433
  when ScalarValue
405
- @domain = single_value.domain
434
+ @domain = single_val.domain
406
435
  else
407
436
  raise TypeError, "cannot overwrite scalar with non-scalar."
408
437
  end
409
438
  end
410
439
 
411
- def narrow_domain!(operator, operand_value)
412
- case operand_single_value = operand_value.to_single_value
440
+ def narrow_domain!(op, ope_val)
441
+ case ope_single_val = ope_val.to_single_value
413
442
  when ScalarValue
414
- orig_domain = @domain
415
- @domain = @domain.narrow(operator, operand_single_value.domain)
416
- !@domain.equal?(orig_domain)
443
+ org_dom = @domain
444
+ @domain = @domain.narrow(op, ope_single_val.domain)
445
+ !@domain.equal?(org_dom)
417
446
  else
418
447
  raise TypeError, "cannot narrow scalar value domain with non-scalar."
419
448
  end
420
449
  end
421
450
 
422
- def widen_domain!(operator, operand_value)
423
- case operand_single_value = operand_value.to_single_value
451
+ def widen_domain!(op, ope_val)
452
+ case ope_single_val = ope_val.to_single_value
424
453
  when ScalarValue
425
- orig_domain = @domain
426
- @domain = @domain.widen(operator, operand_single_value.domain)
427
- !@domain.equal?(orig_domain)
454
+ org_dom = @domain
455
+ @domain = @domain.widen(op, ope_single_val.domain)
456
+ !@domain.equal?(org_dom)
428
457
  else
429
458
  raise TypeError, "cannot widen scalar value domain with non-scalar."
430
459
  end
@@ -434,10 +463,10 @@ module C #:nodoc:
434
463
  @domain = @domain.inversion
435
464
  end
436
465
 
437
- def single_value_unified_with(rhs_value)
438
- case rhs_single_value = rhs_value.to_single_value
466
+ def single_value_unified_with(rhs_val)
467
+ case rhs_single_val = rhs_val.to_single_value
439
468
  when ScalarValue
440
- ScalarValue.new(@domain.union(rhs_single_value.domain))
469
+ ScalarValue.new(@domain.union(rhs_single_val.domain))
441
470
  else
442
471
  raise TypeError, "cannot unify scalar value with non-scalar."
443
472
  end
@@ -455,91 +484,91 @@ module C #:nodoc:
455
484
  ScalarValue.new(-@domain)
456
485
  end
457
486
 
458
- def +(rhs_value)
459
- case rhs_single_value = rhs_value.to_single_value
487
+ def +(rhs_val)
488
+ case rhs_single_val = rhs_val.to_single_value
460
489
  when ScalarValue
461
- ScalarValue.new(@domain + rhs_single_value.domain)
490
+ ScalarValue.new(@domain + rhs_single_val.domain)
462
491
  else
463
492
  raise TypeError, "binary operation between scalar and non-scalar."
464
493
  end
465
494
  end
466
495
 
467
- def -(rhs_value)
468
- case rhs_single_value = rhs_value.to_single_value
496
+ def -(rhs_val)
497
+ case rhs_single_val = rhs_val.to_single_value
469
498
  when ScalarValue
470
- ScalarValue.new(@domain - rhs_single_value.domain)
499
+ ScalarValue.new(@domain - rhs_single_val.domain)
471
500
  else
472
501
  raise TypeError, "binary operation between scalar and non-scalar."
473
502
  end
474
503
  end
475
504
 
476
- def *(rhs_value)
477
- case rhs_single_value = rhs_value.to_single_value
505
+ def *(rhs_val)
506
+ case rhs_single_val = rhs_val.to_single_value
478
507
  when ScalarValue
479
- ScalarValue.new(@domain * rhs_single_value.domain)
508
+ ScalarValue.new(@domain * rhs_single_val.domain)
480
509
  else
481
510
  raise TypeError, "binary operation between scalar and non-scalar."
482
511
  end
483
512
  end
484
513
 
485
- def /(rhs_value)
486
- case rhs_single_value = rhs_value.to_single_value
514
+ def /(rhs_val)
515
+ case rhs_single_val = rhs_val.to_single_value
487
516
  when ScalarValue
488
- ScalarValue.new(@domain / rhs_single_value.domain)
517
+ ScalarValue.new(@domain / rhs_single_val.domain)
489
518
  else
490
519
  raise TypeError, "binary operation between scalar and non-scalar."
491
520
  end
492
521
  end
493
522
 
494
- def %(rhs_value)
495
- case rhs_single_value = rhs_value.to_single_value
523
+ def %(rhs_val)
524
+ case rhs_single_val = rhs_val.to_single_value
496
525
  when ScalarValue
497
- ScalarValue.new(@domain % rhs_single_value.domain)
526
+ ScalarValue.new(@domain % rhs_single_val.domain)
498
527
  else
499
528
  raise TypeError, "binary operation between scalar and non-scalar."
500
529
  end
501
530
  end
502
531
 
503
- def &(rhs_value)
504
- case rhs_single_value = rhs_value.to_single_value
532
+ def &(rhs_val)
533
+ case rhs_single_val = rhs_val.to_single_value
505
534
  when ScalarValue
506
- ScalarValue.new(@domain & rhs_single_value.domain)
535
+ ScalarValue.new(@domain & rhs_single_val.domain)
507
536
  else
508
537
  raise TypeError, "binary operation between scalar and non-scalar."
509
538
  end
510
539
  end
511
540
 
512
- def |(rhs_value)
513
- case rhs_single_value = rhs_value.to_single_value
541
+ def |(rhs_val)
542
+ case rhs_single_val = rhs_val.to_single_value
514
543
  when ScalarValue
515
- ScalarValue.new(@domain | rhs_single_value.domain)
544
+ ScalarValue.new(@domain | rhs_single_val.domain)
516
545
  else
517
546
  raise TypeError, "binary operation between scalar and non-scalar."
518
547
  end
519
548
  end
520
549
 
521
- def ^(rhs_value)
522
- case rhs_single_value = rhs_value.to_single_value
550
+ def ^(rhs_val)
551
+ case rhs_single_val = rhs_val.to_single_value
523
552
  when ScalarValue
524
- ScalarValue.new(@domain ^ rhs_single_value.domain)
553
+ ScalarValue.new(@domain ^ rhs_single_val.domain)
525
554
  else
526
555
  raise TypeError, "binary operation between scalar and non-scalar."
527
556
  end
528
557
  end
529
558
 
530
- def <<(rhs_value)
531
- case rhs_single_value = rhs_value.to_single_value
559
+ def <<(rhs_val)
560
+ case rhs_single_val = rhs_val.to_single_value
532
561
  when ScalarValue
533
- ScalarValue.new(@domain << rhs_single_value.domain)
562
+ ScalarValue.new(@domain << rhs_single_val.domain)
534
563
  else
535
564
  raise TypeError, "binary operation between scalar and non-scalar."
536
565
  end
537
566
  end
538
567
 
539
- def >>(rhs_value)
540
- case rhs_single_value = rhs_value.to_single_value
568
+ def >>(rhs_val)
569
+ case rhs_single_val = rhs_val.to_single_value
541
570
  when ScalarValue
542
- ScalarValue.new(@domain >> rhs_single_value.domain)
571
+ ScalarValue.new(@domain >> rhs_single_val.domain)
543
572
  else
544
573
  raise TypeError, "binary operation between scalar and non-scalar."
545
574
  end
@@ -549,177 +578,177 @@ module C #:nodoc:
549
578
  ScalarValue.new(!@domain)
550
579
  end
551
580
 
552
- def <(rhs_value)
553
- case rhs_single_value = rhs_value.to_single_value
581
+ def <(rhs_val)
582
+ case rhs_single_val = rhs_val.to_single_value
554
583
  when ScalarValue
555
- ScalarValue.new(@domain < rhs_single_value.domain)
584
+ ScalarValue.new(@domain < rhs_single_val.domain)
556
585
  else
557
586
  raise TypeError, "comparison between scalar and non-scalar."
558
587
  end
559
588
  end
560
589
 
561
- def >(rhs_value)
562
- case rhs_single_value = rhs_value.to_single_value
590
+ def >(rhs_val)
591
+ case rhs_single_val = rhs_val.to_single_value
563
592
  when ScalarValue
564
- ScalarValue.new(@domain > rhs_single_value.domain)
593
+ ScalarValue.new(@domain > rhs_single_val.domain)
565
594
  else
566
595
  raise TypeError, "comparison between scalar and non-scalar."
567
596
  end
568
597
  end
569
598
 
570
- def ==(rhs_value)
571
- case rhs_single_value = rhs_value.to_single_value
599
+ def ==(rhs_val)
600
+ case rhs_single_val = rhs_val.to_single_value
572
601
  when ScalarValue
573
- ScalarValue.new(@domain == rhs_single_value.domain)
602
+ ScalarValue.new(@domain == rhs_single_val.domain)
574
603
  else
575
604
  raise TypeError, "comparison between scalar and non-scalar."
576
605
  end
577
606
  end
578
607
 
579
- def !=(rhs_value)
580
- case rhs_single_value = rhs_value.to_single_value
608
+ def !=(rhs_val)
609
+ case rhs_single_val = rhs_val.to_single_value
581
610
  when ScalarValue
582
- ScalarValue.new(@domain != rhs_single_value.domain)
611
+ ScalarValue.new(@domain != rhs_single_val.domain)
583
612
  else
584
613
  raise TypeError, "comparison between scalar and non-scalar."
585
614
  end
586
615
  end
587
616
 
588
- def <=(rhs_value)
589
- case rhs_single_value = rhs_value.to_single_value
617
+ def <=(rhs_val)
618
+ case rhs_single_val = rhs_val.to_single_value
590
619
  when ScalarValue
591
- ScalarValue.new(@domain <= rhs_single_value.domain)
620
+ ScalarValue.new(@domain <= rhs_single_val.domain)
592
621
  else
593
622
  raise TypeError, "comparison between scalar and non-scalar."
594
623
  end
595
624
  end
596
625
 
597
- def >=(rhs_value)
598
- case rhs_single_value = rhs_value.to_single_value
626
+ def >=(rhs_val)
627
+ case rhs_single_val = rhs_val.to_single_value
599
628
  when ScalarValue
600
- ScalarValue.new(@domain >= rhs_single_value.domain)
629
+ ScalarValue.new(@domain >= rhs_single_val.domain)
601
630
  else
602
631
  raise TypeError, "comparison between scalar and non-scalar."
603
632
  end
604
633
  end
605
634
 
606
- def logical_and(rhs_value)
607
- case rhs_single_value = rhs_value.to_single_value
635
+ def logical_and(rhs_val)
636
+ case rhs_single_val = rhs_val.to_single_value
608
637
  when ScalarValue
609
- ScalarValue.new(@domain.logical_and(rhs_single_value.domain))
638
+ ScalarValue.new(@domain.logical_and(rhs_single_val.domain))
610
639
  else
611
640
  raise TypeError, "comparison between scalar and non-scalar."
612
641
  end
613
642
  end
614
643
 
615
- def logical_or(rhs_value)
616
- case rhs_single_value = rhs_value.to_single_value
644
+ def logical_or(rhs_val)
645
+ case rhs_single_val = rhs_val.to_single_value
617
646
  when ScalarValue
618
- ScalarValue.new(@domain.logical_or(rhs_single_value.domain))
647
+ ScalarValue.new(@domain.logical_or(rhs_single_val.domain))
619
648
  else
620
649
  raise TypeError, "comparison between scalar and non-scalar."
621
650
  end
622
651
  end
623
652
 
624
- def must_be_equal_to?(value)
625
- case single_value = value.to_single_value.dup
653
+ def must_be_equal_to?(val)
654
+ case single_val = val.to_single_value.dup
626
655
  when ScalarValue
627
- comp_result = (self == single_value)
628
- single_value.invert_domain!
629
- single_value.narrow_domain!(Operator::EQ, self)
630
- comp_result.domain.intersect?(ScalarValue.of_true.domain) &&
631
- !comp_result.domain.contain?(ScalarValue.of_false.domain) &&
632
- !@domain.intersect?(single_value.domain)
656
+ comp_val = (self == single_val)
657
+ single_val.invert_domain!
658
+ single_val.narrow_domain!(Operator::EQ, self)
659
+ comp_val.domain.intersect?(scalar_value_of_true.domain) &&
660
+ !comp_val.domain.contain?(scalar_value_of_false.domain) &&
661
+ !@domain.intersect?(single_val.domain)
633
662
  else
634
663
  raise TypeError, "comparison between scalar and non-scalar."
635
664
  end
636
665
  end
637
666
 
638
- def may_be_equal_to?(value)
639
- case single_value = value.to_single_value
667
+ def may_be_equal_to?(val)
668
+ case single_val = val.to_single_value
640
669
  when ScalarValue
641
- (self == single_value).domain.intersect?(ScalarValue.of_true.domain)
670
+ (self == single_val).domain.intersect?(scalar_value_of_true.domain)
642
671
  else
643
672
  raise TypeError, "comparison between scalar and non-scalar."
644
673
  end
645
674
  end
646
675
 
647
- def must_not_be_equal_to?(value)
648
- case single_value = value.to_single_value
676
+ def must_not_be_equal_to?(val)
677
+ case single_val = val.to_single_value
649
678
  when ScalarValue
650
- comp_result = (self != single_value)
651
- comp_result.domain.intersect?(ScalarValue.of_true.domain) &&
652
- !comp_result.domain.contain?(ScalarValue.of_false.domain) &&
653
- !@domain.intersect?(single_value.domain)
679
+ comp_val = (self != single_val)
680
+ comp_val.domain.intersect?(scalar_value_of_true.domain) &&
681
+ !comp_val.domain.contain?(scalar_value_of_false.domain) &&
682
+ !@domain.intersect?(single_val.domain)
654
683
  else
655
684
  raise TypeError, "comparison between scalar and non-scalar."
656
685
  end
657
686
  end
658
687
 
659
- def may_not_be_equal_to?(value)
660
- case single_value = value.to_single_value
688
+ def may_not_be_equal_to?(val)
689
+ case single_val = val.to_single_value
661
690
  when ScalarValue
662
- (self != single_value).domain.intersect?(ScalarValue.of_true.domain)
691
+ (self != single_val).domain.intersect?(scalar_value_of_true.domain)
663
692
  else
664
693
  raise TypeError, "comparison between scalar and non-scalar."
665
694
  end
666
695
  end
667
696
 
668
- def must_be_less_than?(value)
669
- case single_value = value.to_single_value
697
+ def must_be_less_than?(val)
698
+ case single_val = val.to_single_value
670
699
  when ScalarValue
671
- comp_result = (self < single_value)
672
- comp_result.domain.intersect?(ScalarValue.of_true.domain) &&
673
- !comp_result.domain.contain?(ScalarValue.of_false.domain)
700
+ comp_val = (self < single_val)
701
+ comp_val.domain.intersect?(scalar_value_of_true.domain) &&
702
+ !comp_val.domain.contain?(scalar_value_of_false.domain)
674
703
  else
675
704
  raise TypeError, "comparison between scalar and non-scalar."
676
705
  end
677
706
  end
678
707
 
679
- def may_be_less_than?(value)
680
- case single_value = value.to_single_value
708
+ def may_be_less_than?(val)
709
+ case single_val = val.to_single_value
681
710
  when ScalarValue
682
- (self < single_value).domain.intersect?(ScalarValue.of_true.domain)
711
+ (self < single_val).domain.intersect?(scalar_value_of_true.domain)
683
712
  else
684
713
  raise TypeError, "comparison between scalar and non-scalar."
685
714
  end
686
715
  end
687
716
 
688
- def must_be_greater_than?(value)
689
- case single_value = value.to_single_value
717
+ def must_be_greater_than?(val)
718
+ case single_val = val.to_single_value
690
719
  when ScalarValue
691
- comp_result = (self > single_value)
692
- comp_result.domain.intersect?(ScalarValue.of_true.domain) &&
693
- !comp_result.domain.contain?(ScalarValue.of_false.domain)
720
+ comp_val = (self > single_val)
721
+ comp_val.domain.intersect?(scalar_value_of_true.domain) &&
722
+ !comp_val.domain.contain?(scalar_value_of_false.domain)
694
723
  else
695
724
  raise TypeError, "comparison between scalar and non-scalar."
696
725
  end
697
726
  end
698
727
 
699
- def may_be_greater_than?(value)
700
- case single_value = value.to_single_value
728
+ def may_be_greater_than?(val)
729
+ case single_val = val.to_single_value
701
730
  when ScalarValue
702
- (self > single_value).domain.intersect?(ScalarValue.of_true.domain)
731
+ (self > single_val).domain.intersect?(scalar_value_of_true.domain)
703
732
  else
704
733
  raise TypeError, "comparison between scalar and non-scalar."
705
734
  end
706
735
  end
707
736
 
708
737
  def must_be_true?
709
- self.may_be_equal_to?(ScalarValue.of_true) &&
710
- self.must_not_be_equal_to?(ScalarValue.of_false)
738
+ self.may_be_equal_to?(scalar_value_of_true) &&
739
+ self.must_not_be_equal_to?(scalar_value_of_false)
711
740
  end
712
741
 
713
742
  def may_be_true?
714
- self.may_be_equal_to?(ScalarValue.of_true)
743
+ self.may_be_equal_to?(scalar_value_of_true)
715
744
  end
716
745
 
717
746
  def must_be_false?
718
- self.must_be_equal_to?(ScalarValue.of_false)
747
+ self.must_be_equal_to?(scalar_value_of_false)
719
748
  end
720
749
 
721
750
  def may_be_false?
722
- self.may_be_equal_to?(ScalarValue.of_false)
751
+ self.may_be_equal_to?(scalar_value_of_false)
723
752
  end
724
753
 
725
754
  def coerce_to(type)
@@ -734,8 +763,8 @@ module C #:nodoc:
734
763
  ScalarValue.new(@domain.to_defined_domain)
735
764
  end
736
765
 
737
- def eql?(rhs_value)
738
- rhs_value.kind_of?(ScalarValue) && @domain.eql?(rhs_value.domain)
766
+ def eql?(rhs_val)
767
+ rhs_val.kind_of?(ScalarValue) && @domain.eql?(rhs_val.domain)
739
768
  end
740
769
 
741
770
  def hash
@@ -748,11 +777,16 @@ module C #:nodoc:
748
777
 
749
778
  protected
750
779
  attr_reader :domain
780
+
781
+ private
782
+ def logical_shr?
783
+ @domain.logical_shr?
784
+ end
751
785
  end
752
786
 
753
787
  class ArrayValue < SingleValue
754
- def initialize(values)
755
- @values = values
788
+ def initialize(vals)
789
+ @values = vals
756
790
  end
757
791
 
758
792
  attr_reader :values
@@ -770,18 +804,18 @@ module C #:nodoc:
770
804
  end
771
805
 
772
806
  def exist?
773
- @values.empty? ? true : @values.all? { |value| value.exist? }
807
+ @values.empty? ? true : @values.all? { |val| val.exist? }
774
808
  end
775
809
 
776
810
  def definite?
777
- @values.empty? ? true : @values.all? { |value| value.definite? }
811
+ @values.empty? ? true : @values.all? { |val| val.definite? }
778
812
  end
779
813
 
780
- def contain?(value)
781
- case single_value = value.to_single_value
814
+ def contain?(val)
815
+ case single_val = val.to_single_value
782
816
  when ArrayValue
783
- if @values.size == single_value.values.size
784
- @values.zip(single_value.values).all? do |lhs, rhs|
817
+ if @values.size == single_val.values.size
818
+ @values.zip(single_val.values).all? do |lhs, rhs|
785
819
  lhs.contain?(rhs)
786
820
  end
787
821
  else
@@ -793,17 +827,17 @@ module C #:nodoc:
793
827
  end
794
828
 
795
829
  def undefined?
796
- @values.empty? ? false : @values.all? { |value| value.undefined? }
830
+ @values.empty? ? false : @values.all? { |val| val.undefined? }
797
831
  end
798
832
 
799
833
  def ambiguous?
800
- @values.empty? ? false : @values.all? { |value| value.ambiguous? }
834
+ @values.empty? ? false : @values.all? { |val| val.ambiguous? }
801
835
  end
802
836
 
803
- def overwrite!(value)
804
- case single_value = value.to_single_value
837
+ def overwrite!(val)
838
+ case single_val = val.to_single_value
805
839
  when ArrayValue
806
- @values.zip(single_value.values).each do |lhs, rhs|
840
+ @values.zip(single_val.values).each do |lhs, rhs|
807
841
  rhs && lhs.overwrite!(rhs)
808
842
  end
809
843
  else
@@ -811,12 +845,12 @@ module C #:nodoc:
811
845
  end
812
846
  end
813
847
 
814
- def narrow_domain!(operator, operand_value)
815
- case operand_single_value = operand_value.to_single_value
848
+ def narrow_domain!(op, ope_val)
849
+ case ope_single_val = ope_val.to_single_value
816
850
  when ArrayValue
817
- @values.zip(operand_single_value.values).map { |lhs, rhs|
851
+ @values.zip(ope_single_val.values).map { |lhs, rhs|
818
852
  if rhs
819
- lhs.narrow_domain!(operator, rhs)
853
+ lhs.narrow_domain!(op, rhs)
820
854
  else
821
855
  next
822
856
  end
@@ -826,12 +860,12 @@ module C #:nodoc:
826
860
  end
827
861
  end
828
862
 
829
- def widen_domain!(operator, operand_value)
830
- case operand_single_value = operand_value.to_single_value
863
+ def widen_domain!(op, ope_val)
864
+ case ope_single_val = ope_val.to_single_value
831
865
  when ArrayValue
832
- @values.zip(operand_single_value.values).map { |lhs, rhs|
866
+ @values.zip(ope_single_val.values).map { |lhs, rhs|
833
867
  if rhs
834
- lhs.widen_domain!(operator, rhs)
868
+ lhs.widen_domain!(op, rhs)
835
869
  else
836
870
  next
837
871
  end
@@ -842,13 +876,13 @@ module C #:nodoc:
842
876
  end
843
877
 
844
878
  def invert_domain!
845
- @values.each { |value| value.invert_domain! }
879
+ @values.each { |val| val.invert_domain! }
846
880
  end
847
881
 
848
- def single_value_unified_with(rhs_value)
849
- case rhs_single_value = rhs_value.to_single_value
882
+ def single_value_unified_with(rhs_val)
883
+ case rhs_single_val = rhs_val.to_single_value
850
884
  when ArrayValue
851
- ArrayValue.new(@values.zip(rhs_single_value.values).map { |lhs, rhs|
885
+ ArrayValue.new(@values.zip(rhs_single_val.values).map { |lhs, rhs|
852
886
  lhs.single_value_unified_with(rhs)
853
887
  })
854
888
  else
@@ -877,70 +911,70 @@ module C #:nodoc:
877
911
  dup # NOTREACHED
878
912
  end
879
913
 
880
- def +(rhs_value)
914
+ def +(rhs_val)
881
915
  # NOTE: When an array variable appears in expressions, object-specifier
882
916
  # of an array variable should be evaluated into a pointer to the
883
917
  # array body.
884
918
  dup # NOTREACHED
885
919
  end
886
920
 
887
- def -(rhs_value)
921
+ def -(rhs_val)
888
922
  # NOTE: When an array variable appears in expressions, object-specifier
889
923
  # of an array variable should be evaluated into a pointer to the
890
924
  # array body.
891
925
  dup # NOTREACHED
892
926
  end
893
927
 
894
- def *(rhs_value)
928
+ def *(rhs_val)
895
929
  # NOTE: When an array variable appears in expressions, object-specifier
896
930
  # of an array variable should be evaluated into a pointer to the
897
931
  # array body.
898
932
  dup # NOTREACHED
899
933
  end
900
934
 
901
- def /(rhs_value)
935
+ def /(rhs_val)
902
936
  # NOTE: When an array variable appears in expressions, object-specifier
903
937
  # of an array variable should be evaluated into a pointer to the
904
938
  # array body.
905
939
  dup # NOTREACHED
906
940
  end
907
941
 
908
- def %(rhs_value)
942
+ def %(rhs_val)
909
943
  # NOTE: When an array variable appears in expressions, object-specifier
910
944
  # of an array variable should be evaluated into a pointer to the
911
945
  # array body.
912
946
  dup # NOTREACHED
913
947
  end
914
948
 
915
- def &(rhs_value)
949
+ def &(rhs_val)
916
950
  # NOTE: When an array variable appears in expressions, object-specifier
917
951
  # of an array variable should be evaluated into a pointer to the
918
952
  # array body.
919
953
  dup # NOTREACHED
920
954
  end
921
955
 
922
- def |(rhs_value)
956
+ def |(rhs_val)
923
957
  # NOTE: When an array variable appears in expressions, object-specifier
924
958
  # of an array variable should be evaluated into a pointer to the
925
959
  # array body.
926
960
  dup # NOTREACHED
927
961
  end
928
962
 
929
- def ^(rhs_value)
963
+ def ^(rhs_val)
930
964
  # NOTE: When an array variable appears in expressions, object-specifier
931
965
  # of an array variable should be evaluated into a pointer to the
932
966
  # array body.
933
967
  dup # NOTREACHED
934
968
  end
935
969
 
936
- def <<(rhs_value)
970
+ def <<(rhs_val)
937
971
  # NOTE: When an array variable appears in expressions, object-specifier
938
972
  # of an array variable should be evaluated into a pointer to the
939
973
  # array body.
940
974
  dup # NOTREACHED
941
975
  end
942
976
 
943
- def >>(rhs_value)
977
+ def >>(rhs_val)
944
978
  # NOTE: When an array variable appears in expressions, object-specifier
945
979
  # of an array variable should be evaluated into a pointer to the
946
980
  # array body.
@@ -951,236 +985,236 @@ module C #:nodoc:
951
985
  # NOTE: When an array variable appears in expressions, object-specifier
952
986
  # of an array variable should be evaluated into a pointer to the
953
987
  # array body.
954
- ScalarValue.of_false # NOTREACHED
988
+ scalar_value_of_false # NOTREACHED
955
989
  end
956
990
 
957
- def <(rhs_value)
991
+ def <(rhs_val)
958
992
  # NOTE: When an array variable appears in expressions, object-specifier
959
993
  # of an array variable should be evaluated into a pointer to the
960
994
  # array body.
961
995
  # So, this comparison operator should not be reached.
962
- case rhs_single_value = rhs_value.to_single_value
996
+ case rhs_single_val = rhs_val.to_single_value
963
997
  when ArrayValue
964
- if @values.size == rhs_single_value.values.size
965
- zipped = @values.zip(rhs_single_value.values)
966
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
967
- result.single_value_unified_with(lhs < rhs)
998
+ if @values.size == rhs_single_val.values.size
999
+ zipped = @values.zip(rhs_single_val.values)
1000
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1001
+ res_val.single_value_unified_with(lhs < rhs)
968
1002
  end
969
1003
  else
970
- ScalarValue.of_false
1004
+ scalar_value_of_false
971
1005
  end
972
1006
  else
973
1007
  raise TypeError, "comparison between array and non-array."
974
1008
  end
975
1009
  end
976
1010
 
977
- def >(rhs_value)
1011
+ def >(rhs_val)
978
1012
  # NOTE: When an array variable appears in expressions, object-specifier
979
1013
  # of an array variable should be evaluated into a pointer to the
980
1014
  # array body.
981
1015
  # So, this comparison operator should not be reached.
982
- case rhs_single_value = rhs_value.to_single_value
1016
+ case rhs_single_val = rhs_val.to_single_value
983
1017
  when ArrayValue
984
- if @values.size == rhs_single_value.values.size
985
- zipped = @values.zip(rhs_single_value.values)
986
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
987
- result.single_value_unified_with(lhs > rhs)
1018
+ if @values.size == rhs_single_val.values.size
1019
+ zipped = @values.zip(rhs_single_val.values)
1020
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1021
+ res_val.single_value_unified_with(lhs > rhs)
988
1022
  end
989
1023
  else
990
- ScalarValue.of_false
1024
+ scalar_value_of_false
991
1025
  end
992
1026
  else
993
1027
  raise TypeError, "comparison between array and non-array."
994
1028
  end
995
1029
  end
996
1030
 
997
- def ==(rhs_value)
1031
+ def ==(rhs_val)
998
1032
  # NOTE: When an array variable appears in expressions, object-specifier
999
1033
  # of an array variable should be evaluated into a pointer to the
1000
1034
  # array body.
1001
1035
  # So, this comparison operator should not be reached.
1002
- case rhs_single_value = rhs_value.to_single_value
1036
+ case rhs_single_val = rhs_val.to_single_value
1003
1037
  when ArrayValue
1004
1038
  if @values.size == rhs_single_value.values.size
1005
- zipped = @values.zip(rhs_single_value.values)
1006
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
1007
- result.single_value_unified_with(lhs == rhs)
1039
+ zipped = @values.zip(rhs_single_val.values)
1040
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1041
+ res_val.single_value_unified_with(lhs == rhs)
1008
1042
  end
1009
1043
  else
1010
- ScalarValue.of_false
1044
+ scalar_value_of_false
1011
1045
  end
1012
1046
  else
1013
1047
  raise TypeError, "comparison between array and non-array."
1014
1048
  end
1015
1049
  end
1016
1050
 
1017
- def !=(rhs_value)
1051
+ def !=(rhs_val)
1018
1052
  # NOTE: When an array variable appears in expressions, object-specifier
1019
1053
  # of an array variable should be evaluated into a pointer to the
1020
1054
  # array body.
1021
1055
  # So, this comparison operator should not be reached.
1022
- case rhs_single_value = rhs_value.to_single_value
1056
+ case rhs_single_val = rhs_val.to_single_value
1023
1057
  when ArrayValue
1024
- if @values.size == rhs_single_value.values.size
1025
- zipped = @values.zip(rhs_single_value.values)
1026
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
1027
- result.single_value_unified_with(lhs != rhs)
1058
+ if @values.size == rhs_single_val.values.size
1059
+ zipped = @values.zip(rhs_single_val.values)
1060
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1061
+ res_val.single_value_unified_with(lhs != rhs)
1028
1062
  end
1029
1063
  else
1030
- ScalarValue.of_false
1064
+ scalar_value_of_false
1031
1065
  end
1032
1066
  else
1033
1067
  raise TypeError, "comparison between array and non-array."
1034
1068
  end
1035
1069
  end
1036
1070
 
1037
- def <=(rhs_value)
1071
+ def <=(rhs_val)
1038
1072
  # NOTE: When an array variable appears in expressions, object-specifier
1039
1073
  # of an array variable should be evaluated into a pointer to the
1040
1074
  # array body.
1041
1075
  # So, this comparison operator should not be reached.
1042
- case rhs_single_value = rhs_value.to_single_value
1076
+ case rhs_single_val = rhs_val.to_single_value
1043
1077
  when ArrayValue
1044
- if @values.size == rhs_single_value.values.size
1045
- zipped = @values.zip(rhs_single_value.values)
1046
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
1047
- result.single_value_unified_with(lhs <= rhs)
1078
+ if @values.size == rhs_single_val.values.size
1079
+ zipped = @values.zip(rhs_single_val.values)
1080
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1081
+ res_val.single_value_unified_with(lhs <= rhs)
1048
1082
  end
1049
1083
  else
1050
- ScalarValue.of_false
1084
+ scalar_value_of_false
1051
1085
  end
1052
1086
  else
1053
1087
  raise TypeError, "comparison between array and non-array."
1054
1088
  end
1055
1089
  end
1056
1090
 
1057
- def >=(rhs_value)
1091
+ def >=(rhs_val)
1058
1092
  # NOTE: When an array variable appears in expressions, object-specifier
1059
1093
  # of an array variable should be evaluated into a pointer to the
1060
1094
  # array body.
1061
1095
  # So, this comparison operator should not be reached.
1062
- case rhs_single_value = rhs_value.to_single_value
1096
+ case rhs_single_val = rhs_val.to_single_value
1063
1097
  when ArrayValue
1064
1098
  if @values.size == rhs_single_value.values.size
1065
- zipped = @values.zip(rhs_single_value.values)
1066
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
1067
- result.single_value_unified_with(lhs >= rhs)
1099
+ zipped = @values.zip(rhs_single_val.values)
1100
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1101
+ res_val.single_value_unified_with(lhs >= rhs)
1068
1102
  end
1069
1103
  else
1070
- ScalarValue.of_false
1104
+ scalar_value_of_false
1071
1105
  end
1072
1106
  else
1073
1107
  raise TypeError, "comparison between array and non-array."
1074
1108
  end
1075
1109
  end
1076
1110
 
1077
- def logical_and(rhs_value)
1111
+ def logical_and(rhs_val)
1078
1112
  # NOTE: When an array variable appears in expressions, object-specifier
1079
1113
  # of an array variable should be evaluated into a pointer to the
1080
1114
  # array body.
1081
1115
  # So, this comparison operator should not be reached.
1082
- case rhs_single_value = rhs_value.to_single_value
1116
+ case rhs_single_val = rhs_val.to_single_value
1083
1117
  when ArrayValue
1084
- if @values.size == rhs_single_value.values.size
1085
- zipped = @values.zip(rhs_single_value.values)
1086
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
1087
- result.single_value_unified_with(lhs.logical_and(rhs))
1118
+ if @values.size == rhs_single_val.values.size
1119
+ zipped = @values.zip(rhs_single_val.values)
1120
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1121
+ res_val.single_value_unified_with(lhs.logical_and(rhs))
1088
1122
  end
1089
1123
  else
1090
- ScalarValue.of_false
1124
+ scalar_value_of_false
1091
1125
  end
1092
1126
  else
1093
1127
  raise TypeError, "comparison between array and non-array."
1094
1128
  end
1095
1129
  end
1096
1130
 
1097
- def logical_or(rhs_value)
1131
+ def logical_or(rhs_val)
1098
1132
  # NOTE: When an array variable appears in expressions, object-specifier
1099
1133
  # of an array variable should be evaluated into a pointer to the
1100
1134
  # array body.
1101
1135
  # So, this comparison operator should not be reached.
1102
- case rhs_single_value = rhs_value.to_single_value
1136
+ case rhs_single_val = rhs_val.to_single_value
1103
1137
  when ArrayValue
1104
- if @values.size == rhs_single_value.values.size
1105
- zipped = @values.zip(rhs_single_value.values)
1106
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
1107
- result.single_value_unified_with(lhs.logical_or(rhs))
1138
+ if @values.size == rhs_single_val.values.size
1139
+ zipped = @values.zip(rhs_single_val.values)
1140
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1141
+ res_val.single_value_unified_with(lhs.logical_or(rhs))
1108
1142
  end
1109
1143
  else
1110
- ScalarValue.of_false
1144
+ scalar_value_of_false
1111
1145
  end
1112
1146
  else
1113
1147
  raise TypeError, "comparison between array and non-array."
1114
1148
  end
1115
1149
  end
1116
1150
 
1117
- def must_be_equal_to?(value)
1118
- case single_value = value.to_single_value
1151
+ def must_be_equal_to?(val)
1152
+ case single_val = val.to_single_value
1119
1153
  when ArrayValue
1120
- (self == single_value).must_be_true?
1154
+ (self == single_val).must_be_true?
1121
1155
  else
1122
1156
  raise TypeError, "comparison between array and non-array."
1123
1157
  end
1124
1158
  end
1125
1159
 
1126
- def may_be_equal_to?(value)
1127
- case single_value = value.to_single_value
1160
+ def may_be_equal_to?(val)
1161
+ case single_val = val.to_single_value
1128
1162
  when ArrayValue
1129
- (self == single_value).may_be_true?
1163
+ (self == single_val).may_be_true?
1130
1164
  else
1131
1165
  raise TypeError, "comparison between array and non-array."
1132
1166
  end
1133
1167
  end
1134
1168
 
1135
- def must_not_be_equal_to?(value)
1136
- case single_value = value.to_single_value
1169
+ def must_not_be_equal_to?(val)
1170
+ case single_val = val.to_single_value
1137
1171
  when ArrayValue
1138
- (self != single_value).must_be_true?
1172
+ (self != single_val).must_be_true?
1139
1173
  else
1140
1174
  raise TypeError, "comparison between array and non-array."
1141
1175
  end
1142
1176
  end
1143
1177
 
1144
- def may_not_be_equal_to?(value)
1145
- case single_value = value.to_single_value
1178
+ def may_not_be_equal_to?(val)
1179
+ case single_val = val.to_single_value
1146
1180
  when ArrayValue
1147
- (self != single_value).may_be_true?
1181
+ (self != single_val).may_be_true?
1148
1182
  else
1149
1183
  raise TypeError, "comparison between array and non-array."
1150
1184
  end
1151
1185
  end
1152
1186
 
1153
- def must_be_less_than?(value)
1154
- case single_value = value.to_single_value
1187
+ def must_be_less_than?(val)
1188
+ case single_val = value.to_single_value
1155
1189
  when ArrayValue
1156
- (self < single_value).must_be_true?
1190
+ (self < single_val).must_be_true?
1157
1191
  else
1158
1192
  raise TypeError, "comparison between array and non-array."
1159
1193
  end
1160
1194
  end
1161
1195
 
1162
- def may_be_less_than?(value)
1163
- case single_value = value.to_single_value
1196
+ def may_be_less_than?(val)
1197
+ case single_val = val.to_single_value
1164
1198
  when ArrayValue
1165
- (self < single_value).may_be_true?
1199
+ (self < single_val).may_be_true?
1166
1200
  else
1167
1201
  raise TypeError, "comparison between array and non-array."
1168
1202
  end
1169
1203
  end
1170
1204
 
1171
- def must_be_greater_than?(value)
1172
- case single_value = value.to_single_value
1205
+ def must_be_greater_than?(val)
1206
+ case single_val = val.to_single_value
1173
1207
  when ArrayValue
1174
- (self > single_value).must_be_true?
1208
+ (self > single_val).must_be_true?
1175
1209
  else
1176
1210
  raise TypeError, "comparison between array and non-array."
1177
1211
  end
1178
1212
  end
1179
1213
 
1180
- def may_be_greater_than?(value)
1181
- case single_value = value.to_single_value
1214
+ def may_be_greater_than?(val)
1215
+ case single_val = val.to_single_value
1182
1216
  when ArrayValue
1183
- (self > single_value).may_be_true?
1217
+ (self > single_val).may_be_true?
1184
1218
  else
1185
1219
  raise TypeError, "comparison between array and non-array."
1186
1220
  end
@@ -1191,7 +1225,7 @@ module C #:nodoc:
1191
1225
  # of an array variable should be evaluated into a pointer to the
1192
1226
  # array body.
1193
1227
  # So, this method should not be reached.
1194
- @values.all? { |value| value.must_be_true? }
1228
+ @values.all? { |val| val.must_be_true? }
1195
1229
  end
1196
1230
 
1197
1231
  def may_be_true?
@@ -1199,7 +1233,7 @@ module C #:nodoc:
1199
1233
  # of an array variable should be evaluated into a pointer to the
1200
1234
  # array body.
1201
1235
  # So, this method should not be reached.
1202
- @values.all? { |value| value.may_be_true? }
1236
+ @values.all? { |val| val.may_be_true? }
1203
1237
  end
1204
1238
 
1205
1239
  def must_be_false?
@@ -1207,7 +1241,7 @@ module C #:nodoc:
1207
1241
  # of an array variable should be evaluated into a pointer to the
1208
1242
  # array body.
1209
1243
  # So, this method should not be reached.
1210
- @values.all? { |value| value.must_be_false? }
1244
+ @values.all? { |val| val.must_be_false? }
1211
1245
  end
1212
1246
 
1213
1247
  def may_be_false?
@@ -1215,7 +1249,7 @@ module C #:nodoc:
1215
1249
  # of an array variable should be evaluated into a pointer to the
1216
1250
  # array body.
1217
1251
  # So, this method should not be reached.
1218
- @values.all? { |value| value.may_be_false? }
1252
+ @values.all? { |val| val.may_be_false? }
1219
1253
  end
1220
1254
 
1221
1255
  def coerce_to(type)
@@ -1224,15 +1258,15 @@ module C #:nodoc:
1224
1258
 
1225
1259
  def to_enum
1226
1260
  # FIXME: This method generates only one of sample values.
1227
- @values.map { |value| value.to_enum.first }
1261
+ @values.map { |val| val.to_enum.first }
1228
1262
  end
1229
1263
 
1230
1264
  def to_defined_value
1231
- ArrayValue.new(@values.map { |value| value.to_defined_value })
1265
+ ArrayValue.new(@values.map { |val| val.to_defined_value })
1232
1266
  end
1233
1267
 
1234
- def eql?(rhs_value)
1235
- rhs_value.kind_of?(ArrayValue) && @values.eql?(rhs_value.values)
1268
+ def eql?(rhs_val)
1269
+ rhs_val.kind_of?(ArrayValue) && @values.eql?(rhs_val.values)
1236
1270
  end
1237
1271
 
1238
1272
  def hash
@@ -1240,13 +1274,19 @@ module C #:nodoc:
1240
1274
  end
1241
1275
 
1242
1276
  def dup
1243
- ArrayValue.new(@values.map { |value| value.dup })
1277
+ ArrayValue.new(@values.map { |val| val.dup })
1244
1278
  end
1279
+
1280
+ private
1281
+ def logical_shr?
1282
+ @values.all? { |val| val.logical_shr? }
1283
+ end
1284
+ memoize :logical_shr?
1245
1285
  end
1246
1286
 
1247
1287
  class CompositeValue < SingleValue
1248
- def initialize(values)
1249
- @values = values
1288
+ def initialize(vals)
1289
+ @values = vals
1250
1290
  end
1251
1291
 
1252
1292
  attr_reader :values
@@ -1264,18 +1304,18 @@ module C #:nodoc:
1264
1304
  end
1265
1305
 
1266
1306
  def exist?
1267
- @values.empty? ? true : @values.all? { |value| value.exist? }
1307
+ @values.empty? ? true : @values.all? { |val| val.exist? }
1268
1308
  end
1269
1309
 
1270
1310
  def definite?
1271
- @values.empty? ? true : @values.all? { |value| value.definite? }
1311
+ @values.empty? ? true : @values.all? { |val| val.definite? }
1272
1312
  end
1273
1313
 
1274
- def contain?(value)
1275
- case single_value = value.to_single_value
1314
+ def contain?(val)
1315
+ case single_val = val.to_single_value
1276
1316
  when CompositeValue
1277
- if @values.size == single_value.values.size
1278
- @values.zip(single_value.values).all? do |lhs, rhs|
1317
+ if @values.size == single_val.values.size
1318
+ @values.zip(single_val.values).all? do |lhs, rhs|
1279
1319
  lhs.contain?(rhs)
1280
1320
  end
1281
1321
  else
@@ -1287,17 +1327,17 @@ module C #:nodoc:
1287
1327
  end
1288
1328
 
1289
1329
  def undefined?
1290
- @values.empty? ? false : @values.all? { |value| value.undefined? }
1330
+ @values.empty? ? false : @values.all? { |val| val.undefined? }
1291
1331
  end
1292
1332
 
1293
1333
  def ambiguous?
1294
- @values.empty? ? false : @values.all? { |value| value.ambiguous? }
1334
+ @values.empty? ? false : @values.all? { |val| val.ambiguous? }
1295
1335
  end
1296
1336
 
1297
- def overwrite!(value)
1298
- case single_value = value.to_single_value
1337
+ def overwrite!(val)
1338
+ case single_val = val.to_single_value
1299
1339
  when CompositeValue
1300
- @values.zip(single_value.values).each do |lhs, rhs|
1340
+ @values.zip(single_val.values).each do |lhs, rhs|
1301
1341
  rhs && lhs.overwrite!(rhs)
1302
1342
  end
1303
1343
  else
@@ -1305,12 +1345,12 @@ module C #:nodoc:
1305
1345
  end
1306
1346
  end
1307
1347
 
1308
- def narrow_domain!(operator, operand_value)
1309
- case operand_single_value = operand_value.to_single_value
1348
+ def narrow_domain!(op, ope_val)
1349
+ case ope_single_val = ope_val.to_single_value
1310
1350
  when CompositeValue
1311
- @values.zip(operand_single_value.values).map { |lhs, rhs|
1351
+ @values.zip(ope_single_val.values).map { |lhs, rhs|
1312
1352
  if rhs
1313
- lhs.narrow_domain!(operator, rhs)
1353
+ lhs.narrow_domain!(op, rhs)
1314
1354
  else
1315
1355
  next
1316
1356
  end
@@ -1321,12 +1361,12 @@ module C #:nodoc:
1321
1361
  end
1322
1362
  end
1323
1363
 
1324
- def widen_domain!(operator, operand_value)
1325
- case operand_single_value = operand_value.to_single_value
1364
+ def widen_domain!(op, ope_val)
1365
+ case ope_single_val = ope_val.to_single_value
1326
1366
  when CompositeValue
1327
- @values.zip(operand_single_value.values).map { |lhs, rhs|
1367
+ @values.zip(ope_single_val.values).map { |lhs, rhs|
1328
1368
  if rhs
1329
- lhs.widen_domain!(operator, rhs)
1369
+ lhs.widen_domain!(op, rhs)
1330
1370
  else
1331
1371
  next
1332
1372
  end
@@ -1338,14 +1378,14 @@ module C #:nodoc:
1338
1378
  end
1339
1379
 
1340
1380
  def invert_domain!
1341
- @values.each { |value| value.invert_domain! }
1381
+ @values.each { |val| val.invert_domain! }
1342
1382
  end
1343
1383
 
1344
- def single_value_unified_with(rhs_value)
1345
- case rhs_single_value = rhs_value.to_single_value
1384
+ def single_value_unified_with(rhs_val)
1385
+ case rhs_single_val = rhs_val.to_single_value
1346
1386
  when CompositeValue
1347
1387
  CompositeValue.new(
1348
- @values.zip(rhs_single_value.values).map { |lhs, rhs|
1388
+ @values.zip(rhs_single_val.values).map { |lhs, rhs|
1349
1389
  lhs.single_value_unified_with(rhs)
1350
1390
  })
1351
1391
  else
@@ -1371,61 +1411,61 @@ module C #:nodoc:
1371
1411
  dup # NOTREACHED
1372
1412
  end
1373
1413
 
1374
- def +(rhs_value)
1414
+ def +(rhs_val)
1375
1415
  # NOTE: A composite variable cannot appear in expressions except the
1376
1416
  # primary-expression(object-specifier followed by `.').
1377
1417
  dup # NOTREACHED
1378
1418
  end
1379
1419
 
1380
- def -(rhs_value)
1420
+ def -(rhs_val)
1381
1421
  # NOTE: A composite variable cannot appear in expressions except the
1382
1422
  # primary-expression(object-specifier followed by `.').
1383
1423
  dup # NOTREACHED
1384
1424
  end
1385
1425
 
1386
- def *(rhs_value)
1426
+ def *(rhs_val)
1387
1427
  # NOTE: A composite variable cannot appear in expressions except the
1388
1428
  # primary-expression(object-specifier followed by `.').
1389
1429
  dup # NOTREACHED
1390
1430
  end
1391
1431
 
1392
- def /(rhs_value)
1432
+ def /(rhs_val)
1393
1433
  # NOTE: A composite variable cannot appear in expressions except the
1394
1434
  # primary-expression(object-specifier followed by `.').
1395
1435
  dup # NOTREACHED
1396
1436
  end
1397
1437
 
1398
- def %(rhs_value)
1438
+ def %(rhs_val)
1399
1439
  # NOTE: A composite variable cannot appear in expressions except the
1400
1440
  # primary-expression(object-specifier followed by `.').
1401
1441
  dup # NOTREACHED
1402
1442
  end
1403
1443
 
1404
- def &(rhs_value)
1444
+ def &(rhs_val)
1405
1445
  # NOTE: A composite variable cannot appear in expressions except the
1406
1446
  # primary-expression(object-specifier followed by `.').
1407
1447
  dup # NOTREACHED
1408
1448
  end
1409
1449
 
1410
- def |(rhs_value)
1450
+ def |(rhs_val)
1411
1451
  # NOTE: A composite variable cannot appear in expressions except the
1412
1452
  # primary-expression(object-specifier followed by `.').
1413
1453
  dup # NOTREACHED
1414
1454
  end
1415
1455
 
1416
- def ^(rhs_value)
1456
+ def ^(rhs_val)
1417
1457
  # NOTE: A composite variable cannot appear in expressions except the
1418
1458
  # primary-expression(object-specifier followed by `.').
1419
1459
  dup # NOTREACHED
1420
1460
  end
1421
1461
 
1422
- def <<(rhs_value)
1462
+ def <<(rhs_val)
1423
1463
  # NOTE: A composite variable cannot appear in expressions except the
1424
1464
  # primary-expression(object-specifier followed by `.').
1425
1465
  dup # NOTREACHED
1426
1466
  end
1427
1467
 
1428
- def >>(rhs_value)
1468
+ def >>(rhs_val)
1429
1469
  # NOTE: A composite variable cannot appear in expressions except the
1430
1470
  # primary-expression(object-specifier followed by `.').
1431
1471
  dup # NOTREACHED
@@ -1434,220 +1474,220 @@ module C #:nodoc:
1434
1474
  def !
1435
1475
  # NOTE: A composite variable cannot appear in expressions except the
1436
1476
  # primary-expression(object-specifier followed by `.').
1437
- ScalarValue.of_false # NOTREACHED
1477
+ scalar_value_of_false # NOTREACHED
1438
1478
  end
1439
1479
 
1440
- def <(rhs_value)
1480
+ def <(rhs_val)
1441
1481
  # NOTE: A composite variable cannot appear in expressions except the
1442
1482
  # primary-expression(object-specifier followed by `.').
1443
- case rhs_single_value = rhs_value.to_single_value
1483
+ case rhs_single_val = rhs_val.to_single_value
1444
1484
  when CompositeValue
1445
- if @values.size == rhs_single_value.values.size
1446
- zipped = @values.zip(rhs_single_value.values)
1447
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
1448
- result.single_value_unified_with(lhs < rhs)
1485
+ if @values.size == rhs_single_val.values.size
1486
+ zipped = @values.zip(rhs_single_val.values)
1487
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1488
+ res_val.single_value_unified_with(lhs < rhs)
1449
1489
  end
1450
1490
  else
1451
- ScalarValue.of_false
1491
+ scalar_value_of_false
1452
1492
  end
1453
1493
  else
1454
1494
  raise TypeError, "comparison between composite and non-composite."
1455
1495
  end
1456
1496
  end
1457
1497
 
1458
- def >(rhs_value)
1498
+ def >(rhs_val)
1459
1499
  # NOTE: A composite variable cannot appear in expressions except the
1460
1500
  # primary-expression(object-specifier followed by `.').
1461
- case rhs_single_value = rhs_value.to_single_value
1501
+ case rhs_single_val = rhs_val.to_single_value
1462
1502
  when CompositeValue
1463
- if @values.size == rhs_single_value.values.size
1464
- zipped = @values.zip(rhs_single_value.values)
1465
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
1466
- result.single_value_unified_with(lhs > rhs)
1503
+ if @values.size == rhs_single_val.values.size
1504
+ zipped = @values.zip(rhs_single_val.values)
1505
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1506
+ res_val.single_value_unified_with(lhs > rhs)
1467
1507
  end
1468
1508
  else
1469
- ScalarValue.of_false
1509
+ scalar_value_of_false
1470
1510
  end
1471
1511
  else
1472
1512
  raise TypeError, "comparison between composite and non-composite."
1473
1513
  end
1474
1514
  end
1475
1515
 
1476
- def ==(rhs_value)
1516
+ def ==(rhs_val)
1477
1517
  # NOTE: A composite variable cannot appear in expressions except the
1478
1518
  # primary-expression(object-specifier followed by `.').
1479
- case rhs_single_value = rhs_value.to_single_value
1519
+ case rhs_single_val = rhs_val.to_single_value
1480
1520
  when CompositeValue
1481
- if @values.size == rhs_single_value.values.size
1482
- zipped = @values.zip(rhs_single_value.values)
1483
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
1484
- result.single_value_unified_with(lhs == rhs)
1521
+ if @values.size == rhs_single_val.values.size
1522
+ zipped = @values.zip(rhs_single_val.values)
1523
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1524
+ res_val.single_value_unified_with(lhs == rhs)
1485
1525
  end
1486
1526
  else
1487
- ScalarValue.of_false
1527
+ scalar_value_of_false
1488
1528
  end
1489
1529
  else
1490
1530
  raise TypeError, "comparison between composite and non-composite."
1491
1531
  end
1492
1532
  end
1493
1533
 
1494
- def !=(rhs_value)
1534
+ def !=(rhs_val)
1495
1535
  # NOTE: A composite variable cannot appear in expressions except the
1496
1536
  # primary-expression(object-specifier followed by `.').
1497
- case rhs_single_value = rhs_value.to_single_value
1537
+ case rhs_single_val = rhs_val.to_single_value
1498
1538
  when CompositeValue
1499
- if @values.size == rhs_single_value.values.size
1500
- zipped = @values.zip(rhs_single_value.values)
1501
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
1502
- result.single_value_unified_with(lhs != rhs)
1539
+ if @values.size == rhs_single_val.values.size
1540
+ zipped = @values.zip(rhs_single_val.values)
1541
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1542
+ res_val.single_value_unified_with(lhs != rhs)
1503
1543
  end
1504
1544
  else
1505
- ScalarValue.of_false
1545
+ scalar_value_of_false
1506
1546
  end
1507
1547
  else
1508
1548
  raise TypeError, "comparison between composite and non-composite."
1509
1549
  end
1510
1550
  end
1511
1551
 
1512
- def <=(rhs_value)
1552
+ def <=(rhs_val)
1513
1553
  # NOTE: A composite variable cannot appear in expressions except the
1514
1554
  # primary-expression(object-specifier followed by `.').
1515
- case rhs_single_value = rhs_value.to_single_value
1555
+ case rhs_single_val = rhs_val.to_single_value
1516
1556
  when CompositeValue
1517
- if @values.size == rhs_single_value.values.size
1518
- zipped = @values.zip(rhs_single_value.values)
1519
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
1520
- result.single_value_unified_with(lhs <= rhs)
1557
+ if @values.size == rhs_single_val.values.size
1558
+ zipped = @values.zip(rhs_single_val.values)
1559
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1560
+ res_val.single_value_unified_with(lhs <= rhs)
1521
1561
  end
1522
1562
  else
1523
- ScalarValue.of_false
1563
+ scalar_value_of_false
1524
1564
  end
1525
1565
  else
1526
1566
  raise TypeError, "comparison between composite and non-composite."
1527
1567
  end
1528
1568
  end
1529
1569
 
1530
- def >=(rhs_value)
1570
+ def >=(rhs_val)
1531
1571
  # NOTE: A composite variable cannot appear in expressions except the
1532
1572
  # primary-expression(object-specifier followed by `.').
1533
- case rhs_single_value = rhs_value.to_single_value
1573
+ case rhs_single_val = rhs_val.to_single_value
1534
1574
  when CompositeValue
1535
- if @values.size == rhs_single_value.values.size
1536
- zipped = @values.zip(rhs_single_value.values)
1537
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
1538
- result.single_value_unified_with(lhs >= rhs)
1575
+ if @values.size == rhs_single_val.values.size
1576
+ zipped = @values.zip(rhs_single_val.values)
1577
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1578
+ res_val.single_value_unified_with(lhs >= rhs)
1539
1579
  end
1540
1580
  else
1541
- ScalarValue.of_false
1581
+ scalar_value_of_false
1542
1582
  end
1543
1583
  else
1544
1584
  raise TypeError, "comparison between composite and non-composite."
1545
1585
  end
1546
1586
  end
1547
1587
 
1548
- def logical_and(rhs_value)
1588
+ def logical_and(rhs_val)
1549
1589
  # NOTE: A composite variable cannot appear in expressions except the
1550
1590
  # primary-expression(object-specifier followed by `.').
1551
- case rhs_single_value = rhs_value.to_single_value
1591
+ case rhs_single_val = rhs_val.to_single_value
1552
1592
  when CompositeValue
1553
- if @values.size == rhs_single_value.values.size
1554
- zipped = @values.zip(rhs_single_value.values)
1555
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
1556
- result.single_value_unified_with(lhs.logical_and(rhs))
1593
+ if @values.size == rhs_single_val.values.size
1594
+ zipped = @values.zip(rhs_single_val.values)
1595
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1596
+ res_val.single_value_unified_with(lhs.logical_and(rhs))
1557
1597
  end
1558
1598
  else
1559
- ScalarValue.of_false
1599
+ scalar_value_of_false
1560
1600
  end
1561
1601
  else
1562
1602
  raise TypeError, "comparison between composite and non-composite."
1563
1603
  end
1564
1604
  end
1565
1605
 
1566
- def logical_or(rhs_value)
1606
+ def logical_or(rhs_val)
1567
1607
  # NOTE: A composite variable cannot appear in expressions except the
1568
1608
  # primary-expression(object-specifier followed by `.').
1569
- case rhs_single_value = rhs_value.to_single_value
1609
+ case rhs_single_val = rhs_val.to_single_value
1570
1610
  when CompositeValue
1571
- if @values.size == rhs_single_value.values.size
1572
- zipped = @values.zip(rhs_single_value.values)
1573
- zipped.reduce(ScalarValue.of_nil) do |result, (lhs, rhs)|
1574
- result.single_value_unified_with(lhs.logical_or(rhs))
1611
+ if @values.size == rhs_single_val.values.size
1612
+ zipped = @values.zip(rhs_single_val.values)
1613
+ zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1614
+ res_val.single_value_unified_with(lhs.logical_or(rhs))
1575
1615
  end
1576
1616
  else
1577
- ScalarValue.of_false
1617
+ scalar_value_of_false
1578
1618
  end
1579
1619
  else
1580
1620
  raise TypeError, "comparison between composite and non-composite."
1581
1621
  end
1582
1622
  end
1583
1623
 
1584
- def must_be_equal_to?(value)
1585
- case single_value = value.to_single_value
1624
+ def must_be_equal_to?(val)
1625
+ case single_val = val.to_single_value
1586
1626
  when CompositeValue
1587
- (self == single_value).must_be_true?
1627
+ (self == single_val).must_be_true?
1588
1628
  else
1589
1629
  raise TypeError, "comparison between composite and non-composite."
1590
1630
  end
1591
1631
  end
1592
1632
 
1593
- def may_be_equal_to?(value)
1594
- case single_value = value.to_single_value
1633
+ def may_be_equal_to?(val)
1634
+ case single_val = val.to_single_value
1595
1635
  when CompositeValue
1596
- (self == single_value).may_be_true?
1636
+ (self == single_val).may_be_true?
1597
1637
  else
1598
1638
  raise TypeError, "comparison between composite and non-composite."
1599
1639
  end
1600
1640
  end
1601
1641
 
1602
- def must_not_be_equal_to?(value)
1603
- case single_value = value.to_single_value
1642
+ def must_not_be_equal_to?(val)
1643
+ case single_val = val.to_single_value
1604
1644
  when CompositeValue
1605
- (self != single_value).must_be_true?
1645
+ (self != single_val).must_be_true?
1606
1646
  else
1607
1647
  raise TypeError, "comparison between composite and non-composite."
1608
1648
  end
1609
1649
  end
1610
1650
 
1611
- def may_not_be_equal_to?(value)
1612
- case single_value = value.to_single_value
1651
+ def may_not_be_equal_to?(val)
1652
+ case single_val = val.to_single_value
1613
1653
  when CompositeValue
1614
- (self != single_value).may_be_true?
1654
+ (self != single_val).may_be_true?
1615
1655
  else
1616
1656
  raise TypeError, "comparison between composite and non-composite."
1617
1657
  end
1618
1658
  end
1619
1659
 
1620
- def must_be_less_than?(value)
1621
- case single_value = value.to_single_value
1660
+ def must_be_less_than?(val)
1661
+ case single_val = val.to_single_value
1622
1662
  when CompositeValue
1623
- (self < single_value).must_be_true?
1663
+ (self < single_val).must_be_true?
1624
1664
  else
1625
1665
  raise TypeError, "comparison between composite and non-composite."
1626
1666
  end
1627
1667
  end
1628
1668
 
1629
- def may_be_less_than?(value)
1630
- case single_value = value.to_single_value
1669
+ def may_be_less_than?(val)
1670
+ case single_val = val.to_single_value
1631
1671
  when CompositeValue
1632
- (self < single_value).may_be_true?
1672
+ (self < single_val).may_be_true?
1633
1673
  else
1634
1674
  raise TypeError, "comparison between composite and non-composite."
1635
1675
  end
1636
1676
  end
1637
1677
 
1638
- def must_be_greater_than?(value)
1639
- case single_value = value.to_single_value
1678
+ def must_be_greater_than?(val)
1679
+ case single_val = val.to_single_value
1640
1680
  when CompositeValue
1641
- (self > single_value).must_be_true?
1681
+ (self > single_val).must_be_true?
1642
1682
  else
1643
1683
  raise TypeError, "comparison between composite and non-composite."
1644
1684
  end
1645
1685
  end
1646
1686
 
1647
- def may_be_greater_than?(value)
1648
- case single_value = value.to_single_value
1687
+ def may_be_greater_than?(val)
1688
+ case single_val = val.to_single_value
1649
1689
  when CompositeValue
1650
- (self > single_value).may_be_true?
1690
+ (self > single_val).may_be_true?
1651
1691
  else
1652
1692
  raise TypeError, "comparison between composite and non-composite."
1653
1693
  end
@@ -1656,25 +1696,25 @@ module C #:nodoc:
1656
1696
  def must_be_true?
1657
1697
  # NOTE: A composite variable cannot appear in expressions except the
1658
1698
  # primary-expression(object-specifier followed by `.').
1659
- @values.all? { |value| value.must_be_true? }
1699
+ @values.all? { |val| val.must_be_true? }
1660
1700
  end
1661
1701
 
1662
1702
  def may_be_true?
1663
1703
  # NOTE: A composite variable cannot appear in expressions except the
1664
1704
  # primary-expression(object-specifier followed by `.').
1665
- @values.all? { |value| value.may_be_true? }
1705
+ @values.all? { |val| val.may_be_true? }
1666
1706
  end
1667
1707
 
1668
1708
  def must_be_false?
1669
1709
  # NOTE: A composite variable cannot appear in expressions except the
1670
1710
  # primary-expression(object-specifier followed by `.').
1671
- @values.all? { |value| value.must_be_false? }
1711
+ @values.all? { |val| val.must_be_false? }
1672
1712
  end
1673
1713
 
1674
1714
  def may_be_false?
1675
1715
  # NOTE: A composite variable cannot appear in expressions except the
1676
1716
  # primary-expression(object-specifier followed by `.').
1677
- @values.all? { |value| value.may_be_false? }
1717
+ @values.all? { |val| val.may_be_false? }
1678
1718
  end
1679
1719
 
1680
1720
  def coerce_to(type)
@@ -1683,15 +1723,15 @@ module C #:nodoc:
1683
1723
 
1684
1724
  def to_enum
1685
1725
  # FIXME: This method generates only one of sample values.
1686
- @values.map { |value| value.to_enum.first }
1726
+ @values.map { |val| val.to_enum.first }
1687
1727
  end
1688
1728
 
1689
1729
  def to_defined_value
1690
- CompositeValue.new(@values.map { |value| value.to_defined_value })
1730
+ CompositeValue.new(@values.map { |val| val.to_defined_value })
1691
1731
  end
1692
1732
 
1693
- def eql?(rhs_value)
1694
- rhs_value.kind_of?(CompositeValue) && @values.eql?(rhs_value.values)
1733
+ def eql?(rhs_val)
1734
+ rhs_val.kind_of?(CompositeValue) && @values.eql?(rhs_val.values)
1695
1735
  end
1696
1736
 
1697
1737
  def hash
@@ -1699,13 +1739,19 @@ module C #:nodoc:
1699
1739
  end
1700
1740
 
1701
1741
  def dup
1702
- CompositeValue.new(@values.map { |value| value.dup })
1742
+ CompositeValue.new(@values.map { |val| val.dup })
1743
+ end
1744
+
1745
+ private
1746
+ def logical_shr?
1747
+ @values.all? { |val| val.logical_shr? }
1703
1748
  end
1749
+ memoize :logical_shr?
1704
1750
  end
1705
1751
 
1706
1752
  class MultipleValue < Value
1707
- def initialize(value, ancestor)
1708
- @base_value = value.to_single_value
1753
+ def initialize(val, ancestor)
1754
+ @base_value = val.to_single_value
1709
1755
  @ancestor = ancestor
1710
1756
  @descendants = []
1711
1757
  end
@@ -1719,25 +1765,25 @@ module C #:nodoc:
1719
1765
  def_delegator :@base_value, :composite?
1720
1766
 
1721
1767
  def undefined?
1722
- effective_values.all? { |multi_value| multi_value.base_value.undefined? }
1768
+ effective_values.all? { |multi_val| multi_val.base_value.undefined? }
1723
1769
  end
1724
1770
 
1725
1771
  def ambiguous?
1726
- effective_values.all? { |multi_value| multi_value.base_value.ambiguous? }
1772
+ effective_values.all? { |multi_val| multi_val.base_value.ambiguous? }
1727
1773
  end
1728
1774
 
1729
1775
  def exist?
1730
- effective_values.any? { |multi_value| multi_value.base_value.exist? }
1776
+ effective_values.any? { |multi_val| multi_val.base_value.exist? }
1731
1777
  end
1732
1778
 
1733
1779
  def definite?
1734
- effective_values.all? { |multi_value| multi_value.base_value.definite? }
1780
+ effective_values.all? { |multi_val| multi_val.base_value.definite? }
1735
1781
  end
1736
1782
 
1737
- def contain?(value)
1738
- single_value = value.to_single_value
1739
- effective_values.all? do |multi_value|
1740
- multi_value.base_value.contain?(single_value)
1783
+ def contain?(val)
1784
+ single_val = val.to_single_value
1785
+ effective_values.all? do |multi_val|
1786
+ multi_val.base_value.contain?(single_val)
1741
1787
  end
1742
1788
  end
1743
1789
 
@@ -1745,51 +1791,47 @@ module C #:nodoc:
1745
1791
  true
1746
1792
  end
1747
1793
 
1748
- def overwrite!(value)
1749
- single_value = value.to_single_value
1750
- effective_values.each do |multi_value|
1751
- multi_value.base_value.overwrite!(single_value)
1794
+ def overwrite!(val)
1795
+ single_val = val.to_single_value
1796
+ effective_values.each do |multi_val|
1797
+ multi_val.base_value.overwrite!(single_val)
1752
1798
  end
1753
1799
  end
1754
1800
 
1755
- def narrow_domain!(operator, operand_value)
1756
- operand_single_value = operand_value.to_single_value
1757
- effective_values.map { |multi_value|
1758
- if ancestor = multi_value.ancestor
1759
- ancestor.base_value.narrow_domain!(operator.for_complement,
1760
- operand_single_value)
1801
+ def narrow_domain!(op, ope_val)
1802
+ ope_single_val = ope_val.to_single_value
1803
+ effective_values.map { |multi_val|
1804
+ if anc = multi_val.ancestor
1805
+ anc.base_value.narrow_domain!(op.for_complement, ope_single_val)
1761
1806
  end
1762
- multi_value.base_value.narrow_domain!(operator, operand_single_value)
1807
+ multi_val.base_value.narrow_domain!(op, ope_single_val)
1763
1808
  }.any?
1764
1809
  end
1765
1810
 
1766
- def widen_domain!(operator, operand_value)
1767
- operand_single_value = operand_value.to_single_value
1768
- effective_values.map { |multi_value|
1769
- if ancestor = multi_value.ancestor
1770
- ancestor.base_value.narrow_domain!(operator.for_complement,
1771
- operand_single_value)
1811
+ def widen_domain!(op, ope_val)
1812
+ ope_single_val = ope_val.to_single_value
1813
+ effective_values.map { |multi_val|
1814
+ if anc = multi_val.ancestor
1815
+ anc.base_value.narrow_domain!(op.for_complement, ope_single_val)
1772
1816
  end
1773
- multi_value.base_value.widen_domain!(operator, operand_single_value)
1817
+ multi_val.base_value.widen_domain!(op, ope_single_val)
1774
1818
  }.any?
1775
1819
  end
1776
1820
 
1777
1821
  def invert_domain!
1778
- effective_values.each do |multi_value|
1779
- multi_value.base_value.invert_domain!
1822
+ effective_values.each do |multi_val|
1823
+ multi_val.base_value.invert_domain!
1780
1824
  end
1781
1825
  end
1782
1826
 
1783
- def single_value_unified_with(rhs_value)
1784
- to_single_value.single_value_unified_with(rhs_value)
1827
+ def single_value_unified_with(rhs_val)
1828
+ to_single_value.single_value_unified_with(rhs_val)
1785
1829
  end
1786
1830
 
1787
1831
  def fork
1788
- same_value = @descendants.find { |multi_value|
1789
- multi_value.eql?(@base_value)
1790
- }
1791
- if same_value
1792
- same_value
1832
+ same_val = @descendants.find { |multi_val| multi_val.eql?(@base_value) }
1833
+ if same_val
1834
+ same_val
1793
1835
  else
1794
1836
  new_descendant = MultipleValue.new(@base_value.dup, self)
1795
1837
  @descendants.push(new_descendant)
@@ -1817,201 +1859,214 @@ module C #:nodoc:
1817
1859
  -to_single_value
1818
1860
  end
1819
1861
 
1820
- def +(rhs_value)
1821
- to_single_value + rhs_value.to_single_value
1862
+ def +(rhs_val)
1863
+ to_single_value + rhs_val.to_single_value
1822
1864
  end
1823
1865
 
1824
- def -(rhs_value)
1825
- to_single_value - rhs_value.to_single_value
1866
+ def -(rhs_val)
1867
+ to_single_value - rhs_val.to_single_value
1826
1868
  end
1827
1869
 
1828
- def *(rhs_value)
1829
- to_single_value * rhs_value.to_single_value
1870
+ def *(rhs_val)
1871
+ to_single_value * rhs_val.to_single_value
1830
1872
  end
1831
1873
 
1832
- def /(rhs_value)
1833
- to_single_value / rhs_value.to_single_value
1874
+ def /(rhs_val)
1875
+ to_single_value / rhs_val.to_single_value
1834
1876
  end
1835
1877
 
1836
- def %(rhs_value)
1837
- to_single_value % rhs_value.to_single_value
1878
+ def %(rhs_val)
1879
+ to_single_value % rhs_val.to_single_value
1838
1880
  end
1839
1881
 
1840
- def &(rhs_value)
1841
- to_single_value & rhs_value.to_single_value
1882
+ def &(rhs_val)
1883
+ to_single_value & rhs_val.to_single_value
1842
1884
  end
1843
1885
 
1844
- def |(rhs_value)
1845
- to_single_value | rhs_value.to_single_value
1886
+ def |(rhs_val)
1887
+ to_single_value | rhs_val.to_single_value
1846
1888
  end
1847
1889
 
1848
- def ^(rhs_value)
1849
- to_single_value ^ rhs_value.to_single_value
1890
+ def ^(rhs_val)
1891
+ to_single_value ^ rhs_val.to_single_value
1850
1892
  end
1851
1893
 
1852
- def <<(rhs_value)
1853
- to_single_value << rhs_value.to_single_value
1894
+ def <<(rhs_val)
1895
+ to_single_value << rhs_val.to_single_value
1854
1896
  end
1855
1897
 
1856
- def >>(rhs_value)
1857
- to_single_value >> rhs_value.to_single_value
1898
+ def >>(rhs_val)
1899
+ to_single_value >> rhs_val.to_single_value
1858
1900
  end
1859
1901
 
1860
1902
  def !
1861
1903
  !to_single_value
1862
1904
  end
1863
1905
 
1864
- def <(rhs_value)
1865
- to_single_value < rhs_value.to_single_value
1906
+ def <(rhs_val)
1907
+ to_single_value < rhs_val.to_single_value
1866
1908
  end
1867
1909
 
1868
- def >(rhs_value)
1869
- to_single_value > rhs_value.to_single_value
1910
+ def >(rhs_val)
1911
+ to_single_value > rhs_val.to_single_value
1870
1912
  end
1871
1913
 
1872
- def ==(rhs_value)
1873
- to_single_value == rhs_value.to_single_value
1914
+ def ==(rhs_val)
1915
+ to_single_value == rhs_val.to_single_value
1874
1916
  end
1875
1917
 
1876
- def !=(rhs_value)
1877
- to_single_value != rhs_value.to_single_value
1918
+ def !=(rhs_val)
1919
+ to_single_value != rhs_val.to_single_value
1878
1920
  end
1879
1921
 
1880
- def <=(rhs_value)
1881
- to_single_value <= rhs_value.to_single_value
1922
+ def <=(rhs_val)
1923
+ to_single_value <= rhs_val.to_single_value
1882
1924
  end
1883
1925
 
1884
- def >=(rhs_value)
1885
- to_single_value >= rhs_value.to_single_value
1926
+ def >=(rhs_val)
1927
+ to_single_value >= rhs_val.to_single_value
1886
1928
  end
1887
1929
 
1888
- def logical_and(rhs_value)
1889
- to_single_value.logical_and(rhs_value.to_single_value)
1930
+ def logical_and(rhs_val)
1931
+ to_single_value.logical_and(rhs_val.to_single_value)
1890
1932
  end
1891
1933
 
1892
- def logical_or(rhs_value)
1893
- to_single_value.logical_or(rhs_value.to_single_value)
1934
+ def logical_or(rhs_val)
1935
+ to_single_value.logical_or(rhs_val.to_single_value)
1894
1936
  end
1895
1937
 
1896
- def must_be_equal_to?(value)
1897
- single_value = value.to_single_value
1898
- non_nil_values = effective_values.select { |multi_value|
1899
- multi_value.base_value.exist?
1938
+ def must_be_equal_to?(val)
1939
+ single_val = val.to_single_value
1940
+ non_nil_vals = effective_values.select { |multi_val|
1941
+ multi_val.base_value.exist?
1900
1942
  }
1901
- return false if non_nil_values.empty?
1902
1943
 
1903
- non_nil_values.all? do |multi_value|
1904
- multi_value.base_value.must_be_equal_to?(single_value)
1944
+ if non_nil_vals.empty?
1945
+ false
1946
+ else
1947
+ non_nil_vals.all? do |multi_val|
1948
+ multi_val.base_value.must_be_equal_to?(single_val)
1949
+ end
1905
1950
  end
1906
1951
  end
1907
1952
 
1908
- def may_be_equal_to?(value)
1909
- single_value = value.to_single_value
1910
- effective_values.any? do |multi_value|
1911
- multi_value.base_value.may_be_equal_to?(single_value)
1953
+ def may_be_equal_to?(val)
1954
+ single_val = val.to_single_value
1955
+ effective_values.any? do |multi_val|
1956
+ multi_val.base_value.may_be_equal_to?(single_val)
1912
1957
  end
1913
1958
  end
1914
1959
 
1915
- def must_not_be_equal_to?(value)
1916
- single_value = value.to_single_value
1917
- non_nil_values = effective_values.select { |multi_value|
1918
- multi_value.base_value.exist?
1960
+ def must_not_be_equal_to?(val)
1961
+ single_val = val.to_single_value
1962
+ non_nil_vals = effective_values.select { |multi_val|
1963
+ multi_val.base_value.exist?
1919
1964
  }
1920
- return false if non_nil_values.empty?
1921
-
1922
- non_nil_values.all? do |multi_value|
1923
- multi_value.base_value.must_not_be_equal_to?(single_value)
1965
+ if non_nil_vals.empty?
1966
+ false
1967
+ else
1968
+ non_nil_vals.all? do |multi_val|
1969
+ multi_val.base_value.must_not_be_equal_to?(single_val)
1970
+ end
1924
1971
  end
1925
1972
  end
1926
1973
 
1927
- def may_not_be_equal_to?(value)
1928
- single_value = value.to_single_value
1929
- effective_values.any? do |multi_value|
1930
- multi_value.base_value.may_not_be_equal_to?(single_value)
1974
+ def may_not_be_equal_to?(val)
1975
+ single_val = val.to_single_value
1976
+ effective_values.any? do |multi_val|
1977
+ multi_val.base_value.may_not_be_equal_to?(single_val)
1931
1978
  end
1932
1979
  end
1933
1980
 
1934
- def must_be_less_than?(value)
1935
- single_value = value.to_single_value
1936
- non_nil_values = effective_values.select { |multi_value|
1937
- multi_value.base_value.exist?
1981
+ def must_be_less_than?(val)
1982
+ single_val = val.to_single_value
1983
+ non_nil_vals = effective_values.select { |multi_val|
1984
+ multi_val.base_value.exist?
1938
1985
  }
1939
- return false if non_nil_values.empty?
1940
-
1941
- non_nil_values.all? do |multi_value|
1942
- multi_value.base_value.must_be_less_than?(single_value)
1986
+ if non_nil_vals.empty?
1987
+ false
1988
+ else
1989
+ non_nil_vals.all? do |multi_val|
1990
+ multi_val.base_value.must_be_less_than?(single_val)
1991
+ end
1943
1992
  end
1944
1993
  end
1945
1994
 
1946
- def may_be_less_than?(value)
1947
- single_value = value.to_single_value
1948
- effective_values.any? do |multi_value|
1949
- multi_value.base_value.may_be_less_than?(single_value)
1995
+ def may_be_less_than?(val)
1996
+ single_val = val.to_single_value
1997
+ effective_values.any? do |multi_val|
1998
+ multi_val.base_value.may_be_less_than?(single_val)
1950
1999
  end
1951
2000
  end
1952
2001
 
1953
- def must_be_greater_than?(value)
1954
- single_value = value.to_single_value
1955
- non_nil_values = effective_values.select { |multi_value|
1956
- multi_value.base_value.exist?
2002
+ def must_be_greater_than?(val)
2003
+ single_val = val.to_single_value
2004
+ non_nil_vals = effective_values.select { |multi_val|
2005
+ multi_val.base_value.exist?
1957
2006
  }
1958
- return false if non_nil_values.empty?
1959
-
1960
- non_nil_values.all? do |multi_value|
1961
- multi_value.base_value.must_be_greater_than?(single_value)
2007
+ if non_nil_vals.empty?
2008
+ false
2009
+ else
2010
+ non_nil_vals.all? do |multi_val|
2011
+ multi_val.base_value.must_be_greater_than?(single_val)
2012
+ end
1962
2013
  end
1963
2014
  end
1964
2015
 
1965
- def may_be_greater_than?(value)
1966
- single_value = value.to_single_value
1967
- effective_values.any? do |multi_value|
1968
- multi_value.base_value.may_be_greater_than?(single_value)
2016
+ def may_be_greater_than?(val)
2017
+ single_val = val.to_single_value
2018
+ effective_values.any? do |multi_val|
2019
+ multi_val.base_value.may_be_greater_than?(single_val)
1969
2020
  end
1970
2021
  end
1971
2022
 
1972
2023
  def must_be_undefined?
1973
- effective_values.all? do |multi_value|
1974
- multi_value.base_value.must_be_undefined?
2024
+ effective_values.all? do |multi_val|
2025
+ multi_val.base_value.must_be_undefined?
1975
2026
  end
1976
2027
  end
1977
2028
 
1978
2029
  def may_be_undefined?
1979
- effective_values.any? do |multi_value|
1980
- multi_value.base_value.may_be_undefined?
2030
+ effective_values.any? do |multi_val|
2031
+ multi_val.base_value.may_be_undefined?
1981
2032
  end
1982
2033
  end
1983
2034
 
1984
2035
  def must_be_true?
1985
- non_nil_values = effective_values.select { |multi_value|
1986
- multi_value.base_value.exist?
2036
+ non_nil_vals = effective_values.select { |multi_val|
2037
+ multi_val.base_value.exist?
1987
2038
  }
1988
- return false if non_nil_values.empty?
1989
-
1990
- non_nil_values.all? do |multi_value|
1991
- multi_value.base_value.must_be_true?
2039
+ if non_nil_vals.empty?
2040
+ false
2041
+ else
2042
+ non_nil_vals.all? do |multi_val|
2043
+ multi_val.base_value.must_be_true?
2044
+ end
1992
2045
  end
1993
2046
  end
1994
2047
 
1995
2048
  def may_be_true?
1996
- effective_values.any? do |multi_value|
1997
- multi_value.base_value.may_be_true?
2049
+ effective_values.any? do |multi_val|
2050
+ multi_val.base_value.may_be_true?
1998
2051
  end
1999
2052
  end
2000
2053
 
2001
2054
  def must_be_false?
2002
- non_nil_values = effective_values.select { |multi_value|
2003
- multi_value.base_value.exist?
2055
+ non_nil_vals = effective_values.select { |multi_val|
2056
+ multi_val.base_value.exist?
2004
2057
  }
2005
- return false if non_nil_values.empty?
2006
-
2007
- non_nil_values.all? do |multi_value|
2008
- multi_value.base_value.must_be_false?
2058
+ if non_nil_vals.empty?
2059
+ false
2060
+ else
2061
+ non_nil_vals.all? do |multi_val|
2062
+ multi_val.base_value.must_be_false?
2063
+ end
2009
2064
  end
2010
2065
  end
2011
2066
 
2012
2067
  def may_be_false?
2013
- effective_values.any? do |multi_value|
2014
- multi_value.base_value.may_be_false?
2068
+ effective_values.any? do |multi_val|
2069
+ multi_val.base_value.may_be_false?
2015
2070
  end
2016
2071
  end
2017
2072
 
@@ -2025,10 +2080,10 @@ module C #:nodoc:
2025
2080
 
2026
2081
  def to_single_value
2027
2082
  # NOTE: The base_value of the MultipleValue object must be a SingleValue.
2028
- effective_values.map { |multi_value|
2029
- multi_value.base_value
2030
- }.reduce do |unified_value, single_value|
2031
- unified_value.single_value_unified_with(single_value)
2083
+ effective_values.map { |multi_val|
2084
+ multi_val.base_value
2085
+ }.reduce do |unified_val, single_val|
2086
+ unified_val.single_value_unified_with(single_val)
2032
2087
  end
2033
2088
  end
2034
2089
 
@@ -2036,8 +2091,8 @@ module C #:nodoc:
2036
2091
  to_single_value.to_defined_value
2037
2092
  end
2038
2093
 
2039
- def eql?(rhs_value)
2040
- to_single_value.eql?(rhs_value.to_single_value)
2094
+ def eql?(rhs_val)
2095
+ to_single_value.eql?(rhs_val.to_single_value)
2041
2096
  end
2042
2097
 
2043
2098
  def hash
@@ -2056,7 +2111,7 @@ module C #:nodoc:
2056
2111
  if @descendants.empty?
2057
2112
  [self]
2058
2113
  else
2059
- @descendants.map { |multi_value| multi_value.descendants }.flatten.uniq
2114
+ @descendants.map { |multi_val| multi_val.descendants }.flatten.uniq
2060
2115
  end
2061
2116
  end
2062
2117
 
@@ -2065,10 +2120,10 @@ module C #:nodoc:
2065
2120
  end
2066
2121
 
2067
2122
  class VersionedValue < MultipleValue
2068
- def initialize(original_value)
2069
- # NOTE: `original_value.to_single_value' will be done in
2123
+ def initialize(org_val)
2124
+ # NOTE: `org_val.to_single_value' will be done in
2070
2125
  # MultipleValue#initialize.
2071
- super(original_value, nil)
2126
+ super(org_val, nil)
2072
2127
 
2073
2128
  @version_controller = ValueVersionController.new(self)
2074
2129
  end
@@ -2094,36 +2149,35 @@ module C #:nodoc:
2094
2149
  end
2095
2150
 
2096
2151
  def thin_latest_version!(with_rollback)
2097
- if @version_controller.thin_current_version(with_rollback)
2098
- invalidate_memo!
2099
- end
2152
+ @version_controller.thin_current_version(with_rollback)
2153
+ invalidate_memo!
2100
2154
  end
2101
2155
 
2102
2156
  def rollback_all_versions!
2103
2157
  delete_descendants!
2104
- original_value = @version_controller.original_value
2158
+ org_val = @version_controller.original_value
2105
2159
  @version_controller = nil
2106
- _orig_overwrite!(original_value)
2160
+ _org_overwrite!(org_val)
2107
2161
  @version_controller = ValueVersionController.new(self)
2108
2162
  invalidate_memo!
2109
2163
  end
2110
2164
 
2111
- alias :_orig_overwrite! :overwrite!
2165
+ alias :_org_overwrite! :overwrite!
2112
2166
 
2113
- def overwrite!(value)
2167
+ def overwrite!(val)
2114
2168
  @version_controller.fork_current_version
2115
- super(value.to_single_value)
2169
+ super(val.to_single_value)
2116
2170
  @version_controller.mark_current_versioning_group_as_sticky
2117
2171
  invalidate_memo!
2118
2172
  end
2119
2173
 
2120
- def narrow_domain!(operator, operand_value)
2174
+ def narrow_domain!(op, ope_val)
2121
2175
  @version_controller.fork_current_version
2122
2176
  super
2123
2177
  invalidate_memo!
2124
2178
  end
2125
2179
 
2126
- def widen_domain!(operator, operand_value)
2180
+ def widen_domain!(op, ope_val)
2127
2181
  @version_controller.fork_current_version
2128
2182
  super
2129
2183
  invalidate_memo!
@@ -2143,25 +2197,23 @@ module C #:nodoc:
2143
2197
  @version_controller ? @version_controller.current_values : [self]
2144
2198
  end
2145
2199
 
2146
- extend Memoizable
2147
-
2148
2200
  memoize :to_single_value
2149
2201
 
2150
2202
  def invalidate_memo!
2151
- forget_to_single_value_memo
2203
+ forget_memo_of__to_single_value
2152
2204
  end
2153
2205
 
2154
2206
  private
2155
2207
  def compact_descendants!
2156
- @descendants = @version_controller.current_values.reject { |multi_value|
2157
- multi_value.equal?(self)
2208
+ @descendants = @version_controller.current_values.reject { |multi_val|
2209
+ multi_val.equal?(self)
2158
2210
  }.uniq
2159
2211
  end
2160
2212
  end
2161
2213
 
2162
2214
  class ValueVersionController
2163
- def initialize(original_value)
2164
- @versioning_group_stack = [RootVersioningGroup.new(original_value)]
2215
+ def initialize(org_val)
2216
+ @versioning_group_stack = [RootVersioningGroup.new(org_val)]
2165
2217
  end
2166
2218
 
2167
2219
  def original_value
@@ -2195,26 +2247,28 @@ module C #:nodoc:
2195
2247
 
2196
2248
  def thin_current_version(with_rollback)
2197
2249
  # NOTE: This method must be called in the forking section.
2198
- return false unless current_version.forked?
2250
+
2251
+ forked = current_version.forked?
2199
2252
 
2200
2253
  if with_rollback
2201
- initial_values = current_version.initial_values
2202
- current_versioning_group.delete_current_version
2203
- base_values = current_versioning_group.base_values
2204
- base_values.zip(initial_values).each do |multi_value, init_value|
2205
- multi_value.rollback!
2206
- multi_value.overwrite!(init_value) if init_value
2254
+ initial_vals = current_version.initial_values
2255
+ current_versioning_group.delete_current_version_completely
2256
+ base_vals = current_versioning_group.base_values
2257
+ base_vals.zip(initial_vals).each do |multi_val, initial_val|
2258
+ forked and multi_val.rollback!
2259
+ initial_val and multi_val.overwrite!(initial_val)
2207
2260
  end
2261
+ begin_forking
2208
2262
  else
2209
2263
  current_versioning_group.delete_current_version
2210
- current_versioning_group.base_values.each do |multi_value|
2211
- multi_value.rollback!
2264
+ if forked
2265
+ current_versioning_group.base_values.each do |multi_val|
2266
+ multi_val.rollback!
2267
+ end
2212
2268
  end
2213
2269
  end
2214
2270
 
2215
- begin_forking
2216
2271
  mark_current_versioning_group_as_sticky
2217
- true
2218
2272
  end
2219
2273
 
2220
2274
  def mark_current_versioning_group_as_sticky
@@ -2232,40 +2286,39 @@ module C #:nodoc:
2232
2286
 
2233
2287
  # NOTE: This method must be called between ending of the forking section
2234
2288
  # and ending of the versioning group.
2235
- current_values.each do |multi_value|
2236
- base_value = multi_value.base_value
2237
- already_exist = multi_value.descendants.any? { |desc_multi_value|
2238
- !desc_multi_value.equal?(multi_value) &&
2239
- desc_multi_value.eql?(base_value)
2289
+ current_values.each do |multi_val|
2290
+ base_val = multi_val.base_value
2291
+ already_exist = multi_val.descendants.any? { |desc_multi_val|
2292
+ !desc_multi_val.equal?(multi_val) && desc_multi_val.eql?(base_val)
2240
2293
  }
2241
- multi_value.fork unless already_exist
2294
+ multi_val.fork unless already_exist
2242
2295
  end
2243
2296
  end
2244
2297
 
2245
2298
  def merge_forked_versions
2246
2299
  # NOTE: This method must be called between ending of the forking section
2247
2300
  # and ending of the versioning group.
2248
- base_version = current_versioning_group.base_version
2301
+ base_ver = current_versioning_group.base_version
2249
2302
 
2250
2303
  case
2251
2304
  when current_versioning_group.sticky?
2252
2305
  fork_all_versions
2253
- base_version.values = base_version.values.map { |base_multi_value|
2254
- base_multi_value.descendants
2306
+ base_ver.values = base_ver.values.map { |base_multi_val|
2307
+ base_multi_val.descendants
2255
2308
  }.flatten.uniq
2256
2309
  when current_versioning_group.versions_forked?
2257
2310
  # NOTE: When versions in the current versioning group have been forked,
2258
2311
  # base_version of the current versioning group has already been
2259
2312
  # forked. So, it is safe to overwrite the base_version's values
2260
2313
  # with the current versioning group's initial snapshot values.
2261
- initial_values = current_versioning_group.initial_values
2262
- values = base_version.values.zip(initial_values)
2263
- values.each do |base_multi_value, initial_single_value|
2264
- base_multi_value.delete_descendants!
2265
- if base_multi_value.kind_of?(VersionedValue)
2266
- base_multi_value._orig_overwrite!(initial_single_value)
2314
+ initial_vals = current_versioning_group.initial_values
2315
+ vals = base_ver.values.zip(initial_vals)
2316
+ vals.each do |base_multi_val, initial_single_val|
2317
+ base_multi_val.delete_descendants!
2318
+ if base_multi_val.kind_of?(VersionedValue)
2319
+ base_multi_val._org_overwrite!(initial_single_val)
2267
2320
  else
2268
- base_multi_value.overwrite!(initial_single_value)
2321
+ base_multi_val.overwrite!(initial_single_val)
2269
2322
  end
2270
2323
  end
2271
2324
  else
@@ -2301,12 +2354,12 @@ module C #:nodoc:
2301
2354
  end
2302
2355
 
2303
2356
  class VersioningGroup
2304
- def initialize(base_version, sticky = false)
2305
- @base_version = base_version
2357
+ def initialize(base_ver, sticky = false)
2358
+ @base_version = base_ver
2306
2359
  @sticky = sticky
2307
2360
 
2308
- @initial_values = base_version.values.map { |multi_value|
2309
- multi_value.base_value.dup
2361
+ @initial_values = base_ver.values.map { |multi_val|
2362
+ multi_val.base_value.dup
2310
2363
  }
2311
2364
  @version_stack = []
2312
2365
  @all_versions = []
@@ -2321,7 +2374,7 @@ module C #:nodoc:
2321
2374
  end
2322
2375
 
2323
2376
  def versions_forked?
2324
- @all_versions.any? { |version| version.forked? }
2377
+ @all_versions.any? { |ver| ver.forked? }
2325
2378
  end
2326
2379
 
2327
2380
  def base_values
@@ -2337,36 +2390,40 @@ module C #:nodoc:
2337
2390
  end
2338
2391
 
2339
2392
  def begin_new_version
2340
- new_version = Version.new(base_values)
2341
- @version_stack.push(new_version)
2342
- @all_versions.push(new_version)
2393
+ new_ver = Version.new(base_values)
2394
+ @version_stack.push(new_ver)
2395
+ @all_versions.push(new_ver)
2343
2396
  end
2344
2397
 
2345
2398
  def end_current_version
2346
2399
  @version_stack.pop
2347
2400
  end
2348
2401
 
2349
- def delete_current_version
2402
+ def delete_current_version_completely
2350
2403
  end_current_version
2404
+ delete_current_version
2405
+ end
2406
+
2407
+ def delete_current_version
2351
2408
  @all_versions.pop
2352
2409
  end
2353
2410
 
2354
2411
  def fork_all_versions
2355
- @all_versions.each { |version| version.fork_from(@base_version) }
2412
+ @all_versions.each { |ver| ver.fork_from(@base_version) }
2356
2413
  end
2357
2414
  end
2358
2415
  private_constant :VersioningGroup
2359
2416
 
2360
2417
  class RootVersioningGroup < VersioningGroup
2361
- def initialize(original_value)
2362
- super(Version.new([original_value], true), true)
2418
+ def initialize(org_val)
2419
+ super(Version.new([org_val], true), true)
2363
2420
  end
2364
2421
  end
2365
2422
  private_constant :RootVersioningGroup
2366
2423
 
2367
2424
  class Version
2368
- def initialize(values, original = false)
2369
- @values = values
2425
+ def initialize(vals, original = false)
2426
+ @values = vals
2370
2427
  @initial_values = []
2371
2428
  @state = original ? :original : :forking
2372
2429
  end
@@ -2386,11 +2443,11 @@ module C #:nodoc:
2386
2443
  @state == :forked
2387
2444
  end
2388
2445
 
2389
- def fork_from(base_version)
2446
+ def fork_from(base_ver)
2390
2447
  if forking?
2391
- @values = base_version.values.map { |multi_value| multi_value.fork }
2392
- @initial_values = @values.each_with_object([]) { |value, ary|
2393
- ary.push(value.to_single_value.dup)
2448
+ @values = base_ver.values.map { |multi_val| multi_val.fork }
2449
+ @initial_values = @values.each_with_object([]) { |val, ary|
2450
+ ary.push(val.to_single_value.dup)
2394
2451
  }
2395
2452
  @state = :forked
2396
2453
  end