adlint 2.6.14 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -3
- data/ChangeLog +511 -0
- data/INSTALL +1 -1
- data/MANIFEST +57 -37
- data/NEWS +36 -7
- data/README +2 -2
- data/Rakefile +6 -6
- data/TODO +1 -1
- data/bin/adlint +25 -16
- data/bin/adlint_chk +22 -12
- data/bin/adlint_cma +17 -12
- data/bin/adlint_sma +22 -12
- data/bin/adlintize +98 -17
- data/etc/conf.d/fallback/cinit.erb +1 -1
- data/etc/conf.d/fallback/traits.erb +37 -37
- data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +1 -1
- data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +41 -41
- data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +1 -1
- data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +40 -40
- data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +1 -1
- data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +40 -40
- data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +1 -1
- data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +40 -40
- data/etc/conf.d/noarch/GNUmakefile.erb +1 -1
- data/etc/conf.d/noarch/adlint_all_bat.erb +1 -1
- data/etc/conf.d/noarch/adlint_all_sh.erb +1 -1
- data/etc/conf.d/noarch/pinit.erb +1 -1
- data/etc/conf.d/x86_64-ubuntu_12.04/cinit-gcc_4.6.3.erb +1 -1
- data/etc/conf.d/x86_64-ubuntu_12.04/traits-gcc_4.6.3.erb +42 -42
- data/etc/mesg.d/c_builtin/en_US/messages.yml +33 -33
- data/etc/mesg.d/c_builtin/ja_JP/messages.yml +5 -5
- data/etc/mesg.d/core/en_US/messages.yml +2 -2
- data/etc/mesg.d/core/ja_JP/messages.yml +2 -2
- data/features/code_check/W0018.feature +197 -0
- data/features/code_check/W0019.feature +79 -0
- data/features/code_check/W0021.feature +81 -0
- data/features/code_check/W0023.feature +203 -0
- data/features/code_check/W0024.feature +226 -0
- data/features/code_check/W0025.feature +5 -0
- data/features/code_check/W0088.feature +2 -2
- data/features/code_check/W0109.feature +2 -2
- data/features/code_check/W0477.feature +0 -3
- data/features/code_check/W0478.feature +0 -1
- data/features/code_check/W0582.feature +3 -3
- data/features/code_check/W0583.feature +4 -7
- data/features/code_check/W0646.feature +0 -1
- data/features/code_check/W0695.feature +0 -1
- data/features/code_check/W0705.feature +8 -0
- data/features/code_check/W0723.feature +0 -1
- data/features/code_check/W0745.feature +1 -0
- data/features/code_check/W0781.feature +1 -0
- data/features/code_check/W1057.feature +141 -0
- data/features/code_check/W1058.feature +93 -0
- data/features/code_check/W1059.feature +86 -0
- data/features/code_check/W1060.feature +77 -0
- data/features/code_check/W1061.feature +143 -0
- data/features/code_check/W1062.feature +162 -0
- data/features/code_check/W1063.feature +123 -0
- data/features/code_check/W1064.feature +83 -0
- data/features/code_check/W1065.feature +82 -0
- data/features/code_check/W9003.feature +2 -0
- data/features/step_definitions/code_check_steps.rb +1 -0
- data/features/support/env.rb +16 -13
- data/lib/adlint.rb +7 -4
- data/lib/adlint/analyzer.rb +131 -157
- data/lib/adlint/annot.rb +149 -0
- data/lib/adlint/cc1.rb +57 -0
- data/lib/adlint/{c → cc1}/branch.rb +74 -62
- data/lib/adlint/{c → cc1}/builtin.rb +21 -21
- data/lib/adlint/{c → cc1}/const.rb +119 -117
- data/lib/adlint/{c → cc1}/conv.rb +76 -78
- data/lib/adlint/{c → cc1}/ctrlexpr.rb +69 -86
- data/lib/adlint/cc1/domain.rb +8103 -0
- data/lib/adlint/{c → cc1}/enum.rb +3 -3
- data/lib/adlint/{c → cc1}/environ.rb +21 -21
- data/lib/adlint/{c → cc1}/expr.rb +232 -218
- data/lib/adlint/{c → cc1}/format.rb +305 -342
- data/lib/adlint/{c → cc1}/interp.rb +269 -220
- data/lib/adlint/cc1/lexer.rb +246 -0
- data/lib/adlint/{c → cc1}/mediator.rb +78 -84
- data/lib/adlint/{c → cc1}/object.rb +261 -264
- data/lib/adlint/{c → cc1}/operator.rb +7 -7
- data/lib/adlint/{c → cc1}/option.rb +4 -3
- data/lib/adlint/{c → cc1}/parser.rb +274 -506
- data/lib/adlint/{c → cc1}/parser.y +69 -301
- data/lib/adlint/cc1/phase.rb +138 -0
- data/lib/adlint/{c → cc1}/resolver.rb +66 -78
- data/lib/adlint/{c → cc1}/scanner.rb +57 -49
- data/lib/adlint/{c → cc1}/scope.rb +3 -3
- data/lib/adlint/{c → cc1}/seqp.rb +13 -5
- data/lib/adlint/{c → cc1}/syntax.rb +819 -1122
- data/lib/adlint/{c → cc1}/type.rb +1498 -1479
- data/lib/adlint/{c → cc1}/util.rb +20 -12
- data/lib/adlint/{c → cc1}/value.rb +699 -642
- data/lib/adlint/code.rb +163 -164
- data/lib/adlint/cpp.rb +2 -2
- data/lib/adlint/cpp/asm.rb +13 -14
- data/lib/adlint/cpp/constexpr.rb +42 -38
- data/lib/adlint/cpp/constexpr.y +44 -40
- data/lib/adlint/cpp/eval.rb +435 -435
- data/lib/adlint/cpp/lexer.rb +343 -340
- data/lib/adlint/cpp/macro.rb +188 -190
- data/lib/adlint/cpp/phase.rb +66 -45
- data/lib/adlint/cpp/scanner.rb +14 -17
- data/lib/adlint/cpp/source.rb +49 -55
- data/lib/adlint/cpp/subst.rb +65 -65
- data/lib/adlint/cpp/syntax.rb +155 -275
- data/lib/adlint/cpp/util.rb +22 -19
- data/lib/adlint/driver.rb +86 -93
- data/lib/adlint/error.rb +33 -52
- data/lib/adlint/exam.rb +158 -24
- data/lib/adlint/exam/c_builtin.rb +7 -7
- data/lib/adlint/exam/c_builtin/cc1_check.rb +20522 -0
- data/lib/adlint/exam/c_builtin/cc1_check_shima.rb +957 -0
- data/lib/adlint/exam/c_builtin/cc1_code.rb +459 -0
- data/lib/adlint/exam/c_builtin/cc1_metric.rb +794 -0
- data/lib/adlint/exam/c_builtin/cpp_check.rb +486 -441
- data/lib/adlint/exam/c_builtin/cpp_check_shima.rb +36 -39
- data/lib/adlint/exam/c_builtin/cpp_code.rb +63 -65
- data/lib/adlint/exam/c_builtin/ld_check.rb +136 -129
- data/lib/adlint/exam/c_builtin/ld_metric.rb +11 -11
- data/lib/adlint/lang.rb +25 -25
- data/lib/adlint/ld.rb +2 -2
- data/lib/adlint/ld/object.rb +220 -188
- data/lib/adlint/ld/phase.rb +94 -63
- data/lib/adlint/ld/typedef.rb +22 -11
- data/lib/adlint/ld/util.rb +43 -35
- data/lib/adlint/lexer.rb +59 -56
- data/lib/adlint/location.rb +140 -0
- data/lib/adlint/memo.rb +157 -0
- data/lib/adlint/message.rb +207 -156
- data/lib/adlint/metric.rb +139 -217
- data/lib/adlint/monitor.rb +45 -43
- data/lib/adlint/phase.rb +56 -29
- data/lib/adlint/prelude.rb +66 -54
- data/lib/adlint/report.rb +253 -332
- data/lib/adlint/source.rb +26 -27
- data/lib/adlint/supp.rb +131 -0
- data/lib/adlint/symbol.rb +14 -16
- data/lib/adlint/token.rb +19 -91
- data/lib/adlint/traits.rb +242 -226
- data/lib/adlint/util.rb +116 -205
- data/lib/adlint/version.rb +8 -8
- data/share/HEADER +2 -2
- data/share/doc/developers_guide_ja.html +148 -19
- data/share/doc/developers_guide_ja.texi +141 -11
- data/share/doc/samples/GNUmakefile +1 -1
- data/share/doc/samples/adlint_traits.yml +45 -36
- data/share/doc/users_guide_en.html +1321 -1252
- data/share/doc/users_guide_en.texi +475 -408
- data/share/doc/users_guide_ja.html +1932 -1878
- data/share/doc/users_guide_ja.texi +324 -273
- data/share/sample/bison-2.5/adlint/GNUmakefile +5 -1
- data/share/sample/bison-2.5/adlint/adlint_traits.yml +38 -38
- data/share/sample/bison-2.5/adlint/lib/GNUmakefile +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +1 -1
- data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +50 -42
- data/share/sample/bison-2.5/adlint/src/GNUmakefile +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +1 -1
- data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +50 -42
- data/share/sample/ctags-5.8/adlint/GNUmakefile +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_cinit.h +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_pinit.h +1 -1
- data/share/sample/ctags-5.8/adlint/adlint_traits.yml +50 -42
- data/share/sample/flex-2.5.35/adlint/GNUmakefile +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +1 -1
- data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +46 -38
- data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +50 -42
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +1 -1
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +50 -42
- data/share/sample/screen-4.0.3/adlint/GNUmakefile +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +1 -1
- data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +50 -42
- data/share/sample/vim-7.3/adlint/vim/GNUmakefile +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +1 -1
- data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +50 -42
- data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +1 -1
- data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +49 -41
- data/share/sample/zsh-4.3.15/adlint/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +46 -38
- data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +50 -42
- data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +1 -1
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +50 -42
- data/spec/adlint/{c → cc1}/ctrlexpr_spec.rb +51 -49
- data/spec/adlint/{c → cc1}/domain_spec.rb +210 -179
- data/spec/adlint/{c → cc1}/operator_spec.rb +3 -3
- data/spec/adlint/{c → cc1}/syntax_spec.rb +10 -12
- data/spec/adlint/{c → cc1}/type_spec.rb +61 -68
- data/{lib/adlint/c.rb → spec/adlint/location_spec.rb} +24 -29
- data/spec/conf.d/default_traits.yml +38 -37
- data/spec/conf.d/empty_cinit.h +1 -1
- data/spec/conf.d/empty_pinit.h +1 -1
- data/spec/conf.d/project/foo.c +0 -0
- data/spec/spec_helper.rb +2 -2
- metadata +60 -40
- data/lib/adlint/c/domain.rb +0 -7931
- data/lib/adlint/c/lexer.rb +0 -252
- data/lib/adlint/c/phase.rb +0 -135
- data/lib/adlint/exam/c_builtin/c_check.rb +0 -20745
- data/lib/adlint/exam/c_builtin/c_check_shima.rb +0 -983
- data/lib/adlint/exam/c_builtin/c_code.rb +0 -477
- data/lib/adlint/exam/c_builtin/c_metric.rb +0 -818
@@ -0,0 +1,246 @@
|
|
1
|
+
# Lexical analyzer which retokenizes pp-tokens into c-tokens.
|
2
|
+
#
|
3
|
+
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
4
|
+
# Copyright:: Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
5
|
+
# License:: GPLv3+: GNU General Public License version 3 or later
|
6
|
+
#
|
7
|
+
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
8
|
+
|
9
|
+
#--
|
10
|
+
# ___ ____ __ ___ _________
|
11
|
+
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
12
|
+
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
13
|
+
# / __ |/ /_/ / /___/ / /| / / /
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
15
|
+
#
|
16
|
+
# This file is part of AdLint.
|
17
|
+
#
|
18
|
+
# AdLint is free software: you can redistribute it and/or modify it under the
|
19
|
+
# terms of the GNU General Public License as published by the Free Software
|
20
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
21
|
+
# version.
|
22
|
+
#
|
23
|
+
# AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
|
24
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
25
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
26
|
+
#
|
27
|
+
# You should have received a copy of the GNU General Public License along with
|
28
|
+
# AdLint. If not, see <http://www.gnu.org/licenses/>.
|
29
|
+
#
|
30
|
+
#++
|
31
|
+
|
32
|
+
require "adlint/lexer"
|
33
|
+
require "adlint/util"
|
34
|
+
require "adlint/cc1/scanner"
|
35
|
+
require "adlint/cc1/scope"
|
36
|
+
|
37
|
+
module AdLint #:nodoc:
|
38
|
+
module Cc1 #:nodoc:
|
39
|
+
|
40
|
+
class Lexer < TokensRelexer
|
41
|
+
def initialize(pp_src)
|
42
|
+
super(pp_src.pp_tokens)
|
43
|
+
@lst_tok = nil
|
44
|
+
@nxt_tok = nil
|
45
|
+
@typedef_names = ScopedNameSet.new
|
46
|
+
@object_names = ScopedNameSet.new
|
47
|
+
@identifier_translation = true
|
48
|
+
end
|
49
|
+
|
50
|
+
extend Pluggable
|
51
|
+
|
52
|
+
def_plugin :on_string_literals_concatenated
|
53
|
+
|
54
|
+
def add_typedef_name(tok)
|
55
|
+
@typedef_names.add(tok.value)
|
56
|
+
end
|
57
|
+
|
58
|
+
def add_object_name(tok)
|
59
|
+
@object_names.add(tok.value)
|
60
|
+
end
|
61
|
+
|
62
|
+
def enter_scope
|
63
|
+
@typedef_names.enter_scope
|
64
|
+
@object_names.enter_scope
|
65
|
+
end
|
66
|
+
|
67
|
+
def leave_scope
|
68
|
+
@typedef_names.leave_scope
|
69
|
+
@object_names.leave_scope
|
70
|
+
end
|
71
|
+
|
72
|
+
def start_identifier_translation
|
73
|
+
@identifier_translation = true
|
74
|
+
end
|
75
|
+
|
76
|
+
def stop_identifier_translation
|
77
|
+
@identifier_translation = false
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
def create_lexer_context(tok_ary)
|
82
|
+
LexerContext.new(TokensContent.new(tok_ary))
|
83
|
+
end
|
84
|
+
|
85
|
+
def tokenize(lexer_ctxt)
|
86
|
+
if @nxt_tok
|
87
|
+
tok = @nxt_tok
|
88
|
+
@nxt_tok = nil
|
89
|
+
else
|
90
|
+
until lexer_ctxt.content.empty?
|
91
|
+
pp_tok = lexer_ctxt.content.next_token
|
92
|
+
|
93
|
+
if type_hint = pp_tok.type_hint
|
94
|
+
tok = pp_tok.class.new(type_hint, pp_tok.value, pp_tok.location)
|
95
|
+
else
|
96
|
+
tok = retokenize_keyword(pp_tok, lexer_ctxt) ||
|
97
|
+
retokenize_constant(pp_tok, lexer_ctxt) ||
|
98
|
+
retokenize_string_literal(pp_tok, lexer_ctxt) ||
|
99
|
+
retokenize_null_constant(pp_tok, lexer_ctxt) ||
|
100
|
+
retokenize_identifier(pp_tok, lexer_ctxt) ||
|
101
|
+
retokenize_punctuator(pp_tok, lexer_ctxt)
|
102
|
+
end
|
103
|
+
|
104
|
+
break if tok
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
if tok
|
109
|
+
case tok.type
|
110
|
+
when :IDENTIFIER
|
111
|
+
tok = translate_identifier(tok, lexer_ctxt)
|
112
|
+
when :STRING_LITERAL
|
113
|
+
tok = concat_contiguous_string_literals(tok, lexer_ctxt)
|
114
|
+
end
|
115
|
+
@lst_tok = tok
|
116
|
+
else
|
117
|
+
nil
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def translate_identifier(tok, lexer_ctxt)
|
122
|
+
if @identifier_translation
|
123
|
+
if tok.type == :IDENTIFIER
|
124
|
+
return tok if @object_names.include?(tok.value)
|
125
|
+
if @typedef_names.include?(tok.value)
|
126
|
+
unless @lst_tok and
|
127
|
+
@lst_tok.type == :STRUCT || @lst_tok.type == :UNION ||
|
128
|
+
@lst_tok.type == :ENUM ||
|
129
|
+
@lst_tok.type == "->" || @lst_tok.type == "."
|
130
|
+
tok = tok.class.new(:TYPEDEF_NAME, tok.value, tok.location)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
tok
|
136
|
+
end
|
137
|
+
|
138
|
+
def concat_contiguous_string_literals(tok, lexer_ctxt)
|
139
|
+
until lexer_ctxt.content.empty?
|
140
|
+
nxt_tok = tokenize(lexer_ctxt)
|
141
|
+
if nxt_tok.type == :STRING_LITERAL
|
142
|
+
res_tok = tok.class.new(tok.type, tok.value.sub(/"\z/, "") +
|
143
|
+
nxt_tok.value.sub(/\AL?"/, ""),
|
144
|
+
tok.location)
|
145
|
+
notify_string_literals_concatenated(tok, nxt_tok, res_tok)
|
146
|
+
return res_tok
|
147
|
+
else
|
148
|
+
@nxt_tok = nxt_tok
|
149
|
+
break
|
150
|
+
end
|
151
|
+
end
|
152
|
+
tok
|
153
|
+
end
|
154
|
+
|
155
|
+
def retokenize_keyword(pp_tok, lexer_ctxt)
|
156
|
+
if keyword = Scanner::KEYWORDS[pp_tok.value]
|
157
|
+
pp_tok.class.new(keyword, pp_tok.value, pp_tok.location)
|
158
|
+
else
|
159
|
+
nil
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def retokenize_constant(pp_tok, lexer_ctxt)
|
164
|
+
# NOTE: For extended bit-access operators.
|
165
|
+
return nil if @lst_tok && @lst_tok.type == :IDENTIFIER
|
166
|
+
|
167
|
+
case pp_tok.value
|
168
|
+
when /\AL?'.*'\z/,
|
169
|
+
/\A(?:[0-9]*\.[0-9]+|[0-9]+\.)[FL]*\z/i,
|
170
|
+
/\A(?:[0-9]*\.[0-9]*E[+-]?[0-9]+|[0-9]+\.?E[+-]?[0-9]+)[FL]*\z/i,
|
171
|
+
/\A(?:0x[0-9a-f]+|0b[01]+|[0-9]+)[UL]*\z/i
|
172
|
+
pp_tok.class.new(:CONSTANT, pp_tok.value, pp_tok.location)
|
173
|
+
else
|
174
|
+
nil
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def retokenize_string_literal(pp_tok, lexer_ctxt)
|
179
|
+
if pp_tok.value =~ /\AL?".*"\z/
|
180
|
+
pp_tok.class.new(:STRING_LITERAL, pp_tok.value, pp_tok.location)
|
181
|
+
else
|
182
|
+
nil
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def retokenize_null_constant(pp_tok, lexer_ctxt)
|
187
|
+
if pp_tok.value == "NULL"
|
188
|
+
pp_tok.class.new(:NULL, pp_tok.value, pp_tok.location)
|
189
|
+
else
|
190
|
+
nil
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def retokenize_identifier(pp_tok, lexer_ctxt)
|
195
|
+
if pp_tok.value =~ /\A[a-z_][a-z_0-9]*\z/i
|
196
|
+
pp_tok.class.new(:IDENTIFIER, pp_tok.value, pp_tok.location)
|
197
|
+
else
|
198
|
+
nil
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def retokenize_punctuator(pp_tok, lexer_ctxt)
|
203
|
+
case pp_tok.value
|
204
|
+
when "{", "}", "(", ")", "[", "]", ";", ",", "::", ":", "?", "||",
|
205
|
+
"|=", "|", "&&", "&=", "&", "^=", "^", "==", "=", "!=", "!",
|
206
|
+
"<<=", "<=", "<<", "<", ">>=", ">=", ">>", ">", "+=", "++", "+",
|
207
|
+
"->*", "->", "-=", "--", "-", "*=", "*", "/=", "/", "%=", "%",
|
208
|
+
"...", ".*", ".", "~"
|
209
|
+
pp_tok.class.new(pp_tok.value, pp_tok.value, pp_tok.location)
|
210
|
+
else
|
211
|
+
nil
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def notify_string_literals_concatenated(former, latter, res_tok)
|
216
|
+
on_string_literals_concatenated.invoke(former, latter, res_tok)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
class ScopedNameSet
|
221
|
+
def initialize
|
222
|
+
@name_stack = [Set.new]
|
223
|
+
@scope_stack = [GlobalScope.new]
|
224
|
+
end
|
225
|
+
|
226
|
+
def enter_scope
|
227
|
+
@name_stack.push(Set.new)
|
228
|
+
@scope_stack.push(Scope.new(@scope_stack.size))
|
229
|
+
end
|
230
|
+
|
231
|
+
def leave_scope
|
232
|
+
@name_stack.pop
|
233
|
+
@scope_stack.pop
|
234
|
+
end
|
235
|
+
|
236
|
+
def add(name)
|
237
|
+
@name_stack.last.add(name)
|
238
|
+
end
|
239
|
+
|
240
|
+
def include?(name)
|
241
|
+
@name_stack.any? { |set| set.include?(name) }
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
246
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# C interpreter mediator.
|
2
2
|
#
|
3
3
|
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
4
|
-
# Copyright:: Copyright (C) 2010-
|
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-
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2013, OGIS-RI Co.,Ltd.
|
15
15
|
#
|
16
16
|
# This file is part of AdLint.
|
17
17
|
#
|
@@ -29,16 +29,17 @@
|
|
29
29
|
#
|
30
30
|
#++
|
31
31
|
|
32
|
-
require "adlint/
|
33
|
-
require "adlint/
|
34
|
-
require "adlint/
|
35
|
-
require "adlint/
|
32
|
+
require "adlint/traits"
|
33
|
+
require "adlint/cc1/type"
|
34
|
+
require "adlint/cc1/object"
|
35
|
+
require "adlint/cc1/enum"
|
36
|
+
require "adlint/cc1/syntax"
|
36
37
|
|
37
38
|
module AdLint #:nodoc:
|
38
|
-
module
|
39
|
+
module Cc1 #:nodoc:
|
39
40
|
|
40
41
|
module TypeTableMediator
|
41
|
-
# NOTE:
|
42
|
+
# NOTE: Host class must respond to #type_table.
|
42
43
|
|
43
44
|
include StandardTypeCatalogAccessor
|
44
45
|
|
@@ -46,7 +47,7 @@ module C #:nodoc:
|
|
46
47
|
|
47
48
|
def_delegator :type_table, :lookup, :type_of
|
48
49
|
def_delegator :type_table, :undeclared_type
|
49
|
-
def_delegator :type_table, :
|
50
|
+
def_delegator :type_table, :wchar_t
|
50
51
|
def_delegator :type_table, :array_type
|
51
52
|
def_delegator :type_table, :function_type
|
52
53
|
def_delegator :type_table, :bitfield_type
|
@@ -57,49 +58,38 @@ module C #:nodoc:
|
|
57
58
|
def standard_type_catalog
|
58
59
|
type_table.standard_type_catalog
|
59
60
|
end
|
60
|
-
|
61
|
-
def type_table
|
62
|
-
# NOTE: Host class must respond to #type_table.
|
63
|
-
subclass_responsibility
|
64
|
-
end
|
65
61
|
end
|
66
62
|
|
67
63
|
module MemoryPoolMediator
|
68
|
-
# NOTE:
|
64
|
+
# NOTE: Host class must respond to #memory_pool.
|
69
65
|
|
70
66
|
extend Forwardable
|
71
67
|
|
72
68
|
def_delegator :memory_pool, :lookup, :memory_at
|
73
69
|
|
74
|
-
def pointee_of(
|
70
|
+
def pointee_of(ptr)
|
75
71
|
# FIXME: This method should return multiple objects, because domain of
|
76
72
|
# the pointer_value may have multiple address values.
|
77
73
|
#
|
78
|
-
#
|
79
|
-
#
|
74
|
+
# ptr.value.to_enum.map { |addr|
|
75
|
+
# mem = memory_at(addr) ? mem.binding.object : nil
|
80
76
|
# }.compact
|
81
77
|
|
82
|
-
|
83
|
-
if
|
84
|
-
|
85
|
-
if
|
86
|
-
|
87
|
-
return
|
78
|
+
ptr.value.to_enum.each do |addr|
|
79
|
+
if mem = memory_at(addr)
|
80
|
+
obj = mem.binding.object
|
81
|
+
if obj.variable? or
|
82
|
+
obj.function? && ptr.type.unqualify.base_type.function?
|
83
|
+
return obj
|
88
84
|
end
|
89
85
|
end
|
90
86
|
end
|
91
87
|
nil
|
92
88
|
end
|
93
|
-
|
94
|
-
private
|
95
|
-
def memory_pool
|
96
|
-
# NOTE: Host class must respond to #memory_pool.
|
97
|
-
subclass_responsibility
|
98
|
-
end
|
99
89
|
end
|
100
90
|
|
101
91
|
module VariableTableMediator
|
102
|
-
# NOTE:
|
92
|
+
# NOTE: Host class must respond to #variable_table.
|
103
93
|
|
104
94
|
extend Forwardable
|
105
95
|
|
@@ -109,80 +99,64 @@ module C #:nodoc:
|
|
109
99
|
def_delegator :variable_table, :storage_duration_of
|
110
100
|
|
111
101
|
def local_variables
|
112
|
-
variable_table.all_named_variables.select { |
|
113
|
-
variable.scope.local?
|
114
|
-
}
|
102
|
+
variable_table.all_named_variables.select { |var| var.scope.local? }
|
115
103
|
end
|
116
104
|
|
117
|
-
def
|
118
|
-
variable_table.define_temporary(type,
|
119
|
-
end
|
120
|
-
|
121
|
-
private
|
122
|
-
def variable_table
|
123
|
-
# NOTE: Host class must respond to #variable_table.
|
124
|
-
subclass_responsibility
|
105
|
+
def create_tmpvar(type = undeclared_type, val = type.undefined_value)
|
106
|
+
variable_table.define_temporary(type, val)
|
125
107
|
end
|
126
108
|
end
|
127
109
|
|
128
110
|
module FunctionTableMediator
|
129
111
|
# NOTE: The host class of this module must include TypeTableMediator.
|
130
|
-
# NOTE:
|
112
|
+
# NOTE: Host class must respond to #function_table.
|
131
113
|
|
132
114
|
extend Forwardable
|
133
115
|
|
134
116
|
def_delegator :function_table, :lookup, :function_named
|
135
|
-
def_delegator :function_table, :declare, :declare_function
|
136
|
-
def_delegator :function_table, :define, :define_function
|
137
117
|
|
138
|
-
def
|
139
|
-
|
118
|
+
def declare_explicit_function(fun_dcl)
|
119
|
+
function_table.declare_explicitly(fun_dcl)
|
120
|
+
end
|
121
|
+
|
122
|
+
def declare_implicit_function(name)
|
123
|
+
function_table.declare_implicitly(
|
124
|
+
ImplicitFunction.new(default_function_type, name))
|
140
125
|
end
|
141
126
|
|
142
|
-
def
|
143
|
-
|
127
|
+
def define_explicit_function(fun_dcl_or_def)
|
128
|
+
function_table.define(ExplicitFunction.new(fun_dcl_or_def))
|
144
129
|
end
|
145
130
|
|
146
131
|
def define_anonymous_function(type)
|
147
|
-
|
132
|
+
function_table.define(AnonymousFunction.new(type))
|
148
133
|
end
|
149
134
|
|
150
135
|
private
|
151
136
|
def default_function_type
|
152
|
-
function_type(
|
153
|
-
end
|
154
|
-
|
155
|
-
def function_table
|
156
|
-
# NOTE: Host class must respond to #function_table.
|
157
|
-
subclass_responsibility
|
137
|
+
function_type(int_t, [])
|
158
138
|
end
|
159
139
|
end
|
160
140
|
|
161
141
|
module EnumeratorTableMediator
|
162
|
-
# NOTE:
|
142
|
+
# NOTE: Host class must respond to #enumerator_table.
|
163
143
|
|
164
144
|
extend Forwardable
|
165
145
|
|
166
146
|
def_delegator :enumerator_table, :lookup, :enumerator_named
|
167
147
|
def_delegator :enumerator_table, :define, :define_enumerator
|
168
|
-
|
169
|
-
private
|
170
|
-
def enumerator_table
|
171
|
-
# NOTE: Host class must respond to #enumerator_table.
|
172
|
-
subclass_responsibility
|
173
|
-
end
|
174
148
|
end
|
175
149
|
|
176
150
|
module NotifierMediator
|
177
|
-
# NOTE:
|
151
|
+
# NOTE: Host class must respond to #interpreter.
|
178
152
|
|
179
153
|
extend Forwardable
|
180
154
|
|
181
155
|
def_delegator :interpreter, :notify_variable_declared
|
182
156
|
def_delegator :interpreter, :notify_variable_defined
|
183
157
|
def_delegator :interpreter, :notify_variable_initialized
|
184
|
-
def_delegator :interpreter, :
|
185
|
-
def_delegator :interpreter, :
|
158
|
+
def_delegator :interpreter, :notify_explicit_function_declared
|
159
|
+
def_delegator :interpreter, :notify_explicit_function_defined
|
186
160
|
def_delegator :interpreter, :notify_struct_declared
|
187
161
|
def_delegator :interpreter, :notify_union_declared
|
188
162
|
def_delegator :interpreter, :notify_enum_declared
|
@@ -195,6 +169,7 @@ module C #:nodoc:
|
|
195
169
|
def_delegator :interpreter, :notify_variable_value_referred
|
196
170
|
def_delegator :interpreter, :notify_variable_value_updated
|
197
171
|
def_delegator :interpreter, :notify_function_referred
|
172
|
+
def_delegator :interpreter, :notify_implicit_function_declared
|
198
173
|
def_delegator :interpreter, :notify_sizeof_expr_evaled
|
199
174
|
def_delegator :interpreter, :notify_sizeof_type_expr_evaled
|
200
175
|
def_delegator :interpreter, :notify_explicit_conv_performed
|
@@ -252,25 +227,20 @@ module C #:nodoc:
|
|
252
227
|
def_delegator :interpreter, :notify_translation_unit_started
|
253
228
|
def_delegator :interpreter, :notify_translation_unit_ended
|
254
229
|
def_delegator :interpreter, :notify_sequence_point_reached
|
255
|
-
|
256
|
-
private
|
257
|
-
def interpreter
|
258
|
-
# NOTE: Host class must respond to #interpreter.
|
259
|
-
subclass_responsibility
|
260
|
-
end
|
261
230
|
end
|
262
231
|
|
263
232
|
module InterpreterMediator
|
264
|
-
# NOTE:
|
233
|
+
# NOTE: Host class must respond to #interpreter.
|
265
234
|
|
266
235
|
include TypeTableMediator
|
267
236
|
include MemoryPoolMediator
|
268
237
|
include VariableTableMediator
|
269
238
|
include FunctionTableMediator
|
270
239
|
include EnumeratorTableMediator
|
240
|
+
include ArithmeticAccessor
|
271
241
|
|
272
|
-
def interpret(node, *
|
273
|
-
interpreter.execute(node, *
|
242
|
+
def interpret(node, *opts)
|
243
|
+
interpreter.execute(node, *opts)
|
274
244
|
end
|
275
245
|
|
276
246
|
def reset_environment
|
@@ -283,6 +253,22 @@ module C #:nodoc:
|
|
283
253
|
def_delegator :interpreter, :value_of
|
284
254
|
def_delegator :interpreter, :pointer_value_of
|
285
255
|
|
256
|
+
def scalar_value_of(numeric)
|
257
|
+
ScalarValue.of(numeric, logical_right_shift?)
|
258
|
+
end
|
259
|
+
|
260
|
+
def scalar_value_of_true
|
261
|
+
ScalarValue.of_true(logical_right_shift?)
|
262
|
+
end
|
263
|
+
|
264
|
+
def scalar_value_of_false
|
265
|
+
ScalarValue.of_false(logical_right_shift?)
|
266
|
+
end
|
267
|
+
|
268
|
+
def scalar_value_of_arbitrary
|
269
|
+
ScalarValue.of_arbitrary(logical_right_shift?)
|
270
|
+
end
|
271
|
+
|
286
272
|
private
|
287
273
|
def scoped_eval(&block)
|
288
274
|
environment.enter_scope
|
@@ -291,10 +277,10 @@ module C #:nodoc:
|
|
291
277
|
environment.leave_scope
|
292
278
|
end
|
293
279
|
|
294
|
-
def branched_eval(
|
295
|
-
current_branch = environment.enter_branch(*
|
280
|
+
def branched_eval(expr = nil, *opts, &block)
|
281
|
+
current_branch = environment.enter_branch(*opts)
|
296
282
|
interpreter.notify_branch_started(current_branch)
|
297
|
-
current_branch.execute(interpreter,
|
283
|
+
current_branch.execute(interpreter, expr, &block)
|
298
284
|
ensure
|
299
285
|
interpreter.notify_branch_ended(current_branch)
|
300
286
|
environment.leave_branch_group if current_branch.final?
|
@@ -307,18 +293,26 @@ module C #:nodoc:
|
|
307
293
|
|
308
294
|
extend Forwardable
|
309
295
|
|
310
|
-
def_delegator :interpreter, :environment
|
311
|
-
|
312
296
|
def_delegator :environment, :type_table
|
297
|
+
private :type_table
|
298
|
+
|
313
299
|
def_delegator :environment, :memory_pool
|
300
|
+
private :memory_pool
|
301
|
+
|
314
302
|
def_delegator :environment, :variable_table
|
303
|
+
private :variable_table
|
304
|
+
|
315
305
|
def_delegator :environment, :function_table
|
306
|
+
private :function_table
|
307
|
+
|
316
308
|
def_delegator :environment, :enumerator_table
|
309
|
+
private :enumerator_table
|
317
310
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
311
|
+
def_delegator :interpreter, :environment
|
312
|
+
private :environment
|
313
|
+
|
314
|
+
def_delegator :interpreter, :traits
|
315
|
+
private :traits
|
322
316
|
end
|
323
317
|
|
324
318
|
end
|