adlint 2.6.14 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
  # C runtime object model.
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,14 +30,14 @@
30
30
  #++
31
31
 
32
32
  require "adlint/util"
33
- require "adlint/c/syntax"
34
- require "adlint/c/value"
35
- require "adlint/c/scope"
36
- require "adlint/c/seqp"
37
- require "adlint/c/operator"
33
+ require "adlint/cc1/syntax"
34
+ require "adlint/cc1/value"
35
+ require "adlint/cc1/scope"
36
+ require "adlint/cc1/seqp"
37
+ require "adlint/cc1/operator"
38
38
 
39
39
  module AdLint #:nodoc:
40
- module C #:nodoc:
40
+ module Cc1 #:nodoc:
41
41
 
42
42
  module Bindable
43
43
  attr_accessor :binding
@@ -51,10 +51,10 @@ module C #:nodoc:
51
51
  end
52
52
  end
53
53
 
54
- def be_alias_to(memory)
55
- case memory
54
+ def be_alias_to(mem)
55
+ case mem
56
56
  when Memory
57
- Binding.create_alias(self, memory)
57
+ Binding.create_alias(self, mem)
58
58
  else
59
59
  raise TypeError, "an object cannot be an alias to other objects."
60
60
  end
@@ -62,22 +62,22 @@ module C #:nodoc:
62
62
  end
63
63
 
64
64
  class Binding
65
- def self.bind(object, memory)
66
- binding = new(object, memory)
67
- object.binding = binding
68
- memory.binding = binding
65
+ def self.bind(obj, mem)
66
+ binding = new(obj, mem)
67
+ obj.binding = binding
68
+ mem.binding = binding
69
69
  binding
70
70
  end
71
71
 
72
- def self.create_alias(object, memory)
73
- binding = new(object, memory)
74
- object.binding = binding
72
+ def self.create_alias(obj, mem)
73
+ binding = new(obj, mem)
74
+ obj.binding = binding
75
75
  binding
76
76
  end
77
77
 
78
- def initialize(object, memory)
79
- @object = object
80
- @memory = memory
78
+ def initialize(obj, mem)
79
+ @object = obj
80
+ @memory = mem
81
81
  end
82
82
  private_class_method :new
83
83
 
@@ -88,36 +88,33 @@ module C #:nodoc:
88
88
  class Object
89
89
  include Bindable
90
90
 
91
- def initialize(declaration_or_definition = nil)
92
- @declarations_and_definitions = [declaration_or_definition].compact
91
+ def initialize(dcl_or_def = nil)
92
+ @declarations_and_definitions = [dcl_or_def].compact
93
93
  end
94
94
 
95
95
  attr_reader :declarations_and_definitions
96
96
 
97
97
  def storage_class_specifiers
