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
@@ -1,7 +1,7 @@
|
|
1
1
|
# C runtime scope.
|
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
|
#
|
@@ -30,7 +30,7 @@
|
|
30
30
|
#++
|
31
31
|
|
32
32
|
module AdLint #:nodoc:
|
33
|
-
module
|
33
|
+
module Cc1 #:nodoc:
|
34
34
|
|
35
35
|
class Scope
|
36
36
|
def initialize(depth)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Sequence points of C language evaluation.
|
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,8 +29,10 @@
|
|
29
29
|
#
|
30
30
|
#++
|
31
31
|
|
32
|
+
require "adlint/location"
|
33
|
+
|
32
34
|
module AdLint #:nodoc:
|
33
|
-
module
|
35
|
+
module Cc1 #:nodoc:
|
34
36
|
|
35
37
|
# NOTE: The ISO C99 standard says;
|
36
38
|
#
|
@@ -56,13 +58,19 @@ module C #:nodoc:
|
|
56
58
|
# movement of the objects passed as arguments to that call (7.20.5).
|
57
59
|
|
58
60
|
class SequencePoint
|
59
|
-
|
60
|
-
|
61
|
+
include LocationHolder
|
62
|
+
|
63
|
+
def initialize(lst_node, obvious = true)
|
64
|
+
@last_node = lst_node
|
61
65
|
@obvious = obvious
|
62
66
|
end
|
63
67
|
|
64
68
|
attr_reader :last_node
|
65
69
|
|
70
|
+
def location
|
71
|
+
@last_node.location
|
72
|
+
end
|
73
|
+
|
66
74
|
def obvious?
|
67
75
|
@obvious
|
68
76
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# AST of C language.
|
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
|
#
|
@@ -30,134 +30,137 @@
|
|
30
30
|
#++
|
31
31
|
|
32
32
|
require "adlint/symbol"
|
33
|
+
require "adlint/location"
|
34
|
+
require "adlint/exam"
|
33
35
|
require "adlint/util"
|
34
|
-
require "adlint/
|
35
|
-
require "adlint/
|
36
|
+
require "adlint/cc1/seqp"
|
37
|
+
require "adlint/cc1/operator"
|
36
38
|
|
37
39
|
module AdLint #:nodoc:
|
38
|
-
module
|
40
|
+
module Cc1 #:nodoc:
|
39
41
|
|
40
42
|
# == DESCRIPTION
|
41
43
|
# === SyntaxNode class hierarchy
|
42
44
|
# SyntaxNode
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#
|
114
|
-
#
|
115
|
-
#
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
121
|
-
#
|
122
|
-
#
|
123
|
-
#
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
#
|
132
|
-
#
|
133
|
-
#
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
#
|
143
|
-
#
|
144
|
-
#
|
145
|
-
#
|
146
|
-
#
|
147
|
-
#
|
148
|
-
#
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
153
|
-
#
|
154
|
-
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
45
|
+
# <-- Expression
|
46
|
+
# <-- ErrorExpression
|
47
|
+
# <-- PrimaryExpression
|
48
|
+
# <-- ObjectSpecifier
|
49
|
+
# <-- ConstantSpecifier
|
50
|
+
# <-- StringLiteralSpecifier
|
51
|
+
# <-- NullConstantSpecifier
|
52
|
+
# <-- GroupedExpression
|
53
|
+
# <-- PostfixExpression
|
54
|
+
# <-- ArraySubscriptExpression
|
55
|
+
# <-- FunctionCallExpression
|
56
|
+
# <-- MemberAccessByValueExpression
|
57
|
+
# <-- MemberAccessByPointerExpression
|
58
|
+
# <-- BitAccessByValueExpression
|
59
|
+
# <-- BitAccessByPointerExpression
|
60
|
+
# <-- PostfixIncrementExpression
|
61
|
+
# <-- PostfixDecrementExpression
|
62
|
+
# <-- CompoundLiteralExpression
|
63
|
+
# <-- UnaryExpression
|
64
|
+
# <-- PrefixIncrementExpression
|
65
|
+
# <-- PrefixDecrementExpression
|
66
|
+
# <-- AddressExpression
|
67
|
+
# <-- IndirectionExpression
|
68
|
+
# <-- UnaryArithmeticExpression
|
69
|
+
# <-- SizeofExpression
|
70
|
+
# <-- SizeofTypeExpression
|
71
|
+
# <-- AlignofExpression
|
72
|
+
# <-- AlignofTypeExpression
|
73
|
+
# <-- CastExpression
|
74
|
+
# <-- BinaryExpression
|
75
|
+
# <-- MultiplicativeExpression
|
76
|
+
# <-- AdditiveExpression
|
77
|
+
# <-- ShiftExpression
|
78
|
+
# <-- RelationalExpression
|
79
|
+
# <-- EqualityExpression
|
80
|
+
# <-- AndExpression
|
81
|
+
# <-- ExclusiveOrExpression
|
82
|
+
# <-- InclusiveOrExpression
|
83
|
+
# <-- LogicalAndExpression
|
84
|
+
# <-- LogicalOrExpression
|
85
|
+
# <-- ConditionalExpression
|
86
|
+
# <-- SimpleAssignmentExpression
|
87
|
+
# <-- CompoundAssignmentExpression
|
88
|
+
# <-- CommaSeparatedExpression
|
89
|
+
# <-- Declaration
|
90
|
+
# <-- FunctionDeclaration -------------------- SymbolicElement <<module>>
|
91
|
+
# <-- VariableDeclaration ----------------------+ | | | |
|
92
|
+
# <-- Definition | | | |
|
93
|
+
# <-- VariableDefinition --------------------+ | | |
|
94
|
+
# <-- PseudoVariableDefinition | | |
|
95
|
+
# <-- FunctionDefinition -----------------------+ | |
|
96
|
+
# <-- KandRFunctionDefinition | |
|
97
|
+
# <-- AnsiFunctionDefinition | |
|
98
|
+
# <-- ParameterDefinition | |
|
99
|
+
# <-- TypeDeclaration -----------------------------------+ |
|
100
|
+
# <-- TypedefDeclaration |
|
101
|
+
# <-- StructTypeDeclaration |
|
102
|
+
# <-- PseudoStructTypeDeclaration |
|
103
|
+
# <-- UnionTypeDeclaration |
|
104
|
+
# <-- PseudoUnionTypeDeclaration |
|
105
|
+
# <-- EnumTypeDeclaration |
|
106
|
+
# <-- PseudoEnumTypeDeclaration |
|
107
|
+
# <-- DeclarationSpecifiers |
|
108
|
+
# <-- InitDeclarator |
|
109
|
+
# <-- TypeSpecifier |
|
110
|
+
# <-- StandardTypeSpecifier |
|
111
|
+
# <-- TypedefTypeSpecifier |
|
112
|
+
# <-- StructSpecifier |
|
113
|
+
# <-- UnionSpecifier |
|
114
|
+
# <-- TypeofTypeSpecifier |
|
115
|
+
# <-- StructDeclaration |
|
116
|
+
# <-- MemberDeclaration |
|
117
|
+
# <-- SpecifierQualifierList |
|
118
|
+
# <-- StructDeclarator |
|
119
|
+
# <-- EnumSpecifier |
|
120
|
+
# <-- Enumerator -------------------------------------------+
|
121
|
+
# <-- Declarator
|
122
|
+
# <-- IdentifierDeclarator
|
123
|
+
# <-- GroupedDeclarator
|
124
|
+
# <-- ArrayDeclarator
|
125
|
+
# <-- FunctionDeclarator
|
126
|
+
# <-- AnsiFunctionDeclarator
|
127
|
+
# <-- KandRFunctionDeclarator
|
128
|
+
# <-- AbbreviatedFunctionDeclarator
|
129
|
+
# <-- AbstractDeclarator
|
130
|
+
# <-- PointerAbstractDeclarator
|
131
|
+
# <-- GroupedAbstractDeclarator
|
132
|
+
# <-- ArrayAbstractDeclarator
|
133
|
+
# <-- FunctionAbstractDeclarator
|
134
|
+
# <-- ParameterTypeList
|
135
|
+
# <-- ParameterDeclaration
|
136
|
+
# <-- Statement
|
137
|
+
# <-- ErrorStatement
|
138
|
+
# <-- LabeledStatement
|
139
|
+
# <-- GenericLabeledStatement
|
140
|
+
# <-- CaseLabeledStatement
|
141
|
+
# <-- DefaultLabeledStatement
|
142
|
+
# <-- CompoundStatement
|
143
|
+
# <-- ExpressionStatement
|
144
|
+
# <-- SelectionStatement
|
145
|
+
# <-- IfStatement
|
146
|
+
# <-- IfElseStatement
|
147
|
+
# <-- SwitchStatement
|
148
|
+
# <-- IterationStatement
|
149
|
+
# <-- WhileStatement
|
150
|
+
# <-- DoStatement
|
151
|
+
# <-- ForStatement
|
152
|
+
# <-- C99ForStatement
|
153
|
+
# <-- JumpStatement
|
154
|
+
# <-- GotoStatement
|
155
|
+
# <-- ContinueStatement
|
156
|
+
# <-- BreakStatement
|
157
|
+
# <-- ReturnStatement
|
158
|
+
# <-- TranslationUnit
|
159
|
+
# <-- TypeName
|
160
|
+
# <-- Initializer
|
159
161
|
class SyntaxNode
|
160
162
|
include Visitable
|
163
|
+
include LocationHolder
|
161
164
|
|
162
165
|
def initialize
|
163
166
|
@head_token = nil
|
@@ -206,8 +209,8 @@ module C #:nodoc:
|
|
206
209
|
module SyntaxNodeCollector
|
207
210
|
def collect_object_specifiers(node)
|
208
211
|
if node
|
209
|
-
ObjectSpecifierCollector.new.tap { |
|
210
|
-
node.accept(
|
212
|
+
ObjectSpecifierCollector.new.tap { |col|
|
213
|
+
node.accept(col)
|
211
214
|
}.object_specifiers
|
212
215
|
else
|
213
216
|
[]
|
@@ -217,8 +220,8 @@ module C #:nodoc:
|
|
217
220
|
|
218
221
|
def collect_identifier_declarators(node)
|
219
222
|
if node
|
220
|
-
IdentifierDeclaratorCollector.new.tap { |
|
221
|
-
node.accept(
|
223
|
+
IdentifierDeclaratorCollector.new.tap { |col|
|
224
|
+
node.accept(col)
|
222
225
|
}.identifier_declarators
|
223
226
|
else
|
224
227
|
[]
|
@@ -228,8 +231,8 @@ module C #:nodoc:
|
|
228
231
|
|
229
232
|
def collect_typedef_type_specifiers(node)
|
230
233
|
if node
|
231
|
-
TypedefTypeSpecifierCollector.new.tap { |
|
232
|
-
node.accept(
|
234
|
+
TypedefTypeSpecifierCollector.new.tap { |col|
|
235
|
+
node.accept(col)
|
233
236
|
}.typedef_type_specifiers
|
234
237
|
else
|
235
238
|
[]
|
@@ -239,8 +242,8 @@ module C #:nodoc:
|
|
239
242
|
|
240
243
|
def collect_function_declarators(node)
|
241
244
|
if node
|
242
|
-
FunctionDeclaratorCollector.new.tap { |
|
243
|
-
node.accept(
|
245
|
+
FunctionDeclaratorCollector.new.tap { |col|
|
246
|
+
node.accept(col)
|
244
247
|
}.function_declarators
|
245
248
|
else
|
246
249
|
[]
|
@@ -250,8 +253,8 @@ module C #:nodoc:
|
|
250
253
|
|
251
254
|
def collect_simple_assignment_expressions(node)
|
252
255
|
if node
|
253
|
-
SimpleAssignmentExpressionCollector.new.tap { |
|
254
|
-
node.accept(
|
256
|
+
SimpleAssignmentExpressionCollector.new.tap { |col|
|
257
|
+
node.accept(col)
|
255
258
|
}.simple_assignment_expressions
|
256
259
|
else
|
257
260
|
[]
|
@@ -261,8 +264,8 @@ module C #:nodoc:
|
|
261
264
|
|
262
265
|
def collect_compound_assignment_expressions(node)
|
263
266
|
if node
|
264
|
-
CompoundAssignmentExpressionCollector.new.tap { |
|
265
|
-
node.accept(
|
267
|
+
CompoundAssignmentExpressionCollector.new.tap { |col|
|
268
|
+
node.accept(col)
|
266
269
|
}.compound_assignment_expressions
|
267
270
|
else
|
268
271
|
[]
|
@@ -272,8 +275,8 @@ module C #:nodoc:
|
|
272
275
|
|
273
276
|
def collect_prefix_increment_expressions(node)
|
274
277
|
if node
|
275
|
-
PrefixIncrementExpressionCollector.new.tap { |
|
276
|
-
node.accept(
|
278
|
+
PrefixIncrementExpressionCollector.new.tap { |col|
|
279
|
+
node.accept(col)
|
277
280
|
}.prefix_increment_expressions
|
278
281
|
else
|
279
282
|
[]
|
@@ -283,8 +286,8 @@ module C #:nodoc:
|
|
283
286
|
|
284
287
|
def collect_prefix_decrement_expressions(node)
|
285
288
|
if node
|
286
|
-
PrefixDecrementExpressionCollector.new.tap { |
|
287
|
-
node.accept(
|
289
|
+
PrefixDecrementExpressionCollector.new.tap { |col|
|
290
|
+
node.accept(col)
|
288
291
|
}.prefix_decrement_expressions
|
289
292
|
else
|
290
293
|
[]
|
@@ -294,8 +297,8 @@ module C #:nodoc:
|
|
294
297
|
|
295
298
|
def collect_postfix_increment_expressions(node)
|
296
299
|
if node
|
297
|
-
PostfixIncrementExpressionCollector.new.tap { |
|
298
|
-
node.accept(
|
300
|
+
PostfixIncrementExpressionCollector.new.tap { |col|
|
301
|
+
node.accept(col)
|
299
302
|
}.postfix_increment_expressions
|
300
303
|
else
|
301
304
|
[]
|
@@ -305,8 +308,8 @@ module C #:nodoc:
|
|
305
308
|
|
306
309
|
def collect_postfix_decrement_expressions(node)
|
307
310
|
if node
|
308
|
-
PostfixDecrementExpressionCollector.new.tap { |
|
309
|
-
node.accept(
|
311
|
+
PostfixDecrementExpressionCollector.new.tap { |col|
|
312
|
+
node.accept(col)
|
310
313
|
}.postfix_decrement_expressions
|
311
314
|
else
|
312
315
|
[]
|
@@ -316,8 +319,8 @@ module C #:nodoc:
|
|
316
319
|
|
317
320
|
def collect_additive_expressions(node)
|
318
321
|
if node
|
319
|
-
AdditiveExpressionCollector.new.tap { |
|
320
|
-
node.accept(
|
322
|
+
AdditiveExpressionCollector.new.tap { |col|
|
323
|
+
node.accept(col)
|
321
324
|
}.additive_expressions
|
322
325
|
else
|
323
326
|
[]
|
@@ -327,8 +330,8 @@ module C #:nodoc:
|
|
327
330
|
|
328
331
|
def collect_relational_expressions(node)
|
329
332
|
if node
|
330
|
-
RelationalExpressionCollector.new.tap { |
|
331
|
-
node.accept(
|
333
|
+
RelationalExpressionCollector.new.tap { |col|
|
334
|
+
node.accept(col)
|
332
335
|
}.relational_expressions
|
333
336
|
else
|
334
337
|
[]
|
@@ -338,8 +341,8 @@ module C #:nodoc:
|
|
338
341
|
|
339
342
|
def collect_equality_expressions(node)
|
340
343
|
if node
|
341
|
-
EqualityExpressionCollector.new.tap { |
|
342
|
-
node.accept(
|
344
|
+
EqualityExpressionCollector.new.tap { |col|
|
345
|
+
node.accept(col)
|
343
346
|
}.equality_expressions
|
344
347
|
else
|
345
348
|
[]
|
@@ -349,8 +352,8 @@ module C #:nodoc:
|
|
349
352
|
|
350
353
|
def collect_logical_and_expressions(node)
|
351
354
|
if node
|
352
|
-
LogicalAndExpressionCollector.new.tap { |
|
353
|
-
node.accept(
|
355
|
+
LogicalAndExpressionCollector.new.tap { |col|
|
356
|
+
node.accept(col)
|
354
357
|
}.logical_and_expressions
|
355
358
|
else
|
356
359
|
[]
|
@@ -360,8 +363,8 @@ module C #:nodoc:
|
|
360
363
|
|
361
364
|
def collect_logical_or_expressions(node)
|
362
365
|
if node
|
363
|
-
LogicalOrExpressionCollector.new.tap { |
|
364
|
-
node.accept(
|
366
|
+
LogicalOrExpressionCollector.new.tap { |col|
|
367
|
+
node.accept(col)
|
365
368
|
}.logical_or_expressions
|
366
369
|
else
|
367
370
|
[]
|
@@ -371,8 +374,8 @@ module C #:nodoc:
|
|
371
374
|
|
372
375
|
def collect_generic_labeled_statements(node)
|
373
376
|
if node
|
374
|
-
GenericLabeledStatementCollector.new.tap { |
|
375
|
-
node.accept(
|
377
|
+
GenericLabeledStatementCollector.new.tap { |col|
|
378
|
+
node.accept(col)
|
376
379
|
}.generic_labeled_statements
|
377
380
|
else
|
378
381
|
[]
|
@@ -382,8 +385,8 @@ module C #:nodoc:
|
|
382
385
|
|
383
386
|
def collect_if_statements(node)
|
384
387
|
if node
|
385
|
-
IfStatementCollector.new.tap { |
|
386
|
-
node.accept(
|
388
|
+
IfStatementCollector.new.tap { |col|
|
389
|
+
node.accept(col)
|
387
390
|
}.if_statements
|
388
391
|
else
|
389
392
|
[]
|
@@ -393,8 +396,8 @@ module C #:nodoc:
|
|
393
396
|
|
394
397
|
def collect_if_else_statements(node)
|
395
398
|
if node
|
396
|
-
IfElseStatementCollector.new.tap { |
|
397
|
-
node.accept(
|
399
|
+
IfElseStatementCollector.new.tap { |col|
|
400
|
+
node.accept(col)
|
398
401
|
}.if_else_statements
|
399
402
|
else
|
400
403
|
[]
|
@@ -404,8 +407,8 @@ module C #:nodoc:
|
|
404
407
|
|
405
408
|
def collect_goto_statements(node)
|
406
409
|
if node
|
407
|
-
GotoStatementCollector.new.tap { |
|
408
|
-
node.accept(
|
410
|
+
GotoStatementCollector.new.tap { |col|
|
411
|
+
node.accept(col)
|
409
412
|
}.goto_statements
|
410
413
|
else
|
411
414
|
[]
|
@@ -415,8 +418,8 @@ module C #:nodoc:
|
|
415
418
|
|
416
419
|
def collect_array_declarators(node)
|
417
420
|
if node
|
418
|
-
ArrayDeclaratorCollector.new.tap { |
|
419
|
-
node.accept(
|
421
|
+
ArrayDeclaratorCollector.new.tap { |col|
|
422
|
+
node.accept(col)
|
420
423
|
}.array_declarators
|
421
424
|
else
|
422
425
|
[]
|
@@ -426,8 +429,8 @@ module C #:nodoc:
|
|
426
429
|
|
427
430
|
def collect_constant_specifiers(node)
|
428
431
|
if node
|
429
|
-
ConstantSpecifierCollector.new.tap { |
|
430
|
-
node.accept(
|
432
|
+
ConstantSpecifierCollector.new.tap { |col|
|
433
|
+
node.accept(col)
|
431
434
|
}.constant_specifiers
|
432
435
|
else
|
433
436
|
[]
|
@@ -442,8 +445,8 @@ module C #:nodoc:
|
|
442
445
|
@full = false
|
443
446
|
end
|
444
447
|
|
445
|
-
def full=(
|
446
|
-
@full =
|
448
|
+
def full=(expr_is_full)
|
449
|
+
@full = expr_is_full
|
447
450
|
|
448
451
|
# NOTE: The ISO C99 standard says;
|
449
452
|
#
|
@@ -456,7 +459,7 @@ module C #:nodoc:
|
|
456
459
|
# expression of a while or do statement (6.8.5); each of the
|
457
460
|
# expressions of a for statement (6.8.5.3); the expression in a
|
458
461
|
# return statement (6.8.6.4).
|
459
|
-
if
|
462
|
+
if expr_is_full
|
460
463
|
append_sequence_point!
|
461
464
|
else
|
462
465
|
delete_sequence_point!
|
@@ -467,10 +470,8 @@ module C #:nodoc:
|
|
467
470
|
subclass_responsibility
|
468
471
|
end
|
469
472
|
|
470
|
-
def constant?(
|
471
|
-
object_specifiers.all?
|
472
|
-
enumerator_table.lookup(object_specifier.identifier.value)
|
473
|
-
end
|
473
|
+
def constant?(enum_tbl)
|
474
|
+
object_specifiers.all? { |os| enum_tbl.lookup(os.identifier.value) }
|
474
475
|
end
|
475
476
|
|
476
477
|
def logical?
|
@@ -486,12 +487,12 @@ module C #:nodoc:
|
|
486
487
|
end
|
487
488
|
|
488
489
|
def object_specifiers
|
489
|
-
ObjectSpecifierCollector.new.tap { |
|
490
|
-
self.accept(
|
490
|
+
ObjectSpecifierCollector.new.tap { |col|
|
491
|
+
self.accept(col)
|
491
492
|
}.object_specifiers
|
492
493
|
end
|
493
494
|
|
494
|
-
def to_normalized_logical(
|
495
|
+
def to_normalized_logical(parent_expr = nil)
|
495
496
|
subclass_responsibility
|
496
497
|
end
|
497
498
|
|
@@ -505,17 +506,17 @@ module C #:nodoc:
|
|
505
506
|
end
|
506
507
|
|
507
508
|
private
|
508
|
-
def create_normalized_logical_of(
|
509
|
-
EqualityExpression.new(Token.new("!=", "!=",
|
510
|
-
GroupedExpression.new(
|
511
|
-
ConstantSpecifier.of_zero(
|
509
|
+
def create_normalized_logical_of(expr)
|
510
|
+
EqualityExpression.new(Token.new("!=", "!=", expr.location),
|
511
|
+
GroupedExpression.new(expr),
|
512
|
+
ConstantSpecifier.of_zero(expr.location))
|
512
513
|
end
|
513
514
|
end
|
514
515
|
|
515
516
|
class ErrorExpression < Expression
|
516
|
-
def initialize(
|
517
|
+
def initialize(err_tok)
|
517
518
|
super()
|
518
|
-
@error_token =
|
519
|
+
@error_token = err_tok
|
519
520
|
end
|
520
521
|
|
521
522
|
def location
|
@@ -538,7 +539,7 @@ module C #:nodoc:
|
|
538
539
|
false
|
539
540
|
end
|
540
541
|
|
541
|
-
def to_normalized_logical(
|
542
|
+
def to_normalized_logical(parent_expr = nil)
|
542
543
|
self
|
543
544
|
end
|
544
545
|
|
@@ -559,9 +560,9 @@ module C #:nodoc:
|
|
559
560
|
class PrimaryExpression < Expression; end
|
560
561
|
|
561
562
|
class ObjectSpecifier < PrimaryExpression
|
562
|
-
def initialize(
|
563
|
+
def initialize(id)
|
563
564
|
super()
|
564
|
-
@identifier =
|
565
|
+
@identifier = id
|
565
566
|
end
|
566
567
|
|
567
568
|
attr_reader :identifier
|
@@ -586,8 +587,8 @@ module C #:nodoc:
|
|
586
587
|
false
|
587
588
|
end
|
588
589
|
|
589
|
-
def to_normalized_logical(
|
590
|
-
case
|
590
|
+
def to_normalized_logical(parent_expr = nil)
|
591
|
+
case parent_expr
|
591
592
|
when nil, LogicalAndExpression, LogicalOrExpression
|
592
593
|
create_normalized_logical_of(self)
|
593
594
|
else
|
@@ -610,13 +611,13 @@ module C #:nodoc:
|
|
610
611
|
end
|
611
612
|
|
612
613
|
class ConstantSpecifier < PrimaryExpression
|
613
|
-
def self.of_zero(
|
614
|
-
self.new(Token.new(:CONSTANT, "0",
|
614
|
+
def self.of_zero(loc = nil)
|
615
|
+
self.new(Token.new(:CONSTANT, "0", loc || Location.new))
|
615
616
|
end
|
616
617
|
|
617
|
-
def initialize(
|
618
|
+
def initialize(const)
|
618
619
|
super()
|
619
|
-
@constant =
|
620
|
+
@constant = const
|
620
621
|
end
|
621
622
|
|
622
623
|
attr_reader :constant
|
@@ -626,7 +627,7 @@ module C #:nodoc:
|
|
626
627
|
end
|
627
628
|
|
628
629
|
def prefix
|
629
|
-
@constant.value.scan(/\A(?:0x|0b|L)/i).first
|
630
|
+
@constant.value.scan(/\A(?:0x|0b|0(?=[0-9])|L)/i).first
|
630
631
|
end
|
631
632
|
|
632
633
|
def suffix
|
@@ -653,8 +654,8 @@ module C #:nodoc:
|
|
653
654
|
false
|
654
655
|
end
|
655
656
|
|
656
|
-
def to_normalized_logical(
|
657
|
-
case
|
657
|
+
def to_normalized_logical(parent_expr = nil)
|
658
|
+
case parent_expr
|
658
659
|
when nil, LogicalAndExpression, LogicalOrExpression
|
659
660
|
create_normalized_logical_of(self)
|
660
661
|
else
|
@@ -677,9 +678,9 @@ module C #:nodoc:
|
|
677
678
|
end
|
678
679
|
|
679
680
|
class StringLiteralSpecifier < PrimaryExpression
|
680
|
-
def initialize(
|
681
|
+
def initialize(lit)
|
681
682
|
super()
|
682
|
-
@literal =
|
683
|
+
@literal = lit
|
683
684
|
end
|
684
685
|
|
685
686
|
attr_reader :literal
|
@@ -708,8 +709,8 @@ module C #:nodoc:
|
|
708
709
|
false
|
709
710
|
end
|
710
711
|
|
711
|
-
def to_normalized_logical(
|
712
|
-
case
|
712
|
+
def to_normalized_logical(parent_expr = nil)
|
713
|
+
case parent_expr
|
713
714
|
when nil, LogicalAndExpression, LogicalOrExpression
|
714
715
|
create_normalized_logical_of(self)
|
715
716
|
else
|
@@ -732,9 +733,9 @@ module C #:nodoc:
|
|
732
733
|
end
|
733
734
|
|
734
735
|
class NullConstantSpecifier < PrimaryExpression
|
735
|
-
def initialize(
|
736
|
+
def initialize(tok)
|
736
737
|
super()
|
737
|
-
@token =
|
738
|
+
@token = tok
|
738
739
|
end
|
739
740
|
|
740
741
|
attr_reader :token
|
@@ -759,8 +760,8 @@ module C #:nodoc:
|
|
759
760
|
false
|
760
761
|
end
|
761
762
|
|
762
|
-
def to_normalized_logical(
|
763
|
-
case
|
763
|
+
def to_normalized_logical(parent_expr = nil)
|
764
|
+
case parent_expr
|
764
765
|
when nil, LogicalAndExpression, LogicalOrExpression
|
765
766
|
create_normalized_logical_of(self)
|
766
767
|
else
|
@@ -783,11 +784,11 @@ module C #:nodoc:
|
|
783
784
|
end
|
784
785
|
|
785
786
|
class GroupedExpression < PrimaryExpression
|
786
|
-
def initialize(
|
787
|
+
def initialize(expr)
|
787
788
|
super()
|
788
|
-
@expression =
|
789
|
-
self.head_token =
|
790
|
-
self.tail_token =
|
789
|
+
@expression = expr
|
790
|
+
self.head_token = expr.head_token
|
791
|
+
self.tail_token = expr.tail_token
|
791
792
|
end
|
792
793
|
|
793
794
|
attr_reader :expression
|
@@ -812,11 +813,10 @@ module C #:nodoc:
|
|
812
813
|
@expression.bitwise?
|
813
814
|
end
|
814
815
|
|
815
|
-
def to_normalized_logical(
|
816
|
-
case
|
816
|
+
def to_normalized_logical(parent_expr = nil)
|
817
|
+
case parent_expr
|
817
818
|
when nil, LogicalAndExpression, LogicalOrExpression
|
818
|
-
GroupedExpression.new(
|
819
|
-
@expression.to_normalized_logical(parent_expression))
|
819
|
+
GroupedExpression.new(@expression.to_normalized_logical(parent_expr))
|
820
820
|
else
|
821
821
|
self
|
822
822
|
end
|
@@ -837,8 +837,8 @@ module C #:nodoc:
|
|
837
837
|
end
|
838
838
|
|
839
839
|
class PostfixExpression < Expression
|
840
|
-
def initialize(
|
841
|
-
@operator =
|
840
|
+
def initialize(op)
|
841
|
+
@operator = op
|
842
842
|
end
|
843
843
|
|
844
844
|
attr_reader :operator
|
@@ -849,10 +849,10 @@ module C #:nodoc:
|
|
849
849
|
end
|
850
850
|
|
851
851
|
class ArraySubscriptExpression < PostfixExpression
|
852
|
-
def initialize(
|
852
|
+
def initialize(expr, ary_subs, left_bracket)
|
853
853
|
super(left_bracket)
|
854
|
-
@expression =
|
855
|
-
@array_subscript =
|
854
|
+
@expression = expr
|
855
|
+
@array_subscript = ary_subs
|
856
856
|
end
|
857
857
|
|
858
858
|
attr_reader :expression
|
@@ -874,8 +874,8 @@ module C #:nodoc:
|
|
874
874
|
false
|
875
875
|
end
|
876
876
|
|
877
|
-
def to_normalized_logical(
|
878
|
-
case
|
877
|
+
def to_normalized_logical(parent_expr = nil)
|
878
|
+
case parent_expr
|
879
879
|
when nil, LogicalAndExpression, LogicalOrExpression
|
880
880
|
create_normalized_logical_of(self)
|
881
881
|
else
|
@@ -899,10 +899,10 @@ module C #:nodoc:
|
|
899
899
|
end
|
900
900
|
|
901
901
|
class FunctionCallExpression < PostfixExpression
|
902
|
-
def initialize(
|
902
|
+
def initialize(expr, arg_exprs, left_paren)
|
903
903
|
super(left_paren)
|
904
|
-
@expression =
|
905
|
-
@argument_expressions =
|
904
|
+
@expression = expr
|
905
|
+
@argument_expressions = arg_exprs
|
906
906
|
end
|
907
907
|
|
908
908
|
attr_reader :expression
|
@@ -924,8 +924,8 @@ module C #:nodoc:
|
|
924
924
|
false
|
925
925
|
end
|
926
926
|
|
927
|
-
def to_normalized_logical(
|
928
|
-
case
|
927
|
+
def to_normalized_logical(parent_expr = nil)
|
928
|
+
case parent_expr
|
929
929
|
when nil, LogicalAndExpression, LogicalOrExpression
|
930
930
|
create_normalized_logical_of(self)
|
931
931
|
else
|
@@ -950,10 +950,10 @@ module C #:nodoc:
|
|
950
950
|
end
|
951
951
|
|
952
952
|
class MemberAccessByValueExpression < PostfixExpression
|
953
|
-
def initialize(
|
953
|
+
def initialize(expr, id, dot)
|
954
954
|
super(dot)
|
955
|
-
@expression =
|
956
|
-
@identifier =
|
955
|
+
@expression = expr
|
956
|
+
@identifier = id
|
957
957
|
end
|
958
958
|
|
959
959
|
attr_reader :expression
|
@@ -975,8 +975,8 @@ module C #:nodoc:
|
|
975
975
|
false
|
976
976
|
end
|
977
977
|
|
978
|
-
def to_normalized_logical(
|
979
|
-
case
|
978
|
+
def to_normalized_logical(parent_expr = nil)
|
979
|
+
case parent_expr
|
980
980
|
when nil, LogicalAndExpression, LogicalOrExpression
|
981
981
|
create_normalized_logical_of(self)
|
982
982
|
else
|
@@ -999,10 +999,10 @@ module C #:nodoc:
|
|
999
999
|
end
|
1000
1000
|
|
1001
1001
|
class MemberAccessByPointerExpression < PostfixExpression
|
1002
|
-
def initialize(
|
1002
|
+
def initialize(expr, id, arrow)
|
1003
1003
|
super(arrow)
|
1004
|
-
@expression =
|
1005
|
-
@identifier =
|
1004
|
+
@expression = expr
|
1005
|
+
@identifier = id
|
1006
1006
|
end
|
1007
1007
|
|
1008
1008
|
attr_reader :expression
|
@@ -1024,8 +1024,8 @@ module C #:nodoc:
|
|
1024
1024
|
false
|
1025
1025
|
end
|
1026
1026
|
|
1027
|
-
def to_normalized_logical(
|
1028
|
-
case
|
1027
|
+
def to_normalized_logical(parent_expr = nil)
|
1028
|
+
case parent_expr
|
1029
1029
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1030
1030
|
create_normalized_logical_of(self)
|
1031
1031
|
else
|
@@ -1048,10 +1048,10 @@ module C #:nodoc:
|
|
1048
1048
|
end
|
1049
1049
|
|
1050
1050
|
class BitAccessByValueExpression < PostfixExpression
|
1051
|
-
def initialize(
|
1051
|
+
def initialize(expr, const, dot)
|
1052
1052
|
super(dot)
|
1053
|
-
@expression =
|
1054
|
-
@constant =
|
1053
|
+
@expression = expr
|
1054
|
+
@constant = const
|
1055
1055
|
end
|
1056
1056
|
|
1057
1057
|
attr_reader :expression
|
@@ -1073,8 +1073,8 @@ module C #:nodoc:
|
|
1073
1073
|
false
|
1074
1074
|
end
|
1075
1075
|
|
1076
|
-
def to_normalized_logical(
|
1077
|
-
case
|
1076
|
+
def to_normalized_logical(parent_expr = nil)
|
1077
|
+
case parent_expr
|
1078
1078
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1079
1079
|
create_normalized_logical_of(self)
|
1080
1080
|
else
|
@@ -1097,10 +1097,10 @@ module C #:nodoc:
|
|
1097
1097
|
end
|
1098
1098
|
|
1099
1099
|
class BitAccessByPointerExpression < PostfixExpression
|
1100
|
-
def initialize(
|
1100
|
+
def initialize(expr, const, arrow)
|
1101
1101
|
super(arrow)
|
1102
|
-
@expression =
|
1103
|
-
@constant =
|
1102
|
+
@expression = expr
|
1103
|
+
@constant = const
|
1104
1104
|
end
|
1105
1105
|
|
1106
1106
|
attr_reader :expression
|
@@ -1122,8 +1122,8 @@ module C #:nodoc:
|
|
1122
1122
|
false
|
1123
1123
|
end
|
1124
1124
|
|
1125
|
-
def to_normalized_logical(
|
1126
|
-
case
|
1125
|
+
def to_normalized_logical(parent_expr = nil)
|
1126
|
+
case parent_expr
|
1127
1127
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1128
1128
|
create_normalized_logical_of(self)
|
1129
1129
|
else
|
@@ -1146,9 +1146,9 @@ module C #:nodoc:
|
|
1146
1146
|
end
|
1147
1147
|
|
1148
1148
|
class PostfixIncrementExpression < PostfixExpression
|
1149
|
-
def initialize(
|
1150
|
-
super(
|
1151
|
-
@operand =
|
1149
|
+
def initialize(op, ope)
|
1150
|
+
super(op)
|
1151
|
+
@operand = ope
|
1152
1152
|
end
|
1153
1153
|
|
1154
1154
|
attr_reader :operand
|
@@ -1169,8 +1169,8 @@ module C #:nodoc:
|
|
1169
1169
|
false
|
1170
1170
|
end
|
1171
1171
|
|
1172
|
-
def to_normalized_logical(
|
1173
|
-
case
|
1172
|
+
def to_normalized_logical(parent_expr = nil)
|
1173
|
+
case parent_expr
|
1174
1174
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1175
1175
|
create_normalized_logical_of(self)
|
1176
1176
|
else
|
@@ -1193,9 +1193,9 @@ module C #:nodoc:
|
|
1193
1193
|
end
|
1194
1194
|
|
1195
1195
|
class PostfixDecrementExpression < PostfixExpression
|
1196
|
-
def initialize(
|
1197
|
-
super(
|
1198
|
-
@operand =
|
1196
|
+
def initialize(op, ope)
|
1197
|
+
super(op)
|
1198
|
+
@operand = ope
|
1199
1199
|
end
|
1200
1200
|
|
1201
1201
|
attr_reader :operand
|
@@ -1216,8 +1216,8 @@ module C #:nodoc:
|
|
1216
1216
|
false
|
1217
1217
|
end
|
1218
1218
|
|
1219
|
-
def to_normalized_logical(
|
1220
|
-
case
|
1219
|
+
def to_normalized_logical(parent_expr = nil)
|
1220
|
+
case parent_expr
|
1221
1221
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1222
1222
|
create_normalized_logical_of(self)
|
1223
1223
|
else
|
@@ -1240,10 +1240,10 @@ module C #:nodoc:
|
|
1240
1240
|
end
|
1241
1241
|
|
1242
1242
|
class CompoundLiteralExpression < PostfixExpression
|
1243
|
-
def initialize(type_name,
|
1243
|
+
def initialize(type_name, inits, left_paren)
|
1244
1244
|
super(left_paren)
|
1245
1245
|
@type_name = type_name
|
1246
|
-
@initializers =
|
1246
|
+
@initializers = inits
|
1247
1247
|
end
|
1248
1248
|
|
1249
1249
|
attr_reader :type_name
|
@@ -1265,8 +1265,8 @@ module C #:nodoc:
|
|
1265
1265
|
false
|
1266
1266
|
end
|
1267
1267
|
|
1268
|
-
def to_normalized_logical(
|
1269
|
-
case
|
1268
|
+
def to_normalized_logical(parent_expr = nil)
|
1269
|
+
case parent_expr
|
1270
1270
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1271
1271
|
create_normalized_logical_of(self)
|
1272
1272
|
else
|
@@ -1290,10 +1290,10 @@ module C #:nodoc:
|
|
1290
1290
|
end
|
1291
1291
|
|
1292
1292
|
class UnaryExpression < Expression
|
1293
|
-
def initialize(
|
1293
|
+
def initialize(op, ope)
|
1294
1294
|
super()
|
1295
|
-
@operator =
|
1296
|
-
@operand =
|
1295
|
+
@operator = op
|
1296
|
+
@operand = ope
|
1297
1297
|
end
|
1298
1298
|
|
1299
1299
|
attr_reader :operator
|
@@ -1330,8 +1330,8 @@ module C #:nodoc:
|
|
1330
1330
|
false
|
1331
1331
|
end
|
1332
1332
|
|
1333
|
-
def to_normalized_logical(
|
1334
|
-
case
|
1333
|
+
def to_normalized_logical(parent_expr = nil)
|
1334
|
+
case parent_expr
|
1335
1335
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1336
1336
|
create_normalized_logical_of(self)
|
1337
1337
|
else
|
@@ -1361,8 +1361,8 @@ module C #:nodoc:
|
|
1361
1361
|
false
|
1362
1362
|
end
|
1363
1363
|
|
1364
|
-
def to_normalized_logical(
|
1365
|
-
case
|
1364
|
+
def to_normalized_logical(parent_expr = nil)
|
1365
|
+
case parent_expr
|
1366
1366
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1367
1367
|
create_normalized_logical_of(self)
|
1368
1368
|
else
|
@@ -1392,8 +1392,8 @@ module C #:nodoc:
|
|
1392
1392
|
false
|
1393
1393
|
end
|
1394
1394
|
|
1395
|
-
def to_normalized_logical(
|
1396
|
-
case
|
1395
|
+
def to_normalized_logical(parent_expr = nil)
|
1396
|
+
case parent_expr
|
1397
1397
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1398
1398
|
create_normalized_logical_of(self)
|
1399
1399
|
else
|
@@ -1423,8 +1423,8 @@ module C #:nodoc:
|
|
1423
1423
|
false
|
1424
1424
|
end
|
1425
1425
|
|
1426
|
-
def to_normalized_logical(
|
1427
|
-
case
|
1426
|
+
def to_normalized_logical(parent_expr = nil)
|
1427
|
+
case parent_expr
|
1428
1428
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1429
1429
|
create_normalized_logical_of(self)
|
1430
1430
|
else
|
@@ -1454,12 +1454,12 @@ module C #:nodoc:
|
|
1454
1454
|
operator.type == "~"
|
1455
1455
|
end
|
1456
1456
|
|
1457
|
-
def to_normalized_logical(
|
1457
|
+
def to_normalized_logical(parent_expr = nil)
|
1458
1458
|
if operator.type == "!"
|
1459
1459
|
normalized_operand = @operand.to_normalized_logical
|
1460
1460
|
GroupedExpression.new(normalized_operand.to_complemental_logical)
|
1461
1461
|
else
|
1462
|
-
case
|
1462
|
+
case parent_expr
|
1463
1463
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1464
1464
|
create_normalized_logical_of(self)
|
1465
1465
|
else
|
@@ -1496,8 +1496,8 @@ module C #:nodoc:
|
|
1496
1496
|
false
|
1497
1497
|
end
|
1498
1498
|
|
1499
|
-
def to_normalized_logical(
|
1500
|
-
case
|
1499
|
+
def to_normalized_logical(parent_expr = nil)
|
1500
|
+
case parent_expr
|
1501
1501
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1502
1502
|
create_normalized_logical_of(self)
|
1503
1503
|
else
|
@@ -1531,8 +1531,8 @@ module C #:nodoc:
|
|
1531
1531
|
false
|
1532
1532
|
end
|
1533
1533
|
|
1534
|
-
def to_normalized_logical(
|
1535
|
-
case
|
1534
|
+
def to_normalized_logical(parent_expr = nil)
|
1535
|
+
case parent_expr
|
1536
1536
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1537
1537
|
create_normalized_logical_of(self)
|
1538
1538
|
else
|
@@ -1566,8 +1566,8 @@ module C #:nodoc:
|
|
1566
1566
|
false
|
1567
1567
|
end
|
1568
1568
|
|
1569
|
-
def to_normalized_logical(
|
1570
|
-
case
|
1569
|
+
def to_normalized_logical(parent_expr = nil)
|
1570
|
+
case parent_expr
|
1571
1571
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1572
1572
|
create_normalized_logical_of(self)
|
1573
1573
|
else
|
@@ -1601,8 +1601,8 @@ module C #:nodoc:
|
|
1601
1601
|
false
|
1602
1602
|
end
|
1603
1603
|
|
1604
|
-
def to_normalized_logical(
|
1605
|
-
case
|
1604
|
+
def to_normalized_logical(parent_expr = nil)
|
1605
|
+
case parent_expr
|
1606
1606
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1607
1607
|
create_normalized_logical_of(self)
|
1608
1608
|
else
|
@@ -1620,10 +1620,10 @@ module C #:nodoc:
|
|
1620
1620
|
end
|
1621
1621
|
|
1622
1622
|
class CastExpression < Expression
|
1623
|
-
def initialize(type_name,
|
1623
|
+
def initialize(type_name, ope)
|
1624
1624
|
super()
|
1625
1625
|
@type_name = type_name
|
1626
|
-
@operand =
|
1626
|
+
@operand = ope
|
1627
1627
|
end
|
1628
1628
|
|
1629
1629
|
attr_reader :type_name
|
@@ -1649,8 +1649,8 @@ module C #:nodoc:
|
|
1649
1649
|
@operand.bitwise?
|
1650
1650
|
end
|
1651
1651
|
|
1652
|
-
def to_normalized_logical(
|
1653
|
-
case
|
1652
|
+
def to_normalized_logical(parent_expr = nil)
|
1653
|
+
case parent_expr
|
1654
1654
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1655
1655
|
create_normalized_logical_of(self)
|
1656
1656
|
else
|
@@ -1673,9 +1673,9 @@ module C #:nodoc:
|
|
1673
1673
|
end
|
1674
1674
|
|
1675
1675
|
class BinaryExpression < Expression
|
1676
|
-
def initialize(
|
1676
|
+
def initialize(op, lhs_operand, rhs_operand)
|
1677
1677
|
super()
|
1678
|
-
@operator =
|
1678
|
+
@operator = op
|
1679
1679
|
@lhs_operand = lhs_operand
|
1680
1680
|
@rhs_operand = rhs_operand
|
1681
1681
|
end
|
@@ -1715,8 +1715,8 @@ module C #:nodoc:
|
|
1715
1715
|
false
|
1716
1716
|
end
|
1717
1717
|
|
1718
|
-
def to_normalized_logical(
|
1719
|
-
case
|
1718
|
+
def to_normalized_logical(parent_expr = nil)
|
1719
|
+
case parent_expr
|
1720
1720
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1721
1721
|
create_normalized_logical_of(self)
|
1722
1722
|
else
|
@@ -1746,8 +1746,8 @@ module C #:nodoc:
|
|
1746
1746
|
false
|
1747
1747
|
end
|
1748
1748
|
|
1749
|
-
def to_normalized_logical(
|
1750
|
-
case
|
1749
|
+
def to_normalized_logical(parent_expr = nil)
|
1750
|
+
case parent_expr
|
1751
1751
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1752
1752
|
create_normalized_logical_of(self)
|
1753
1753
|
else
|
@@ -1777,8 +1777,8 @@ module C #:nodoc:
|
|
1777
1777
|
true
|
1778
1778
|
end
|
1779
1779
|
|
1780
|
-
def to_normalized_logical(
|
1781
|
-
case
|
1780
|
+
def to_normalized_logical(parent_expr = nil)
|
1781
|
+
case parent_expr
|
1782
1782
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1783
1783
|
create_normalized_logical_of(self)
|
1784
1784
|
else
|
@@ -1808,14 +1808,14 @@ module C #:nodoc:
|
|
1808
1808
|
false
|
1809
1809
|
end
|
1810
1810
|
|
1811
|
-
def to_normalized_logical(
|
1811
|
+
def to_normalized_logical(parent_expr = nil)
|
1812
1812
|
self
|
1813
1813
|
end
|
1814
1814
|
|
1815
1815
|
def to_complemental_logical
|
1816
|
-
|
1817
|
-
|
1818
|
-
RelationalExpression.new(
|
1816
|
+
op = ComparisonOperator.new(@operator).for_complement.to_s
|
1817
|
+
op_tok = Token.new(op, op, @operator.location)
|
1818
|
+
RelationalExpression.new(op_tok, @lhs_operand, @rhs_operand)
|
1819
1819
|
end
|
1820
1820
|
end
|
1821
1821
|
|
@@ -1836,14 +1836,14 @@ module C #:nodoc:
|
|
1836
1836
|
false
|
1837
1837
|
end
|
1838
1838
|
|
1839
|
-
def to_normalized_logical(
|
1839
|
+
def to_normalized_logical(parent_expr = nil)
|
1840
1840
|
self
|
1841
1841
|
end
|
1842
1842
|
|
1843
1843
|
def to_complemental_logical
|
1844
|
-
|
1845
|
-
|
1846
|
-
EqualityExpression.new(
|
1844
|
+
op = ComparisonOperator.new(@operator).for_complement.to_s
|
1845
|
+
op_tok = Token.new(op, op, @operator.location)
|
1846
|
+
EqualityExpression.new(op_tok, @lhs_operand, @rhs_operand)
|
1847
1847
|
end
|
1848
1848
|
end
|
1849
1849
|
|
@@ -1864,8 +1864,8 @@ module C #:nodoc:
|
|
1864
1864
|
true
|
1865
1865
|
end
|
1866
1866
|
|
1867
|
-
def to_normalized_logical(
|
1868
|
-
case
|
1867
|
+
def to_normalized_logical(parent_expr = nil)
|
1868
|
+
case parent_expr
|
1869
1869
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1870
1870
|
create_normalized_logical_of(self)
|
1871
1871
|
else
|
@@ -1895,8 +1895,8 @@ module C #:nodoc:
|
|
1895
1895
|
true
|
1896
1896
|
end
|
1897
1897
|
|
1898
|
-
def to_normalized_logical(
|
1899
|
-
case
|
1898
|
+
def to_normalized_logical(parent_expr = nil)
|
1899
|
+
case parent_expr
|
1900
1900
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1901
1901
|
create_normalized_logical_of(self)
|
1902
1902
|
else
|
@@ -1926,8 +1926,8 @@ module C #:nodoc:
|
|
1926
1926
|
true
|
1927
1927
|
end
|
1928
1928
|
|
1929
|
-
def to_normalized_logical(
|
1930
|
-
case
|
1929
|
+
def to_normalized_logical(parent_expr = nil)
|
1930
|
+
case parent_expr
|
1931
1931
|
when nil, LogicalAndExpression, LogicalOrExpression
|
1932
1932
|
create_normalized_logical_of(self)
|
1933
1933
|
else
|
@@ -1941,7 +1941,7 @@ module C #:nodoc:
|
|
1941
1941
|
end
|
1942
1942
|
|
1943
1943
|
class LogicalAndExpression < BinaryExpression
|
1944
|
-
def initialize(
|
1944
|
+
def initialize(op, lhs_operand, rhs_operand)
|
1945
1945
|
super
|
1946
1946
|
|
1947
1947
|
# NOTE: The ISO C99 standard says;
|
@@ -1976,7 +1976,7 @@ module C #:nodoc:
|
|
1976
1976
|
false
|
1977
1977
|
end
|
1978
1978
|
|
1979
|
-
def to_normalized_logical(
|
1979
|
+
def to_normalized_logical(parent_expr = nil)
|
1980
1980
|
LogicalAndExpression.new(@operator,
|
1981
1981
|
@lhs_operand.to_normalized_logical(self),
|
1982
1982
|
@rhs_operand.to_normalized_logical(self))
|
@@ -1990,7 +1990,7 @@ module C #:nodoc:
|
|
1990
1990
|
end
|
1991
1991
|
|
1992
1992
|
class LogicalOrExpression < BinaryExpression
|
1993
|
-
def initialize(
|
1993
|
+
def initialize(op, lhs_operand, rhs_operand)
|
1994
1994
|
super
|
1995
1995
|
|
1996
1996
|
# NOTE: The ISO C99 standard says;
|
@@ -2025,7 +2025,7 @@ module C #:nodoc:
|
|
2025
2025
|
false
|
2026
2026
|
end
|
2027
2027
|
|
2028
|
-
def to_normalized_logical(
|
2028
|
+
def to_normalized_logical(parent_expr = nil)
|
2029
2029
|
LogicalOrExpression.new(@operator,
|
2030
2030
|
@lhs_operand.to_normalized_logical(self),
|
2031
2031
|
@rhs_operand.to_normalized_logical(self))
|
@@ -2039,11 +2039,11 @@ module C #:nodoc:
|
|
2039
2039
|
end
|
2040
2040
|
|
2041
2041
|
class ConditionalExpression < Expression
|
2042
|
-
def initialize(
|
2042
|
+
def initialize(cond, then_expr, else_expr, question_mark)
|
2043
2043
|
super()
|
2044
|
-
@condition =
|
2045
|
-
@then_expression =
|
2046
|
-
@else_expression =
|
2044
|
+
@condition = cond
|
2045
|
+
@then_expression = then_expr
|
2046
|
+
@else_expression = else_expr
|
2047
2047
|
@question_mark = question_mark
|
2048
2048
|
|
2049
2049
|
# NOTE: The ISO C99 standard says;
|
@@ -2095,8 +2095,8 @@ module C #:nodoc:
|
|
2095
2095
|
@then_expression.bitwise? || @else_expression.bitwise?
|
2096
2096
|
end
|
2097
2097
|
|
2098
|
-
def to_normalized_logical(
|
2099
|
-
case
|
2098
|
+
def to_normalized_logical(parent_expr = nil)
|
2099
|
+
case parent_expr
|
2100
2100
|
when nil, LogicalAndExpression, LogicalOrExpression
|
2101
2101
|
create_normalized_logical_of(self)
|
2102
2102
|
else
|
@@ -2138,8 +2138,8 @@ module C #:nodoc:
|
|
2138
2138
|
rhs_operand.bitwise?
|
2139
2139
|
end
|
2140
2140
|
|
2141
|
-
def to_normalized_logical(
|
2142
|
-
case
|
2141
|
+
def to_normalized_logical(parent_expr = nil)
|
2142
|
+
case parent_expr
|
2143
2143
|
when nil, LogicalAndExpression, LogicalOrExpression
|
2144
2144
|
create_normalized_logical_of(self)
|
2145
2145
|
else
|
@@ -2169,8 +2169,8 @@ module C #:nodoc:
|
|
2169
2169
|
["<<=", ">>=", "&=", "^=", "|="].include?(operator.type)
|
2170
2170
|
end
|
2171
2171
|
|
2172
|
-
def to_normalized_logical(
|
2173
|
-
case
|
2172
|
+
def to_normalized_logical(parent_expr = nil)
|
2173
|
+
case parent_expr
|
2174
2174
|
when nil, LogicalAndExpression, LogicalOrExpression
|
2175
2175
|
create_normalized_logical_of(self)
|
2176
2176
|
else
|
@@ -2184,10 +2184,10 @@ module C #:nodoc:
|
|
2184
2184
|
end
|
2185
2185
|
|
2186
2186
|
class CommaSeparatedExpression < Expression
|
2187
|
-
def initialize(
|
2187
|
+
def initialize(fst_expr)
|
2188
2188
|
super()
|
2189
2189
|
@expressions = []
|
2190
|
-
push(
|
2190
|
+
push(fst_expr)
|
2191
2191
|
end
|
2192
2192
|
|
2193
2193
|
attr_reader :expressions
|
@@ -2212,8 +2212,8 @@ module C #:nodoc:
|
|
2212
2212
|
@expressions.last.bitwise?
|
2213
2213
|
end
|
2214
2214
|
|
2215
|
-
def to_normalized_logical(
|
2216
|
-
case
|
2215
|
+
def to_normalized_logical(parent_expr = nil)
|
2216
|
+
case parent_expr
|
2217
2217
|
when nil, LogicalAndExpression, LogicalOrExpression
|
2218
2218
|
create_normalized_logical_of(@expressions.last)
|
2219
2219
|
else
|
@@ -2229,8 +2229,10 @@ module C #:nodoc:
|
|
2229
2229
|
@expressions.map { |expr| expr.to_s }.join(",")
|
2230
2230
|
end
|
2231
2231
|
|
2232
|
-
def push(
|
2233
|
-
@expressions.
|
2232
|
+
def push(expr)
|
2233
|
+
self.head_token = expr.head_token if @expressions.empty?
|
2234
|
+
@expressions.push(expr)
|
2235
|
+
self.tail_token = expr.tail_token
|
2234
2236
|
|
2235
2237
|
# NOTE: The ISO C99 standard says;
|
2236
2238
|
#
|
@@ -2285,12 +2287,11 @@ module C #:nodoc:
|
|
2285
2287
|
class Declaration < SyntaxNode
|
2286
2288
|
include DeclarationSpecifiersHolder
|
2287
2289
|
|
2288
|
-
def initialize(
|
2290
|
+
def initialize(dcl_specs, init_dcrs, sym_tbl)
|
2289
2291
|
super()
|
2290
|
-
@declaration_specifiers =
|
2291
|
-
@init_declarators =
|
2292
|
-
@items = build_items(
|
2293
|
-
symbol_table)
|
2292
|
+
@declaration_specifiers = dcl_specs
|
2293
|
+
@init_declarators = init_dcrs
|
2294
|
+
@items = build_items(dcl_specs, init_dcrs, sym_tbl)
|
2294
2295
|
end
|
2295
2296
|
|
2296
2297
|
attr_reader :declaration_specifiers
|
@@ -2307,95 +2308,77 @@ module C #:nodoc:
|
|
2307
2308
|
end
|
2308
2309
|
|
2309
2310
|
private
|
2310
|
-
def build_items(
|
2311
|
-
build_type_declaration(
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
|
2324
|
-
|
2325
|
-
|
2326
|
-
|
2327
|
-
declaration_specifiers.type_specifiers.each do |type_specifier|
|
2328
|
-
visitor = TypeDeclarationBuilder.new(symbol_table)
|
2329
|
-
type_specifier.accept(visitor)
|
2330
|
-
result.concat(visitor.type_declarations)
|
2311
|
+
def build_items(dcl_specs, init_dcrs, sym_tbl)
|
2312
|
+
build_type_declaration(dcl_specs, init_dcrs, sym_tbl) +
|
2313
|
+
build_function_declaration(dcl_specs, init_dcrs, sym_tbl) +
|
2314
|
+
build_variable_declaration(dcl_specs, init_dcrs, sym_tbl) +
|
2315
|
+
build_variable_definition(dcl_specs, init_dcrs, sym_tbl)
|
2316
|
+
end
|
2317
|
+
|
2318
|
+
def build_type_declaration(dcl_specs, init_dcrs, sym_tbl)
|
2319
|
+
return [] unless dcl_specs
|
2320
|
+
|
2321
|
+
type_dcls = []
|
2322
|
+
|
2323
|
+
dcl_specs.type_specifiers.each do |type_spec|
|
2324
|
+
visitor = TypeDeclarationBuilder.new(sym_tbl)
|
2325
|
+
type_spec.accept(visitor)
|
2326
|
+
type_dcls.concat(visitor.type_declarations)
|
2331
2327
|
end
|
2332
2328
|
|
2333
|
-
if
|
2334
|
-
|
2335
|
-
|
2336
|
-
|
2337
|
-
|
2338
|
-
result.push(TypedefDeclaration.new(declaration_specifiers,
|
2339
|
-
init_declarator, symbol))
|
2329
|
+
if sc = dcl_specs.storage_class_specifier and sc.type == :TYPEDEF
|
2330
|
+
init_dcrs.each do |init_dcr|
|
2331
|
+
id = init_dcr.declarator.identifier
|
2332
|
+
sym = sym_tbl.create_new_symbol(TypedefName, id)
|
2333
|
+
type_dcls.push(TypedefDeclaration.new(dcl_specs, init_dcr, sym))
|
2340
2334
|
end
|
2341
2335
|
end
|
2342
2336
|
|
2343
|
-
|
2337
|
+
type_dcls
|
2344
2338
|
end
|
2345
2339
|
|
2346
|
-
def build_function_declaration(
|
2347
|
-
|
2348
|
-
|
2349
|
-
declaration_specifiers.storage_class_specifier &&
|
2350
|
-
declaration_specifiers.storage_class_specifier.type == :TYPEDEF
|
2340
|
+
def build_function_declaration(dcl_specs, init_dcrs, sym_tbl)
|
2341
|
+
if dcl_specs && sc_spec = dcl_specs.storage_class_specifier and
|
2342
|
+
sc_spec.type == :TYPEDEF
|
2351
2343
|
return []
|
2352
2344
|
end
|
2353
2345
|
|
2354
|
-
|
2355
|
-
if
|
2356
|
-
|
2357
|
-
|
2358
|
-
|
2359
|
-
init_declarator, symbol))
|
2346
|
+
init_dcrs.each_with_object([]) do |init_dcr, fun_dcls|
|
2347
|
+
if init_dcr.declarator.function?
|
2348
|
+
id = init_dcr.declarator.identifier
|
2349
|
+
sym = sym_tbl.create_new_symbol(ObjectName, id)
|
2350
|
+
fun_dcls.push(FunctionDeclaration.new(dcl_specs, init_dcr, sym))
|
2360
2351
|
end
|
2361
2352
|
end
|
2362
2353
|
end
|
2363
2354
|
|
2364
|
-
def build_variable_declaration(
|
2365
|
-
|
2366
|
-
return [] unless declaration_specifiers
|
2355
|
+
def build_variable_declaration(dcl_specs, init_dcrs, sym_tbl)
|
2356
|
+
return [] unless dcl_specs
|
2367
2357
|
|
2368
|
-
unless
|
2369
|
-
declaration_specifiers.storage_class_specifier.type == :EXTERN
|
2358
|
+
unless sc = dcl_specs.storage_class_specifier and sc.type == :EXTERN
|
2370
2359
|
return []
|
2371
2360
|
end
|
2372
2361
|
|
2373
|
-
|
2374
|
-
if
|
2375
|
-
|
2376
|
-
|
2377
|
-
|
2378
|
-
result.push(VariableDeclaration.new(declaration_specifiers,
|
2379
|
-
declarator, symbol))
|
2362
|
+
init_dcrs.each_with_object([]) do |init_dcr, var_dcls|
|
2363
|
+
if init_dcr.declarator.variable?
|
2364
|
+
dcr = init_dcr.declarator
|
2365
|
+
sym = sym_tbl.create_new_symbol(ObjectName, dcr.identifier)
|
2366
|
+
var_dcls.push(VariableDeclaration.new(dcl_specs, dcr, sym))
|
2380
2367
|
end
|
2381
2368
|
end
|
2382
2369
|
end
|
2383
2370
|
|
2384
|
-
def build_variable_definition(
|
2385
|
-
|
2386
|
-
|
2387
|
-
declaration_specifiers.storage_class_specifier &&
|
2388
|
-
(declaration_specifiers.storage_class_specifier.type == :EXTERN ||
|
2389
|
-
declaration_specifiers.storage_class_specifier.type == :TYPEDEF)
|
2371
|
+
def build_variable_definition(dcl_specs, init_dcrs, sym_tbl)
|
2372
|
+
if dcl_specs && sc = dcl_specs.storage_class_specifier and
|
2373
|
+
sc.type == :EXTERN || sc.type == :TYPEDEF
|
2390
2374
|
return []
|
2391
2375
|
end
|
2392
2376
|
|
2393
|
-
|
2394
|
-
if
|
2395
|
-
|
2396
|
-
|
2397
|
-
|
2398
|
-
init_declarator, symbol))
|
2377
|
+
init_dcrs.each_with_object([]) do |init_dcr, var_defs|
|
2378
|
+
if init_dcr.declarator.variable?
|
2379
|
+
id = init_dcr.declarator.identifier
|
2380
|
+
sym = sym_tbl.create_new_symbol(ObjectName, id)
|
2381
|
+
var_defs.push(VariableDefinition.new(dcl_specs, init_dcr, sym))
|
2399
2382
|
end
|
2400
2383
|
end
|
2401
2384
|
end
|
@@ -2406,11 +2389,11 @@ module C #:nodoc:
|
|
2406
2389
|
include DeclarationSpecifiersHolder
|
2407
2390
|
include SyntaxNodeCollector
|
2408
2391
|
|
2409
|
-
def initialize(
|
2392
|
+
def initialize(dcl_specs, init_dcr, sym)
|
2410
2393
|
super()
|
2411
|
-
@declaration_specifiers =
|
2412
|
-
@init_declarator =
|
2413
|
-
@symbol =
|
2394
|
+
@declaration_specifiers = dcl_specs
|
2395
|
+
@init_declarator = init_dcr
|
2396
|
+
@symbol = sym
|
2414
2397
|
@type = nil
|
2415
2398
|
end
|
2416
2399
|
|
@@ -2445,11 +2428,11 @@ module C #:nodoc:
|
|
2445
2428
|
include SymbolicElement
|
2446
2429
|
include DeclarationSpecifiersHolder
|
2447
2430
|
|
2448
|
-
def initialize(
|
2431
|
+
def initialize(dcl_specs, dcr, sym)
|
2449
2432
|
super()
|
2450
|
-
@declaration_specifiers =
|
2451
|
-
@declarator =
|
2452
|
-
@symbol =
|
2433
|
+
@declaration_specifiers = dcl_specs
|
2434
|
+
@declarator = dcr
|
2435
|
+
@symbol = sym
|
2453
2436
|
@type = nil
|
2454
2437
|
end
|
2455
2438
|
|
@@ -2475,8 +2458,8 @@ module C #:nodoc:
|
|
2475
2458
|
class Definition < SyntaxNode
|
2476
2459
|
include DeclarationSpecifiersHolder
|
2477
2460
|
|
2478
|
-
def initialize(
|
2479
|
-
@declaration_specifiers =
|
2461
|
+
def initialize(dcl_specs)
|
2462
|
+
@declaration_specifiers = dcl_specs
|
2480
2463
|
@type = nil
|
2481
2464
|
end
|
2482
2465
|
|
@@ -2487,11 +2470,11 @@ module C #:nodoc:
|
|
2487
2470
|
class VariableDefinition < Definition
|
2488
2471
|
include SymbolicElement
|
2489
2472
|
|
2490
|
-
def initialize(
|
2491
|
-
super(
|
2473
|
+
def initialize(dcl_specs, init_dcr, sym)
|
2474
|
+
super(dcl_specs)
|
2492
2475
|
|
2493
|
-
@init_declarator =
|
2494
|
-
@symbol =
|
2476
|
+
@init_declarator = init_dcr
|
2477
|
+
@symbol = sym
|
2495
2478
|
end
|
2496
2479
|
|
2497
2480
|
attr_reader :init_declarator
|
@@ -2518,9 +2501,9 @@ module C #:nodoc:
|
|
2518
2501
|
class TypeDeclaration < SyntaxNode
|
2519
2502
|
include SymbolicElement
|
2520
2503
|
|
2521
|
-
def initialize(
|
2504
|
+
def initialize(sym)
|
2522
2505
|
super()
|
2523
|
-
@symbol =
|
2506
|
+
@symbol = sym
|
2524
2507
|
end
|
2525
2508
|
|
2526
2509
|
attr_reader :symbol
|
@@ -2529,10 +2512,10 @@ module C #:nodoc:
|
|
2529
2512
|
class TypedefDeclaration < TypeDeclaration
|
2530
2513
|
include DeclarationSpecifiersHolder
|
2531
2514
|
|
2532
|
-
def initialize(
|
2533
|
-
super(
|
2534
|
-
@declaration_specifiers =
|
2535
|
-
@init_declarator =
|
2515
|
+
def initialize(dcl_specs, init_dcr, sym)
|
2516
|
+
super(sym)
|
2517
|
+
@declaration_specifiers = dcl_specs
|
2518
|
+
@init_declarator = init_dcr
|
2536
2519
|
@type = nil
|
2537
2520
|
end
|
2538
2521
|
|
@@ -2559,10 +2542,10 @@ module C #:nodoc:
|
|
2559
2542
|
end
|
2560
2543
|
|
2561
2544
|
class StructTypeDeclaration < TypeDeclaration
|
2562
|
-
def initialize(
|
2563
|
-
super(
|
2564
|
-
@struct_specifier =
|
2565
|
-
@struct_declarations =
|
2545
|
+
def initialize(struct_spec, sym)
|
2546
|
+
super(sym)
|
2547
|
+
@struct_specifier = struct_spec
|
2548
|
+
@struct_declarations = struct_spec.struct_declarations
|
2566
2549
|
@type = nil
|
2567
2550
|
end
|
2568
2551
|
|
@@ -2586,18 +2569,18 @@ module C #:nodoc:
|
|
2586
2569
|
end
|
2587
2570
|
|
2588
2571
|
class PseudoStructTypeDeclaration < StructTypeDeclaration
|
2589
|
-
def initialize(
|
2590
|
-
super(
|
2572
|
+
def initialize(struct_spec)
|
2573
|
+
super(struct_spec, nil)
|
2591
2574
|
end
|
2592
2575
|
|
2593
|
-
def mark_as_referred_by(
|
2576
|
+
def mark_as_referred_by(tok) end
|
2594
2577
|
end
|
2595
2578
|
|
2596
2579
|
class UnionTypeDeclaration < TypeDeclaration
|
2597
|
-
def initialize(
|
2598
|
-
super(
|
2599
|
-
@union_specifier =
|
2600
|
-
@struct_declarations =
|
2580
|
+
def initialize(union_spec, sym)
|
2581
|
+
super(sym)
|
2582
|
+
@union_specifier = union_spec
|
2583
|
+
@struct_declarations = union_spec.struct_declarations
|
2601
2584
|
@type = nil
|
2602
2585
|
end
|
2603
2586
|
|
@@ -2621,17 +2604,17 @@ module C #:nodoc:
|
|
2621
2604
|
end
|
2622
2605
|
|
2623
2606
|
class PseudoUnionTypeDeclaration < UnionTypeDeclaration
|
2624
|
-
def initialize(
|
2625
|
-
super(
|
2607
|
+
def initialize(union_spec)
|
2608
|
+
super(union_spec, nil)
|
2626
2609
|
end
|
2627
2610
|
|
2628
|
-
def mark_as_referred_by(
|
2611
|
+
def mark_as_referred_by(tok) end
|
2629
2612
|
end
|
2630
2613
|
|
2631
2614
|
class EnumTypeDeclaration < TypeDeclaration
|
2632
|
-
def initialize(
|
2633
|
-
super(
|
2634
|
-
@enum_specifier =
|
2615
|
+
def initialize(enum_spec, sym)
|
2616
|
+
super(sym)
|
2617
|
+
@enum_specifier = enum_spec
|
2635
2618
|
@type = nil
|
2636
2619
|
end
|
2637
2620
|
|
@@ -2657,11 +2640,11 @@ module C #:nodoc:
|
|
2657
2640
|
end
|
2658
2641
|
|
2659
2642
|
class PseudoEnumTypeDeclaration < EnumTypeDeclaration
|
2660
|
-
def initialize(
|
2661
|
-
super(
|
2643
|
+
def initialize(enum_spec)
|
2644
|
+
super(enum_spec, nil)
|
2662
2645
|
end
|
2663
2646
|
|
2664
|
-
def mark_as_referred_by(
|
2647
|
+
def mark_as_referred_by(tok) end
|
2665
2648
|
end
|
2666
2649
|
|
2667
2650
|
class DeclarationSpecifiers < SyntaxNode
|
@@ -2696,10 +2679,10 @@ module C #:nodoc:
|
|
2696
2679
|
end
|
2697
2680
|
|
2698
2681
|
class InitDeclarator < SyntaxNode
|
2699
|
-
def initialize(
|
2682
|
+
def initialize(dcr, init)
|
2700
2683
|
super()
|
2701
|
-
@declarator =
|
2702
|
-
@initializer =
|
2684
|
+
@declarator = dcr
|
2685
|
+
@initializer = init
|
2703
2686
|
end
|
2704
2687
|
|
2705
2688
|
attr_reader :declarator
|
@@ -2721,9 +2704,9 @@ module C #:nodoc:
|
|
2721
2704
|
end
|
2722
2705
|
|
2723
2706
|
class StandardTypeSpecifier < TypeSpecifier
|
2724
|
-
def initialize(
|
2707
|
+
def initialize(tok)
|
2725
2708
|
super()
|
2726
|
-
@token =
|
2709
|
+
@token = tok
|
2727
2710
|
end
|
2728
2711
|
|
2729
2712
|
attr_reader :token
|
@@ -2742,9 +2725,9 @@ module C #:nodoc:
|
|
2742
2725
|
end
|
2743
2726
|
|
2744
2727
|
class TypedefTypeSpecifier < TypeSpecifier
|
2745
|
-
def initialize(
|
2728
|
+
def initialize(tok)
|
2746
2729
|
super()
|
2747
|
-
@token =
|
2730
|
+
@token = tok
|
2748
2731
|
end
|
2749
2732
|
|
2750
2733
|
attr_reader :token
|
@@ -2768,10 +2751,10 @@ module C #:nodoc:
|
|
2768
2751
|
end
|
2769
2752
|
|
2770
2753
|
class StructSpecifier < TypeSpecifier
|
2771
|
-
def initialize(
|
2754
|
+
def initialize(id, struct_dcls)
|
2772
2755
|
super()
|
2773
|
-
@identifier =
|
2774
|
-
@struct_declarations =
|
2756
|
+
@identifier = id
|
2757
|
+
@struct_declarations = struct_dcls
|
2775
2758
|
end
|
2776
2759
|
|
2777
2760
|
attr_reader :identifier
|
@@ -2800,10 +2783,10 @@ module C #:nodoc:
|
|
2800
2783
|
end
|
2801
2784
|
|
2802
2785
|
class UnionSpecifier < TypeSpecifier
|
2803
|
-
def initialize(
|
2786
|
+
def initialize(id, struct_dcls)
|
2804
2787
|
super()
|
2805
|
-
@identifier =
|
2806
|
-
@struct_declarations =
|
2788
|
+
@identifier = id
|
2789
|
+
@struct_declarations = struct_dcls
|
2807
2790
|
end
|
2808
2791
|
|
2809
2792
|
attr_reader :identifier
|
@@ -2833,11 +2816,11 @@ module C #:nodoc:
|
|
2833
2816
|
end
|
2834
2817
|
|
2835
2818
|
class StructDeclaration < SyntaxNode
|
2836
|
-
def initialize(
|
2819
|
+
def initialize(spec_qual_list, struct_dcrs)
|
2837
2820
|
super()
|
2838
|
-
@specifier_qualifier_list =
|
2839
|
-
@struct_declarators =
|
2840
|
-
@items = build_items(
|
2821
|
+
@specifier_qualifier_list = spec_qual_list
|
2822
|
+
@struct_declarators = struct_dcrs
|
2823
|
+
@items = build_items(spec_qual_list, struct_dcrs)
|
2841
2824
|
end
|
2842
2825
|
|
2843
2826
|
attr_reader :specifier_qualifier_list
|
@@ -2858,21 +2841,20 @@ module C #:nodoc:
|
|
2858
2841
|
end
|
2859
2842
|
|
2860
2843
|
private
|
2861
|
-
def build_items(
|
2862
|
-
|
2844
|
+
def build_items(spec_qual_list, struct_dcrs)
|
2845
|
+
struct_dcrs.each_with_object([]) do |struct_dcr, items|
|
2863
2846
|
# FIXME: Must support unnamed bit padding.
|
2864
|
-
next unless
|
2865
|
-
items.push(MemberDeclaration.new(
|
2866
|
-
struct_declarator))
|
2847
|
+
next unless struct_dcr.declarator
|
2848
|
+
items.push(MemberDeclaration.new(spec_qual_list, struct_dcr))
|
2867
2849
|
end
|
2868
2850
|
end
|
2869
2851
|
end
|
2870
2852
|
|
2871
2853
|
class MemberDeclaration < SyntaxNode
|
2872
|
-
def initialize(
|
2854
|
+
def initialize(spec_qual_list, struct_dcl)
|
2873
2855
|
super()
|
2874
|
-
@specifier_qualifier_list =
|
2875
|
-
@struct_declarator =
|
2856
|
+
@specifier_qualifier_list = spec_qual_list
|
2857
|
+
@struct_declarator = struct_dcl
|
2876
2858
|
@type = nil
|
2877
2859
|
end
|
2878
2860
|
|
@@ -2918,10 +2900,10 @@ module C #:nodoc:
|
|
2918
2900
|
end
|
2919
2901
|
|
2920
2902
|
class StructDeclarator < SyntaxNode
|
2921
|
-
def initialize(
|
2903
|
+
def initialize(dcr, expr)
|
2922
2904
|
super()
|
2923
|
-
@declarator =
|
2924
|
-
@expression =
|
2905
|
+
@declarator = dcr
|
2906
|
+
@expression = expr
|
2925
2907
|
end
|
2926
2908
|
|
2927
2909
|
attr_reader :declarator
|
@@ -2941,10 +2923,10 @@ module C #:nodoc:
|
|
2941
2923
|
end
|
2942
2924
|
|
2943
2925
|
class EnumSpecifier < TypeSpecifier
|
2944
|
-
def initialize(
|
2926
|
+
def initialize(id, enums, trailing_comma = nil)
|
2945
2927
|
super()
|
2946
|
-
@identifier =
|
2947
|
-
@enumerators =
|
2928
|
+
@identifier = id
|
2929
|
+
@enumerators = enums
|
2948
2930
|
@trailing_comma = trailing_comma
|
2949
2931
|
end
|
2950
2932
|
|
@@ -2977,11 +2959,11 @@ module C #:nodoc:
|
|
2977
2959
|
class Enumerator < SyntaxNode
|
2978
2960
|
include SymbolicElement
|
2979
2961
|
|
2980
|
-
def initialize(
|
2962
|
+
def initialize(id, expr, sym)
|
2981
2963
|
super()
|
2982
|
-
@identifier =
|
2983
|
-
@expression =
|
2984
|
-
@symbol =
|
2964
|
+
@identifier = id
|
2965
|
+
@expression = expr
|
2966
|
+
@symbol = sym
|
2985
2967
|
end
|
2986
2968
|
|
2987
2969
|
attr_reader :identifier
|
@@ -3008,9 +2990,9 @@ module C #:nodoc:
|
|
3008
2990
|
end
|
3009
2991
|
|
3010
2992
|
class TypeofTypeSpecifier < TypeSpecifier
|
3011
|
-
def initialize(
|
2993
|
+
def initialize(expr, type_name)
|
3012
2994
|
super()
|
3013
|
-
@expression =
|
2995
|
+
@expression = expr
|
3014
2996
|
@type_name = type_name
|
3015
2997
|
end
|
3016
2998
|
|
@@ -3051,8 +3033,8 @@ module C #:nodoc:
|
|
3051
3033
|
false
|
3052
3034
|
end
|
3053
3035
|
|
3054
|
-
def full=(
|
3055
|
-
@full =
|
3036
|
+
def full=(dcr_is_full)
|
3037
|
+
@full = dcr_is_full
|
3056
3038
|
|
3057
3039
|
# NOTE: The ISO C99 standard says;
|
3058
3040
|
#
|
@@ -3067,7 +3049,7 @@ module C #:nodoc:
|
|
3067
3049
|
# specified by the full declarator is said to be variably modified.
|
3068
3050
|
# Furthermore, any type derived by declarator type derivation from a
|
3069
3051
|
# variably modified type is itself variably modified.
|
3070
|
-
if
|
3052
|
+
if dcr_is_full
|
3071
3053
|
append_sequence_point!
|
3072
3054
|
else
|
3073
3055
|
delete_sequence_point!
|
@@ -3104,9 +3086,9 @@ module C #:nodoc:
|
|
3104
3086
|
end
|
3105
3087
|
|
3106
3088
|
class IdentifierDeclarator < Declarator
|
3107
|
-
def initialize(
|
3089
|
+
def initialize(id)
|
3108
3090
|
super()
|
3109
|
-
@identifier =
|
3091
|
+
@identifier = id
|
3110
3092
|
end
|
3111
3093
|
|
3112
3094
|
attr_reader :identifier
|
@@ -3142,15 +3124,15 @@ module C #:nodoc:
|
|
3142
3124
|
end
|
3143
3125
|
|
3144
3126
|
class GroupedDeclarator < Declarator
|
3145
|
-
def initialize(
|
3127
|
+
def initialize(base_dcr)
|
3146
3128
|
super()
|
3147
|
-
@base =
|
3129
|
+
@base = base_dcr
|
3148
3130
|
end
|
3149
3131
|
|
3150
3132
|
attr_reader :base
|
3151
3133
|
|
3152
3134
|
def location
|
3153
|
-
@base.location
|
3135
|
+
@base ? @base.location || head_location : head_location
|
3154
3136
|
end
|
3155
3137
|
|
3156
3138
|
def identifier
|
@@ -3181,17 +3163,17 @@ module C #:nodoc:
|
|
3181
3163
|
end
|
3182
3164
|
|
3183
3165
|
class ArrayDeclarator < Declarator
|
3184
|
-
def initialize(
|
3166
|
+
def initialize(base_dcr, size_expr)
|
3185
3167
|
super()
|
3186
|
-
@base =
|
3187
|
-
@size_expression =
|
3168
|
+
@base = base_dcr
|
3169
|
+
@size_expression = size_expr
|
3188
3170
|
end
|
3189
3171
|
|
3190
3172
|
attr_reader :base
|
3191
3173
|
attr_reader :size_expression
|
3192
3174
|
|
3193
3175
|
def location
|
3194
|
-
@base.location
|
3176
|
+
@base ? @base.location || head_location : head_location
|
3195
3177
|
end
|
3196
3178
|
|
3197
3179
|
def identifier
|
@@ -3223,15 +3205,15 @@ module C #:nodoc:
|
|
3223
3205
|
end
|
3224
3206
|
|
3225
3207
|
class FunctionDeclarator < Declarator
|
3226
|
-
def initialize(
|
3208
|
+
def initialize(base_dcr)
|
3227
3209
|
super()
|
3228
|
-
@base =
|
3210
|
+
@base = base_dcr
|
3229
3211
|
end
|
3230
3212
|
|
3231
3213
|
attr_reader :base
|
3232
3214
|
|
3233
3215
|
def location
|
3234
|
-
@base.location
|
3216
|
+
@base ? @base.location || head_location : head_location
|
3235
3217
|
end
|
3236
3218
|
|
3237
3219
|
def identifier
|
@@ -3251,9 +3233,9 @@ module C #:nodoc:
|
|
3251
3233
|
end
|
3252
3234
|
|
3253
3235
|
class AnsiFunctionDeclarator < FunctionDeclarator
|
3254
|
-
def initialize(
|
3255
|
-
super(
|
3256
|
-
@parameter_type_list =
|
3236
|
+
def initialize(base_dcr, param_type_list)
|
3237
|
+
super(base_dcr)
|
3238
|
+
@parameter_type_list = param_type_list
|
3257
3239
|
end
|
3258
3240
|
|
3259
3241
|
attr_accessor :parameter_type_list
|
@@ -3268,9 +3250,9 @@ module C #:nodoc:
|
|
3268
3250
|
end
|
3269
3251
|
|
3270
3252
|
class KandRFunctionDeclarator < FunctionDeclarator
|
3271
|
-
def initialize(
|
3272
|
-
super(
|
3273
|
-
@identifier_list =
|
3253
|
+
def initialize(base_dcr, id_list)
|
3254
|
+
super(base_dcr)
|
3255
|
+
@identifier_list = id_list
|
3274
3256
|
end
|
3275
3257
|
|
3276
3258
|
attr_reader :identifier_list
|
@@ -3299,9 +3281,9 @@ module C #:nodoc:
|
|
3299
3281
|
end
|
3300
3282
|
|
3301
3283
|
class ParameterTypeList < SyntaxNode
|
3302
|
-
def initialize(
|
3284
|
+
def initialize(params, have_va_list)
|
3303
3285
|
super()
|
3304
|
-
@parameters =
|
3286
|
+
@parameters = params
|
3305
3287
|
@have_va_list = have_va_list
|
3306
3288
|
end
|
3307
3289
|
|
@@ -3323,10 +3305,10 @@ module C #:nodoc:
|
|
3323
3305
|
class ParameterDeclaration < SyntaxNode
|
3324
3306
|
include DeclarationSpecifiersHolder
|
3325
3307
|
|
3326
|
-
def initialize(
|
3308
|
+
def initialize(dcl_specs, dcr)
|
3327
3309
|
super()
|
3328
|
-
@declaration_specifiers =
|
3329
|
-
@declarator =
|
3310
|
+
@declaration_specifiers = dcl_specs
|
3311
|
+
@declarator = dcr
|
3330
3312
|
@type = nil
|
3331
3313
|
end
|
3332
3314
|
|
@@ -3357,9 +3339,9 @@ module C #:nodoc:
|
|
3357
3339
|
end
|
3358
3340
|
|
3359
3341
|
class ErrorStatement < Statement
|
3360
|
-
def initialize(
|
3342
|
+
def initialize(err_tok)
|
3361
3343
|
super()
|
3362
|
-
@error_token =
|
3344
|
+
@error_token = err_tok
|
3363
3345
|
end
|
3364
3346
|
|
3365
3347
|
def location
|
@@ -3374,10 +3356,10 @@ module C #:nodoc:
|
|
3374
3356
|
class LabeledStatement < Statement; end
|
3375
3357
|
|
3376
3358
|
class GenericLabeledStatement < LabeledStatement
|
3377
|
-
def initialize(label,
|
3359
|
+
def initialize(label, stmt)
|
3378
3360
|
super()
|
3379
3361
|
@label = label
|
3380
|
-
@statement =
|
3362
|
+
@statement = stmt
|
3381
3363
|
@referrers = []
|
3382
3364
|
end
|
3383
3365
|
|
@@ -3396,10 +3378,10 @@ module C #:nodoc:
|
|
3396
3378
|
end
|
3397
3379
|
|
3398
3380
|
class CaseLabeledStatement < LabeledStatement
|
3399
|
-
def initialize(
|
3381
|
+
def initialize(expr, stmt)
|
3400
3382
|
super()
|
3401
|
-
@expression =
|
3402
|
-
@statement =
|
3383
|
+
@expression = expr
|
3384
|
+
@statement = stmt
|
3403
3385
|
end
|
3404
3386
|
|
3405
3387
|
attr_reader :expression
|
@@ -3417,9 +3399,9 @@ module C #:nodoc:
|
|
3417
3399
|
end
|
3418
3400
|
|
3419
3401
|
class DefaultLabeledStatement < LabeledStatement
|
3420
|
-
def initialize(
|
3402
|
+
def initialize(stmt)
|
3421
3403
|
super()
|
3422
|
-
@statement =
|
3404
|
+
@statement = stmt
|
3423
3405
|
end
|
3424
3406
|
|
3425
3407
|
attr_reader :statement
|
@@ -3453,9 +3435,9 @@ module C #:nodoc:
|
|
3453
3435
|
end
|
3454
3436
|
|
3455
3437
|
class ExpressionStatement < Statement
|
3456
|
-
def initialize(
|
3438
|
+
def initialize(expr)
|
3457
3439
|
super()
|
3458
|
-
@expression =
|
3440
|
+
@expression = expr
|
3459
3441
|
end
|
3460
3442
|
|
3461
3443
|
attr_reader :expression
|
@@ -3473,11 +3455,11 @@ module C #:nodoc:
|
|
3473
3455
|
class SelectionStatement < Statement; end
|
3474
3456
|
|
3475
3457
|
class IfStatement < SelectionStatement
|
3476
|
-
def initialize(
|
3458
|
+
def initialize(expr, stmt, header_term)
|
3477
3459
|
super()
|
3478
|
-
@expression =
|
3479
|
-
@statement =
|
3480
|
-
@header_terminator =
|
3460
|
+
@expression = expr
|
3461
|
+
@statement = stmt
|
3462
|
+
@header_terminator = header_term
|
3481
3463
|
end
|
3482
3464
|
|
3483
3465
|
attr_reader :expression
|
@@ -3495,14 +3477,13 @@ module C #:nodoc:
|
|
3495
3477
|
end
|
3496
3478
|
|
3497
3479
|
class IfElseStatement < SelectionStatement
|
3498
|
-
def initialize(
|
3499
|
-
then_header_terminator, else_header_terminator)
|
3480
|
+
def initialize(expr, then_stmt, else_stmt, then_term, else_term)
|
3500
3481
|
super()
|
3501
|
-
@expression =
|
3502
|
-
@then_statement =
|
3503
|
-
@else_statement =
|
3504
|
-
@then_header_terminator =
|
3505
|
-
@else_header_terminator =
|
3482
|
+
@expression = expr
|
3483
|
+
@then_statement = then_stmt
|
3484
|
+
@else_statement = else_stmt
|
3485
|
+
@then_header_terminator = then_term
|
3486
|
+
@else_header_terminator = else_term
|
3506
3487
|
end
|
3507
3488
|
|
3508
3489
|
attr_reader :expression
|
@@ -3524,10 +3505,10 @@ module C #:nodoc:
|
|
3524
3505
|
end
|
3525
3506
|
|
3526
3507
|
class SwitchStatement < SelectionStatement
|
3527
|
-
def initialize(
|
3508
|
+
def initialize(expr, stmt)
|
3528
3509
|
super()
|
3529
|
-
@expression =
|
3530
|
-
@statement =
|
3510
|
+
@expression = expr
|
3511
|
+
@statement = stmt
|
3531
3512
|
derive_clause_conditions
|
3532
3513
|
end
|
3533
3514
|
|
@@ -3545,71 +3526,70 @@ module C #:nodoc:
|
|
3545
3526
|
|
3546
3527
|
private
|
3547
3528
|
def derive_clause_conditions
|
3548
|
-
|
3549
|
-
|
3550
|
-
|
3551
|
-
@statement.block_items.each do |block_item|
|
3552
|
-
while block_item.kind_of?(GenericLabeledStatement)
|
3553
|
-
block_item = block_item.statement
|
3554
|
-
end
|
3529
|
+
case_exprs = []
|
3530
|
+
default_stmt = nil
|
3555
3531
|
|
3556
|
-
|
3532
|
+
@statement.block_items.each do |item|
|
3533
|
+
case item
|
3534
|
+
when GenericLabeledStatement
|
3535
|
+
item = item.statement
|
3536
|
+
redo
|
3557
3537
|
when CaseLabeledStatement
|
3558
|
-
|
3559
|
-
@expression,
|
3560
|
-
|
3538
|
+
item.normalized_expression =
|
3539
|
+
equal_to_expression(@expression, item.expression, item.location)
|
3540
|
+
case_exprs.push(item.normalized_expression)
|
3541
|
+
item = item.statement
|
3542
|
+
redo
|
3561
3543
|
when DefaultLabeledStatement
|
3562
|
-
|
3544
|
+
default_stmt = item
|
3545
|
+
item = item.statement
|
3546
|
+
redo
|
3563
3547
|
end
|
3564
3548
|
end
|
3565
3549
|
|
3566
|
-
if
|
3567
|
-
|
3568
|
-
derive_default_clause_condition(
|
3569
|
-
default_labeled_statement.location)
|
3550
|
+
if default_stmt
|
3551
|
+
default_stmt.normalized_expression =
|
3552
|
+
derive_default_clause_condition(case_exprs, default_stmt.location)
|
3570
3553
|
end
|
3571
3554
|
end
|
3572
3555
|
|
3573
|
-
def derive_default_clause_condition(
|
3574
|
-
if
|
3575
|
-
equal_to_expression(@expression, @expression,
|
3556
|
+
def derive_default_clause_condition(case_exprs, loc)
|
3557
|
+
if case_exprs.empty?
|
3558
|
+
equal_to_expression(@expression, @expression, loc)
|
3576
3559
|
else
|
3577
|
-
|
3578
|
-
not_equal_to_expression(expr.lhs_operand, expr.rhs_operand,
|
3579
|
-
}.reduce
|
3580
|
-
logical_and_expression(result, expr, location)
|
3581
|
-
end
|
3560
|
+
case_exprs.map { |expr|
|
3561
|
+
not_equal_to_expression(expr.lhs_operand, expr.rhs_operand, loc)
|
3562
|
+
}.reduce { |cond, expr| logical_and_expression(cond, expr, loc) }
|
3582
3563
|
end
|
3583
3564
|
end
|
3584
3565
|
|
3585
|
-
def equal_to_expression(lhs, rhs,
|
3586
|
-
EqualityExpression.new(equal_to_operator(
|
3566
|
+
def equal_to_expression(lhs, rhs, loc)
|
3567
|
+
EqualityExpression.new(equal_to_operator(loc), lhs, rhs)
|
3587
3568
|
end
|
3588
3569
|
|
3589
|
-
def not_equal_to_expression(lhs, rhs,
|
3590
|
-
EqualityExpression.new(not_equal_to_operator(
|
3570
|
+
def not_equal_to_expression(lhs, rhs, loc)
|
3571
|
+
EqualityExpression.new(not_equal_to_operator(loc), lhs, rhs)
|
3591
3572
|
end
|
3592
3573
|
|
3593
|
-
def logical_and_expression(lhs, rhs,
|
3594
|
-
LogicalAndExpression.new(logical_and_operator(
|
3574
|
+
def logical_and_expression(lhs, rhs, loc)
|
3575
|
+
LogicalAndExpression.new(logical_and_operator(loc), lhs, rhs)
|
3595
3576
|
end
|
3596
3577
|
|
3597
|
-
def equal_to_operator(
|
3598
|
-
Token.new("==", "==",
|
3578
|
+
def equal_to_operator(loc)
|
3579
|
+
Token.new("==", "==", loc)
|
3599
3580
|
end
|
3600
3581
|
|
3601
|
-
def not_equal_to_operator(
|
3602
|
-
Token.new("!=", "!=",
|
3582
|
+
def not_equal_to_operator(loc)
|
3583
|
+
Token.new("!=", "!=", loc)
|
3603
3584
|
end
|
3604
3585
|
|
3605
|
-
def logical_and_operator(
|
3606
|
-
Token.new("&&", "&&",
|
3586
|
+
def logical_and_operator(loc)
|
3587
|
+
Token.new("&&", "&&", loc)
|
3607
3588
|
end
|
3608
3589
|
end
|
3609
3590
|
|
3610
3591
|
class IterationStatement < Statement
|
3611
3592
|
include SyntaxNodeCollector
|
3612
|
-
extend Memoizable
|
3613
3593
|
|
3614
3594
|
def deduct_controlling_expression
|
3615
3595
|
subclass_responsibility
|
@@ -3625,9 +3605,9 @@ module C #:nodoc:
|
|
3625
3605
|
end
|
3626
3606
|
|
3627
3607
|
private
|
3628
|
-
def deduct_controlling_expression_candidates(
|
3608
|
+
def deduct_controlling_expression_candidates(rough_cands)
|
3629
3609
|
varying_var_names = varying_variable_names
|
3630
|
-
|
3610
|
+
rough_cands.select do |expr_pair|
|
3631
3611
|
collect_object_specifiers(expr_pair.first).any? do |os|
|
3632
3612
|
varying_var_names.include?(os.identifier.value)
|
3633
3613
|
end
|
@@ -3655,8 +3635,10 @@ module C #:nodoc:
|
|
3655
3635
|
def contain_loop_breaking?(node)
|
3656
3636
|
items = node.kind_of?(CompoundStatement) ? node.block_items : [node]
|
3657
3637
|
items.any? do |item|
|
3658
|
-
item = item.statement while item.kind_of?(GenericLabeledStatement)
|
3659
3638
|
case item
|
3639
|
+
when GenericLabeledStatement
|
3640
|
+
item = item.statement
|
3641
|
+
redo
|
3660
3642
|
when GotoStatement
|
3661
3643
|
# FIXME: Must check whether the goto-statement goes outside of the
|
3662
3644
|
# loop or not.
|
@@ -3714,11 +3696,11 @@ module C #:nodoc:
|
|
3714
3696
|
end
|
3715
3697
|
|
3716
3698
|
class WhileStatement < IterationStatement
|
3717
|
-
def initialize(
|
3699
|
+
def initialize(expr, stmt, header_term)
|
3718
3700
|
super()
|
3719
|
-
@expression =
|
3720
|
-
@statement =
|
3721
|
-
@header_terminator =
|
3701
|
+
@expression = expr
|
3702
|
+
@statement = stmt
|
3703
|
+
@header_terminator = header_term
|
3722
3704
|
end
|
3723
3705
|
|
3724
3706
|
attr_reader :expression
|
@@ -3730,10 +3712,8 @@ module C #:nodoc:
|
|
3730
3712
|
end
|
3731
3713
|
|
3732
3714
|
def deduct_controlling_expression
|
3733
|
-
|
3734
|
-
|
3735
|
-
[@expression, @expression]
|
3736
|
-
] + selections.map { |stmt|
|
3715
|
+
sels = collect_loop_breaking_selection_statements(@statement)
|
3716
|
+
rough_cands = [[@expression, @expression]] + sels.map { |stmt|
|
3737
3717
|
[stmt.expression,
|
3738
3718
|
stmt.expression.to_normalized_logical.to_complemental_logical]
|
3739
3719
|
}
|
@@ -3743,7 +3723,7 @@ module C #:nodoc:
|
|
3743
3723
|
# FIXME: When the loop breaking selection-statement is a
|
3744
3724
|
# if-else-statement and the loop breaking is in the else branch,
|
3745
3725
|
# the controlling expression should be inverted.
|
3746
|
-
deduct_controlling_expression_candidates(
|
3726
|
+
deduct_controlling_expression_candidates(rough_cands).first
|
3747
3727
|
end
|
3748
3728
|
|
3749
3729
|
def inspect(indent = 0)
|
@@ -3753,12 +3733,12 @@ module C #:nodoc:
|
|
3753
3733
|
end
|
3754
3734
|
|
3755
3735
|
class DoStatement < IterationStatement
|
3756
|
-
def initialize(
|
3736
|
+
def initialize(stmt, expr, header_term, footer_init)
|
3757
3737
|
super()
|
3758
|
-
@statement =
|
3759
|
-
@expression =
|
3760
|
-
@header_terminator =
|
3761
|
-
@footer_initiator =
|
3738
|
+
@statement = stmt
|
3739
|
+
@expression = expr
|
3740
|
+
@header_terminator = header_term
|
3741
|
+
@footer_initiator = footer_init
|
3762
3742
|
end
|
3763
3743
|
|
3764
3744
|
attr_reader :statement
|
@@ -3771,10 +3751,8 @@ module C #:nodoc:
|
|
3771
3751
|
end
|
3772
3752
|
|
3773
3753
|
def deduct_controlling_expression
|
3774
|
-
|
3775
|
-
|
3776
|
-
[@expression, @expression]
|
3777
|
-
] + selections.map { |stmt|
|
3754
|
+
sels = collect_loop_breaking_selection_statements(@statement)
|
3755
|
+
rough_cands = [[@expression, @expression]] + sels.map { |stmt|
|
3778
3756
|
[stmt.expression,
|
3779
3757
|
stmt.expression.to_normalized_logical.to_complemental_logical]
|
3780
3758
|
}
|
@@ -3784,7 +3762,7 @@ module C #:nodoc:
|
|
3784
3762
|
# FIXME: When the loop breaking selection-statement is a
|
3785
3763
|
# if-else-statement and the loop breaking is in the else branch,
|
3786
3764
|
# the controlling expression should be inverted.
|
3787
|
-
deduct_controlling_expression_candidates(
|
3765
|
+
deduct_controlling_expression_candidates(rough_cands).first
|
3788
3766
|
end
|
3789
3767
|
|
3790
3768
|
def inspect(indent = 0)
|
@@ -3794,14 +3772,13 @@ module C #:nodoc:
|
|
3794
3772
|
end
|
3795
3773
|
|
3796
3774
|
class ForStatement < IterationStatement
|
3797
|
-
def initialize(
|
3798
|
-
body_statement, header_terminator)
|
3775
|
+
def initialize(init_stmt, cond_stmt, expr, body_stmt, header_term)
|
3799
3776
|
super()
|
3800
|
-
@initial_statement
|
3801
|
-
@condition_statement =
|
3802
|
-
@expression
|
3803
|
-
@body_statement
|
3804
|
-
@header_terminator
|
3777
|
+
@initial_statement = init_stmt
|
3778
|
+
@condition_statement = cond_stmt
|
3779
|
+
@expression = expr
|
3780
|
+
@body_statement = body_stmt
|
3781
|
+
@header_terminator = header_term
|
3805
3782
|
end
|
3806
3783
|
|
3807
3784
|
attr_reader :initial_statement
|
@@ -3815,10 +3792,10 @@ module C #:nodoc:
|
|
3815
3792
|
end
|
3816
3793
|
|
3817
3794
|
def deduct_controlling_expression
|
3818
|
-
|
3819
|
-
|
3795
|
+
sels = collect_loop_breaking_selection_statements(@body_statement)
|
3796
|
+
rough_cands = [
|
3820
3797
|
[@condition_statement.expression, @condition_statement.expression]
|
3821
|
-
] +
|
3798
|
+
] + sels.map { |stmt|
|
3822
3799
|
[stmt.expression,
|
3823
3800
|
stmt.expression.to_normalized_logical.to_complemental_logical]
|
3824
3801
|
}
|
@@ -3828,7 +3805,7 @@ module C #:nodoc:
|
|
3828
3805
|
# FIXME: When the loop breaking selection-statement is a
|
3829
3806
|
# if-else-statement and the loop breaking is in the else branch,
|
3830
3807
|
# the controlling expression should be inverted.
|
3831
|
-
deduct_controlling_expression_candidates(
|
3808
|
+
deduct_controlling_expression_candidates(rough_cands).first
|
3832
3809
|
end
|
3833
3810
|
|
3834
3811
|
def inspect(indent = 0)
|
@@ -3841,14 +3818,13 @@ module C #:nodoc:
|
|
3841
3818
|
end
|
3842
3819
|
|
3843
3820
|
class C99ForStatement < IterationStatement
|
3844
|
-
def initialize(
|
3845
|
-
body_statement, header_terminator)
|
3821
|
+
def initialize(dcl, cond_stmt, expr, body_stmt, header_term)
|
3846
3822
|
super()
|
3847
|
-
@declaration
|
3848
|
-
@condition_statement =
|
3849
|
-
@expression
|
3850
|
-
@body_statement
|
3851
|
-
@header_terminator
|
3823
|
+
@declaration = dcl
|
3824
|
+
@condition_statement = cond_stmt
|
3825
|
+
@expression = expr
|
3826
|
+
@body_statement = body_stmt
|
3827
|
+
@header_terminator = header_term
|
3852
3828
|
end
|
3853
3829
|
|
3854
3830
|
attr_reader :declaration
|
@@ -3862,10 +3838,10 @@ module C #:nodoc:
|
|
3862
3838
|
end
|
3863
3839
|
|
3864
3840
|
def deduct_controlling_expression
|
3865
|
-
|
3866
|
-
|
3841
|
+
sels = collect_loop_breaking_selection_statements(@body_statement)
|
3842
|
+
rough_cands = [
|
3867
3843
|
[@condition_statement.expression, @condition_statement.expression]
|
3868
|
-
] +
|
3844
|
+
] + sels.map { |stmt|
|
3869
3845
|
[stmt.expression,
|
3870
3846
|
stmt.expression.to_normalized_logical.to_complemental_logical]
|
3871
3847
|
}
|
@@ -3875,7 +3851,7 @@ module C #:nodoc:
|
|
3875
3851
|
# FIXME: When the loop breaking selection-statement is a
|
3876
3852
|
# if-else-statement and the loop breaking is in the else branch,
|
3877
3853
|
# the controlling expression should be inverted.
|
3878
|
-
deduct_controlling_expression_candidates(
|
3854
|
+
deduct_controlling_expression_candidates(rough_cands).first
|
3879
3855
|
end
|
3880
3856
|
|
3881
3857
|
def inspect(indent = 0)
|
@@ -3894,9 +3870,9 @@ module C #:nodoc:
|
|
3894
3870
|
end
|
3895
3871
|
|
3896
3872
|
class GotoStatement < JumpStatement
|
3897
|
-
def initialize(
|
3873
|
+
def initialize(id)
|
3898
3874
|
super()
|
3899
|
-
@identifier =
|
3875
|
+
@identifier = id
|
3900
3876
|
end
|
3901
3877
|
|
3902
3878
|
attr_reader :identifier
|
@@ -3919,9 +3895,9 @@ module C #:nodoc:
|
|
3919
3895
|
end
|
3920
3896
|
|
3921
3897
|
class ReturnStatement < JumpStatement
|
3922
|
-
def initialize(
|
3898
|
+
def initialize(expr)
|
3923
3899
|
super()
|
3924
|
-
@expression =
|
3900
|
+
@expression = expr
|
3925
3901
|
end
|
3926
3902
|
|
3927
3903
|
attr_reader :expression
|
@@ -3934,14 +3910,18 @@ module C #:nodoc:
|
|
3934
3910
|
|
3935
3911
|
class TranslationUnit < SyntaxNode
|
3936
3912
|
def initialize
|
3937
|
-
super
|
3913
|
+
super
|
3938
3914
|
@external_declarations = []
|
3939
3915
|
end
|
3940
3916
|
|
3941
3917
|
attr_reader :external_declarations
|
3942
3918
|
|
3943
|
-
def push(
|
3944
|
-
@external_declarations.
|
3919
|
+
def push(external_dcl)
|
3920
|
+
if @external_declarations.empty?
|
3921
|
+
self.head_token = external_dcl.head_token
|
3922
|
+
end
|
3923
|
+
@external_declarations.push(external_dcl)
|
3924
|
+
self.tail_token = external_dcl.tail_token
|
3945
3925
|
self
|
3946
3926
|
end
|
3947
3927
|
|
@@ -3959,17 +3939,15 @@ module C #:nodoc:
|
|
3959
3939
|
include SymbolicElement
|
3960
3940
|
include SyntaxNodeCollector
|
3961
3941
|
|
3962
|
-
def initialize(
|
3963
|
-
|
3964
|
-
super(declaration_specifiers)
|
3942
|
+
def initialize(dcl_specs, dcr, param_defs, compound_stmt, sym_tbl)
|
3943
|
+
super(dcl_specs)
|
3965
3944
|
|
3966
|
-
@declarator =
|
3967
|
-
@parameter_definitions =
|
3968
|
-
@function_body =
|
3969
|
-
@symbol =
|
3970
|
-
@type_declaration = build_type_declaration(
|
3971
|
-
|
3972
|
-
build_label_references(compound_statement)
|
3945
|
+
@declarator = dcr
|
3946
|
+
@parameter_definitions = param_defs
|
3947
|
+
@function_body = compound_stmt
|
3948
|
+
@symbol = sym_tbl.create_new_symbol(ObjectName, identifier)
|
3949
|
+
@type_declaration = build_type_declaration(dcl_specs, sym_tbl)
|
3950
|
+
build_label_references(compound_stmt)
|
3973
3951
|
end
|
3974
3952
|
|
3975
3953
|
attr_reader :declarator
|
@@ -4010,11 +3988,11 @@ module C #:nodoc:
|
|
4010
3988
|
end
|
4011
3989
|
|
4012
3990
|
private
|
4013
|
-
def build_type_declaration(
|
4014
|
-
return nil unless
|
4015
|
-
|
4016
|
-
visitor = TypeDeclarationBuilder.new(
|
4017
|
-
|
3991
|
+
def build_type_declaration(dcl_specs, sym_tbl)
|
3992
|
+
return nil unless dcl_specs
|
3993
|
+
dcl_specs.type_specifiers.each do |type_spec|
|
3994
|
+
visitor = TypeDeclarationBuilder.new(sym_tbl)
|
3995
|
+
type_spec.accept(visitor)
|
4018
3996
|
unless visitor.type_declarations.empty?
|
4019
3997
|
return visitor.type_declarations.first
|
4020
3998
|
end
|
@@ -4022,29 +4000,26 @@ module C #:nodoc:
|
|
4022
4000
|
nil
|
4023
4001
|
end
|
4024
4002
|
|
4025
|
-
def build_label_references(
|
4026
|
-
labels = collect_generic_labeled_statements(
|
4003
|
+
def build_label_references(compound_stmt)
|
4004
|
+
labels = collect_generic_labeled_statements(compound_stmt)
|
4027
4005
|
|
4028
|
-
gotos = collect_goto_statements(
|
4006
|
+
gotos = collect_goto_statements(compound_stmt)
|
4029
4007
|
|
4030
|
-
labels.each do |
|
4031
|
-
label_name =
|
4032
|
-
gotos.select { |
|
4033
|
-
|
4034
|
-
}.each do |
|
4035
|
-
|
4008
|
+
labels.each do |generic_labeled_stmt|
|
4009
|
+
label_name = generic_labeled_stmt.label.value
|
4010
|
+
gotos.select { |goto_stmt|
|
4011
|
+
goto_stmt.identifier.value == label_name
|
4012
|
+
}.each do |goto_stmt|
|
4013
|
+
generic_labeled_stmt.referrers.push(goto_stmt)
|
4036
4014
|
end
|
4037
4015
|
end
|
4038
4016
|
end
|
4039
4017
|
end
|
4040
4018
|
|
4041
4019
|
class KandRFunctionDefinition < FunctionDefinition
|
4042
|
-
def initialize(
|
4043
|
-
|
4044
|
-
|
4045
|
-
declarations, symbol_table)
|
4046
|
-
super(declaration_specifiers, declarator, parameter_definitions,
|
4047
|
-
compound_statement, symbol_table)
|
4020
|
+
def initialize(dcl_specs, dcr, dcls, compound_stmt, sym_tbl)
|
4021
|
+
param_defs = create_parameters(dcr.identifier_list, dcls, sym_tbl)
|
4022
|
+
super(dcl_specs, dcr, param_defs, compound_stmt, sym_tbl)
|
4048
4023
|
end
|
4049
4024
|
|
4050
4025
|
def identifier_list
|
@@ -4052,62 +4027,59 @@ module C #:nodoc:
|
|
4052
4027
|
end
|
4053
4028
|
|
4054
4029
|
private
|
4055
|
-
def create_parameters(
|
4056
|
-
return [] unless
|
4057
|
-
|
4058
|
-
|
4059
|
-
|
4060
|
-
|
4061
|
-
result.push(
|
4062
|
-
variable_definition_to_parameter_definition(variable_definition))
|
4030
|
+
def create_parameters(param_names, dcls, sym_tbl)
|
4031
|
+
return [] unless param_names
|
4032
|
+
|
4033
|
+
param_names.each_with_object([]) do |name, param_defs|
|
4034
|
+
var_def = find_variable_definition(dcls, name, sym_tbl)
|
4035
|
+
param_defs.push(variable_definition_to_parameter_definition(var_def))
|
4063
4036
|
end
|
4064
4037
|
end
|
4065
4038
|
|
4066
|
-
def find_variable_definition(
|
4067
|
-
|
4068
|
-
|
4039
|
+
def find_variable_definition(dcls, name, sym_tbl)
|
4040
|
+
dcls.each do |dcl|
|
4041
|
+
dcl.items.select { |item|
|
4069
4042
|
item.kind_of?(VariableDefinition)
|
4070
|
-
}.each do |
|
4071
|
-
|
4043
|
+
}.each do |var_def|
|
4044
|
+
if var_def.identifier.value == name.value
|
4045
|
+
return var_def
|
4046
|
+
end
|
4072
4047
|
end
|
4073
4048
|
end
|
4074
4049
|
|
4075
|
-
|
4076
|
-
|
4077
|
-
declaration.items.first
|
4050
|
+
dcls.push(dcl = implicit_parameter_definition(name, sym_tbl))
|
4051
|
+
dcl.items.first
|
4078
4052
|
end
|
4079
4053
|
|
4080
|
-
def variable_definition_to_parameter_definition(
|
4081
|
-
|
4082
|
-
|
4083
|
-
|
4054
|
+
def variable_definition_to_parameter_definition(var_def)
|
4055
|
+
dcl_specs = var_def.declaration_specifiers
|
4056
|
+
dcr = var_def.init_declarator.declarator
|
4057
|
+
param_def = ParameterDefinition.new(dcl_specs, dcr)
|
4084
4058
|
|
4085
|
-
unless
|
4086
|
-
|
4087
|
-
|
4059
|
+
unless dcl_specs
|
4060
|
+
param_def.head_token = dcr.head_token
|
4061
|
+
param_def.tail_token = dcr.tail_token
|
4088
4062
|
end
|
4089
4063
|
|
4090
|
-
unless
|
4091
|
-
|
4092
|
-
|
4064
|
+
unless dcr
|
4065
|
+
param_def.head_token = dcl_specs.head_token
|
4066
|
+
param_def.tail_token = dcl_specs.tail_token
|
4093
4067
|
end
|
4094
4068
|
|
4095
|
-
|
4069
|
+
param_def
|
4096
4070
|
end
|
4097
4071
|
|
4098
|
-
def implicit_parameter_definition(
|
4099
|
-
|
4100
|
-
|
4101
|
-
Declaration.new(nil, [init_declarator], symbol_table)
|
4072
|
+
def implicit_parameter_definition(id, sym_tbl)
|
4073
|
+
init_dcr = InitDeclarator.new(IdentifierDeclarator.new(id), nil)
|
4074
|
+
Declaration.new(nil, [init_dcr], sym_tbl)
|
4102
4075
|
end
|
4103
4076
|
end
|
4104
4077
|
|
4105
4078
|
class AnsiFunctionDefinition < FunctionDefinition
|
4106
|
-
def initialize(
|
4107
|
-
|
4108
|
-
|
4109
|
-
|
4110
|
-
compound_statement, symbol_table)
|
4079
|
+
def initialize(dcl_specs, dcr, compound_stmt, sym_tbl)
|
4080
|
+
super(dcl_specs, dcr,
|
4081
|
+
create_parameters(dcr.innermost_parameter_type_list),
|
4082
|
+
compound_stmt, sym_tbl)
|
4111
4083
|
end
|
4112
4084
|
|
4113
4085
|
def parameter_type_list
|
@@ -4115,33 +4087,32 @@ module C #:nodoc:
|
|
4115
4087
|
end
|
4116
4088
|
|
4117
4089
|
private
|
4118
|
-
def create_parameters(
|
4119
|
-
return [] unless
|
4120
|
-
|
4121
|
-
|
4122
|
-
|
4123
|
-
|
4124
|
-
|
4125
|
-
unless
|
4126
|
-
|
4127
|
-
|
4090
|
+
def create_parameters(param_type_list)
|
4091
|
+
return [] unless param_type_list
|
4092
|
+
param_type_list.parameters.map do |param_dcl|
|
4093
|
+
dcl_specs = param_dcl.declaration_specifiers
|
4094
|
+
dcr = param_dcl.declarator
|
4095
|
+
param_def = ParameterDefinition.new(dcl_specs, dcr)
|
4096
|
+
|
4097
|
+
unless dcl_specs
|
4098
|
+
param_def.head_token = dcr.head_token
|
4099
|
+
param_def.tail_token = dcr.tail_token
|
4128
4100
|
end
|
4129
4101
|
|
4130
|
-
unless
|
4131
|
-
|
4132
|
-
|
4102
|
+
unless dcr
|
4103
|
+
param_def.head_token = dcl_specs.head_token
|
4104
|
+
param_def.tail_token = dcl_specs.tail_token
|
4133
4105
|
end
|
4134
4106
|
|
4135
|
-
|
4107
|
+
param_def
|
4136
4108
|
end
|
4137
4109
|
end
|
4138
4110
|
end
|
4139
4111
|
|
4140
4112
|
class ParameterDefinition < Definition
|
4141
|
-
def initialize(
|
4142
|
-
super(
|
4143
|
-
|
4144
|
-
@declarator = declarator
|
4113
|
+
def initialize(dcl_specs, dcr)
|
4114
|
+
super(dcl_specs)
|
4115
|
+
@declarator = dcr
|
4145
4116
|
end
|
4146
4117
|
|
4147
4118
|
attr_reader :declarator
|
@@ -4159,7 +4130,14 @@ module C #:nodoc:
|
|
4159
4130
|
end
|
4160
4131
|
|
4161
4132
|
def location
|
4162
|
-
|
4133
|
+
case
|
4134
|
+
when identifier
|
4135
|
+
identifier.location
|
4136
|
+
when declaration_specifiers
|
4137
|
+
declaration_specifiers.location
|
4138
|
+
else
|
4139
|
+
Location.new
|
4140
|
+
end
|
4163
4141
|
end
|
4164
4142
|
|
4165
4143
|
def to_variable_definition
|
@@ -4176,9 +4154,8 @@ module C #:nodoc:
|
|
4176
4154
|
end
|
4177
4155
|
|
4178
4156
|
class PseudoVariableDefinition < VariableDefinition
|
4179
|
-
def initialize(
|
4180
|
-
super(
|
4181
|
-
|
4157
|
+
def initialize(dcl_specs, init_dcr, type)
|
4158
|
+
super(dcl_specs, init_dcr, nil)
|
4182
4159
|
self.type = type
|
4183
4160
|
end
|
4184
4161
|
|
@@ -4186,13 +4163,12 @@ module C #:nodoc:
|
|
4186
4163
|
end
|
4187
4164
|
|
4188
4165
|
class TypeName < SyntaxNode
|
4189
|
-
def initialize(
|
4166
|
+
def initialize(spec_qual_list, abstract_dcr, sym_tbl)
|
4190
4167
|
super()
|
4191
|
-
@specifier_qualifier_list =
|
4192
|
-
@abstract_declarator =
|
4168
|
+
@specifier_qualifier_list = spec_qual_list
|
4169
|
+
@abstract_declarator = abstract_dcr
|
4193
4170
|
@type = nil
|
4194
|
-
@type_declaration = build_type_declaration(
|
4195
|
-
symbol_table)
|
4171
|
+
@type_declaration = build_type_declaration(spec_qual_list, sym_tbl)
|
4196
4172
|
end
|
4197
4173
|
|
4198
4174
|
attr_reader :specifier_qualifier_list
|
@@ -4213,10 +4189,10 @@ module C #:nodoc:
|
|
4213
4189
|
end
|
4214
4190
|
|
4215
4191
|
private
|
4216
|
-
def build_type_declaration(
|
4217
|
-
|
4218
|
-
visitor = TypeDeclarationBuilder.new(
|
4219
|
-
|
4192
|
+
def build_type_declaration(spec_qual_list, sym_tbl)
|
4193
|
+
spec_qual_list.type_specifiers.each do |type_spec|
|
4194
|
+
visitor = TypeDeclarationBuilder.new(sym_tbl)
|
4195
|
+
type_spec.accept(visitor)
|
4220
4196
|
unless visitor.type_declarations.empty?
|
4221
4197
|
return visitor.type_declarations.first
|
4222
4198
|
end
|
@@ -4236,16 +4212,16 @@ module C #:nodoc:
|
|
4236
4212
|
end
|
4237
4213
|
|
4238
4214
|
class PointerAbstractDeclarator < AbstractDeclarator
|
4239
|
-
def initialize(
|
4215
|
+
def initialize(abstract_dcr, ptr)
|
4240
4216
|
super()
|
4241
|
-
@base =
|
4242
|
-
@pointer =
|
4217
|
+
@base = abstract_dcr
|
4218
|
+
@pointer = ptr
|
4243
4219
|
end
|
4244
4220
|
|
4245
4221
|
attr_reader :base
|
4246
4222
|
|
4247
4223
|
def location
|
4248
|
-
head_location
|
4224
|
+
@base ? @base.location || head_location : head_location
|
4249
4225
|
end
|
4250
4226
|
|
4251
4227
|
def function?(stack = [])
|
@@ -4272,15 +4248,15 @@ module C #:nodoc:
|
|
4272
4248
|
end
|
4273
4249
|
|
4274
4250
|
class GroupedAbstractDeclarator < AbstractDeclarator
|
4275
|
-
def initialize(
|
4251
|
+
def initialize(abstract_dcr)
|
4276
4252
|
super()
|
4277
|
-
@base =
|
4253
|
+
@base = abstract_dcr
|
4278
4254
|
end
|
4279
4255
|
|
4280
4256
|
attr_reader :base
|
4281
4257
|
|
4282
4258
|
def location
|
4283
|
-
@base.location
|
4259
|
+
@base ? @base.location || head_location : head_location
|
4284
4260
|
end
|
4285
4261
|
|
4286
4262
|
def function?
|
@@ -4305,19 +4281,17 @@ module C #:nodoc:
|
|
4305
4281
|
end
|
4306
4282
|
|
4307
4283
|
class ArrayAbstractDeclarator < AbstractDeclarator
|
4308
|
-
def initialize(
|
4284
|
+
def initialize(abstract_dcr, size_expr)
|
4309
4285
|
super()
|
4310
|
-
@base =
|
4311
|
-
@size_expression =
|
4286
|
+
@base = abstract_dcr
|
4287
|
+
@size_expression = size_expr
|
4312
4288
|
end
|
4313
4289
|
|
4314
4290
|
attr_reader :base
|
4315
4291
|
attr_reader :size_expression
|
4316
4292
|
|
4317
4293
|
def location
|
4318
|
-
|
4319
|
-
return @size_expression.location if @size_expression
|
4320
|
-
nil
|
4294
|
+
@base ? @base.location || head_location : head_location
|
4321
4295
|
end
|
4322
4296
|
|
4323
4297
|
def function?(stack = [])
|
@@ -4344,19 +4318,17 @@ module C #:nodoc:
|
|
4344
4318
|
end
|
4345
4319
|
|
4346
4320
|
class FunctionAbstractDeclarator < AbstractDeclarator
|
4347
|
-
def initialize(
|
4321
|
+
def initialize(abstract_dcr, param_type_list)
|
4348
4322
|
super()
|
4349
|
-
@base =
|
4350
|
-
@parameter_type_list =
|
4323
|
+
@base = abstract_dcr
|
4324
|
+
@parameter_type_list = param_type_list
|
4351
4325
|
end
|
4352
4326
|
|
4353
4327
|
attr_reader :base
|
4354
4328
|
attr_reader :parameter_type_list
|
4355
4329
|
|
4356
4330
|
def location
|
4357
|
-
|
4358
|
-
return @parameter_type_list.location if @parameter_type_list
|
4359
|
-
nil
|
4331
|
+
@base ? @base.location || head_location : head_location
|
4360
4332
|
end
|
4361
4333
|
|
4362
4334
|
def function?(stack = [])
|
@@ -4375,10 +4347,10 @@ module C #:nodoc:
|
|
4375
4347
|
end
|
4376
4348
|
|
4377
4349
|
class Initializer < SyntaxNode
|
4378
|
-
def initialize(
|
4350
|
+
def initialize(expr, inits)
|
4379
4351
|
super()
|
4380
|
-
@expression =
|
4381
|
-
@initializers =
|
4352
|
+
@expression = expr
|
4353
|
+
@initializers = inits
|
4382
4354
|
end
|
4383
4355
|
|
4384
4356
|
attr_reader :expression
|
@@ -4431,8 +4403,8 @@ module C #:nodoc:
|
|
4431
4403
|
end
|
4432
4404
|
|
4433
4405
|
class TypeDeclarationBuilder
|
4434
|
-
def initialize(
|
4435
|
-
@symbol_table =
|
4406
|
+
def initialize(sym_tbl)
|
4407
|
+
@symbol_table = sym_tbl
|
4436
4408
|
@type_declarations = []
|
4437
4409
|
end
|
4438
4410
|
|
@@ -4447,23 +4419,23 @@ module C #:nodoc:
|
|
4447
4419
|
def visit_struct_specifier(node)
|
4448
4420
|
if node.struct_declarations
|
4449
4421
|
node.struct_declarations.each { |child| child.accept(self) }
|
4450
|
-
|
4451
|
-
@type_declarations.push(StructTypeDeclaration.new(node,
|
4422
|
+
sym = @symbol_table.create_new_symbol(StructTag, node.identifier)
|
4423
|
+
@type_declarations.push(StructTypeDeclaration.new(node, sym))
|
4452
4424
|
end
|
4453
4425
|
end
|
4454
4426
|
|
4455
4427
|
def visit_union_specifier(node)
|
4456
4428
|
if node.struct_declarations
|
4457
4429
|
node.struct_declarations.each { |child| child.accept(self) }
|
4458
|
-
|
4459
|
-
@type_declarations.push(UnionTypeDeclaration.new(node,
|
4430
|
+
sym = @symbol_table.create_new_symbol(UnionTag, node.identifier)
|
4431
|
+
@type_declarations.push(UnionTypeDeclaration.new(node, sym))
|
4460
4432
|
end
|
4461
4433
|
end
|
4462
4434
|
|
4463
4435
|
def visit_enum_specifier(node)
|
4464
4436
|
if node.enumerators
|
4465
|
-
|
4466
|
-
@type_declarations.push(EnumTypeDeclaration.new(node,
|
4437
|
+
sym = @symbol_table.create_new_symbol(EnumTag, node.identifier)
|
4438
|
+
@type_declarations.push(EnumTypeDeclaration.new(node, sym))
|
4467
4439
|
end
|
4468
4440
|
end
|
4469
4441
|
|
@@ -4535,7 +4507,7 @@ module C #:nodoc:
|
|
4535
4507
|
|
4536
4508
|
def visit_compound_literal_expression(node)
|
4537
4509
|
node.type_name.accept(self) if node.type_name
|
4538
|
-
node.initializers.each { |
|
4510
|
+
node.initializers.each { |init| init.accept(self) }
|
4539
4511
|
end
|
4540
4512
|
|
4541
4513
|
def visit_prefix_increment_expression(node)
|
@@ -4651,7 +4623,7 @@ module C #:nodoc:
|
|
4651
4623
|
|
4652
4624
|
def visit_declaration(node)
|
4653
4625
|
node.declaration_specifiers.accept(self) if node.declaration_specifiers
|
4654
|
-
node.init_declarators.each { |
|
4626
|
+
node.init_declarators.each { |dcr| dcr.accept(self) }
|
4655
4627
|
node.items.each { |item| item.accept(self) }
|
4656
4628
|
end
|
4657
4629
|
|
@@ -4677,7 +4649,7 @@ module C #:nodoc:
|
|
4677
4649
|
end
|
4678
4650
|
|
4679
4651
|
def visit_declaration_specifiers(node)
|
4680
|
-
node.type_specifiers.each { |
|
4652
|
+
node.type_specifiers.each { |type_spec| type_spec.accept(self) }
|
4681
4653
|
end
|
4682
4654
|
|
4683
4655
|
def visit_init_declarator(node)
|
@@ -4693,19 +4665,19 @@ module C #:nodoc:
|
|
4693
4665
|
|
4694
4666
|
def visit_struct_specifier(node)
|
4695
4667
|
if node.struct_declarations
|
4696
|
-
node.struct_declarations.each { |
|
4668
|
+
node.struct_declarations.each { |dcl| dcl.accept(self) }
|
4697
4669
|
end
|
4698
4670
|
end
|
4699
4671
|
|
4700
4672
|
def visit_union_specifier(node)
|
4701
4673
|
if node.struct_declarations
|
4702
|
-
node.struct_declarations.each { |
|
4674
|
+
node.struct_declarations.each { |dcl| dcl.accept(self) }
|
4703
4675
|
end
|
4704
4676
|
end
|
4705
4677
|
|
4706
4678
|
def visit_struct_declaration(node)
|
4707
4679
|
node.specifier_qualifier_list.accept(self)
|
4708
|
-
node.struct_declarators.each { |
|
4680
|
+
node.struct_declarators.each { |dcr| dcr.accept(self) }
|
4709
4681
|
node.items.each { |item| item.accept(self) }
|
4710
4682
|
end
|
4711
4683
|
|
@@ -4713,7 +4685,7 @@ module C #:nodoc:
|
|
4713
4685
|
end
|
4714
4686
|
|
4715
4687
|
def visit_specifier_qualifier_list(node)
|
4716
|
-
node.type_specifiers.each { |
|
4688
|
+
node.type_specifiers.each { |type_spec| type_spec.accept(self) }
|
4717
4689
|
end
|
4718
4690
|
|
4719
4691
|
def visit_struct_declarator(node)
|
@@ -4848,13 +4820,13 @@ module C #:nodoc:
|
|
4848
4820
|
end
|
4849
4821
|
|
4850
4822
|
def visit_translation_unit(node)
|
4851
|
-
node.external_declarations.each { |
|
4823
|
+
node.external_declarations.each { |dcl| dcl.accept(self) }
|
4852
4824
|
end
|
4853
4825
|
|
4854
4826
|
def visit_kandr_function_definition(node)
|
4855
4827
|
node.declaration_specifiers.accept(self) if node.declaration_specifiers
|
4856
4828
|
node.declarator.accept(self)
|
4857
|
-
node.parameter_definitions.each { |
|
4829
|
+
node.parameter_definitions.each { |param_def| param_def.accept(self) }
|
4858
4830
|
node.function_body.accept(self)
|
4859
4831
|
node.type_declaration.accept(self) if node.type_declaration
|
4860
4832
|
end
|
@@ -4862,7 +4834,7 @@ module C #:nodoc:
|
|
4862
4834
|
def visit_ansi_function_definition(node)
|
4863
4835
|
node.declaration_specifiers.accept(self) if node.declaration_specifiers
|
4864
4836
|
node.declarator.accept(self)
|
4865
|
-
node.parameter_definitions.each { |
|
4837
|
+
node.parameter_definitions.each { |param_def| param_def.accept(self) }
|
4866
4838
|
node.function_body.accept(self)
|
4867
4839
|
node.type_declaration.accept(self) if node.type_declaration
|
4868
4840
|
end
|
@@ -4899,7 +4871,7 @@ module C #:nodoc:
|
|
4899
4871
|
when node.expression
|
4900
4872
|
node.expression.accept(self)
|
4901
4873
|
when node.initializers
|
4902
|
-
node.initializers.each { |
|
4874
|
+
node.initializers.each { |init| init.accept(self) }
|
4903
4875
|
end
|
4904
4876
|
end
|
4905
4877
|
end
|
@@ -5098,385 +5070,110 @@ module C #:nodoc:
|
|
5098
5070
|
def_plugin :enter_initializer
|
5099
5071
|
def_plugin :leave_initializer
|
5100
5072
|
|
5101
|
-
def
|
5102
|
-
|
5103
|
-
|
5104
|
-
|
5105
|
-
|
5106
|
-
|
5107
|
-
end
|
5108
|
-
|
5109
|
-
|
5110
|
-
|
5111
|
-
|
5112
|
-
|
5113
|
-
|
5114
|
-
|
5115
|
-
|
5116
|
-
|
5117
|
-
|
5118
|
-
|
5119
|
-
|
5120
|
-
|
5121
|
-
|
5122
|
-
|
5123
|
-
|
5124
|
-
|
5125
|
-
|
5126
|
-
|
5127
|
-
|
5128
|
-
|
5129
|
-
|
5130
|
-
|
5131
|
-
|
5132
|
-
|
5133
|
-
|
5134
|
-
|
5135
|
-
|
5136
|
-
|
5137
|
-
|
5138
|
-
|
5139
|
-
|
5140
|
-
|
5141
|
-
|
5142
|
-
|
5143
|
-
|
5144
|
-
|
5145
|
-
|
5146
|
-
|
5147
|
-
|
5148
|
-
|
5149
|
-
|
5150
|
-
|
5151
|
-
|
5152
|
-
|
5153
|
-
|
5154
|
-
|
5155
|
-
|
5156
|
-
|
5157
|
-
|
5158
|
-
|
5159
|
-
|
5160
|
-
|
5161
|
-
|
5162
|
-
|
5163
|
-
|
5164
|
-
|
5165
|
-
|
5166
|
-
|
5167
|
-
|
5168
|
-
|
5169
|
-
|
5170
|
-
|
5171
|
-
|
5172
|
-
|
5173
|
-
|
5174
|
-
|
5175
|
-
|
5176
|
-
|
5177
|
-
|
5178
|
-
|
5179
|
-
|
5180
|
-
|
5181
|
-
|
5182
|
-
|
5183
|
-
|
5184
|
-
|
5185
|
-
|
5186
|
-
|
5187
|
-
|
5188
|
-
|
5189
|
-
|
5190
|
-
|
5191
|
-
|
5192
|
-
|
5193
|
-
|
5194
|
-
|
5195
|
-
|
5196
|
-
|
5197
|
-
|
5198
|
-
|
5199
|
-
|
5200
|
-
|
5201
|
-
|
5202
|
-
|
5203
|
-
|
5204
|
-
|
5205
|
-
def visit_additive_expression(node)
|
5206
|
-
visit_with_notifying(__method__, node) { super }
|
5207
|
-
end
|
5208
|
-
|
5209
|
-
def visit_shift_expression(node)
|
5210
|
-
visit_with_notifying(__method__, node) { super }
|
5211
|
-
end
|
5212
|
-
|
5213
|
-
def visit_relational_expression(node)
|
5214
|
-
visit_with_notifying(__method__, node) { super }
|
5215
|
-
end
|
5216
|
-
|
5217
|
-
def visit_equality_expression(node)
|
5218
|
-
visit_with_notifying(__method__, node) { super }
|
5219
|
-
end
|
5220
|
-
|
5221
|
-
def visit_and_expression(node)
|
5222
|
-
visit_with_notifying(__method__, node) { super }
|
5223
|
-
end
|
5224
|
-
|
5225
|
-
def visit_exclusive_or_expression(node)
|
5226
|
-
visit_with_notifying(__method__, node) { super }
|
5227
|
-
end
|
5228
|
-
|
5229
|
-
def visit_inclusive_or_expression(node)
|
5230
|
-
visit_with_notifying(__method__, node) { super }
|
5231
|
-
end
|
5232
|
-
|
5233
|
-
def visit_logical_and_expression(node)
|
5234
|
-
visit_with_notifying(__method__, node) { super }
|
5235
|
-
end
|
5236
|
-
|
5237
|
-
def visit_logical_or_expression(node)
|
5238
|
-
visit_with_notifying(__method__, node) { super }
|
5239
|
-
end
|
5240
|
-
|
5241
|
-
def visit_conditional_expression(node)
|
5242
|
-
visit_with_notifying(__method__, node) { super }
|
5243
|
-
end
|
5244
|
-
|
5245
|
-
def visit_simple_assignment_expression(node)
|
5246
|
-
visit_with_notifying(__method__, node) { super }
|
5247
|
-
end
|
5248
|
-
|
5249
|
-
def visit_compound_assignment_expression(node)
|
5250
|
-
visit_with_notifying(__method__, node) { super }
|
5251
|
-
end
|
5252
|
-
|
5253
|
-
def visit_comma_separated_expression(node)
|
5254
|
-
visit_with_notifying(__method__, node) { super }
|
5255
|
-
end
|
5256
|
-
|
5257
|
-
def visit_declaration(node)
|
5258
|
-
visit_with_notifying(__method__, node) { super }
|
5259
|
-
end
|
5260
|
-
|
5261
|
-
def visit_function_declaration(node)
|
5262
|
-
visit_with_notifying(__method__, node) { super }
|
5263
|
-
end
|
5264
|
-
|
5265
|
-
def visit_variable_declaration(node)
|
5266
|
-
visit_with_notifying(__method__, node) { super }
|
5267
|
-
end
|
5268
|
-
|
5269
|
-
def visit_variable_definition(node)
|
5270
|
-
visit_with_notifying(__method__, node) { super }
|
5271
|
-
end
|
5272
|
-
|
5273
|
-
def visit_typedef_declaration(node)
|
5274
|
-
visit_with_notifying(__method__, node) { super }
|
5275
|
-
end
|
5276
|
-
|
5277
|
-
def visit_struct_type_declaration(node)
|
5278
|
-
visit_with_notifying(__method__, node) { super }
|
5279
|
-
end
|
5280
|
-
|
5281
|
-
def visit_union_type_declaration(node)
|
5282
|
-
visit_with_notifying(__method__, node) { super }
|
5283
|
-
end
|
5284
|
-
|
5285
|
-
def visit_enum_type_declaration(node)
|
5286
|
-
visit_with_notifying(__method__, node) { super }
|
5287
|
-
end
|
5288
|
-
|
5289
|
-
def visit_declaration_specifiers(node)
|
5290
|
-
visit_with_notifying(__method__, node) { super }
|
5291
|
-
end
|
5292
|
-
|
5293
|
-
def visit_init_declarator(node)
|
5294
|
-
visit_with_notifying(__method__, node) { super }
|
5295
|
-
end
|
5296
|
-
|
5297
|
-
def visit_standard_type_specifier(node)
|
5298
|
-
visit_with_notifying(__method__, node) { super }
|
5299
|
-
end
|
5300
|
-
|
5301
|
-
def visit_typedef_type_specifier(node)
|
5302
|
-
visit_with_notifying(__method__, node) { super }
|
5303
|
-
end
|
5304
|
-
|
5305
|
-
def visit_struct_specifier(node)
|
5306
|
-
visit_with_notifying(__method__, node) { super }
|
5307
|
-
end
|
5308
|
-
|
5309
|
-
def visit_union_specifier(node)
|
5310
|
-
visit_with_notifying(__method__, node) { super }
|
5311
|
-
end
|
5312
|
-
|
5313
|
-
def visit_struct_declaration(node)
|
5314
|
-
visit_with_notifying(__method__, node) { super }
|
5315
|
-
end
|
5316
|
-
|
5317
|
-
def visit_member_declaration(node)
|
5318
|
-
visit_with_notifying(__method__, node) { super }
|
5319
|
-
end
|
5320
|
-
|
5321
|
-
def visit_specifier_qualifier_list(node)
|
5322
|
-
visit_with_notifying(__method__, node) { super }
|
5323
|
-
end
|
5324
|
-
|
5325
|
-
def visit_struct_declarator(node)
|
5326
|
-
visit_with_notifying(__method__, node) { super }
|
5327
|
-
end
|
5328
|
-
|
5329
|
-
def visit_enum_specifier(node)
|
5330
|
-
visit_with_notifying(__method__, node) { super }
|
5331
|
-
end
|
5332
|
-
|
5333
|
-
def visit_enumerator(node)
|
5334
|
-
visit_with_notifying(__method__, node) { super }
|
5335
|
-
end
|
5336
|
-
|
5337
|
-
def visit_typeof_type_specifier(node)
|
5338
|
-
visit_with_notifying(__method__, node) { super }
|
5339
|
-
end
|
5340
|
-
|
5341
|
-
def visit_identifier_declarator(node)
|
5342
|
-
visit_with_notifying(__method__, node) { super }
|
5343
|
-
end
|
5344
|
-
|
5345
|
-
def visit_grouped_declarator(node)
|
5346
|
-
visit_with_notifying(__method__, node) { super }
|
5347
|
-
end
|
5348
|
-
|
5349
|
-
def visit_array_declarator(node)
|
5350
|
-
visit_with_notifying(__method__, node) { super }
|
5351
|
-
end
|
5352
|
-
|
5353
|
-
def visit_ansi_function_declarator(node)
|
5354
|
-
visit_with_notifying(__method__, node) { super }
|
5355
|
-
end
|
5356
|
-
|
5357
|
-
def visit_kandr_function_declarator(node)
|
5358
|
-
visit_with_notifying(__method__, node) { super }
|
5359
|
-
end
|
5360
|
-
|
5361
|
-
def visit_abbreviated_function_declarator(node)
|
5362
|
-
visit_with_notifying(__method__, node) { super }
|
5363
|
-
end
|
5364
|
-
|
5365
|
-
def visit_parameter_type_list(node)
|
5366
|
-
visit_with_notifying(__method__, node) { super }
|
5367
|
-
end
|
5368
|
-
|
5369
|
-
def visit_parameter_declaration(node)
|
5370
|
-
visit_with_notifying(__method__, node) { super }
|
5371
|
-
end
|
5372
|
-
|
5373
|
-
def visit_error_statement(node)
|
5374
|
-
visit_with_notifying(__method__, node) { super }
|
5375
|
-
end
|
5376
|
-
|
5377
|
-
def visit_generic_labeled_statement(node)
|
5378
|
-
visit_with_notifying(__method__, node) { super }
|
5379
|
-
end
|
5380
|
-
|
5381
|
-
def visit_case_labeled_statement(node)
|
5382
|
-
visit_with_notifying(__method__, node) { super }
|
5383
|
-
end
|
5384
|
-
|
5385
|
-
def visit_default_labeled_statement(node)
|
5386
|
-
visit_with_notifying(__method__, node) { super }
|
5387
|
-
end
|
5388
|
-
|
5389
|
-
def visit_compound_statement(node)
|
5390
|
-
visit_with_notifying(__method__, node) { super }
|
5391
|
-
end
|
5392
|
-
|
5393
|
-
def visit_expression_statement(node)
|
5394
|
-
visit_with_notifying(__method__, node) { super }
|
5395
|
-
end
|
5396
|
-
|
5397
|
-
def visit_if_statement(node)
|
5398
|
-
visit_with_notifying(__method__, node) { super }
|
5399
|
-
end
|
5400
|
-
|
5401
|
-
def visit_if_else_statement(node)
|
5402
|
-
visit_with_notifying(__method__, node) { super }
|
5403
|
-
end
|
5404
|
-
|
5405
|
-
def visit_switch_statement(node)
|
5406
|
-
visit_with_notifying(__method__, node) { super }
|
5407
|
-
end
|
5408
|
-
|
5409
|
-
def visit_while_statement(node)
|
5410
|
-
visit_with_notifying(__method__, node) { super }
|
5411
|
-
end
|
5412
|
-
|
5413
|
-
def visit_do_statement(node)
|
5414
|
-
visit_with_notifying(__method__, node) { super }
|
5415
|
-
end
|
5416
|
-
|
5417
|
-
def visit_for_statement(node)
|
5418
|
-
visit_with_notifying(__method__, node) { super }
|
5419
|
-
end
|
5420
|
-
|
5421
|
-
def visit_c99_for_statement(node)
|
5422
|
-
visit_with_notifying(__method__, node) { super }
|
5423
|
-
end
|
5424
|
-
|
5425
|
-
def visit_goto_statement(node)
|
5426
|
-
visit_with_notifying(__method__, node) { super }
|
5427
|
-
end
|
5428
|
-
|
5429
|
-
def visit_continue_statement(node)
|
5430
|
-
visit_with_notifying(__method__, node) { super }
|
5431
|
-
end
|
5432
|
-
|
5433
|
-
def visit_break_statement(node)
|
5434
|
-
visit_with_notifying(__method__, node) { super }
|
5435
|
-
end
|
5436
|
-
|
5437
|
-
def visit_return_statement(node)
|
5438
|
-
visit_with_notifying(__method__, node) { super }
|
5439
|
-
end
|
5440
|
-
|
5441
|
-
def visit_translation_unit(node)
|
5442
|
-
visit_with_notifying(__method__, node) { super }
|
5443
|
-
end
|
5444
|
-
|
5445
|
-
def visit_kandr_function_definition(node)
|
5446
|
-
visit_with_notifying(__method__, node) { super }
|
5447
|
-
end
|
5448
|
-
|
5449
|
-
def visit_ansi_function_definition(node)
|
5450
|
-
visit_with_notifying(__method__, node) { super }
|
5451
|
-
end
|
5452
|
-
|
5453
|
-
def visit_parameter_definition(node)
|
5454
|
-
visit_with_notifying(__method__, node) { super }
|
5455
|
-
end
|
5456
|
-
|
5457
|
-
def visit_type_name(node)
|
5458
|
-
visit_with_notifying(__method__, node) { super }
|
5459
|
-
end
|
5460
|
-
|
5461
|
-
def visit_pointer_abstract_declarator(node)
|
5462
|
-
visit_with_notifying(__method__, node) { super }
|
5463
|
-
end
|
5464
|
-
|
5465
|
-
def visit_grouped_abstract_declarator(node)
|
5466
|
-
visit_with_notifying(__method__, node) { super }
|
5467
|
-
end
|
5468
|
-
|
5469
|
-
def visit_array_abstract_declarator(node)
|
5470
|
-
visit_with_notifying(__method__, node) { super }
|
5471
|
-
end
|
5472
|
-
|
5473
|
-
def visit_function_abstract_declarator(node)
|
5474
|
-
visit_with_notifying(__method__, node) { super }
|
5475
|
-
end
|
5476
|
-
|
5477
|
-
def visit_initializer(node)
|
5478
|
-
visit_with_notifying(__method__, node) { super }
|
5479
|
-
end
|
5073
|
+
def self.def_visitor_method(node_name)
|
5074
|
+
class_eval <<-EOS
|
5075
|
+
define_method("visit_#{node_name}") do |*args|
|
5076
|
+
visit_with_notifying(__method__, args.first) { super(args.first) }
|
5077
|
+
end
|
5078
|
+
EOS
|
5079
|
+
end
|
5080
|
+
private_class_method :def_visitor_method
|
5081
|
+
|
5082
|
+
def_visitor_method :error_expression
|
5083
|
+
def_visitor_method :object_specifier
|
5084
|
+
def_visitor_method :constant_specifier
|
5085
|
+
def_visitor_method :string_literal_specifier
|
5086
|
+
def_visitor_method :null_constant_specifier
|
5087
|
+
def_visitor_method :grouped_expression
|
5088
|
+
def_visitor_method :array_subscript_expression
|
5089
|
+
def_visitor_method :function_call_expression
|
5090
|
+
def_visitor_method :member_access_by_value_expression
|
5091
|
+
def_visitor_method :member_access_by_pointer_expression
|
5092
|
+
def_visitor_method :bit_access_by_value_expression
|
5093
|
+
def_visitor_method :bit_access_by_pointer_expression
|
5094
|
+
def_visitor_method :postfix_increment_expression
|
5095
|
+
def_visitor_method :postfix_decrement_expression
|
5096
|
+
def_visitor_method :compound_literal_expression
|
5097
|
+
def_visitor_method :prefix_increment_expression
|
5098
|
+
def_visitor_method :prefix_decrement_expression
|
5099
|
+
def_visitor_method :address_expression
|
5100
|
+
def_visitor_method :indirection_expression
|
5101
|
+
def_visitor_method :unary_arithmetic_expression
|
5102
|
+
def_visitor_method :sizeof_expression
|
5103
|
+
def_visitor_method :sizeof_type_expression
|
5104
|
+
def_visitor_method :alignof_expression
|
5105
|
+
def_visitor_method :alignof_type_expression
|
5106
|
+
def_visitor_method :cast_expression
|
5107
|
+
def_visitor_method :multiplicative_expression
|
5108
|
+
def_visitor_method :additive_expression
|
5109
|
+
def_visitor_method :shift_expression
|
5110
|
+
def_visitor_method :relational_expression
|
5111
|
+
def_visitor_method :equality_expression
|
5112
|
+
def_visitor_method :and_expression
|
5113
|
+
def_visitor_method :exclusive_or_expression
|
5114
|
+
def_visitor_method :inclusive_or_expression
|
5115
|
+
def_visitor_method :logical_and_expression
|
5116
|
+
def_visitor_method :logical_or_expression
|
5117
|
+
def_visitor_method :conditional_expression
|
5118
|
+
def_visitor_method :simple_assignment_expression
|
5119
|
+
def_visitor_method :compound_assignment_expression
|
5120
|
+
def_visitor_method :comma_separated_expression
|
5121
|
+
def_visitor_method :declaration
|
5122
|
+
def_visitor_method :function_declaration
|
5123
|
+
def_visitor_method :variable_declaration
|
5124
|
+
def_visitor_method :variable_definition
|
5125
|
+
def_visitor_method :typedef_declaration
|
5126
|
+
def_visitor_method :struct_type_declaration
|
5127
|
+
def_visitor_method :union_type_declaration
|
5128
|
+
def_visitor_method :enum_type_declaration
|
5129
|
+
def_visitor_method :declaration_specifiers
|
5130
|
+
def_visitor_method :init_declarator
|
5131
|
+
def_visitor_method :standard_type_specifier
|
5132
|
+
def_visitor_method :typedef_type_specifier
|
5133
|
+
def_visitor_method :struct_specifier
|
5134
|
+
def_visitor_method :union_specifier
|
5135
|
+
def_visitor_method :struct_declaration
|
5136
|
+
def_visitor_method :member_declaration
|
5137
|
+
def_visitor_method :specifier_qualifier_list
|
5138
|
+
def_visitor_method :struct_declarator
|
5139
|
+
def_visitor_method :enum_specifier
|
5140
|
+
def_visitor_method :enumerator
|
5141
|
+
def_visitor_method :typeof_type_specifier
|
5142
|
+
def_visitor_method :identifier_declarator
|
5143
|
+
def_visitor_method :grouped_declarator
|
5144
|
+
def_visitor_method :array_declarator
|
5145
|
+
def_visitor_method :ansi_function_declarator
|
5146
|
+
def_visitor_method :kandr_function_declarator
|
5147
|
+
def_visitor_method :abbreviated_function_declarator
|
5148
|
+
def_visitor_method :parameter_type_list
|
5149
|
+
def_visitor_method :parameter_declaration
|
5150
|
+
def_visitor_method :error_statement
|
5151
|
+
def_visitor_method :generic_labeled_statement
|
5152
|
+
def_visitor_method :case_labeled_statement
|
5153
|
+
def_visitor_method :default_labeled_statement
|
5154
|
+
def_visitor_method :compound_statement
|
5155
|
+
def_visitor_method :expression_statement
|
5156
|
+
def_visitor_method :if_statement
|
5157
|
+
def_visitor_method :if_else_statement
|
5158
|
+
def_visitor_method :switch_statement
|
5159
|
+
def_visitor_method :while_statement
|
5160
|
+
def_visitor_method :do_statement
|
5161
|
+
def_visitor_method :for_statement
|
5162
|
+
def_visitor_method :c99_for_statement
|
5163
|
+
def_visitor_method :goto_statement
|
5164
|
+
def_visitor_method :continue_statement
|
5165
|
+
def_visitor_method :break_statement
|
5166
|
+
def_visitor_method :return_statement
|
5167
|
+
def_visitor_method :translation_unit
|
5168
|
+
def_visitor_method :kandr_function_definition
|
5169
|
+
def_visitor_method :ansi_function_definition
|
5170
|
+
def_visitor_method :parameter_definition
|
5171
|
+
def_visitor_method :type_name
|
5172
|
+
def_visitor_method :pointer_abstract_declarator
|
5173
|
+
def_visitor_method :grouped_abstract_declarator
|
5174
|
+
def_visitor_method :array_abstract_declarator
|
5175
|
+
def_visitor_method :function_abstract_declarator
|
5176
|
+
def_visitor_method :initializer
|
5480
5177
|
|
5481
5178
|
private
|
5482
5179
|
def visit_with_notifying(caller_method, node, &block)
|