98
- @declarations_and_definitions.map { |decl_or_def|
99
- decl_or_def.storage_class_specifier
98
+ @declarations_and_definitions.map { |dcl_or_def|
99
+ dcl_or_def.storage_class_specifier
100
100
  }.compact
101
101
  end
102
102
 
103
103
  def declared_as_extern?
104
- first_sc_spec = first_storage_class_specifier
105
- first_sc_spec.nil? || first_sc_spec.type == :EXTERN
104
+ sc_spec = first_storage_class_specifier
105
+ sc_spec.nil? || sc_spec.type == :EXTERN
106
106
  end
107
107
 
108
108
  def declared_as_static?
109
- first_sc_spec = first_storage_class_specifier and
110
- first_sc_spec.type == :STATIC
109
+ sc_spec = first_storage_class_specifier and sc_spec.type == :STATIC
111
110
  end
112
111
 
113
112
  def declared_as_auto?
114
- first_sc_spec = first_storage_class_specifier and
115
- first_sc_spec.type == :AUTO
113
+ sc_spec = first_storage_class_specifier and sc_spec.type == :AUTO
116
114
  end
117
115
 
118
116
  def declared_as_register?
119
- first_sc_spec = first_storage_class_specifier and
120
- first_sc_spec.type == :REGISTER
117
+ sc_spec = first_storage_class_specifier and sc_spec.type == :REGISTER
121
118
  end
122
119
 
123
120
  def designated_by_lvalue?
@@ -151,8 +148,8 @@ module C #:nodoc:
151
148
  end
152
149
 
153
150
  class TypedObject < Object
154
- def initialize(type, declaration_or_definition = nil)
155
- super(declaration_or_definition)
151
+ def initialize(type, dcl_or_def = nil)
152
+ super(dcl_or_def)
156
153
  @type = type
157
154
  end
158
155
 
@@ -162,19 +159,18 @@ module C #:nodoc:
162
159
  # == DESCRIPTION
163
160
  # === Variable class hierarchy
164
161
  # Variable
165
- # <--- ScopedVariable
166
- # <--- OuterVariable
167
- # <--- NamedVariable --------- Nameable <<module>>
168
- # <--- AliasVariable |
169
- # <--- TemporaryVariable |
170
- # <--- InnerVariable -------------+
171
- # <--- ArrayElementVariable
172
- # <--- CompositeMemberVariable
162
+ # <-- ScopedVariable
163
+ # <-- OuterVariable
164
+ # <-- NamedVariable --------> Nameable <<module>>
165
+ # <-- AliasVariable ^
166
+ # <-- TemporaryVariable |
167
+ # <-- InnerVariable -------------+
168
+ # <-- ArrayElementVariable
169
+ # <-- CompositeMemberVariable
173
170
  class Variable < TypedObject
174
- def initialize(memory, declaration_or_definition, type)
175
- super(type, declaration_or_definition)
176
-
177
- relate_to_memory(memory)
171
+ def initialize(mem, dcl_or_def, type)
172
+ super(type, dcl_or_def)
173
+ relate_to_memory(mem)
178
174
  end
179
175
 
180
176
  def function?
@@ -205,28 +201,28 @@ module C #:nodoc:
205
201
  binding.memory.read
206
202
  end
207
203
 
208
- def assign!(value)
204
+ def assign!(val)
209
205
  # NOTE: Length of the incomplete array type should be deducted while
210
206
  # initializer evaluation. So, adjustment of the assigning value
211
207
  # can be done at this point by Value#coerce_to(type).
212
208
  # NOTE: Domain of the assigning value must be narrowed before writing to
213
209
  # the memory by Value#coerce_to(type).
214
- binding.memory.write(value.coerce_to(type))
210
+ binding.memory.write(val.coerce_to(type))
215
211
  end
216
212
 
217
213
  def uninitialize!
218
214
  assign!(self.type.undefined_value)
219
215
  end
220
216
 
221
- def narrow_value_domain!(operator, value)
217
+ def narrow_value_domain!(op, val)
222
218
  assign!(type.arbitrary_value) unless self.value
223
- self.value.narrow_domain!(operator, value.coerce_to(type))
219
+ self.value.narrow_domain!(op, val.coerce_to(type))
224
220
  self.value.exist?
225
221
  end
226
222
 
227
- def widen_value_domain!(operator, value)
223
+ def widen_value_domain!(op, val)
228
224
  assign!(type.nil_value) unless self.value
229
- self.value.widen_domain!(operator, value.coerce_to(type))
225
+ self.value.widen_domain!(op, val.coerce_to(type))
230
226
  self.value.exist?
231
227
  end
232
228
 
@@ -255,14 +251,14 @@ module C #:nodoc:
255
251
  end
256
252
 
257
253
  private
258
- def relate_to_memory(memory)
259
- bind_to(memory)
254
+ def relate_to_memory(mem)
255
+ bind_to(mem)
260
256
  end
261
257
  end
262
258
 
263
259
  class ScopedVariable < Variable
264
- def initialize(memory, declaration_or_definition, type, scope)
265
- super(memory, declaration_or_definition, type)
260
+ def initialize(mem, dcl_or_def, type, scope)
261
+ super(mem, dcl_or_def, type)
266
262
  @scope = scope
267
263
  end
268
264
 
@@ -272,8 +268,7 @@ module C #:nodoc:
272
268
  if @scope.global?
273
269
  super
274
270
  else
275
- first_sc_spec = first_storage_class_specifier and
276
- first_sc_spec.type == :EXTERN
271
+ sc_spec = first_storage_class_specifier and sc_spec.type == :EXTERN
277
272
  end
278
273
  end
279
274
 
@@ -281,16 +276,15 @@ module C #:nodoc:
281
276
  if @scope.global?
282
277
  super
283
278
  else
284
- first_sc_spec = first_storage_class_specifier
285
- first_sc_spec.nil? || first_sc_spec.type == :AUTO
279
+ sc_spec = first_storage_class_specifier
280
+ sc_spec.nil? || sc_spec.type == :AUTO
286
281
  end
287
282
  end
288
283
  end
289
284
 
290
285
  class OuterVariable < ScopedVariable
291
- def initialize(memory, declaration_or_definition, type, scope)
292
- super(memory, declaration_or_definition, type, scope)
293
-
286
+ def initialize(mem, dcl_or_def, type, scope)
287
+ super(mem, dcl_or_def, type, scope)
294
288
  # TODO: If too slow, make an index of inner variables.
295
289
  @inner_variables = create_inner_variables(type.unqualify, scope)
296
290
  end
@@ -353,12 +347,12 @@ module C #:nodoc:
353
347
  false
354
348
  end
355
349
 
356
- def inner_variable_at(index)
350
+ def inner_variable_at(idx)
357
351
  if @type.array?
358
352
  # TODO: If linear searching is too slow, use an index of inner
359
353
  # variables.
360
- target_name = ArrayElementVariable.component_name_of(index)
361
- @inner_variables.find { |iv| iv.component_name == target_name }
354
+ target_name = ArrayElementVariable.component_name_of(idx)
355
+ @inner_variables.find { |inner| inner.component_name == target_name }
362
356
  else
363
357
  nil
364
358
  end
@@ -369,7 +363,7 @@ module C #:nodoc:
369
363
  # TODO: If linear searching is too slow, use an index of inner
370
364
  # variables.
371
365
  target_name = CompositeMemberVariable.component_name_of(name)
372
- @inner_variables.find { |iv| iv.component_name == target_name }
366
+ @inner_variables.find { |inner| inner.component_name == target_name }
373
367
  else
374
368
  nil
375
369
  end
@@ -387,21 +381,21 @@ module C #:nodoc:
387
381
  end
388
382
  end
389
383
 
390
- def create_array_elements(type, scope, memory)
384
+ def create_array_elements(type, scope, mem)
391
385
  offset = 0
392
- type.impl_length.times.map do |index|
393
- window = memory.create_window(offset, type.base_type.aligned_byte_size)
394
- offset += window.byte_size
395
- ArrayElementVariable.new(window, self, type.base_type, index)
386
+ type.impl_length.times.map do |idx|
387
+ win = mem.create_window(offset, type.base_type.aligned_byte_size)
388
+ offset += win.byte_size
389
+ ArrayElementVariable.new(win, self, type.base_type, idx)
396
390
  end
397
391
  end
398
392
 
399
- def create_composite_members(type, scope, memory)
393
+ def create_composite_members(type, scope, mem)
400
394
  offset = 0
401
- type.members.map do |member|
402
- window = memory.create_window(offset, member.type.aligned_byte_size)
403
- offset += window.byte_size
404
- CompositeMemberVariable.new(window, self, member.type, member.name)
395
+ type.members.map do |memb|
396
+ win = mem.create_window(offset, memb.type.aligned_byte_size)
397
+ offset += win.byte_size
398
+ CompositeMemberVariable.new(win, self, memb.type, memb.name)
405
399
  end
406
400
  end
407
401
  end
@@ -423,11 +417,9 @@ module C #:nodoc:
423
417
  class NamedVariable < OuterVariable
424
418
  include Nameable
425
419
 
426
- def initialize(memory, declaration_or_definition, scope)
427
- self.name = declaration_or_definition.identifier.value
428
-
429
- super(memory, declaration_or_definition, declaration_or_definition.type,
430
- scope)
420
+ def initialize(mem, dcl_or_def, scope)
421
+ self.name = dcl_or_def.identifier.value
422
+ super(mem, dcl_or_def, dcl_or_def.type, scope)
431
423
  end
432
424
 
433
425
  def temporary?
@@ -451,8 +443,8 @@ module C #:nodoc:
451
443
  end
452
444
 
453
445
  class TemporaryVariable < OuterVariable
454
- def initialize(memory, type, scope)
455
- super(memory, nil, type, scope)
446
+ def initialize(mem, type, scope)
447
+ super(mem, nil, type, scope)
456
448
  end
457
449
 
458
450
  def temporary?
@@ -477,12 +469,11 @@ module C #:nodoc:
477
469
  class InnerVariable < OuterVariable
478
470
  include Nameable
479
471
 
480
- def initialize(memory, outer_variable, type, component_name)
481
- @owner = outer_variable
472
+ def initialize(mem, outer_var, type, component_name)
473
+ @owner = outer_var
482
474
  @component_name = component_name
483
- self.name = create_qualified_name(outer_variable, component_name)
484
-
485
- super(memory, nil, type, outer_variable.scope)
475
+ self.name = create_qualified_name(outer_var, component_name)
476
+ super(mem, nil, type, outer_var.scope)
486
477
  end
487
478
 
488
479
  attr_reader :owner
@@ -529,9 +520,9 @@ module C #:nodoc:
529
520
  end
530
521
 
531
522
  private
532
- def create_qualified_name(outer_variable, component_name)
533
- if outer_variable.named?
534
- "#{outer_variable.name}#{component_name}"
523
+ def create_qualified_name(outer_var, component_name)
524
+ if outer_var.named?
525
+ "#{outer_var.name}#{component_name}"
535
526
  else
536
527
  "__adlint__tempvar#{component_name}"
537
528
  end
@@ -539,12 +530,12 @@ module C #:nodoc:
539
530
  end
540
531
 
541
532
  class ArrayElementVariable < InnerVariable
542
- def self.component_name_of(index)
543
- "[#{index}]"
533
+ def self.component_name_of(idx)
534
+ "[#{idx}]"
544
535
  end
545
536
 
546
- def initialize(memory, outer_variable, type, index)
547
- super(memory, outer_variable, type, self.class.component_name_of(index))
537
+ def initialize(mem, outer_var, type, idx)
538
+ super(mem, outer_var, type, self.class.component_name_of(idx))
548
539
  end
549
540
  end
550
541
 
@@ -553,29 +544,29 @@ module C #:nodoc:
553
544
  ".#{name}"
554
545
  end
555
546
 
556
- def initialize(memory, outer_variable, type, name)
557
- super(memory, outer_variable, type, self.class.component_name_of(name))
547
+ def initialize(mem, outer_var, type, name)
548
+ super(mem, outer_var, type, self.class.component_name_of(name))
558
549
  end
559
550
  end
560
551
 
561
552
  class AliasVariable < NamedVariable
562
- def initialize(variable)
563
- super(variable.binding.memory,
564
- variable.declarations_and_definitions.first, variable.scope)
553
+ def initialize(var)
554
+ super(var.binding.memory,
555
+ var.declarations_and_definitions.first, var.scope)
565
556
  end
566
557
 
567
558
  private
568
- def relate_to_memory(memory)
569
- be_alias_to(memory)
559
+ def relate_to_memory(mem)
560
+ be_alias_to(mem)
570
561
  end
571
562
  end
572
563
 
573
564
  class VariableTable
574
- def initialize(memory_pool)
575
- @memory_pool = memory_pool
565
+ def initialize(mem_pool)
566
+ @memory_pool = mem_pool
576
567
  @named_variables = [{}]
577
- @temporary_variables = [[]]
578
- @scope_stack = [GlobalScope.new]
568
+ @temp_variables = [[]]
569
+ @scope_stack = [GlobalScope.new]
579
570
  end
580
571
 
581
572
  def all_named_variables
@@ -584,69 +575,69 @@ module C #:nodoc:
584
575
 
585
576
  def enter_scope
586
577
  @named_variables.push({})
587
- @temporary_variables.push([])
578
+ @temp_variables.push([])
588
579
  @scope_stack.push(Scope.new(@scope_stack.size))
589
580
  end
590
581
 
591
582
  def leave_scope
592
- @named_variables.pop.each_value do |variable|
593
- @memory_pool.free(variable.binding.memory)
583
+ @named_variables.pop.each_value do |var|
584
+ @memory_pool.free(var.binding.memory)
594
585
  end
595
- @temporary_variables.pop.each do |variable|
596
- @memory_pool.free(variable.binding.memory)
586
+ @temp_variables.pop.each do |var|
587
+ @memory_pool.free(var.binding.memory)
597
588
  end
589
+
598
590
  @scope_stack.pop
599
591
  rollback_all_global_variables_value! if current_scope.global?
600
592
  end
601
593
 
602
- def declare(declaration)
603
- if variable = lookup(declaration.identifier.value)
604
- variable.declarations_and_definitions.push(declaration)
605
- return variable
594
+ def declare(dcl)
595
+ if var = lookup(dcl.identifier.value)
596
+ var.declarations_and_definitions.push(dcl)
597
+ return var
606
598
  end
607
599
 
608
600
  # NOTE: External variable may have undefined values.
609
- define_variable(declaration, declaration.type,
610
- allocate_memory(declaration),
611
- declaration.type.undefined_value)
601
+ define_variable(dcl, dcl.type, allocate_memory(dcl),
602
+ dcl.type.undefined_value)
612
603
  end
613
604
 
614
- def define(definition, init_value = nil)
615
- if storage_duration_of(definition) == :static
605
+ def define(dcl_or_def, init_val = nil)
606
+ if storage_duration_of(dcl_or_def) == :static
616
607
  # NOTE: Value of the static duration object should be arbitrary because
617
608
  # execution of its accessors are out of order.
618
609
  # So, a value of the initializer should be ignored.
619
- init_value = definition.type.arbitrary_value
610
+ init_val = dcl_or_def.type.arbitrary_value
620
611
  else
621
- init_value ||= definition.type.undefined_value
612
+ init_val ||= dcl_or_def.type.undefined_value
622
613
  end
623
614
 
624
- if variable = lookup(definition.identifier.value)
625
- if variable.scope == current_scope
626
- variable.declarations_and_definitions.push(definition)
627
- variable.assign!(init_value)
628
- return variable
615
+ if var = lookup(dcl_or_def.identifier.value)
616
+ if var.scope == current_scope
617
+ var.declarations_and_definitions.push(dcl_or_def)
618
+ var.assign!(init_val)
619
+ return var
629
620
  end
630
621
  end
631
622
 
632
623
  # NOTE: Domain of the init-value will be restricted by type's min-max in
633
624
  # define_variable.
634
- define_variable(definition, definition.type,
635
- allocate_memory(definition), init_value)
625
+ define_variable(dcl_or_def, dcl_or_def.type,
626
+ allocate_memory(dcl_or_def), init_val)
636
627
  end
637
628
 
638
- def define_temporary(type, init_value)
639
- memory = @memory_pool.allocate_dynamic(type.aligned_byte_size)
629
+ def define_temporary(type, init_val)
630
+ mem = @memory_pool.allocate_dynamic(type.aligned_byte_size)
640
631
 
641
632
  # NOTE: Domain of the init-value will be restricted by type's min-max in
642
633
  # define_variable.
643
- define_variable(nil, type, memory, init_value)
634
+ define_variable(nil, type, mem, init_val)
644
635
  end
645
636
 
646
637
  def lookup(name_str)
647
638
  @named_variables.reverse_each do |hash|
648
- if variable = hash[name_str]
649
- return variable
639
+ if var = hash[name_str]
640
+ return var
650
641
  end
651
642
  end
652
643
  nil
@@ -654,39 +645,37 @@ module C #:nodoc:
654
645
 
655
646
  def enter_variables_value_versioning_group
656
647
  @named_variables.each do |hash|
657
- hash.each_value { |variable| variable.enter_value_versioning_group }
648
+ hash.each_value { |var| var.enter_value_versioning_group }
658
649
  end
659
650
  end
660
651
 
661
652
  def leave_variables_value_versioning_group(raise_complement)
662
653
  @named_variables.each do |hash|
663
- hash.each_value do |variable|
664
- variable.leave_value_versioning_group(raise_complement)
654
+ hash.each_value do |var|
655
+ var.leave_value_versioning_group(raise_complement)
665
656
  end
666
657
  end
667
658
  end
668
659
 
669
660
  def begin_variables_value_versioning
670
661
  @named_variables.each do |hash|
671
- hash.each_value { |variable| variable.begin_value_versioning }
662
+ hash.each_value { |var| var.begin_value_versioning }
672
663
  end
673
664
  end
674
665
 
675
666
  def end_variables_value_versioning
676
667
  @named_variables.each do |hash|
677
- hash.each_value { |variable| variable.end_value_versioning }
668
+ hash.each_value { |var| var.end_value_versioning }
678
669
  end
679
670
  end
680
671
 
681
672
  def thin_latest_variables_value_version!(with_rollback)
682
673
  @named_variables.each do |hash|
683
- hash.each_value do |variable|
684
- variable.thin_latest_value_version!(with_rollback)
685
- end
674
+ hash.each_value { |var| var.thin_latest_value_version!(with_rollback) }
686
675
  end
687
676
  end
688
677
 
689
- def storage_duration_of(declaration_or_definition)
678
+ def storage_duration_of(dcl_or_def)
690
679
  # NOTE: The ISO C99 standard says;
691
680
  #
692
681
  # 6.2.2 Linkages of identifiers
@@ -734,9 +723,8 @@ module C #:nodoc:
734
723
  # 4 An object whose identifier is declared with no linkage and without
735
724
  # the storage-class specifier static has automatic storage duration.
736
725
 
737
- sc_specifier = declaration_or_definition.storage_class_specifier
738
- if sc_specifier &&
739
- (sc_specifier.type == :EXTERN || sc_specifier.type == :STATIC)
726
+ if sc_spec = dcl_or_def.storage_class_specifier and
727
+ sc_spec.type == :EXTERN || sc_spec.type == :STATIC
740
728
  :static
741
729
  else
742
730
  current_scope.global? ? :static : :automatic
@@ -744,33 +732,33 @@ module C #:nodoc:
744
732
  end
745
733
 
746
734
  private
747
- def define_variable(declaration_or_definition, type, memory, init_value)
748
- variable = create_variable(declaration_or_definition, type, memory)
749
- variable.assign!(init_value)
735
+ def define_variable(dcl_or_def, type, mem, init_val)
736
+ var = create_variable(dcl_or_def, type, mem)
737
+ var.assign!(init_val)
750
738
 
751
- if variable.named?
752
- @named_variables.last[variable.name] = variable
739
+ if var.named?
740
+ @named_variables.last[var.name] = var
753
741
  else
754
- @temporary_variables.last.push(variable)
742
+ @temp_variables.last.push(var)
755
743
  end
756
744
 
757
- variable
745
+ var
758
746
  end
759
747
 
760
- def allocate_memory(declaration_or_definition)
761
- byte_size = declaration_or_definition.type.aligned_byte_size
762
- if storage_duration_of(declaration_or_definition) == :static
748
+ def allocate_memory(dcl_or_def)
749
+ byte_size = dcl_or_def.type.aligned_byte_size
750
+ if storage_duration_of(dcl_or_def) == :static
763
751
  @memory_pool.allocate_static(byte_size)
764
752
  else
765
753
  @memory_pool.allocate_dynamic(byte_size)
766
754
  end
767
755
  end
768
756
 
769
- def create_variable(declaration_or_definition, type, memory)
770
- if declaration_or_definition
771
- NamedVariable.new(memory, declaration_or_definition, current_scope)
757
+ def create_variable(dcl_or_def, type, mem)
758
+ if dcl_or_def
759
+ NamedVariable.new(mem, dcl_or_def, current_scope)
772
760
  else
773
- TemporaryVariable.new(memory, type, current_scope)
761
+ TemporaryVariable.new(mem, type, current_scope)
774
762
  end
775
763
  end
776
764
 
@@ -779,8 +767,8 @@ module C #:nodoc:
779
767
  end
780
768
 
781
769
  def rollback_all_global_variables_value!
782
- @named_variables.first.each_value do |variable|
783
- variable.rollback_all_value_versions!
770
+ @named_variables.first.each_value do |var|
771
+ var.rollback_all_value_versions!
784
772
  end
785
773
  end
786
774
  end
@@ -788,14 +776,14 @@ module C #:nodoc:
788
776
  # == DESCRIPTION
789
777
  # === Function class hierarchy
790
778
  # Function
791
- # <--- NamedFunction --- Nameable <<module>>
792
- # <--- ExplicitFunction
793
- # <--- ImplicitFunction
794
- # <--- BuiltinFunction
795
- # <--- AnonymousFunction
779
+ # <-- NamedFunction ------> Nameable <<module>>
780
+ # <-- ExplicitFunction
781
+ # <-- ImplicitFunction
782
+ # <-- BuiltinFunction
783
+ # <-- AnonymousFunction
796
784
  class Function < TypedObject
797
- def initialize(declaration_or_definition, type)
798
- super(type, declaration_or_definition)
785
+ def initialize(dcl_or_def, type)
786
+ super(type, dcl_or_def)
799
787
  end
800
788
 
801
789
  def name
@@ -830,15 +818,15 @@ module C #:nodoc:
830
818
  subclass_responsibility
831
819
  end
832
820
 
833
- def call(interpreter, funcall_expr, args)
834
- assign_arguments_to_parameters(interpreter, args)
835
- return_values_via_pointer_arguments(interpreter, funcall_expr, args)
821
+ def call(interp, funcall_expr, args)
822
+ assign_arguments_to_parameters(interp, args)
823
+ return_values_via_pointer_arguments(interp, funcall_expr, args)
836
824
 
837
825
  if type.return_type.function?
838
- interpreter.create_tempvar
826
+ interp.create_tmpvar
839
827
  else
840
- return_type = type.return_type
841
- interpreter.create_tempvar(return_type, return_type.return_value)
828
+ retn_type = type.return_type
829
+ interp.create_tmpvar(retn_type, retn_type.return_value)
842
830
  end
843
831
  end
844
832
 
@@ -847,44 +835,44 @@ module C #:nodoc:
847
835
  end
848
836
 
849
837
  private
850
- def assign_arguments_to_parameters(interpreter, args)
838
+ def assign_arguments_to_parameters(interp, args)
851
839
  args.zip(type.parameter_types).each do |(arg, expr), param_type|
852
840
  if param_type
853
841
  case
854
842
  when arg.type.array? && param_type.pointer?
855
- arg_value = interpreter.pointer_value_of(arg)
856
- converted = interpreter.create_tempvar(param_type, arg_value)
843
+ conved = interp.create_tmpvar(param_type,
844
+ interp.pointer_value_of(arg))
857
845
  when arg.type.pointer? && param_type.array?
858
- converted = interpreter.pointee_of(arg)
846
+ conved = interp.pointee_of(arg)
859
847
  when arg.type.function? && param_type.pointer?
860
- arg_value = interpreter.pointer_value_of(arg)
861
- converted = interpreter.create_tempvar(param_type, arg_value)
848
+ conved = interp.create_tmpvar(param_type,
849
+ interp.pointer_value_of(arg))
862
850
  when arg.variable? && !arg.type.same_as?(param_type)
863
- converted = interpreter.do_conversion(arg, param_type) ||
864
- interpreter.create_tempvar(param_type)
851
+ conved = interp.do_conversion(arg, param_type) ||
852
+ interp.create_tmpvar(param_type)
865
853
  else
866
- converted = arg
854
+ conved = arg
867
855
  end
868
856
  else
869
- converted = interpreter.do_default_argument_promotion(arg)
857
+ conved = interp.do_default_argument_promotion(arg)
870
858
  end
871
859
 
872
860
  # NOTE: Value of the argument is referred when the assignment to the
873
861
  # parameter is performed.
874
862
  if arg.variable? && !arg.type.array?
875
- interpreter.notify_variable_value_referred(expr, arg)
863
+ interp.notify_variable_value_referred(expr, arg)
876
864
  end
877
865
 
878
- if converted && arg != converted
879
- interpreter.notify_implicit_conv_performed(expr, arg, converted)
866
+ if conved && arg != conved
867
+ interp.notify_implicit_conv_performed(expr, arg, conved)
880
868
  end
881
869
  end
882
870
  end
883
871
 
884
- def return_values_via_pointer_arguments(interpreter, funcall_expr, args)
872
+ def return_values_via_pointer_arguments(interp, funcall_expr, args)
885
873
  args.zip(type.parameter_types).each do |(arg, expr), param_type|
886
874
  next if param_type && param_type.void?
887
- next unless arg.variable? && (arg.type.pointer? || arg.type.array?)
875
+ next unless arg.variable? and arg.type.pointer? || arg.type.array?
888
876
 
889
877
  param_type = param_type.unqualify if param_type
890
878
 
@@ -898,7 +886,7 @@ module C #:nodoc:
898
886
 
899
887
  case
900
888
  when arg.type.pointer?
901
- pointee = interpreter.pointee_of(arg)
889
+ pointee = interp.pointee_of(arg)
902
890
  if pointee && pointee.designated_by_lvalue? && pointee.variable?
903
891
  sink = pointee
904
892
  else
@@ -909,14 +897,14 @@ module C #:nodoc:
909
897
  end
910
898
 
911
899
  sink.assign!(sink.type.return_value)
912
- interpreter.notify_variable_value_updated(expr, sink)
900
+ interp.notify_variable_value_updated(expr, sink)
913
901
 
914
902
  # NOTE: Returning a value via a pointer parameter can be considered as
915
903
  # an evaluation of a statement-expression with a
916
904
  # simple-assignment-expression.
917
905
  # Control will reach to a sequence-point at the end of a full
918
906
  # expression.
919
- interpreter.notify_sequence_point_reached(
907
+ interp.notify_sequence_point_reached(
920
908
  SequencePoint.new(funcall_expr, false))
921
909
  end
922
910
  end
@@ -925,9 +913,8 @@ module C #:nodoc:
925
913
  class NamedFunction < Function
926
914
  include Nameable
927
915
 
928
- def initialize(declaration_or_definition, type, name)
929
- super(declaration_or_definition, type)
930
-
916
+ def initialize(dcl_or_def, type, name)
917
+ super(dcl_or_def, type)
931
918
  self.name = name
932
919
  end
933
920
 
@@ -935,7 +922,7 @@ module C #:nodoc:
935
922
  true
936
923
  end
937
924
 
938
- def call(interpreter, funcall_expr, args)
925
+ def call(*)
939
926
  case name
940
927
  when "exit", "_exit", "abort"
941
928
  BreakEvent.of_return.throw
@@ -952,9 +939,8 @@ module C #:nodoc:
952
939
  end
953
940
 
954
941
  class ExplicitFunction < NamedFunction
955
- def initialize(declaration_or_definition)
956
- super(declaration_or_definition, declaration_or_definition.type,
957
- declaration_or_definition.identifier.value)
942
+ def initialize(dcl_or_def)
943
+ super(dcl_or_def, dcl_or_def.type, dcl_or_def.identifier.value)
958
944
  end
959
945
 
960
946
  def explicit?
@@ -998,14 +984,14 @@ module C #:nodoc:
998
984
  end
999
985
 
1000
986
  def signature
1001
- FunctionSignature.new("__adlint__anonymous_func", type)
987
+ FunctionSignature.new("__adlint__anon_func", type)
1002
988
  end
1003
989
  end
1004
990
 
1005
991
  class FunctionTable
1006
- def initialize(memory_pool)
1007
- @memory_pool = memory_pool
1008
- @functions = [{}]
992
+ def initialize(mem_pool)
993
+ @memory_pool = mem_pool
994
+ @functions = [{}]
1009
995
  @scope_stack = [GlobalScope.new]
1010
996
  end
1011
997
 
@@ -1015,34 +1001,46 @@ module C #:nodoc:
1015
1001
  end
1016
1002
 
1017
1003
  def leave_scope
1018
- @functions.pop.each_value do |function|
1019
- @memory_pool.free(function.binding.memory)
1004
+ @functions.pop.each_value do |fun|
1005
+ @memory_pool.free(fun.binding.memory)
1020
1006
  end
1021
1007
  @scope_stack.pop
1022
1008
  end
1023
1009
 
1024
- def declare(declaration)
1025
- if function = lookup(declaration.identifier.value)
1026
- function.declarations_and_definitions.push(declaration)
1027
- return function
1010
+ def declare_explicitly(dcl)
1011
+ if fun = lookup(dcl.identifier.value) and fun.explicit?
1012
+ fun.declarations_and_definitions.push(dcl)
1013
+ return fun
1028
1014
  end
1029
1015
 
1030
- define(ExplicitFunction.new(declaration))
1016
+ define(ExplicitFunction.new(dcl))
1031
1017
  end
1032
1018
 
1033
- def define(function)
1019
+ def declare_implicitly(fun)
1020
+ if fun.named? && fun.implicit?
1021
+ define(fun, true)
1022
+ end
1023
+ fun
1024
+ end
1025
+
1026
+ def define(fun, in_global_scope = false)
1034
1027
  # NOTE: A function has a starting address in the TEXT segment.
1035
1028
  # This is ad-hoc implementation, but it's enough for analysis.
1036
- function.bind_to(@memory_pool.allocate_static(0))
1029
+ fun.bind_to(@memory_pool.allocate_static(0))
1037
1030
 
1038
- @functions.last[function.name] = function if function.named?
1039
- function
1031
+ if in_global_scope
1032
+ @functions.first[fun.name] = fun
1033
+ else
1034
+ @functions.last[fun.name] = fun if fun.named?
1035
+ end
1036
+
1037
+ fun
1040
1038
  end
1041
1039
 
1042
1040
  def lookup(name_str)
1043
1041
  @functions.reverse_each do |hash|
1044
- if function = hash[name_str]
1045
- return function
1042
+ if fun = hash[name_str]
1043
+ return fun
1046
1044
  end
1047
1045
  end
1048
1046
  nil
@@ -1052,10 +1050,10 @@ module C #:nodoc:
1052
1050
  class Memory
1053
1051
  include Bindable
1054
1052
 
1055
- def initialize(address, byte_size)
1056
- @address = address
1053
+ def initialize(addr, byte_size)
1054
+ @address = addr
1057
1055
  @byte_size = byte_size
1058
- @value = nil
1056
+ @value = nil
1059
1057
  end
1060
1058
 
1061
1059
  attr_reader :address
@@ -1073,39 +1071,38 @@ module C #:nodoc:
1073
1071
  @value
1074
1072
  end
1075
1073
 
1076
- def write(value)
1074
+ def write(val)
1077
1075
  if @value
1078
- @value.overwrite!(value)
1076
+ @value.overwrite!(val)
1079
1077
  else
1080
- @value = VersionedValue.new(value)
1078
+ @value = VersionedValue.new(val)
1081
1079
  end
1082
1080
  end
1083
1081
  end
1084
1082
 
1085
1083
  class MemoryBlock < Memory
1086
- def initialize(address, byte_size)
1084
+ def initialize(addr, byte_size)
1087
1085
  super
1088
-
1089
1086
  @windows = []
1090
1087
  end
1091
1088
 
1092
1089
  attr_reader :windows
1093
1090
 
1094
1091
  def create_window(offset, byte_size)
1095
- window = MemoryWindow.new(self, @address + offset, byte_size)
1096
- window.on_written += method(:handle_written_through_window)
1097
- @windows.push(window)
1098
- window
1092
+ win = MemoryWindow.new(self, @address + offset, byte_size)
1093
+ win.on_written += method(:handle_written_through_window)
1094
+ @windows.push(win)
1095
+ win
1099
1096
  end
1100
1097
 
1101
- def write(value)
1098
+ def write(val)
1102
1099
  super
1103
1100
  if !@windows.empty? and
1104
- @value.array? && value.array? or
1105
- @value.composite? && value.composite?
1106
- single_value = value.to_single_value
1107
- @windows.zip(single_value.values).each do |window, inner_value|
1108
- window.write(inner_value, false)
1101
+ @value.array? && val.array? or
1102
+ @value.composite? && val.composite?
1103
+ single_val = val.to_single_value
1104
+ @windows.zip(single_val.values).each do |win, inner_val|
1105
+ win.write(inner_val, false)
1109
1106
  end
1110
1107
  end
1111
1108
  end
@@ -1123,20 +1120,20 @@ module C #:nodoc:
1123
1120
  end
1124
1121
 
1125
1122
  private
1126
- def handle_written_through_window(window)
1127
- value = create_value_from_windows
1123
+ def handle_written_through_window(*)
1124
+ val = create_value_from_windows
1128
1125
 
1129
1126
  if @value
1130
- @value.overwrite!(value)
1127
+ @value.overwrite!(val)
1131
1128
  else
1132
- @value = VersionedValue.new(value)
1129
+ @value = VersionedValue.new(val)
1133
1130
  end
1134
1131
  end
1135
1132
  end
1136
1133
 
1137
1134
  class MemoryWindow < MemoryBlock
1138
- def initialize(owner, address, byte_size)
1139
- super(address, byte_size)
1135
+ def initialize(owner, addr, byte_size)
1136
+ super(addr, byte_size)
1140
1137
  @owner = owner
1141
1138
  end
1142
1139
 
@@ -1152,13 +1149,13 @@ module C #:nodoc:
1152
1149
  @owner.dynamic?
1153
1150
  end
1154
1151
 
1155
- def write(value, cascade = true)
1156
- super(value)
1152
+ def write(val, cascade = true)
1153
+ super(val)
1157
1154
  on_written.invoke(self) if cascade
1158
1155
  end
1159
1156
 
1160
1157
  private
1161
- def handle_written_through_window(window)
1158
+ def handle_written_through_window(*)
1162
1159
  super
1163
1160
  on_written.invoke(self)
1164
1161
  end
@@ -1186,40 +1183,40 @@ module C #:nodoc:
1186
1183
 
1187
1184
  class MemoryPool
1188
1185
  def initialize
1189
- @memory_blocks = {}
1186
+ @memory_blocks = {}
1190
1187
  @address_ranges = []
1191
1188
  # NOTE: To make room for NULL and controlling expressions.
1192
1189
  @free_address = 10
1193
1190
  end
1194
1191
 
1195
1192
  def allocate_static(byte_size)
1196
- memory_block = StaticMemoryBlock.new(@free_address, byte_size)
1193
+ mem_block = StaticMemoryBlock.new(@free_address, byte_size)
1197
1194
  @free_address += allocating_byte_size(byte_size)
1198
- @memory_blocks[memory_block.address] = memory_block
1199
- @address_ranges.push(memory_block.address...@free_address)
1200
- memory_block
1195
+ @memory_blocks[mem_block.address] = mem_block
1196
+ @address_ranges.push(mem_block.address...@free_address)
1197
+ mem_block
1201
1198
  end
1202
1199
 
1203
1200
  def allocate_dynamic(byte_size)
1204
- memory_block = DynamicMemoryBlock.new(@free_address, byte_size)
1201
+ mem_block = DynamicMemoryBlock.new(@free_address, byte_size)
1205
1202
  @free_address += allocating_byte_size(byte_size)
1206
- @memory_blocks[memory_block.address] = memory_block
1207
- @address_ranges.push(memory_block.address...@free_address)
1208
- memory_block
1203
+ @memory_blocks[mem_block.address] = mem_block
1204
+ @address_ranges.push(mem_block.address...@free_address)
1205
+ mem_block
1209
1206
  end
1210
1207
 
1211
- def free(memory_block)
1212
- @memory_blocks.delete(memory_block.address)
1213
- @address_ranges.reject! { |range| range.include?(memory_block.address) }
1208
+ def free(mem_block)
1209
+ @memory_blocks.delete(mem_block.address)
1210
+ @address_ranges.reject! { |range| range.include?(mem_block.address) }
1214
1211
  end
1215
1212
 
1216
- def lookup(address)
1217
- if memory_block = @memory_blocks[address]
1218
- return memory_block
1213
+ def lookup(addr)
1214
+ if mem_block = @memory_blocks[addr]
1215
+ return mem_block
1219
1216
  else
1220
- if addr_range = @address_ranges.find { |r| r.include?(address) }
1221
- memory_block = @memory_blocks[addr_range.first]
1222
- return memory_block.windows.find { |w| w.address == address }
1217
+ if addr_range = @address_ranges.find { |r| r.include?(addr) }
1218
+ mem_block = @memory_blocks[addr_range.first]
1219
+ return mem_block.windows.find { |w| w.address == addr }
1223
1220
  end
1224
1221
  end
1225
1222
  nil