adlint 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +27 -0
- data/COPYING +674 -0
- data/ChangeLog +820 -0
- data/INSTALL +78 -0
- data/MANIFEST +464 -0
- data/NEWS +38 -0
- data/README +74 -0
- data/Rakefile +167 -0
- data/TODO +29 -0
- data/bin/adlint +141 -0
- data/bin/adlint_chk +129 -0
- data/bin/adlint_cma +122 -0
- data/bin/adlint_sma +129 -0
- data/bin/adlintize +286 -0
- data/etc/conf.d/fallback/cinit.erb +11 -0
- data/etc/conf.d/fallback/traits.erb +216 -0
- data/etc/conf.d/i686-cygwin/cinit-gcc_4.3.4.erb +149 -0
- data/etc/conf.d/i686-cygwin/traits-gcc_4.3.4.erb +227 -0
- data/etc/conf.d/i686-devkit/cinit-gcc_4.5.2.erb +224 -0
- data/etc/conf.d/i686-devkit/traits-gcc_4.5.2.erb +226 -0
- data/etc/conf.d/i686-linux/cinit-gcc_4.5.1.erb +219 -0
- data/etc/conf.d/i686-linux/traits-gcc_4.5.1.erb +224 -0
- data/etc/conf.d/i686-mingw/cinit-gcc_4.6.1.erb +234 -0
- data/etc/conf.d/i686-mingw/traits-gcc_4.6.1.erb +226 -0
- data/etc/conf.d/noarch/GNUmakefile.erb +119 -0
- data/etc/conf.d/noarch/adlint_all_bat.erb +9 -0
- data/etc/conf.d/noarch/adlint_all_sh.erb +10 -0
- data/etc/conf.d/noarch/pinit.erb +11 -0
- data/etc/mesg.d/en_US/messages.yml +784 -0
- data/etc/mesg.d/ja_JP/messages.yml +784 -0
- data/lib/adlint/analyzer.rb +294 -0
- data/lib/adlint/c/branch.rb +251 -0
- data/lib/adlint/c/builtin.rb +92 -0
- data/lib/adlint/c/code.rb +490 -0
- data/lib/adlint/c/const.rb +465 -0
- data/lib/adlint/c/conv.rb +212 -0
- data/lib/adlint/c/ctrlexpr.rb +949 -0
- data/lib/adlint/c/domain.rb +7499 -0
- data/lib/adlint/c/environ.rb +133 -0
- data/lib/adlint/c/expr.rb +1725 -0
- data/lib/adlint/c/format.rb +3209 -0
- data/lib/adlint/c/interp.rb +1740 -0
- data/lib/adlint/c/lexer.rb +241 -0
- data/lib/adlint/c/mediator.rb +313 -0
- data/lib/adlint/c/message.rb +13597 -0
- data/lib/adlint/c/metric.rb +765 -0
- data/lib/adlint/c/object.rb +1018 -0
- data/lib/adlint/c/parser.rb +3800 -0
- data/lib/adlint/c/parser.y +2054 -0
- data/lib/adlint/c/phase.rb +712 -0
- data/lib/adlint/c/resolver.rb +270 -0
- data/lib/adlint/c/scanner.rb +248 -0
- data/lib/adlint/c/scope.rb +74 -0
- data/lib/adlint/c/syntax.rb +4279 -0
- data/lib/adlint/c/type.rb +7506 -0
- data/lib/adlint/c/util.rb +91 -0
- data/lib/adlint/c/value.rb +2310 -0
- data/lib/adlint/c.rb +56 -0
- data/lib/adlint/code.rb +500 -0
- data/lib/adlint/cpp/code.rb +189 -0
- data/lib/adlint/cpp/constexpr.rb +721 -0
- data/lib/adlint/cpp/constexpr.y +389 -0
- data/lib/adlint/cpp/eval.rb +1012 -0
- data/lib/adlint/cpp/lexer.rb +860 -0
- data/lib/adlint/cpp/macro.rb +637 -0
- data/lib/adlint/cpp/message.rb +992 -0
- data/lib/adlint/cpp/phase.rb +176 -0
- data/lib/adlint/cpp/scanner.rb +93 -0
- data/lib/adlint/cpp/source.rb +169 -0
- data/lib/adlint/cpp/subst.rb +300 -0
- data/lib/adlint/cpp/syntax.rb +1412 -0
- data/lib/adlint/cpp/util.rb +97 -0
- data/lib/adlint/cpp.rb +43 -0
- data/lib/adlint/driver.rb +147 -0
- data/lib/adlint/error.rb +179 -0
- data/lib/adlint/lang.rb +97 -0
- data/lib/adlint/ld/message.rb +259 -0
- data/lib/adlint/ld/metric.rb +57 -0
- data/lib/adlint/ld/object.rb +542 -0
- data/lib/adlint/ld/phase.rb +193 -0
- data/lib/adlint/ld/typedef.rb +109 -0
- data/lib/adlint/ld/util.rb +88 -0
- data/lib/adlint/ld.rb +37 -0
- data/lib/adlint/lexer.rb +293 -0
- data/lib/adlint/message.rb +368 -0
- data/lib/adlint/metric.rb +805 -0
- data/lib/adlint/monitor.rb +144 -0
- data/lib/adlint/phase.rb +90 -0
- data/lib/adlint/prelude.rb +314 -0
- data/lib/adlint/report.rb +617 -0
- data/lib/adlint/source.rb +155 -0
- data/lib/adlint/symbol.rb +127 -0
- data/lib/adlint/token.rb +215 -0
- data/lib/adlint/traits.rb +643 -0
- data/lib/adlint/util.rb +524 -0
- data/lib/adlint/version.rb +71 -0
- data/lib/adlint.rb +66 -0
- data/share/HEADER +45 -0
- data/share/demo/Makefile +110 -0
- data/share/demo/ambig_operator/ambig_operator.c +289 -0
- data/share/demo/arg_points_unset/arg_points_unset.c +37 -0
- data/share/demo/array_range/array_range.c +62 -0
- data/share/demo/bad_bitfields/bad_bitfields.c +74 -0
- data/share/demo/bad_brace/bad_brace.c +19 -0
- data/share/demo/bad_charset/abcde$.h +0 -0
- data/share/demo/bad_charset/bad_charset.c +22 -0
- data/share/demo/bad_comment/bad_comment.c +3 -0
- data/share/demo/bad_const/bad_const.c +19 -0
- data/share/demo/bad_conv/bad_conv.c +48 -0
- data/share/demo/bad_indent/bad_indent.c +50 -0
- data/share/demo/bad_init/bad_init.c +49 -0
- data/share/demo/bad_macro/bad_macro.c +97 -0
- data/share/demo/bitwise_expr/bitwise_expr.c +19 -0
- data/share/demo/call_by_value/call_by_value.c +26 -0
- data/share/demo/cross_ref/cross_ref.c +21 -0
- data/share/demo/dangling_else/dangling_else.c +20 -0
- data/share/demo/dead_code/dead_code.c +237 -0
- data/share/demo/deep_nest/deep_nest.c +57 -0
- data/share/demo/dense_switch/dense_switch.c +62 -0
- data/share/demo/direct_recur/direct_recur.c +15 -0
- data/share/demo/div_by_zero/div_by_zero.c +35 -0
- data/share/demo/dos_source/dos_source.c +7 -0
- data/share/demo/funptr_cast/funptr_cast.c +26 -0
- data/share/demo/goto_stmt/goto_stmt.c +19 -0
- data/share/demo/id_hiding/id_hiding.c +19 -0
- data/share/demo/ill_defined/ill_defined.c +13 -0
- data/share/demo/implicit_conv/implicit_conv.c +60 -0
- data/share/demo/implicit_int/implicit_int.c +14 -0
- data/share/demo/incomplete_type/incomplete_type.c +49 -0
- data/share/demo/indirect_recur/indirect_recur_1.c +14 -0
- data/share/demo/indirect_recur/indirect_recur_1.h +7 -0
- data/share/demo/indirect_recur/indirect_recur_2.c +12 -0
- data/share/demo/indirect_recur/indirect_recur_2.h +6 -0
- data/share/demo/indirect_recur/indirect_recur_3.c +6 -0
- data/share/demo/indirect_recur/indirect_recur_3.h +6 -0
- data/share/demo/indirect_recur/indirect_recur_4.c +25 -0
- data/share/demo/intro_demo/intro_demo.c +76 -0
- data/share/demo/intro_demo/intro_demo.h +12 -0
- data/share/demo/intro_demo/useless_header.h +5 -0
- data/share/demo/invalid_call/invalid_call.c +32 -0
- data/share/demo/kandr_fundef/kandr_fundef.c +10 -0
- data/share/demo/line_comment/line_comment.c +12 -0
- data/share/demo/local_decl/local_decl.c +9 -0
- data/share/demo/logical_trick/logical_trick.c +36 -0
- data/share/demo/long_sym/long_sym.c +5 -0
- data/share/demo/loop_var/loop_var.c +92 -0
- data/share/demo/malloc_or_die/malloc_or_die.c +43 -0
- data/share/demo/may_be_null/may_be_null.c +52 -0
- data/share/demo/may_be_null_arith/may_be_null_arith.c +15 -0
- data/share/demo/may_be_unset/may_be_unset.c +34 -0
- data/share/demo/mmapped_io/mmapped_io.c +23 -0
- data/share/demo/multi_break/multi_break.c +33 -0
- data/share/demo/multi_decl/multi_decl_1.c +17 -0
- data/share/demo/multi_decl/multi_decl_1.h +6 -0
- data/share/demo/multi_decl/multi_decl_2.c +13 -0
- data/share/demo/multi_decl/multi_decl_2.h +6 -0
- data/share/demo/multi_decl/multi_decl_3.c +22 -0
- data/share/demo/multi_def/multi_def_1.c +36 -0
- data/share/demo/multi_def/multi_def_1.h +6 -0
- data/share/demo/multi_def/multi_def_2.c +22 -0
- data/share/demo/multi_def/multi_def_2.h +6 -0
- data/share/demo/multi_def/multi_def_3.c +6 -0
- data/share/demo/multi_typedef/multi_typedef.c +11 -0
- data/share/demo/multi_typedef/multi_typedef_1.h +1 -0
- data/share/demo/multi_typedef/multi_typedef_2.h +1 -0
- data/share/demo/must_be_false/must_be_false.c +53 -0
- data/share/demo/must_be_null/must_be_null.c +13 -0
- data/share/demo/must_be_null_arith/must_be_null_arith.c +14 -0
- data/share/demo/must_be_true/must_be_true.c +21 -0
- data/share/demo/no_eof_nl/no_eof_nl.c +4 -0
- data/share/demo/no_void_arg/no_void_arg.c +14 -0
- data/share/demo/null_stmt/null_stmt.c +19 -0
- data/share/demo/octal_const/octal_const.c +20 -0
- data/share/demo/output_by_param/output_by_param.c +17 -0
- data/share/demo/overflow/overflow.c +74 -0
- data/share/demo/press_release/press_release.c +40 -0
- data/share/demo/retn_lvar_addr/retn_lvar_addr.c +47 -0
- data/share/demo/shift_expr/shift_expr.c +14 -0
- data/share/demo/should_be_typedef/should_be_typedef.c +51 -0
- data/share/demo/static_paths/static_paths.c +153 -0
- data/share/demo/static_vars/static_vars.c +39 -0
- data/share/demo/tag_hiding/tag_hiding.c +18 -0
- data/share/demo/tricky_incdec/tricky_incdec.c +12 -0
- data/share/demo/undefined_macro/undefined_macro.c +17 -0
- data/share/demo/uninit_vars/uninit_vars.c +28 -0
- data/share/demo/union_type/union_type.c +23 -0
- data/share/demo/unmatch_decl/unmatch_decl_1.c +12 -0
- data/share/demo/unmatch_decl/unmatch_decl_1.h +8 -0
- data/share/demo/unmatch_decl/unmatch_decl_2.c +10 -0
- data/share/demo/unmatch_decl/unmatch_decl_2.h +8 -0
- data/share/demo/unmatch_decl/unmatch_decl_3.c +7 -0
- data/share/demo/unmatch_paren_macro/unmatch_paren_macro.c +15 -0
- data/share/demo/unreachable/unreachable.c +34 -0
- data/share/demo/useless_exp_funs/useless_exp_funs_1.c +14 -0
- data/share/demo/useless_exp_funs/useless_exp_funs_1.h +1 -0
- data/share/demo/useless_exp_funs/useless_exp_funs_2.c +6 -0
- data/share/demo/useless_exp_vars/useless_export_1.c +8 -0
- data/share/demo/useless_exp_vars/useless_export_1.h +1 -0
- data/share/demo/useless_exp_vars/useless_export_2.c +7 -0
- data/share/demo/useless_expr/useless_expr.c +17 -0
- data/share/demo/useless_funs/useless_funs_1.c +21 -0
- data/share/demo/useless_funs/useless_funs_1.h +8 -0
- data/share/demo/useless_funs/useless_funs_2.c +6 -0
- data/share/demo/useless_header/useless_header.c +9 -0
- data/share/demo/useless_header/useless_header_1.h +12 -0
- data/share/demo/useless_header/useless_header_2.h +6 -0
- data/share/demo/useless_header/useless_header_3.h +9 -0
- data/share/demo/useless_header/useless_header_4.h +3 -0
- data/share/demo/useless_vars/useless_vars.c +17 -0
- data/share/demo/va_funcall/va_funcall.c +25 -0
- data/share/demo/various_fundef/various_fundef.c +36 -0
- data/share/demo/wchar_wstring/wchar_wstring.c +7 -0
- data/share/demo/wrap_around/wrap_around.c +38 -0
- data/share/doc/Makefile +16 -0
- data/share/doc/adlint_on_adqua.png +0 -0
- data/share/doc/adlint_on_eclipse_en.png +0 -0
- data/share/doc/adlint_on_eclipse_ja.png +0 -0
- data/share/doc/adlint_on_vim_en.png +0 -0
- data/share/doc/adlint_on_vim_ja.png +0 -0
- data/share/doc/developers_guide_ja.html +171 -0
- data/share/doc/developers_guide_ja.texi +87 -0
- data/share/doc/gen_mesg_sections.rb +39 -0
- data/share/doc/samples/GNUmakefile +162 -0
- data/share/doc/samples/adlint_traits.yml +238 -0
- data/share/doc/texinfo.css +22 -0
- data/share/doc/users_guide_en.html +39975 -0
- data/share/doc/users_guide_en.texi +32640 -0
- data/share/doc/users_guide_ja.html +40505 -0
- data/share/doc/users_guide_ja.texi +33189 -0
- data/share/logo/adlint-110.png +0 -0
- data/share/logo/adlint-524.png +0 -0
- data/share/logo/adlint.svg +4637 -0
- data/share/sample/README +6 -0
- data/share/sample/bison-2.5/adlint/GNUmakefile +170 -0
- data/share/sample/bison-2.5/adlint/adlint_traits.yml +225 -0
- data/share/sample/bison-2.5/adlint/lib/GNUmakefile +198 -0
- data/share/sample/bison-2.5/adlint/lib/adlint_cinit.h +228 -0
- data/share/sample/bison-2.5/adlint/lib/adlint_pinit.h +21 -0
- data/share/sample/bison-2.5/adlint/lib/adlint_traits.yml +238 -0
- data/share/sample/bison-2.5/adlint/src/GNUmakefile +166 -0
- data/share/sample/bison-2.5/adlint/src/adlint_cinit.h +228 -0
- data/share/sample/bison-2.5/adlint/src/adlint_pinit.h +21 -0
- data/share/sample/bison-2.5/adlint/src/adlint_traits.yml +239 -0
- data/share/sample/ctags-5.8/adlint/GNUmakefile +169 -0
- data/share/sample/ctags-5.8/adlint/adlint_cinit.h +219 -0
- data/share/sample/ctags-5.8/adlint/adlint_pinit.h +13 -0
- data/share/sample/ctags-5.8/adlint/adlint_traits.yml +225 -0
- data/share/sample/flex-2.5.35/adlint/GNUmakefile +140 -0
- data/share/sample/flex-2.5.35/adlint/adlint_cinit.h +219 -0
- data/share/sample/flex-2.5.35/adlint/adlint_pinit.h +14 -0
- data/share/sample/flex-2.5.35/adlint/adlint_traits.yml +225 -0
- data/share/sample/ruby-1.9.3-p0/adlint/GNUmakefile +314 -0
- data/share/sample/ruby-1.9.3-p0/adlint/adlint_traits.yml +225 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/GNUmakefile +204 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_pinit.h +28 -0
- data/share/sample/ruby-1.9.3-p0/adlint/core/adlint_traits.yml +240 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/GNUmakefile +163 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc/adlint_traits.yml +240 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/GNUmakefile +149 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/enc-trans/adlint_traits.yml +240 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-bigdecimal/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-continuation/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-coverage/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-curses/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/GNUmakefile +134 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-date/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dbm/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-bubblebabble/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-md5/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-rmd160/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha1/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-digest-sha2/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/GNUmakefile +134 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/GNUmakefile +140 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-dl-callback/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-etc/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fcntl/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiber/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/GNUmakefile +134 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-fiddle/adlint_traits.yml +242 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-gdbm/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-iconv/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-console/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-nonblock/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-io-wait/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-generator/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-json-parser/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-complex/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-mathn-rational/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-nkf/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/GNUmakefile +162 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-openssl/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pathname/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/GNUmakefile +135 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-psych/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-pty/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-racc-cparse/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-readline/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-ripper/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/GNUmakefile +132 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-sdbm/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/GNUmakefile +144 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-socket/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-stringio/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-strscan/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/GNUmakefile +140 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syck/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-syslog/adlint_traits.yml +241 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/GNUmakefile +131 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_cinit.h +228 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_pinit.h +24 -0
- data/share/sample/ruby-1.9.3-p0/adlint/ext-zlib/adlint_traits.yml +241 -0
- data/share/sample/screen-4.0.3/adlint/GNUmakefile +162 -0
- data/share/sample/screen-4.0.3/adlint/adlint_cinit.h +228 -0
- data/share/sample/screen-4.0.3/adlint/adlint_pinit.h +21 -0
- data/share/sample/screen-4.0.3/adlint/adlint_traits.yml +238 -0
- data/share/sample/vim-7.3/adlint/vim/GNUmakefile +185 -0
- data/share/sample/vim-7.3/adlint/vim/adlint_cinit.h +228 -0
- data/share/sample/vim-7.3/adlint/vim/adlint_pinit.h +25 -0
- data/share/sample/vim-7.3/adlint/vim/adlint_traits.yml +250 -0
- data/share/sample/vim-7.3/adlint/xxd/GNUmakefile +131 -0
- data/share/sample/vim-7.3/adlint/xxd/adlint_cinit.h +228 -0
- data/share/sample/vim-7.3/adlint/xxd/adlint_pinit.h +24 -0
- data/share/sample/vim-7.3/adlint/xxd/adlint_traits.yml +237 -0
- data/share/sample/zsh-4.3.15/adlint/GNUmakefile +146 -0
- data/share/sample/zsh-4.3.15/adlint/adlint_traits.yml +225 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/GNUmakefile +132 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_pinit.h +24 -0
- data/share/sample/zsh-4.3.15/adlint/builtins/adlint_traits.yml +240 -0
- data/share/sample/zsh-4.3.15/adlint/core/GNUmakefile +153 -0
- data/share/sample/zsh-4.3.15/adlint/core/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/core/adlint_pinit.h +23 -0
- data/share/sample/zsh-4.3.15/adlint/core/adlint_traits.yml +239 -0
- data/share/sample/zsh-4.3.15/adlint/modules/GNUmakefile +147 -0
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_pinit.h +24 -0
- data/share/sample/zsh-4.3.15/adlint/modules/adlint_traits.yml +240 -0
- data/share/sample/zsh-4.3.15/adlint/zle/GNUmakefile +144 -0
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_cinit.h +228 -0
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_pinit.h +24 -0
- data/share/sample/zsh-4.3.15/adlint/zle/adlint_traits.yml +239 -0
- data/spec/MUST_WRITE_SPECS_WITH_RSPEC +0 -0
- metadata +532 -0
|
@@ -0,0 +1,4279 @@
|
|
|
1
|
+
# AST of C language.
|
|
2
|
+
#
|
|
3
|
+
# Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
4
|
+
# Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
|
|
5
|
+
# License:: GPLv3+: GNU General Public License version 3 or later
|
|
6
|
+
#
|
|
7
|
+
# Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
|
|
8
|
+
|
|
9
|
+
#--
|
|
10
|
+
# ___ ____ __ ___ _________
|
|
11
|
+
# / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
|
|
12
|
+
# / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
|
|
13
|
+
# / __ |/ /_/ / /___/ / /| / / /
|
|
14
|
+
# /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
|
|
15
|
+
#
|
|
16
|
+
# This file is part of AdLint.
|
|
17
|
+
#
|
|
18
|
+
# AdLint is free software: you can redistribute it and/or modify it under the
|
|
19
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
20
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
21
|
+
# version.
|
|
22
|
+
#
|
|
23
|
+
# AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
24
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
25
|
+
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
26
|
+
#
|
|
27
|
+
# You should have received a copy of the GNU General Public License along with
|
|
28
|
+
# AdLint. If not, see <http://www.gnu.org/licenses/>.
|
|
29
|
+
#
|
|
30
|
+
#++
|
|
31
|
+
|
|
32
|
+
require "adlint/symbol"
|
|
33
|
+
require "adlint/util"
|
|
34
|
+
|
|
35
|
+
module AdLint #:nodoc:
|
|
36
|
+
module C #:nodoc:
|
|
37
|
+
|
|
38
|
+
class SyntaxNode
|
|
39
|
+
include Visitable
|
|
40
|
+
|
|
41
|
+
def initialize
|
|
42
|
+
@head_token = nil
|
|
43
|
+
@tail_token = nil
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
attr_accessor :head_token
|
|
47
|
+
attr_accessor :tail_token
|
|
48
|
+
|
|
49
|
+
def location
|
|
50
|
+
subclass_responsibility
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def head_location
|
|
54
|
+
@head_token ? @head_token.location : nil
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def tail_location
|
|
58
|
+
@tail_token ? @tail_token.location : nil
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def inspect(indent = 0)
|
|
62
|
+
subclass_responsibility
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def short_class_name
|
|
66
|
+
self.class.name.sub(/\A.*::/, "")
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
module SyntaxNodeCollector
|
|
71
|
+
def collect_object_specifiers(node)
|
|
72
|
+
if node
|
|
73
|
+
ObjectSpecifierCollector.new.tap { |collector|
|
|
74
|
+
node.accept(collector)
|
|
75
|
+
}.object_specifiers
|
|
76
|
+
else
|
|
77
|
+
[]
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
module_function :collect_object_specifiers
|
|
81
|
+
|
|
82
|
+
def collect_identifier_declarators(node)
|
|
83
|
+
if node
|
|
84
|
+
IdentifierDeclaratorCollector.new.tap { |collector|
|
|
85
|
+
node.accept(collector)
|
|
86
|
+
}.identifier_declarators
|
|
87
|
+
else
|
|
88
|
+
[]
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
module_function :collect_identifier_declarators
|
|
92
|
+
|
|
93
|
+
def collect_function_declarators(node)
|
|
94
|
+
if node
|
|
95
|
+
FunctionDeclaratorCollector.new.tap { |collector|
|
|
96
|
+
node.accept(collector)
|
|
97
|
+
}.function_declarators
|
|
98
|
+
else
|
|
99
|
+
[]
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
module_function :collect_function_declarators
|
|
103
|
+
|
|
104
|
+
def collect_simple_assignment_expressions(node)
|
|
105
|
+
if node
|
|
106
|
+
SimpleAssignmentExpressionCollector.new.tap { |collector|
|
|
107
|
+
node.accept(collector)
|
|
108
|
+
}.simple_assignment_expressions
|
|
109
|
+
else
|
|
110
|
+
[]
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
module_function :collect_simple_assignment_expressions
|
|
114
|
+
|
|
115
|
+
def collect_compound_assignment_expressions(node)
|
|
116
|
+
if node
|
|
117
|
+
CompoundAssignmentExpressionCollector.new.tap { |collector|
|
|
118
|
+
node.accept(collector)
|
|
119
|
+
}.compound_assignment_expressions
|
|
120
|
+
else
|
|
121
|
+
[]
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
module_function :collect_compound_assignment_expressions
|
|
125
|
+
|
|
126
|
+
def collect_prefix_increment_expressions(node)
|
|
127
|
+
if node
|
|
128
|
+
PrefixIncrementExpressionCollector.new.tap { |collector|
|
|
129
|
+
node.accept(collector)
|
|
130
|
+
}.prefix_increment_expressions
|
|
131
|
+
else
|
|
132
|
+
[]
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
module_function :collect_prefix_increment_expressions
|
|
136
|
+
|
|
137
|
+
def collect_prefix_decrement_expressions(node)
|
|
138
|
+
if node
|
|
139
|
+
PrefixDecrementExpressionCollector.new.tap { |collector|
|
|
140
|
+
node.accept(collector)
|
|
141
|
+
}.prefix_decrement_expressions
|
|
142
|
+
else
|
|
143
|
+
[]
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
module_function :collect_prefix_decrement_expressions
|
|
147
|
+
|
|
148
|
+
def collect_postfix_increment_expressions(node)
|
|
149
|
+
if node
|
|
150
|
+
PostfixIncrementExpressionCollector.new.tap { |collector|
|
|
151
|
+
node.accept(collector)
|
|
152
|
+
}.postfix_increment_expressions
|
|
153
|
+
else
|
|
154
|
+
[]
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
module_function :collect_postfix_increment_expressions
|
|
158
|
+
|
|
159
|
+
def collect_postfix_decrement_expressions(node)
|
|
160
|
+
if node
|
|
161
|
+
PostfixDecrementExpressionCollector.new.tap { |collector|
|
|
162
|
+
node.accept(collector)
|
|
163
|
+
}.postfix_decrement_expressions
|
|
164
|
+
else
|
|
165
|
+
[]
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
module_function :collect_postfix_decrement_expressions
|
|
169
|
+
|
|
170
|
+
def collect_additive_expressions(node)
|
|
171
|
+
if node
|
|
172
|
+
AdditiveExpressionCollector.new.tap { |collector|
|
|
173
|
+
node.accept(collector)
|
|
174
|
+
}.additive_expressions
|
|
175
|
+
else
|
|
176
|
+
[]
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
module_function :collect_additive_expressions
|
|
180
|
+
|
|
181
|
+
def collect_generic_labeled_statements(node)
|
|
182
|
+
if node
|
|
183
|
+
GenericLabeledStatementCollector.new.tap { |collector|
|
|
184
|
+
node.accept(collector)
|
|
185
|
+
}.generic_labeled_statements
|
|
186
|
+
else
|
|
187
|
+
[]
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
module_function :collect_generic_labeled_statements
|
|
191
|
+
|
|
192
|
+
def collect_if_statements(node)
|
|
193
|
+
if node
|
|
194
|
+
IfStatementCollector.new.tap { |collector|
|
|
195
|
+
node.accept(collector)
|
|
196
|
+
}.if_statements
|
|
197
|
+
else
|
|
198
|
+
[]
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
module_function :collect_if_statements
|
|
202
|
+
|
|
203
|
+
def collect_if_else_statements(node)
|
|
204
|
+
if node
|
|
205
|
+
IfElseStatementCollector.new.tap { |collector|
|
|
206
|
+
node.accept(collector)
|
|
207
|
+
}.if_else_statements
|
|
208
|
+
else
|
|
209
|
+
[]
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
module_function :collect_if_else_statements
|
|
213
|
+
|
|
214
|
+
def collect_goto_statements(node)
|
|
215
|
+
if node
|
|
216
|
+
GotoStatementCollector.new.tap { |collector|
|
|
217
|
+
node.accept(collector)
|
|
218
|
+
}.goto_statements
|
|
219
|
+
else
|
|
220
|
+
[]
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
module_function :collect_goto_statements
|
|
224
|
+
|
|
225
|
+
def collect_array_declarators(node)
|
|
226
|
+
if node
|
|
227
|
+
ArrayDeclaratorCollector.new.tap { |collector|
|
|
228
|
+
node.accept(collector)
|
|
229
|
+
}.array_declarators
|
|
230
|
+
else
|
|
231
|
+
[]
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
module_function :collect_array_declarators
|
|
235
|
+
|
|
236
|
+
def collect_constant_specifiers(node)
|
|
237
|
+
if node
|
|
238
|
+
ConstantSpecifierCollector.new.tap { |collector|
|
|
239
|
+
node.accept(collector)
|
|
240
|
+
}.constant_specifiers
|
|
241
|
+
else
|
|
242
|
+
[]
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
module_function :collect_constant_specifiers
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
class Expression < SyntaxNode
|
|
249
|
+
def have_side_effect?
|
|
250
|
+
subclass_responsibility
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
def constant?
|
|
254
|
+
visitor = ObjectSpecifierCollector.new
|
|
255
|
+
accept(visitor)
|
|
256
|
+
visitor.object_specifiers.empty?
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
def to_s
|
|
260
|
+
subclass_responsibility
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
class ErrorExpression < Expression
|
|
265
|
+
def initialize(error_token)
|
|
266
|
+
super()
|
|
267
|
+
@error_token = error_token
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def location
|
|
271
|
+
head_location
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def have_side_effect?
|
|
275
|
+
true
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def to_s
|
|
279
|
+
@error_token.value
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def inspect(indent = 0)
|
|
283
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
284
|
+
"#{@error_token.value}"
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
class PrimaryExpression < Expression
|
|
289
|
+
def have_side_effect?
|
|
290
|
+
false
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
class ObjectSpecifier < PrimaryExpression
|
|
295
|
+
def initialize(identifier)
|
|
296
|
+
super()
|
|
297
|
+
@identifier = identifier
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
attr_reader :identifier
|
|
301
|
+
|
|
302
|
+
def location
|
|
303
|
+
@identifier.location
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def to_s
|
|
307
|
+
@identifier.value
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
def inspect(indent = 0)
|
|
311
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
312
|
+
"#{@identifier.value}"
|
|
313
|
+
end
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
class ConstantSpecifier < PrimaryExpression
|
|
317
|
+
def initialize(constant)
|
|
318
|
+
super()
|
|
319
|
+
@constant = constant
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
attr_reader :constant
|
|
323
|
+
|
|
324
|
+
def location
|
|
325
|
+
@constant.location
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
def prefix
|
|
329
|
+
@constant.value.scan(/\A(?:0x|0b|L)/i).first
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
def suffix
|
|
333
|
+
@constant.value.scan(/(?:[UL]+|[FL]+)\z/i).first
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
def character?
|
|
337
|
+
@constant.value =~ /'.*'/
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
def to_s
|
|
341
|
+
@constant.value
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
def inspect(indent = 0)
|
|
345
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
346
|
+
"#{@constant.value}"
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
class StringLiteralSpecifier < PrimaryExpression
|
|
351
|
+
def initialize(literal)
|
|
352
|
+
super()
|
|
353
|
+
@literal = literal
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
attr_reader :literal
|
|
357
|
+
|
|
358
|
+
def location
|
|
359
|
+
@literal.location
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
def prefix
|
|
363
|
+
@literal.value.scan(/\AL/i).first
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
def to_s
|
|
367
|
+
@literal.value
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
def inspect(indent = 0)
|
|
371
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
372
|
+
"#{@literal.value}"
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
class NullConstantSpecifier < PrimaryExpression
|
|
377
|
+
def initialize(token)
|
|
378
|
+
super()
|
|
379
|
+
@token = token
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
attr_reader :token
|
|
383
|
+
|
|
384
|
+
def location
|
|
385
|
+
@token.location
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
def to_s
|
|
389
|
+
@token.value
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
def inspect(indent = 0)
|
|
393
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
394
|
+
"#{@token.value}"
|
|
395
|
+
end
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
class GroupedExpression < PrimaryExpression
|
|
399
|
+
def initialize(expression)
|
|
400
|
+
super()
|
|
401
|
+
@expression = expression
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
attr_reader :expression
|
|
405
|
+
|
|
406
|
+
def location
|
|
407
|
+
head_location
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
def have_side_effect?
|
|
411
|
+
@expression.have_side_effect?
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
def to_s
|
|
415
|
+
"(#{expression.to_s})"
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
def inspect(indent = 0)
|
|
419
|
+
" " * indent + "#{short_class_name} (#{location.inspect})\n" +
|
|
420
|
+
@expression.inspect(indent + 1)
|
|
421
|
+
end
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
class PostfixExpression < Expression
|
|
425
|
+
def initialize(operator)
|
|
426
|
+
@operator = operator
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
attr_reader :operator
|
|
430
|
+
|
|
431
|
+
def location
|
|
432
|
+
@operator.location
|
|
433
|
+
end
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
class ArraySubscriptExpression < PostfixExpression
|
|
437
|
+
def initialize(expression, array_subscript, left_bracket)
|
|
438
|
+
super(left_bracket)
|
|
439
|
+
@expression = expression
|
|
440
|
+
@array_subscript = array_subscript
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
attr_reader :expression
|
|
444
|
+
attr_reader :array_subscript
|
|
445
|
+
|
|
446
|
+
def have_side_effect?
|
|
447
|
+
@expression.have_side_effect? || @array_subscript.have_side_effect?
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
def to_s
|
|
451
|
+
"#{@expression.to_s}[#{@array_subscript.to_s}]"
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
def inspect(indent = 0)
|
|
455
|
+
" " * indent + "#{short_class_name} (#{location.inspect})\n" +
|
|
456
|
+
@expression.inspect(indent + 1) + "\n" +
|
|
457
|
+
@array_subscript.inspect(indent + 1)
|
|
458
|
+
end
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
class FunctionCallExpression < PostfixExpression
|
|
462
|
+
def initialize(expression, argument_expressions, left_paren)
|
|
463
|
+
super(left_paren)
|
|
464
|
+
@expression = expression
|
|
465
|
+
@argument_expressions = argument_expressions
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
attr_reader :expression
|
|
469
|
+
attr_reader :argument_expressions
|
|
470
|
+
|
|
471
|
+
def have_side_effect?
|
|
472
|
+
true
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
def to_s
|
|
476
|
+
"#{@expression.to_s}(" +
|
|
477
|
+
@argument_expressions.map { |expr| expr.to_s }.join(",") + ")"
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
def inspect(indent = 0)
|
|
481
|
+
([" " * indent + "#{short_class_name} (#{location.inspect})"] +
|
|
482
|
+
[@expression.inspect(indent + 1)] +
|
|
483
|
+
@argument_expressions.map { |a| a.inspect(indent + 1) }).join("\n")
|
|
484
|
+
end
|
|
485
|
+
end
|
|
486
|
+
|
|
487
|
+
class MemberAccessByValueExpression < PostfixExpression
|
|
488
|
+
def initialize(expression, identifier, dot)
|
|
489
|
+
super(dot)
|
|
490
|
+
@expression = expression
|
|
491
|
+
@identifier = identifier
|
|
492
|
+
end
|
|
493
|
+
|
|
494
|
+
attr_reader :expression
|
|
495
|
+
attr_reader :identifier
|
|
496
|
+
|
|
497
|
+
def have_side_effect?
|
|
498
|
+
@expression.have_side_effect?
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
def to_s
|
|
502
|
+
"#{@expression.to_s}.#{@identifier.value}"
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
def inspect(indent = 0)
|
|
506
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
507
|
+
"#{@expression.inspect}.#{@identifier.value}"
|
|
508
|
+
end
|
|
509
|
+
end
|
|
510
|
+
|
|
511
|
+
class MemberAccessByPointerExpression < PostfixExpression
|
|
512
|
+
def initialize(expression, identifier, arrow)
|
|
513
|
+
super(arrow)
|
|
514
|
+
@expression = expression
|
|
515
|
+
@identifier = identifier
|
|
516
|
+
end
|
|
517
|
+
|
|
518
|
+
attr_reader :expression
|
|
519
|
+
attr_reader :identifier
|
|
520
|
+
|
|
521
|
+
def have_side_effect?
|
|
522
|
+
@expression.have_side_effect?
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
def to_s
|
|
526
|
+
"#{@expression.to_s}->#{@identifier.value}"
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
def inspect(indent = 0)
|
|
530
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
531
|
+
"#{@expression.inspect}->#{@identifier.value}"
|
|
532
|
+
end
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
class BitAccessByValueExpression < PostfixExpression
|
|
536
|
+
def initialize(expression, constant, dot)
|
|
537
|
+
super(dot)
|
|
538
|
+
@expression = expression
|
|
539
|
+
@constant = constant
|
|
540
|
+
end
|
|
541
|
+
|
|
542
|
+
attr_reader :expression
|
|
543
|
+
attr_reader :constant
|
|
544
|
+
|
|
545
|
+
def have_side_effect?
|
|
546
|
+
@expression.have_side_effect?
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
def to_s
|
|
550
|
+
"#{@expression.to_s}.#{@constant.value}"
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
def inspect(indent = 0)
|
|
554
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
555
|
+
"#{@expression.inspect}.#{@constant.value}"
|
|
556
|
+
end
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
class BitAccessByPointerExpression < PostfixExpression
|
|
560
|
+
def initialize(expression, constant, arrow)
|
|
561
|
+
super(arrow)
|
|
562
|
+
@expression = expression
|
|
563
|
+
@constant = constant
|
|
564
|
+
end
|
|
565
|
+
|
|
566
|
+
attr_reader :expression
|
|
567
|
+
attr_reader :constant
|
|
568
|
+
|
|
569
|
+
def have_side_effect?
|
|
570
|
+
@expression.have_side_effect?
|
|
571
|
+
end
|
|
572
|
+
|
|
573
|
+
def to_s
|
|
574
|
+
"#{@expression.to_s}->#{@constant.value}"
|
|
575
|
+
end
|
|
576
|
+
|
|
577
|
+
def inspect(indent = 0)
|
|
578
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
579
|
+
"#{@expression.inspect}->#{@constant.value}"
|
|
580
|
+
end
|
|
581
|
+
end
|
|
582
|
+
|
|
583
|
+
class PostfixIncrementExpression < PostfixExpression
|
|
584
|
+
def initialize(operand, operator)
|
|
585
|
+
super(operator)
|
|
586
|
+
@operand = operand
|
|
587
|
+
end
|
|
588
|
+
|
|
589
|
+
attr_reader :operand
|
|
590
|
+
|
|
591
|
+
def have_side_effect?
|
|
592
|
+
true
|
|
593
|
+
end
|
|
594
|
+
|
|
595
|
+
def to_s
|
|
596
|
+
"#{@operand.to_s}++"
|
|
597
|
+
end
|
|
598
|
+
|
|
599
|
+
def inspect(indent = 0)
|
|
600
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
601
|
+
@operand.inspect
|
|
602
|
+
end
|
|
603
|
+
end
|
|
604
|
+
|
|
605
|
+
class PostfixDecrementExpression < PostfixExpression
|
|
606
|
+
def initialize(operand, operator)
|
|
607
|
+
super(operator)
|
|
608
|
+
@operand = operand
|
|
609
|
+
end
|
|
610
|
+
|
|
611
|
+
attr_reader :operand
|
|
612
|
+
|
|
613
|
+
def have_side_effect?
|
|
614
|
+
true
|
|
615
|
+
end
|
|
616
|
+
|
|
617
|
+
def to_s
|
|
618
|
+
"#{@operand.to_s}--"
|
|
619
|
+
end
|
|
620
|
+
|
|
621
|
+
def inspect(indent = 0)
|
|
622
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
623
|
+
@operand.inspect
|
|
624
|
+
end
|
|
625
|
+
end
|
|
626
|
+
|
|
627
|
+
class CompoundLiteralExpression < PostfixExpression
|
|
628
|
+
def initialize(type_name, initializers, left_paren)
|
|
629
|
+
super(left_paren)
|
|
630
|
+
@type_name = type_name
|
|
631
|
+
@initializers = initializers
|
|
632
|
+
end
|
|
633
|
+
|
|
634
|
+
attr_reader :type_name
|
|
635
|
+
attr_reader :initializers
|
|
636
|
+
|
|
637
|
+
def have_side_effect?
|
|
638
|
+
false
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
def to_s
|
|
642
|
+
"(#{@type_name.to_s}){" +
|
|
643
|
+
@initializers.map { |ini| ini.to_s }.join(",") + "}"
|
|
644
|
+
end
|
|
645
|
+
|
|
646
|
+
def inspect(indent = 0)
|
|
647
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
648
|
+
@initializers.map { |init| init.inspect }.join(",")
|
|
649
|
+
end
|
|
650
|
+
end
|
|
651
|
+
|
|
652
|
+
class UnaryExpression < Expression
|
|
653
|
+
def initialize(operator, operand)
|
|
654
|
+
super()
|
|
655
|
+
@operator = operator
|
|
656
|
+
@operand = operand
|
|
657
|
+
end
|
|
658
|
+
|
|
659
|
+
attr_reader :operator
|
|
660
|
+
attr_reader :operand
|
|
661
|
+
|
|
662
|
+
def location
|
|
663
|
+
@operator.location
|
|
664
|
+
end
|
|
665
|
+
|
|
666
|
+
def have_side_effect?
|
|
667
|
+
@operand.have_side_effect?
|
|
668
|
+
end
|
|
669
|
+
|
|
670
|
+
def to_s
|
|
671
|
+
@operator.value + @operand.to_s
|
|
672
|
+
end
|
|
673
|
+
|
|
674
|
+
def inspect(indent = 0)
|
|
675
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
676
|
+
"#{@operator.value} #{@operand.inspect}"
|
|
677
|
+
end
|
|
678
|
+
end
|
|
679
|
+
|
|
680
|
+
class PrefixIncrementExpression < UnaryExpression
|
|
681
|
+
def have_side_effect?
|
|
682
|
+
true
|
|
683
|
+
end
|
|
684
|
+
end
|
|
685
|
+
|
|
686
|
+
class PrefixDecrementExpression < UnaryExpression
|
|
687
|
+
def have_side_effect?
|
|
688
|
+
true
|
|
689
|
+
end
|
|
690
|
+
end
|
|
691
|
+
|
|
692
|
+
class AddressExpression < UnaryExpression; end
|
|
693
|
+
|
|
694
|
+
class IndirectionExpression < UnaryExpression; end
|
|
695
|
+
|
|
696
|
+
class UnaryArithmeticExpression < UnaryExpression; end
|
|
697
|
+
|
|
698
|
+
class SizeofExpression < UnaryExpression
|
|
699
|
+
def to_s
|
|
700
|
+
"sizeof(#{@operand.to_s})"
|
|
701
|
+
end
|
|
702
|
+
end
|
|
703
|
+
|
|
704
|
+
class SizeofTypeExpression < UnaryExpression
|
|
705
|
+
def have_side_effect?
|
|
706
|
+
false
|
|
707
|
+
end
|
|
708
|
+
|
|
709
|
+
def to_s
|
|
710
|
+
"sizeof(#{@operand.to_s})"
|
|
711
|
+
end
|
|
712
|
+
end
|
|
713
|
+
|
|
714
|
+
class AlignofExpression < UnaryExpression
|
|
715
|
+
def to_s
|
|
716
|
+
"alignof(#{@operand.to_s})"
|
|
717
|
+
end
|
|
718
|
+
end
|
|
719
|
+
|
|
720
|
+
class AlignofTypeExpression < UnaryExpression
|
|
721
|
+
def have_side_effect?
|
|
722
|
+
false
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
def to_s
|
|
726
|
+
"alignof(#{@operand.to_s})"
|
|
727
|
+
end
|
|
728
|
+
end
|
|
729
|
+
|
|
730
|
+
class CastExpression < Expression
|
|
731
|
+
def initialize(type_name, operand)
|
|
732
|
+
super()
|
|
733
|
+
@type_name = type_name
|
|
734
|
+
@operand = operand
|
|
735
|
+
end
|
|
736
|
+
|
|
737
|
+
attr_reader :type_name
|
|
738
|
+
attr_reader :operand
|
|
739
|
+
|
|
740
|
+
def location
|
|
741
|
+
head_location
|
|
742
|
+
end
|
|
743
|
+
|
|
744
|
+
def have_side_effect?
|
|
745
|
+
@operand.have_side_effect?
|
|
746
|
+
end
|
|
747
|
+
|
|
748
|
+
def to_s
|
|
749
|
+
"(#{@type_name.to_s}) #{@operand.to_s}"
|
|
750
|
+
end
|
|
751
|
+
|
|
752
|
+
def inspect(indent = 0)
|
|
753
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
754
|
+
"#{@type_name.inspect} #{@operand.inspect}"
|
|
755
|
+
end
|
|
756
|
+
end
|
|
757
|
+
|
|
758
|
+
class BinaryExpression < Expression
|
|
759
|
+
def initialize(operator, lhs_operand, rhs_operand)
|
|
760
|
+
super()
|
|
761
|
+
@operator = operator
|
|
762
|
+
@lhs_operand = lhs_operand
|
|
763
|
+
@rhs_operand = rhs_operand
|
|
764
|
+
end
|
|
765
|
+
|
|
766
|
+
attr_reader :operator
|
|
767
|
+
attr_reader :lhs_operand
|
|
768
|
+
attr_reader :rhs_operand
|
|
769
|
+
|
|
770
|
+
def location
|
|
771
|
+
@operator.location
|
|
772
|
+
end
|
|
773
|
+
|
|
774
|
+
def have_side_effect?
|
|
775
|
+
lhs_operand.have_side_effect? || rhs_operand.have_side_effect?
|
|
776
|
+
end
|
|
777
|
+
|
|
778
|
+
def to_s
|
|
779
|
+
"#{@lhs_operand.to_s} #{@operator.value} #{@rhs_operand.to_s}"
|
|
780
|
+
end
|
|
781
|
+
|
|
782
|
+
def inspect(indent = 0)
|
|
783
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
784
|
+
"#{@operator.value} #{lhs_operand.inspect} #{rhs_operand.inspect}"
|
|
785
|
+
end
|
|
786
|
+
end
|
|
787
|
+
|
|
788
|
+
class MultiplicativeExpression < BinaryExpression; end
|
|
789
|
+
|
|
790
|
+
class AdditiveExpression < BinaryExpression; end
|
|
791
|
+
|
|
792
|
+
class ShiftExpression < BinaryExpression; end
|
|
793
|
+
|
|
794
|
+
class RelationalExpression < BinaryExpression; end
|
|
795
|
+
|
|
796
|
+
class EqualityExpression < BinaryExpression; end
|
|
797
|
+
|
|
798
|
+
class AndExpression < BinaryExpression; end
|
|
799
|
+
|
|
800
|
+
class ExclusiveOrExpression < BinaryExpression; end
|
|
801
|
+
|
|
802
|
+
class InclusiveOrExpression < BinaryExpression; end
|
|
803
|
+
|
|
804
|
+
class LogicalAndExpression < BinaryExpression; end
|
|
805
|
+
|
|
806
|
+
class LogicalOrExpression < BinaryExpression; end
|
|
807
|
+
|
|
808
|
+
class ConditionalExpression < Expression
|
|
809
|
+
def initialize(condition, then_expression, else_expression, question_mark)
|
|
810
|
+
super()
|
|
811
|
+
@condition = condition
|
|
812
|
+
@then_expression = then_expression
|
|
813
|
+
@else_expression = else_expression
|
|
814
|
+
@question_mark = question_mark
|
|
815
|
+
end
|
|
816
|
+
|
|
817
|
+
attr_reader :condition
|
|
818
|
+
attr_reader :then_expression
|
|
819
|
+
attr_reader :else_expression
|
|
820
|
+
|
|
821
|
+
def location
|
|
822
|
+
@question_mark.location
|
|
823
|
+
end
|
|
824
|
+
|
|
825
|
+
def have_side_effect?
|
|
826
|
+
@condition.have_side_effect? ||
|
|
827
|
+
@then_expression.have_side_effect? ||
|
|
828
|
+
@else_expression.have_side_effect?
|
|
829
|
+
end
|
|
830
|
+
|
|
831
|
+
def to_s
|
|
832
|
+
"#{@condition.to_s} ? " +
|
|
833
|
+
"#{@then_expression.to_s} : #{@else_expression.to_s}"
|
|
834
|
+
end
|
|
835
|
+
|
|
836
|
+
def inspect(indent = 0)
|
|
837
|
+
" " * indent + "#{short_class_name}\n" +
|
|
838
|
+
@condition.inspect(indent + 1) + "\n" +
|
|
839
|
+
@then_expression.inspect(indent + 1) + "\n" +
|
|
840
|
+
@else_expression.inspect(indent + 1)
|
|
841
|
+
end
|
|
842
|
+
end
|
|
843
|
+
|
|
844
|
+
class SimpleAssignmentExpression < BinaryExpression
|
|
845
|
+
def have_side_effect?
|
|
846
|
+
true
|
|
847
|
+
end
|
|
848
|
+
end
|
|
849
|
+
|
|
850
|
+
class CompoundAssignmentExpression < BinaryExpression
|
|
851
|
+
def have_side_effect?
|
|
852
|
+
true
|
|
853
|
+
end
|
|
854
|
+
end
|
|
855
|
+
|
|
856
|
+
class CommaSeparatedExpression < Expression
|
|
857
|
+
def initialize(first_expression)
|
|
858
|
+
super()
|
|
859
|
+
@expressions = [first_expression]
|
|
860
|
+
end
|
|
861
|
+
|
|
862
|
+
attr_reader :expressions
|
|
863
|
+
|
|
864
|
+
def location
|
|
865
|
+
head_location
|
|
866
|
+
end
|
|
867
|
+
|
|
868
|
+
def have_side_effect?
|
|
869
|
+
@expressions.any? { |expr| expr.have_side_effect? }
|
|
870
|
+
end
|
|
871
|
+
|
|
872
|
+
def to_s
|
|
873
|
+
@expressions.map { |expr| expr.to_s }.join(",")
|
|
874
|
+
end
|
|
875
|
+
|
|
876
|
+
def push(expression)
|
|
877
|
+
@expressions.push(expression)
|
|
878
|
+
self
|
|
879
|
+
end
|
|
880
|
+
|
|
881
|
+
def inspect(indent = 0)
|
|
882
|
+
" " * indent + "#{short_class_name}\n" +
|
|
883
|
+
@expressions.map { |expr| expr.inspect(indent + 1) }.join("\n")
|
|
884
|
+
end
|
|
885
|
+
end
|
|
886
|
+
|
|
887
|
+
class Declaration < SyntaxNode
|
|
888
|
+
def initialize(declaration_specifiers, init_declarators, symbol_table)
|
|
889
|
+
super()
|
|
890
|
+
@declaration_specifiers = declaration_specifiers
|
|
891
|
+
@init_declarators = init_declarators
|
|
892
|
+
@items = build_items(declaration_specifiers, init_declarators,
|
|
893
|
+
symbol_table)
|
|
894
|
+
end
|
|
895
|
+
|
|
896
|
+
attr_reader :declaration_specifiers
|
|
897
|
+
attr_reader :init_declarators
|
|
898
|
+
attr_reader :items
|
|
899
|
+
|
|
900
|
+
def location
|
|
901
|
+
head_location
|
|
902
|
+
end
|
|
903
|
+
|
|
904
|
+
def inspect(indent = 0)
|
|
905
|
+
([" " * indent + "#{short_class_name} (#{location.inspect})"] +
|
|
906
|
+
@items.map { |item| item.inspect(indent + 1) }).join("\n")
|
|
907
|
+
end
|
|
908
|
+
|
|
909
|
+
private
|
|
910
|
+
def build_items(declaration_specifiers, init_declarators, symbol_table)
|
|
911
|
+
build_type_declaration(
|
|
912
|
+
declaration_specifiers, init_declarators, symbol_table) +
|
|
913
|
+
build_function_declaration(
|
|
914
|
+
declaration_specifiers, init_declarators, symbol_table) +
|
|
915
|
+
build_variable_declaration(
|
|
916
|
+
declaration_specifiers, init_declarators, symbol_table) +
|
|
917
|
+
build_variable_definition(
|
|
918
|
+
declaration_specifiers, init_declarators, symbol_table)
|
|
919
|
+
end
|
|
920
|
+
|
|
921
|
+
def build_type_declaration(declaration_specifiers, init_declarators,
|
|
922
|
+
symbol_table)
|
|
923
|
+
return [] unless declaration_specifiers
|
|
924
|
+
|
|
925
|
+
result = []
|
|
926
|
+
|
|
927
|
+
declaration_specifiers.type_specifiers.each do |type_specifier|
|
|
928
|
+
visitor = TypeDeclarationBuilder.new(symbol_table)
|
|
929
|
+
type_specifier.accept(visitor)
|
|
930
|
+
result.concat(visitor.type_declarations)
|
|
931
|
+
end
|
|
932
|
+
|
|
933
|
+
if declaration_specifiers.storage_class_specifier &&
|
|
934
|
+
declaration_specifiers.storage_class_specifier.type == :TYPEDEF
|
|
935
|
+
init_declarators.each do |init_declarator|
|
|
936
|
+
symbol = symbol_table.create_new_symbol(
|
|
937
|
+
TypedefName, init_declarator.declarator.identifier)
|
|
938
|
+
result.push(TypedefDeclaration.new(declaration_specifiers,
|
|
939
|
+
init_declarator, symbol))
|
|
940
|
+
end
|
|
941
|
+
end
|
|
942
|
+
|
|
943
|
+
result
|
|
944
|
+
end
|
|
945
|
+
|
|
946
|
+
def build_function_declaration(declaration_specifiers, init_declarators,
|
|
947
|
+
symbol_table)
|
|
948
|
+
if declaration_specifiers &&
|
|
949
|
+
declaration_specifiers.storage_class_specifier &&
|
|
950
|
+
declaration_specifiers.storage_class_specifier.type == :TYPEDEF
|
|
951
|
+
return []
|
|
952
|
+
end
|
|
953
|
+
|
|
954
|
+
result = []
|
|
955
|
+
init_declarators.each do |init_declarator|
|
|
956
|
+
if init_declarator.declarator.function?
|
|
957
|
+
symbol = symbol_table.create_new_symbol(
|
|
958
|
+
ObjectName, init_declarator.declarator.identifier)
|
|
959
|
+
result.push(FunctionDeclaration.new(declaration_specifiers,
|
|
960
|
+
init_declarator, symbol))
|
|
961
|
+
end
|
|
962
|
+
end
|
|
963
|
+
result
|
|
964
|
+
end
|
|
965
|
+
|
|
966
|
+
def build_variable_declaration(declaration_specifiers, init_declarators,
|
|
967
|
+
symbol_table)
|
|
968
|
+
return [] unless declaration_specifiers
|
|
969
|
+
|
|
970
|
+
result = []
|
|
971
|
+
if declaration_specifiers.storage_class_specifier &&
|
|
972
|
+
declaration_specifiers.storage_class_specifier.type == :EXTERN
|
|
973
|
+
init_declarators.each do |init_declarator|
|
|
974
|
+
if init_declarator.declarator.variable?
|
|
975
|
+
declarator = init_declarator.declarator
|
|
976
|
+
symbol =
|
|
977
|
+
symbol_table.create_new_symbol(ObjectName, declarator.identifier)
|
|
978
|
+
result.push(VariableDeclaration.new(declaration_specifiers,
|
|
979
|
+
declarator, symbol))
|
|
980
|
+
end
|
|
981
|
+
end
|
|
982
|
+
end
|
|
983
|
+
result
|
|
984
|
+
end
|
|
985
|
+
|
|
986
|
+
def build_variable_definition(declaration_specifiers, init_declarators,
|
|
987
|
+
symbol_table)
|
|
988
|
+
result = []
|
|
989
|
+
unless declaration_specifiers &&
|
|
990
|
+
declaration_specifiers.storage_class_specifier &&
|
|
991
|
+
(declaration_specifiers.storage_class_specifier.type == :EXTERN ||
|
|
992
|
+
declaration_specifiers.storage_class_specifier.type == :TYPEDEF)
|
|
993
|
+
init_declarators.each do |init_declarator|
|
|
994
|
+
if init_declarator.declarator.variable?
|
|
995
|
+
symbol = symbol_table.create_new_symbol(
|
|
996
|
+
ObjectName, init_declarator.declarator.identifier)
|
|
997
|
+
result.push(VariableDefinition.new(declaration_specifiers,
|
|
998
|
+
init_declarator, symbol))
|
|
999
|
+
end
|
|
1000
|
+
end
|
|
1001
|
+
end
|
|
1002
|
+
result
|
|
1003
|
+
end
|
|
1004
|
+
end
|
|
1005
|
+
|
|
1006
|
+
class FunctionDeclaration < SyntaxNode
|
|
1007
|
+
include SymbolicElement
|
|
1008
|
+
include SyntaxNodeCollector
|
|
1009
|
+
|
|
1010
|
+
def initialize(declaration_specifiers, init_declarator, symbol)
|
|
1011
|
+
super()
|
|
1012
|
+
@declaration_specifiers = declaration_specifiers
|
|
1013
|
+
@init_declarator = init_declarator
|
|
1014
|
+
@symbol = symbol
|
|
1015
|
+
@type = nil
|
|
1016
|
+
end
|
|
1017
|
+
|
|
1018
|
+
attr_reader :declaration_specifiers
|
|
1019
|
+
attr_reader :init_declarator
|
|
1020
|
+
attr_reader :symbol
|
|
1021
|
+
attr_accessor :type
|
|
1022
|
+
|
|
1023
|
+
def identifier
|
|
1024
|
+
@init_declarator.declarator.identifier
|
|
1025
|
+
end
|
|
1026
|
+
|
|
1027
|
+
def storage_class_specifier
|
|
1028
|
+
@declaration_specifiers ?
|
|
1029
|
+
@declaration_specifiers.storage_class_specifier : nil
|
|
1030
|
+
end
|
|
1031
|
+
|
|
1032
|
+
def signature
|
|
1033
|
+
FunctionSignature.new(identifier, @type)
|
|
1034
|
+
end
|
|
1035
|
+
|
|
1036
|
+
def function_declarator
|
|
1037
|
+
collect_function_declarators(@init_declarator).first
|
|
1038
|
+
end
|
|
1039
|
+
|
|
1040
|
+
def location
|
|
1041
|
+
identifier.location
|
|
1042
|
+
end
|
|
1043
|
+
|
|
1044
|
+
def inspect(indent = 0)
|
|
1045
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
1046
|
+
identifier.value
|
|
1047
|
+
end
|
|
1048
|
+
end
|
|
1049
|
+
|
|
1050
|
+
class VariableDeclaration < SyntaxNode
|
|
1051
|
+
include SymbolicElement
|
|
1052
|
+
|
|
1053
|
+
def initialize(declaration_specifiers, declarator, symbol)
|
|
1054
|
+
super()
|
|
1055
|
+
@declaration_specifiers = declaration_specifiers
|
|
1056
|
+
@declarator = declarator
|
|
1057
|
+
@symbol = symbol
|
|
1058
|
+
@type = nil
|
|
1059
|
+
end
|
|
1060
|
+
|
|
1061
|
+
attr_reader :declaration_specifiers
|
|
1062
|
+
attr_reader :declarator
|
|
1063
|
+
attr_reader :symbol
|
|
1064
|
+
attr_accessor :type
|
|
1065
|
+
|
|
1066
|
+
def identifier
|
|
1067
|
+
@declarator.identifier
|
|
1068
|
+
end
|
|
1069
|
+
|
|
1070
|
+
def storage_class_specifier
|
|
1071
|
+
@declaration_specifiers ?
|
|
1072
|
+
@declaration_specifiers.storage_class_specifier : nil
|
|
1073
|
+
end
|
|
1074
|
+
|
|
1075
|
+
def location
|
|
1076
|
+
identifier.location
|
|
1077
|
+
end
|
|
1078
|
+
|
|
1079
|
+
def inspect(indent = 0)
|
|
1080
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
1081
|
+
identifier.value
|
|
1082
|
+
end
|
|
1083
|
+
end
|
|
1084
|
+
|
|
1085
|
+
class Definition < SyntaxNode; end
|
|
1086
|
+
|
|
1087
|
+
class VariableDefinition < Definition
|
|
1088
|
+
include SymbolicElement
|
|
1089
|
+
|
|
1090
|
+
def initialize(declaration_specifiers, init_declarator, symbol)
|
|
1091
|
+
super()
|
|
1092
|
+
@declaration_specifiers = declaration_specifiers
|
|
1093
|
+
@init_declarator = init_declarator
|
|
1094
|
+
@symbol = symbol
|
|
1095
|
+
@type = nil
|
|
1096
|
+
end
|
|
1097
|
+
|
|
1098
|
+
attr_reader :declaration_specifiers
|
|
1099
|
+
attr_reader :init_declarator
|
|
1100
|
+
attr_reader :symbol
|
|
1101
|
+
attr_accessor :type
|
|
1102
|
+
|
|
1103
|
+
def identifier
|
|
1104
|
+
@init_declarator.declarator.identifier
|
|
1105
|
+
end
|
|
1106
|
+
|
|
1107
|
+
def storage_class_specifier
|
|
1108
|
+
@declaration_specifiers ?
|
|
1109
|
+
@declaration_specifiers.storage_class_specifier : nil
|
|
1110
|
+
end
|
|
1111
|
+
|
|
1112
|
+
def initializer
|
|
1113
|
+
@init_declarator.initializer
|
|
1114
|
+
end
|
|
1115
|
+
|
|
1116
|
+
def location
|
|
1117
|
+
identifier.location
|
|
1118
|
+
end
|
|
1119
|
+
|
|
1120
|
+
def inspect(indent = 0)
|
|
1121
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
1122
|
+
identifier.value
|
|
1123
|
+
end
|
|
1124
|
+
end
|
|
1125
|
+
|
|
1126
|
+
class TypeDeclaration < SyntaxNode
|
|
1127
|
+
include SymbolicElement
|
|
1128
|
+
|
|
1129
|
+
def initialize(symbol)
|
|
1130
|
+
super()
|
|
1131
|
+
@symbol = symbol
|
|
1132
|
+
end
|
|
1133
|
+
|
|
1134
|
+
attr_reader :symbol
|
|
1135
|
+
end
|
|
1136
|
+
|
|
1137
|
+
class TypedefDeclaration < TypeDeclaration
|
|
1138
|
+
def initialize(declaration_specifiers, init_declarator, symbol)
|
|
1139
|
+
super(symbol)
|
|
1140
|
+
@declaration_specifiers = declaration_specifiers
|
|
1141
|
+
@init_declarator = init_declarator
|
|
1142
|
+
@type = nil
|
|
1143
|
+
end
|
|
1144
|
+
|
|
1145
|
+
attr_reader :declaration_specifiers
|
|
1146
|
+
attr_reader :init_declarator
|
|
1147
|
+
attr_accessor :type
|
|
1148
|
+
|
|
1149
|
+
def identifier
|
|
1150
|
+
@init_declarator.declarator.identifier
|
|
1151
|
+
end
|
|
1152
|
+
|
|
1153
|
+
def declarator
|
|
1154
|
+
@init_declarator.declarator
|
|
1155
|
+
end
|
|
1156
|
+
|
|
1157
|
+
def type_qualifiers
|
|
1158
|
+
@declaration_specifiers.type_qualifiers
|
|
1159
|
+
end
|
|
1160
|
+
|
|
1161
|
+
def type_specifiers
|
|
1162
|
+
@declaration_specifiers.type_specifiers
|
|
1163
|
+
end
|
|
1164
|
+
|
|
1165
|
+
def location
|
|
1166
|
+
identifier.location
|
|
1167
|
+
end
|
|
1168
|
+
|
|
1169
|
+
def inspect(indent = 0)
|
|
1170
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
1171
|
+
identifier.value
|
|
1172
|
+
end
|
|
1173
|
+
end
|
|
1174
|
+
|
|
1175
|
+
class StructTypeDeclaration < TypeDeclaration
|
|
1176
|
+
def initialize(struct_specifier, symbol)
|
|
1177
|
+
super(symbol)
|
|
1178
|
+
@struct_specifier = struct_specifier
|
|
1179
|
+
@struct_declarations = struct_specifier.struct_declarations
|
|
1180
|
+
@type = nil
|
|
1181
|
+
end
|
|
1182
|
+
|
|
1183
|
+
attr_reader :struct_specifier
|
|
1184
|
+
attr_reader :struct_declarations
|
|
1185
|
+
attr_accessor :type
|
|
1186
|
+
|
|
1187
|
+
def identifier
|
|
1188
|
+
@struct_specifier.identifier
|
|
1189
|
+
end
|
|
1190
|
+
|
|
1191
|
+
def location
|
|
1192
|
+
identifier.location
|
|
1193
|
+
end
|
|
1194
|
+
|
|
1195
|
+
def inspect(indent = 0)
|
|
1196
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
1197
|
+
"#{identifier.value}\n" +
|
|
1198
|
+
@struct_declarations.map { |sd| sd.inspect(indent + 1) }.join("\n")
|
|
1199
|
+
end
|
|
1200
|
+
end
|
|
1201
|
+
|
|
1202
|
+
class PseudoStructTypeDeclaration < StructTypeDeclaration
|
|
1203
|
+
def initialize(struct_specifier)
|
|
1204
|
+
super(struct_specifier, nil)
|
|
1205
|
+
end
|
|
1206
|
+
|
|
1207
|
+
def mark_as_referred_by(token) end
|
|
1208
|
+
end
|
|
1209
|
+
|
|
1210
|
+
class UnionTypeDeclaration < TypeDeclaration
|
|
1211
|
+
def initialize(union_specifier, symbol)
|
|
1212
|
+
super(symbol)
|
|
1213
|
+
@union_specifier = union_specifier
|
|
1214
|
+
@struct_declarations = union_specifier.struct_declarations
|
|
1215
|
+
@type = nil
|
|
1216
|
+
end
|
|
1217
|
+
|
|
1218
|
+
attr_reader :union_specifier
|
|
1219
|
+
attr_reader :struct_declarations
|
|
1220
|
+
attr_accessor :type
|
|
1221
|
+
|
|
1222
|
+
def identifier
|
|
1223
|
+
@union_specifier.identifier
|
|
1224
|
+
end
|
|
1225
|
+
|
|
1226
|
+
def location
|
|
1227
|
+
identifier.location
|
|
1228
|
+
end
|
|
1229
|
+
|
|
1230
|
+
def inspect(indent = 0)
|
|
1231
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
1232
|
+
"#{identifier.value}\n" +
|
|
1233
|
+
@struct_declarations.map { |sd| sd.inspect(indent + 1) }.join("\n")
|
|
1234
|
+
end
|
|
1235
|
+
end
|
|
1236
|
+
|
|
1237
|
+
class PseudoUnionTypeDeclaration < UnionTypeDeclaration
|
|
1238
|
+
def initialize(union_specifier)
|
|
1239
|
+
super(union_specifier, nil)
|
|
1240
|
+
end
|
|
1241
|
+
|
|
1242
|
+
def mark_as_referred_by(token) end
|
|
1243
|
+
end
|
|
1244
|
+
|
|
1245
|
+
class EnumTypeDeclaration < TypeDeclaration
|
|
1246
|
+
def initialize(enum_specifier, symbol)
|
|
1247
|
+
super(symbol)
|
|
1248
|
+
@enum_specifier = enum_specifier
|
|
1249
|
+
@type = nil
|
|
1250
|
+
end
|
|
1251
|
+
|
|
1252
|
+
attr_reader :enum_specifier
|
|
1253
|
+
attr_accessor :type
|
|
1254
|
+
|
|
1255
|
+
def identifier
|
|
1256
|
+
@enum_specifier.identifier
|
|
1257
|
+
end
|
|
1258
|
+
|
|
1259
|
+
def location
|
|
1260
|
+
identifier.location
|
|
1261
|
+
end
|
|
1262
|
+
|
|
1263
|
+
def enumerators
|
|
1264
|
+
@enum_specifier.enumerators
|
|
1265
|
+
end
|
|
1266
|
+
|
|
1267
|
+
def inspect(indent = 0)
|
|
1268
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
1269
|
+
"#{identifier.value}"
|
|
1270
|
+
end
|
|
1271
|
+
end
|
|
1272
|
+
|
|
1273
|
+
class PseudoEnumTypeDeclaration < EnumTypeDeclaration
|
|
1274
|
+
def initialize(enum_specifier)
|
|
1275
|
+
super(enum_specifier, nil)
|
|
1276
|
+
end
|
|
1277
|
+
|
|
1278
|
+
def mark_as_referred_by(token) end
|
|
1279
|
+
end
|
|
1280
|
+
|
|
1281
|
+
class DeclarationSpecifiers < SyntaxNode
|
|
1282
|
+
def initialize
|
|
1283
|
+
super
|
|
1284
|
+
@storage_class_specifier = nil
|
|
1285
|
+
@function_specifier = nil
|
|
1286
|
+
@type_qualifiers = []
|
|
1287
|
+
@type_specifiers = []
|
|
1288
|
+
end
|
|
1289
|
+
|
|
1290
|
+
attr_accessor :storage_class_specifier
|
|
1291
|
+
attr_accessor :function_specifier
|
|
1292
|
+
attr_reader :type_qualifiers
|
|
1293
|
+
attr_reader :type_specifiers
|
|
1294
|
+
|
|
1295
|
+
def location
|
|
1296
|
+
head_location
|
|
1297
|
+
end
|
|
1298
|
+
|
|
1299
|
+
def inspect(indent = 0)
|
|
1300
|
+
" " * indent + short_class_name
|
|
1301
|
+
end
|
|
1302
|
+
end
|
|
1303
|
+
|
|
1304
|
+
class InitDeclarator < SyntaxNode
|
|
1305
|
+
def initialize(declarator, initializer)
|
|
1306
|
+
super()
|
|
1307
|
+
@declarator = declarator
|
|
1308
|
+
@initializer = initializer
|
|
1309
|
+
end
|
|
1310
|
+
|
|
1311
|
+
attr_reader :declarator
|
|
1312
|
+
attr_reader :initializer
|
|
1313
|
+
|
|
1314
|
+
def location
|
|
1315
|
+
@declarator.identifier.location
|
|
1316
|
+
end
|
|
1317
|
+
|
|
1318
|
+
def inspect(indent = 0)
|
|
1319
|
+
" " * indent + short_class_name
|
|
1320
|
+
end
|
|
1321
|
+
end
|
|
1322
|
+
|
|
1323
|
+
class TypeSpecifier < SyntaxNode
|
|
1324
|
+
def to_s
|
|
1325
|
+
subclass_responsibility
|
|
1326
|
+
end
|
|
1327
|
+
end
|
|
1328
|
+
|
|
1329
|
+
class StandardTypeSpecifier < TypeSpecifier
|
|
1330
|
+
def initialize(token)
|
|
1331
|
+
super()
|
|
1332
|
+
@token = token
|
|
1333
|
+
end
|
|
1334
|
+
|
|
1335
|
+
attr_reader :token
|
|
1336
|
+
|
|
1337
|
+
def location
|
|
1338
|
+
head_location
|
|
1339
|
+
end
|
|
1340
|
+
|
|
1341
|
+
def to_s
|
|
1342
|
+
@token.value
|
|
1343
|
+
end
|
|
1344
|
+
|
|
1345
|
+
def inspect(indent = 0)
|
|
1346
|
+
" " * indent + short_class_name
|
|
1347
|
+
end
|
|
1348
|
+
end
|
|
1349
|
+
|
|
1350
|
+
class TypedefTypeSpecifier < TypeSpecifier
|
|
1351
|
+
def initialize(token)
|
|
1352
|
+
super()
|
|
1353
|
+
@token = token
|
|
1354
|
+
end
|
|
1355
|
+
|
|
1356
|
+
attr_reader :token
|
|
1357
|
+
|
|
1358
|
+
def location
|
|
1359
|
+
head_location
|
|
1360
|
+
end
|
|
1361
|
+
|
|
1362
|
+
def identifier
|
|
1363
|
+
@token
|
|
1364
|
+
end
|
|
1365
|
+
|
|
1366
|
+
def to_s
|
|
1367
|
+
@token.value
|
|
1368
|
+
end
|
|
1369
|
+
|
|
1370
|
+
def inspect(indent = 0)
|
|
1371
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
1372
|
+
@token.value
|
|
1373
|
+
end
|
|
1374
|
+
end
|
|
1375
|
+
|
|
1376
|
+
class StructSpecifier < TypeSpecifier
|
|
1377
|
+
def initialize(identifier, struct_declarations)
|
|
1378
|
+
super()
|
|
1379
|
+
@identifier = identifier
|
|
1380
|
+
@struct_declarations = struct_declarations
|
|
1381
|
+
end
|
|
1382
|
+
|
|
1383
|
+
attr_reader :identifier
|
|
1384
|
+
attr_reader :struct_declarations
|
|
1385
|
+
|
|
1386
|
+
def location
|
|
1387
|
+
@identifier.location
|
|
1388
|
+
end
|
|
1389
|
+
|
|
1390
|
+
def to_s
|
|
1391
|
+
if @struct_declarations
|
|
1392
|
+
if @struct_declarations.empty?
|
|
1393
|
+
"struct #{identifier.value} {}"
|
|
1394
|
+
else
|
|
1395
|
+
"struct #{identifier.value} { " +
|
|
1396
|
+
@struct_declarations.map { |decl| decl.to_s }.join(" ") +
|
|
1397
|
+
" }"
|
|
1398
|
+
end
|
|
1399
|
+
else
|
|
1400
|
+
"struct #{identifier.value}"
|
|
1401
|
+
end
|
|
1402
|
+
end
|
|
1403
|
+
|
|
1404
|
+
def inspect(indent = 0)
|
|
1405
|
+
" " * indent + short_class_name
|
|
1406
|
+
end
|
|
1407
|
+
end
|
|
1408
|
+
|
|
1409
|
+
class UnionSpecifier < TypeSpecifier
|
|
1410
|
+
def initialize(identifier, struct_declarations)
|
|
1411
|
+
super()
|
|
1412
|
+
@identifier = identifier
|
|
1413
|
+
@struct_declarations = struct_declarations
|
|
1414
|
+
end
|
|
1415
|
+
|
|
1416
|
+
attr_reader :identifier
|
|
1417
|
+
attr_reader :struct_declarations
|
|
1418
|
+
|
|
1419
|
+
def location
|
|
1420
|
+
@identifier.location
|
|
1421
|
+
end
|
|
1422
|
+
|
|
1423
|
+
def to_s
|
|
1424
|
+
if @struct_declarations
|
|
1425
|
+
if @struct_declarations.empty?
|
|
1426
|
+
"union #{identifier.value} {}"
|
|
1427
|
+
else
|
|
1428
|
+
"union #{identifier.value} { " +
|
|
1429
|
+
@struct_declarations.map { |decl| decl.to_s }.join(" ") +
|
|
1430
|
+
" }"
|
|
1431
|
+
end
|
|
1432
|
+
else
|
|
1433
|
+
"union #{identifier.value}"
|
|
1434
|
+
end
|
|
1435
|
+
end
|
|
1436
|
+
|
|
1437
|
+
def inspect(indent = 0)
|
|
1438
|
+
" " * indent + short_class_name
|
|
1439
|
+
end
|
|
1440
|
+
end
|
|
1441
|
+
|
|
1442
|
+
class StructDeclaration < SyntaxNode
|
|
1443
|
+
def initialize(specifier_qualifier_list, struct_declarators)
|
|
1444
|
+
super()
|
|
1445
|
+
@specifier_qualifier_list = specifier_qualifier_list
|
|
1446
|
+
@struct_declarators = struct_declarators
|
|
1447
|
+
@items = build_items(specifier_qualifier_list, struct_declarators)
|
|
1448
|
+
end
|
|
1449
|
+
|
|
1450
|
+
attr_reader :specifier_qualifier_list
|
|
1451
|
+
attr_reader :struct_declarators
|
|
1452
|
+
attr_reader :items
|
|
1453
|
+
|
|
1454
|
+
def location
|
|
1455
|
+
@specifier_qualifier_list.location
|
|
1456
|
+
end
|
|
1457
|
+
|
|
1458
|
+
def to_s
|
|
1459
|
+
@items.map { |item| item.to_s + ";" }.join(" ")
|
|
1460
|
+
end
|
|
1461
|
+
|
|
1462
|
+
def inspect(indent = 0)
|
|
1463
|
+
([" " * indent + "#{short_class_name} (#{location.inspect})"] +
|
|
1464
|
+
@items.map { |item| item.inspect(indent + 1) }).join("\n")
|
|
1465
|
+
end
|
|
1466
|
+
|
|
1467
|
+
private
|
|
1468
|
+
def build_items(specifier_qualifier_list, struct_declarators)
|
|
1469
|
+
result = []
|
|
1470
|
+
struct_declarators.each do |struct_declarator|
|
|
1471
|
+
# FIXME: Must support unnamed bit padding.
|
|
1472
|
+
next unless struct_declarator.declarator
|
|
1473
|
+
result.push(MemberDeclaration.new(specifier_qualifier_list,
|
|
1474
|
+
struct_declarator))
|
|
1475
|
+
end
|
|
1476
|
+
result
|
|
1477
|
+
end
|
|
1478
|
+
end
|
|
1479
|
+
|
|
1480
|
+
class MemberDeclaration < SyntaxNode
|
|
1481
|
+
def initialize(specifier_qualifier_list, struct_declarator)
|
|
1482
|
+
super()
|
|
1483
|
+
@specifier_qualifier_list = specifier_qualifier_list
|
|
1484
|
+
@struct_declarator = struct_declarator
|
|
1485
|
+
@type = nil
|
|
1486
|
+
end
|
|
1487
|
+
|
|
1488
|
+
attr_reader :specifier_qualifier_list
|
|
1489
|
+
attr_reader :struct_declarator
|
|
1490
|
+
attr_accessor :type
|
|
1491
|
+
|
|
1492
|
+
def identifier
|
|
1493
|
+
@struct_declarator.declarator.identifier
|
|
1494
|
+
end
|
|
1495
|
+
|
|
1496
|
+
def location
|
|
1497
|
+
identifier.location
|
|
1498
|
+
end
|
|
1499
|
+
|
|
1500
|
+
def to_s
|
|
1501
|
+
"#{type.brief_image} #{identifier.value}"
|
|
1502
|
+
end
|
|
1503
|
+
|
|
1504
|
+
def inspect(indent = 0)
|
|
1505
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
1506
|
+
identifier.value
|
|
1507
|
+
end
|
|
1508
|
+
end
|
|
1509
|
+
|
|
1510
|
+
class SpecifierQualifierList < SyntaxNode
|
|
1511
|
+
def initialize
|
|
1512
|
+
super
|
|
1513
|
+
@type_specifiers = []
|
|
1514
|
+
@type_qualifiers = []
|
|
1515
|
+
end
|
|
1516
|
+
|
|
1517
|
+
attr_reader :type_specifiers
|
|
1518
|
+
attr_reader :type_qualifiers
|
|
1519
|
+
|
|
1520
|
+
def location
|
|
1521
|
+
head_location
|
|
1522
|
+
end
|
|
1523
|
+
|
|
1524
|
+
def inspect(indent = 0)
|
|
1525
|
+
" " * indent + short_class_name
|
|
1526
|
+
end
|
|
1527
|
+
end
|
|
1528
|
+
|
|
1529
|
+
class StructDeclarator < SyntaxNode
|
|
1530
|
+
def initialize(declarator, expression)
|
|
1531
|
+
super()
|
|
1532
|
+
@declarator = declarator
|
|
1533
|
+
@expression = expression
|
|
1534
|
+
end
|
|
1535
|
+
|
|
1536
|
+
attr_reader :declarator
|
|
1537
|
+
attr_reader :expression
|
|
1538
|
+
|
|
1539
|
+
def location
|
|
1540
|
+
@declarator ? @declarator.location : @expression.location
|
|
1541
|
+
end
|
|
1542
|
+
|
|
1543
|
+
def bitfield?
|
|
1544
|
+
@expression != nil
|
|
1545
|
+
end
|
|
1546
|
+
|
|
1547
|
+
def inspect(indent = 0)
|
|
1548
|
+
" " * indent + short_class_name
|
|
1549
|
+
end
|
|
1550
|
+
end
|
|
1551
|
+
|
|
1552
|
+
class EnumSpecifier < TypeSpecifier
|
|
1553
|
+
def initialize(identifier, enumerators)
|
|
1554
|
+
super()
|
|
1555
|
+
@identifier = identifier
|
|
1556
|
+
@enumerators = enumerators
|
|
1557
|
+
end
|
|
1558
|
+
|
|
1559
|
+
attr_reader :identifier
|
|
1560
|
+
attr_reader :enumerators
|
|
1561
|
+
|
|
1562
|
+
def location
|
|
1563
|
+
@identifier.location
|
|
1564
|
+
end
|
|
1565
|
+
|
|
1566
|
+
def to_s
|
|
1567
|
+
if @enumerators
|
|
1568
|
+
if @enumerators.empty?
|
|
1569
|
+
"enum #{@identifier.value} {}"
|
|
1570
|
+
else
|
|
1571
|
+
"enum #{@identifier.value} { " +
|
|
1572
|
+
@enumerators.map { |enum| enum.to_s }.join(", ") + " }"
|
|
1573
|
+
end
|
|
1574
|
+
else
|
|
1575
|
+
"enum #{identifier.value}"
|
|
1576
|
+
end
|
|
1577
|
+
end
|
|
1578
|
+
|
|
1579
|
+
def inspect(indent = 0)
|
|
1580
|
+
" " * indent + short_class_name
|
|
1581
|
+
end
|
|
1582
|
+
end
|
|
1583
|
+
|
|
1584
|
+
class Enumerator < SyntaxNode
|
|
1585
|
+
include SymbolicElement
|
|
1586
|
+
|
|
1587
|
+
def initialize(identifier, expression, symbol)
|
|
1588
|
+
super()
|
|
1589
|
+
@identifier = identifier
|
|
1590
|
+
@expression = expression
|
|
1591
|
+
@symbol = symbol
|
|
1592
|
+
end
|
|
1593
|
+
|
|
1594
|
+
attr_reader :identifier
|
|
1595
|
+
attr_reader :expression
|
|
1596
|
+
attr_reader :symbol
|
|
1597
|
+
attr_accessor :value
|
|
1598
|
+
|
|
1599
|
+
def location
|
|
1600
|
+
@identifier.location
|
|
1601
|
+
end
|
|
1602
|
+
|
|
1603
|
+
def to_s
|
|
1604
|
+
if @expression
|
|
1605
|
+
"#{@identifier.value} = #{@expression.to_s}"
|
|
1606
|
+
else
|
|
1607
|
+
"#{@identifier.value}"
|
|
1608
|
+
end
|
|
1609
|
+
end
|
|
1610
|
+
|
|
1611
|
+
def inspect(indent = 0)
|
|
1612
|
+
" " * indent + short_class_name
|
|
1613
|
+
end
|
|
1614
|
+
end
|
|
1615
|
+
|
|
1616
|
+
class TypeofTypeSpecifier < TypeSpecifier
|
|
1617
|
+
def initialize(expression, type_name)
|
|
1618
|
+
super()
|
|
1619
|
+
@expression = expression
|
|
1620
|
+
@type_name = type_name
|
|
1621
|
+
end
|
|
1622
|
+
|
|
1623
|
+
attr_reader :expression
|
|
1624
|
+
attr_reader :type_name
|
|
1625
|
+
|
|
1626
|
+
def location
|
|
1627
|
+
head_location
|
|
1628
|
+
end
|
|
1629
|
+
|
|
1630
|
+
def to_s
|
|
1631
|
+
if @expression
|
|
1632
|
+
"__typeof__(#{@expression.to_s})"
|
|
1633
|
+
else
|
|
1634
|
+
"__typeof__(#{@type_name.to_s})"
|
|
1635
|
+
end
|
|
1636
|
+
end
|
|
1637
|
+
|
|
1638
|
+
def inspect(indent = 0)
|
|
1639
|
+
" " * indent + short_class_name
|
|
1640
|
+
end
|
|
1641
|
+
end
|
|
1642
|
+
|
|
1643
|
+
class Declarator < SyntaxNode
|
|
1644
|
+
def initialize
|
|
1645
|
+
super
|
|
1646
|
+
@pointer = nil
|
|
1647
|
+
end
|
|
1648
|
+
|
|
1649
|
+
attr_accessor :pointer
|
|
1650
|
+
|
|
1651
|
+
def identifier
|
|
1652
|
+
subclass_responsibility
|
|
1653
|
+
end
|
|
1654
|
+
|
|
1655
|
+
def abstract?
|
|
1656
|
+
false
|
|
1657
|
+
end
|
|
1658
|
+
|
|
1659
|
+
def base
|
|
1660
|
+
subclass_responsibility
|
|
1661
|
+
end
|
|
1662
|
+
|
|
1663
|
+
def function?
|
|
1664
|
+
subclass_responsibility
|
|
1665
|
+
end
|
|
1666
|
+
|
|
1667
|
+
def variable?
|
|
1668
|
+
!function?
|
|
1669
|
+
end
|
|
1670
|
+
end
|
|
1671
|
+
|
|
1672
|
+
class IdentifierDeclarator < Declarator
|
|
1673
|
+
def initialize(identifier)
|
|
1674
|
+
super()
|
|
1675
|
+
@identifier = identifier
|
|
1676
|
+
end
|
|
1677
|
+
|
|
1678
|
+
attr_reader :identifier
|
|
1679
|
+
|
|
1680
|
+
def location
|
|
1681
|
+
@identifier.location
|
|
1682
|
+
end
|
|
1683
|
+
|
|
1684
|
+
def base
|
|
1685
|
+
nil
|
|
1686
|
+
end
|
|
1687
|
+
|
|
1688
|
+
def parameter_type_list
|
|
1689
|
+
nil
|
|
1690
|
+
end
|
|
1691
|
+
|
|
1692
|
+
def identifier_list
|
|
1693
|
+
nil
|
|
1694
|
+
end
|
|
1695
|
+
|
|
1696
|
+
def function?(stack = [])
|
|
1697
|
+
stack.push(:pointer) if pointer
|
|
1698
|
+
stack.last == :function
|
|
1699
|
+
end
|
|
1700
|
+
|
|
1701
|
+
def inspect(indent = 0)
|
|
1702
|
+
" " * indent + "#{short_class_name} #{@identifier.value}"
|
|
1703
|
+
end
|
|
1704
|
+
end
|
|
1705
|
+
|
|
1706
|
+
class GroupedDeclarator < Declarator
|
|
1707
|
+
def initialize(declarator)
|
|
1708
|
+
super()
|
|
1709
|
+
@base = declarator
|
|
1710
|
+
end
|
|
1711
|
+
|
|
1712
|
+
attr_reader :base
|
|
1713
|
+
|
|
1714
|
+
def location
|
|
1715
|
+
@base.location
|
|
1716
|
+
end
|
|
1717
|
+
|
|
1718
|
+
def identifier
|
|
1719
|
+
@base.identifier
|
|
1720
|
+
end
|
|
1721
|
+
|
|
1722
|
+
def parameter_type_list
|
|
1723
|
+
@base.parameter_type_list
|
|
1724
|
+
end
|
|
1725
|
+
|
|
1726
|
+
def identifier_list
|
|
1727
|
+
@base.identifier_list
|
|
1728
|
+
end
|
|
1729
|
+
|
|
1730
|
+
def function?(stack = [])
|
|
1731
|
+
stack.push(:pointer) if pointer
|
|
1732
|
+
@base.function?(stack)
|
|
1733
|
+
stack.last == :function
|
|
1734
|
+
end
|
|
1735
|
+
|
|
1736
|
+
def inspect(indent = 0)
|
|
1737
|
+
" " * indent + "#{short_class_name}\n" + @base.inspect(indent + 1)
|
|
1738
|
+
end
|
|
1739
|
+
end
|
|
1740
|
+
|
|
1741
|
+
class ArrayDeclarator < Declarator
|
|
1742
|
+
def initialize(declarator, size_expression)
|
|
1743
|
+
super()
|
|
1744
|
+
@base = declarator
|
|
1745
|
+
@size_expression = size_expression
|
|
1746
|
+
end
|
|
1747
|
+
|
|
1748
|
+
attr_reader :base
|
|
1749
|
+
attr_reader :size_expression
|
|
1750
|
+
|
|
1751
|
+
def location
|
|
1752
|
+
@base.location
|
|
1753
|
+
end
|
|
1754
|
+
|
|
1755
|
+
def identifier
|
|
1756
|
+
@base.identifier
|
|
1757
|
+
end
|
|
1758
|
+
|
|
1759
|
+
def parameter_type_list
|
|
1760
|
+
@base.parameter_type_list
|
|
1761
|
+
end
|
|
1762
|
+
|
|
1763
|
+
def identifier_list
|
|
1764
|
+
@base.identifier_list
|
|
1765
|
+
end
|
|
1766
|
+
|
|
1767
|
+
def function?(stack = [])
|
|
1768
|
+
stack.push(:pointer) if pointer
|
|
1769
|
+
stack.push(:array)
|
|
1770
|
+
@base.function?(stack)
|
|
1771
|
+
stack.last == :function
|
|
1772
|
+
end
|
|
1773
|
+
|
|
1774
|
+
def inspect(indent = 0)
|
|
1775
|
+
" " * indent + "#{short_class_name}\n" + @base.inspect(indent + 1)
|
|
1776
|
+
end
|
|
1777
|
+
end
|
|
1778
|
+
|
|
1779
|
+
class FunctionDeclarator < Declarator
|
|
1780
|
+
def initialize(declarator)
|
|
1781
|
+
super()
|
|
1782
|
+
@base = declarator
|
|
1783
|
+
end
|
|
1784
|
+
|
|
1785
|
+
attr_reader :base
|
|
1786
|
+
|
|
1787
|
+
def location
|
|
1788
|
+
@base.location
|
|
1789
|
+
end
|
|
1790
|
+
|
|
1791
|
+
def identifier
|
|
1792
|
+
@base.identifier
|
|
1793
|
+
end
|
|
1794
|
+
|
|
1795
|
+
def function?(stack = [])
|
|
1796
|
+
stack.push(:pointer) if pointer
|
|
1797
|
+
stack.push(:function)
|
|
1798
|
+
@base.function?(stack)
|
|
1799
|
+
stack.last == :function
|
|
1800
|
+
end
|
|
1801
|
+
|
|
1802
|
+
def inspect(indent = 0)
|
|
1803
|
+
" " * indent + "#{short_class_name}\n" + @base.inspect(indent + 1)
|
|
1804
|
+
end
|
|
1805
|
+
end
|
|
1806
|
+
|
|
1807
|
+
class AnsiFunctionDeclarator < FunctionDeclarator
|
|
1808
|
+
def initialize(declarator, parameter_type_list)
|
|
1809
|
+
super(declarator)
|
|
1810
|
+
@parameter_type_list = parameter_type_list
|
|
1811
|
+
end
|
|
1812
|
+
|
|
1813
|
+
attr_accessor :parameter_type_list
|
|
1814
|
+
|
|
1815
|
+
def identifier_list
|
|
1816
|
+
@base.identifier_list
|
|
1817
|
+
end
|
|
1818
|
+
end
|
|
1819
|
+
|
|
1820
|
+
class KandRFunctionDeclarator < FunctionDeclarator
|
|
1821
|
+
def initialize(declarator, identifier_list)
|
|
1822
|
+
super(declarator)
|
|
1823
|
+
@identifier_list = identifier_list
|
|
1824
|
+
end
|
|
1825
|
+
|
|
1826
|
+
attr_reader :identifier_list
|
|
1827
|
+
|
|
1828
|
+
def parameter_type_list
|
|
1829
|
+
@base.parameter_type_list
|
|
1830
|
+
end
|
|
1831
|
+
end
|
|
1832
|
+
|
|
1833
|
+
class AbbreviatedFunctionDeclarator < FunctionDeclarator
|
|
1834
|
+
def parameter_type_list
|
|
1835
|
+
@base.parameter_type_list
|
|
1836
|
+
end
|
|
1837
|
+
|
|
1838
|
+
def identifier_list
|
|
1839
|
+
@base.identifier_list
|
|
1840
|
+
end
|
|
1841
|
+
end
|
|
1842
|
+
|
|
1843
|
+
class ParameterTypeList < SyntaxNode
|
|
1844
|
+
def initialize(parameters, have_va_list)
|
|
1845
|
+
super()
|
|
1846
|
+
@parameters = parameters
|
|
1847
|
+
@have_va_list = have_va_list
|
|
1848
|
+
end
|
|
1849
|
+
|
|
1850
|
+
attr_reader :parameters
|
|
1851
|
+
|
|
1852
|
+
def location
|
|
1853
|
+
head_location
|
|
1854
|
+
end
|
|
1855
|
+
|
|
1856
|
+
def have_va_list?
|
|
1857
|
+
@have_va_list
|
|
1858
|
+
end
|
|
1859
|
+
|
|
1860
|
+
def inspect(indent = 0)
|
|
1861
|
+
" " * indent + short_class_name
|
|
1862
|
+
end
|
|
1863
|
+
end
|
|
1864
|
+
|
|
1865
|
+
class ParameterDeclaration < SyntaxNode
|
|
1866
|
+
def initialize(declaration_specifiers, declarator)
|
|
1867
|
+
super()
|
|
1868
|
+
@declaration_specifiers = declaration_specifiers
|
|
1869
|
+
@declarator = declarator
|
|
1870
|
+
end
|
|
1871
|
+
|
|
1872
|
+
attr_reader :declaration_specifiers
|
|
1873
|
+
attr_reader :declarator
|
|
1874
|
+
|
|
1875
|
+
def location
|
|
1876
|
+
@declarator ? @declarator.location : @declaration_specifiers.location
|
|
1877
|
+
end
|
|
1878
|
+
|
|
1879
|
+
def inspect(indent = 0)
|
|
1880
|
+
" " * indent + short_class_name
|
|
1881
|
+
end
|
|
1882
|
+
end
|
|
1883
|
+
|
|
1884
|
+
class Statement < SyntaxNode
|
|
1885
|
+
def initialize
|
|
1886
|
+
super
|
|
1887
|
+
@executed = false
|
|
1888
|
+
end
|
|
1889
|
+
|
|
1890
|
+
attr_writer :executed
|
|
1891
|
+
|
|
1892
|
+
def executed?
|
|
1893
|
+
@executed
|
|
1894
|
+
end
|
|
1895
|
+
end
|
|
1896
|
+
|
|
1897
|
+
class ErrorStatement < Statement
|
|
1898
|
+
def initialize(error_token)
|
|
1899
|
+
super()
|
|
1900
|
+
@error_token = error_token
|
|
1901
|
+
end
|
|
1902
|
+
|
|
1903
|
+
def location
|
|
1904
|
+
head_location
|
|
1905
|
+
end
|
|
1906
|
+
|
|
1907
|
+
def inspect(indent = 0)
|
|
1908
|
+
" " * indent + "#{short_class_name}"
|
|
1909
|
+
end
|
|
1910
|
+
end
|
|
1911
|
+
|
|
1912
|
+
class LabeledStatement < Statement; end
|
|
1913
|
+
|
|
1914
|
+
class GenericLabeledStatement < LabeledStatement
|
|
1915
|
+
def initialize(label, statement)
|
|
1916
|
+
super()
|
|
1917
|
+
@label = label
|
|
1918
|
+
@statement = statement
|
|
1919
|
+
@referrers = []
|
|
1920
|
+
end
|
|
1921
|
+
|
|
1922
|
+
attr_reader :label
|
|
1923
|
+
attr_reader :statement
|
|
1924
|
+
attr_reader :referrers
|
|
1925
|
+
|
|
1926
|
+
def location
|
|
1927
|
+
@label.location
|
|
1928
|
+
end
|
|
1929
|
+
|
|
1930
|
+
def inspect(indent = 0)
|
|
1931
|
+
" " * indent + "#{short_class_name} (#{@label.inspect})\n" +
|
|
1932
|
+
@statement.inspect(indent + 1)
|
|
1933
|
+
end
|
|
1934
|
+
end
|
|
1935
|
+
|
|
1936
|
+
class CaseLabeledStatement < LabeledStatement
|
|
1937
|
+
def initialize(expression, statement)
|
|
1938
|
+
super()
|
|
1939
|
+
@expression = expression
|
|
1940
|
+
@statement = statement
|
|
1941
|
+
end
|
|
1942
|
+
|
|
1943
|
+
attr_reader :expression
|
|
1944
|
+
attr_reader :statement
|
|
1945
|
+
attr_accessor :normalized_expression
|
|
1946
|
+
|
|
1947
|
+
def location
|
|
1948
|
+
head_location
|
|
1949
|
+
end
|
|
1950
|
+
|
|
1951
|
+
def inspect(indent = 0)
|
|
1952
|
+
" " * indent + "#{short_class_name}\n" +
|
|
1953
|
+
@expression.inspect(indent + 1) + "\n" +
|
|
1954
|
+
@statement.inspect(indent + 1)
|
|
1955
|
+
end
|
|
1956
|
+
end
|
|
1957
|
+
|
|
1958
|
+
class DefaultLabeledStatement < LabeledStatement
|
|
1959
|
+
def initialize(statement)
|
|
1960
|
+
super()
|
|
1961
|
+
@statement = statement
|
|
1962
|
+
end
|
|
1963
|
+
|
|
1964
|
+
attr_reader :statement
|
|
1965
|
+
attr_accessor :normalized_expression
|
|
1966
|
+
|
|
1967
|
+
def location
|
|
1968
|
+
head_location
|
|
1969
|
+
end
|
|
1970
|
+
|
|
1971
|
+
def inspect(indent = 0)
|
|
1972
|
+
" " * indent + "#{short_class_name}\n" + @statement.inspect(indent + 1)
|
|
1973
|
+
end
|
|
1974
|
+
end
|
|
1975
|
+
|
|
1976
|
+
class CompoundStatement < Statement
|
|
1977
|
+
def initialize(block_items)
|
|
1978
|
+
super()
|
|
1979
|
+
@block_items = block_items
|
|
1980
|
+
end
|
|
1981
|
+
|
|
1982
|
+
attr_reader :block_items
|
|
1983
|
+
|
|
1984
|
+
def location
|
|
1985
|
+
head_location
|
|
1986
|
+
end
|
|
1987
|
+
|
|
1988
|
+
def inspect(indent = 0)
|
|
1989
|
+
([" " * indent + short_class_name] +
|
|
1990
|
+
@block_items.map { |item| item.inspect(indent + 1) }).join("\n")
|
|
1991
|
+
end
|
|
1992
|
+
end
|
|
1993
|
+
|
|
1994
|
+
class ExpressionStatement < Statement
|
|
1995
|
+
def initialize(expression)
|
|
1996
|
+
super()
|
|
1997
|
+
@expression = expression
|
|
1998
|
+
end
|
|
1999
|
+
|
|
2000
|
+
attr_reader :expression
|
|
2001
|
+
|
|
2002
|
+
def location
|
|
2003
|
+
head_location
|
|
2004
|
+
end
|
|
2005
|
+
|
|
2006
|
+
def inspect(indent = 0)
|
|
2007
|
+
" " * indent + "#{short_class_name}" +
|
|
2008
|
+
(@expression ? "\n#{@expression.inspect(indent + 1)}" : "")
|
|
2009
|
+
end
|
|
2010
|
+
end
|
|
2011
|
+
|
|
2012
|
+
class SelectionStatement < Statement; end
|
|
2013
|
+
|
|
2014
|
+
class IfStatement < SelectionStatement
|
|
2015
|
+
def initialize(expression, statement, header_terminator)
|
|
2016
|
+
super()
|
|
2017
|
+
@expression = expression
|
|
2018
|
+
@statement = statement
|
|
2019
|
+
@header_terminator = header_terminator
|
|
2020
|
+
end
|
|
2021
|
+
|
|
2022
|
+
attr_reader :expression
|
|
2023
|
+
attr_reader :statement
|
|
2024
|
+
attr_reader :header_terminator
|
|
2025
|
+
|
|
2026
|
+
def location
|
|
2027
|
+
head_location
|
|
2028
|
+
end
|
|
2029
|
+
|
|
2030
|
+
def inspect(indent = 0)
|
|
2031
|
+
" " * indent + "#{short_class_name}\n" +
|
|
2032
|
+
@expression.inspect(indent + 1) + "\n" +
|
|
2033
|
+
@statement.inspect(indent + 1)
|
|
2034
|
+
end
|
|
2035
|
+
end
|
|
2036
|
+
|
|
2037
|
+
class IfElseStatement < SelectionStatement
|
|
2038
|
+
def initialize(expression, then_statement, else_statement,
|
|
2039
|
+
then_header_terminator, else_header_terminator)
|
|
2040
|
+
super()
|
|
2041
|
+
@expression = expression
|
|
2042
|
+
@then_statement = then_statement
|
|
2043
|
+
@else_statement = else_statement
|
|
2044
|
+
@then_header_terminator = then_header_terminator
|
|
2045
|
+
@else_header_terminator = else_header_terminator
|
|
2046
|
+
end
|
|
2047
|
+
|
|
2048
|
+
attr_reader :expression
|
|
2049
|
+
attr_reader :then_statement
|
|
2050
|
+
attr_reader :else_statement
|
|
2051
|
+
attr_reader :then_header_terminator
|
|
2052
|
+
attr_reader :else_header_terminator
|
|
2053
|
+
|
|
2054
|
+
def location
|
|
2055
|
+
head_location
|
|
2056
|
+
end
|
|
2057
|
+
|
|
2058
|
+
def inspect(indent = 0)
|
|
2059
|
+
" " * indent + "#{short_class_name}\n" +
|
|
2060
|
+
@expression.inspect(indent + 1) + "\n" +
|
|
2061
|
+
@then_statement.inspect(indent + 1) + "\n" +
|
|
2062
|
+
@else_statement.inspect(indent + 1)
|
|
2063
|
+
end
|
|
2064
|
+
end
|
|
2065
|
+
|
|
2066
|
+
class SwitchStatement < SelectionStatement
|
|
2067
|
+
def initialize(expression, statement)
|
|
2068
|
+
super()
|
|
2069
|
+
@expression = expression
|
|
2070
|
+
@statement = statement
|
|
2071
|
+
derive_clause_conditions
|
|
2072
|
+
end
|
|
2073
|
+
|
|
2074
|
+
attr_reader :expression
|
|
2075
|
+
attr_reader :statement
|
|
2076
|
+
|
|
2077
|
+
def location
|
|
2078
|
+
head_location
|
|
2079
|
+
end
|
|
2080
|
+
|
|
2081
|
+
def inspect(indent = 0)
|
|
2082
|
+
" " * indent + "#{short_class_name}\n" +
|
|
2083
|
+
@expression.inspect(indent + 1) + "\n" +
|
|
2084
|
+
@statement.inspect(indent + 1)
|
|
2085
|
+
end
|
|
2086
|
+
|
|
2087
|
+
private
|
|
2088
|
+
def derive_clause_conditions
|
|
2089
|
+
case_expressions = []
|
|
2090
|
+
default_labeled_statement = nil
|
|
2091
|
+
|
|
2092
|
+
@statement.block_items.each do |block_item|
|
|
2093
|
+
while block_item.kind_of?(GenericLabeledStatement)
|
|
2094
|
+
block_item = block_item.statement
|
|
2095
|
+
end
|
|
2096
|
+
|
|
2097
|
+
case block_item
|
|
2098
|
+
when CaseLabeledStatement
|
|
2099
|
+
block_item.normalized_expression = equal_to_expression(
|
|
2100
|
+
@expression, block_item.expression, block_item.location)
|
|
2101
|
+
case_expressions.push(block_item.normalized_expression)
|
|
2102
|
+
when DefaultLabeledStatement
|
|
2103
|
+
default_labeled_statement = block_item
|
|
2104
|
+
end
|
|
2105
|
+
end
|
|
2106
|
+
|
|
2107
|
+
if default_labeled_statement
|
|
2108
|
+
default_labeled_statement.normalized_expression =
|
|
2109
|
+
derive_default_clause_condition(case_expressions,
|
|
2110
|
+
default_labeled_statement.location)
|
|
2111
|
+
end
|
|
2112
|
+
end
|
|
2113
|
+
|
|
2114
|
+
def derive_default_clause_condition(case_expressions, location)
|
|
2115
|
+
if case_expressions.empty?
|
|
2116
|
+
equal_to_expression(@expression, @expression, location)
|
|
2117
|
+
else
|
|
2118
|
+
case_expressions.map { |expr|
|
|
2119
|
+
not_equal_to_expression(expr.lhs_operand, expr.rhs_operand, location)
|
|
2120
|
+
}.reduce do |result, expr|
|
|
2121
|
+
logical_and_expression(result, expr, location)
|
|
2122
|
+
end
|
|
2123
|
+
end
|
|
2124
|
+
end
|
|
2125
|
+
|
|
2126
|
+
def equal_to_expression(lhs, rhs, location)
|
|
2127
|
+
EqualityExpression.new(equal_to_operator(location), lhs, rhs)
|
|
2128
|
+
end
|
|
2129
|
+
|
|
2130
|
+
def not_equal_to_expression(lhs, rhs, location)
|
|
2131
|
+
EqualityExpression.new(not_equal_to_operator(location), lhs, rhs)
|
|
2132
|
+
end
|
|
2133
|
+
|
|
2134
|
+
def logical_and_expression(lhs, rhs, location)
|
|
2135
|
+
LogicalAndExpression.new(logical_and_operator(location), lhs, rhs)
|
|
2136
|
+
end
|
|
2137
|
+
|
|
2138
|
+
def equal_to_operator(location)
|
|
2139
|
+
Token.new("==", "==", location)
|
|
2140
|
+
end
|
|
2141
|
+
|
|
2142
|
+
def not_equal_to_operator(location)
|
|
2143
|
+
Token.new("!=", "!=", location)
|
|
2144
|
+
end
|
|
2145
|
+
|
|
2146
|
+
def logical_and_operator(location)
|
|
2147
|
+
Token.new("&&", "&&", location)
|
|
2148
|
+
end
|
|
2149
|
+
end
|
|
2150
|
+
|
|
2151
|
+
class IterationStatement < Statement
|
|
2152
|
+
include SyntaxNodeCollector
|
|
2153
|
+
extend Memoizable
|
|
2154
|
+
|
|
2155
|
+
def deduct_controlling_expression
|
|
2156
|
+
subclass_responsibility
|
|
2157
|
+
end
|
|
2158
|
+
|
|
2159
|
+
def varying_variable_names
|
|
2160
|
+
collect_varying_variable_names(self).uniq
|
|
2161
|
+
end
|
|
2162
|
+
|
|
2163
|
+
def varying_expressions
|
|
2164
|
+
collect_varying_binary_expressions(self) +
|
|
2165
|
+
collect_varying_unary_expressions(self)
|
|
2166
|
+
end
|
|
2167
|
+
|
|
2168
|
+
private
|
|
2169
|
+
def deduct_controlling_expression_candidates(expressions)
|
|
2170
|
+
varying_var_names = varying_variable_names
|
|
2171
|
+
expressions.compact.select do |expr|
|
|
2172
|
+
collect_object_specifiers(expr).any? do |os|
|
|
2173
|
+
varying_var_names.include?(os.identifier.value)
|
|
2174
|
+
end
|
|
2175
|
+
end
|
|
2176
|
+
end
|
|
2177
|
+
|
|
2178
|
+
def collect_loop_breaking_selection_statements(node)
|
|
2179
|
+
collect_loop_breaking_if_statements(node) +
|
|
2180
|
+
collect_loop_breaking_if_else_statements(node)
|
|
2181
|
+
end
|
|
2182
|
+
|
|
2183
|
+
def collect_loop_breaking_if_statements(node)
|
|
2184
|
+
collect_if_statements(node).select do |stmt|
|
|
2185
|
+
contain_loop_breaking?(stmt.statement)
|
|
2186
|
+
end
|
|
2187
|
+
end
|
|
2188
|
+
|
|
2189
|
+
def collect_loop_breaking_if_else_statements(node)
|
|
2190
|
+
collect_if_else_statements(node).select do |stmt|
|
|
2191
|
+
contain_loop_breaking?(stmt.then_statement) ||
|
|
2192
|
+
contain_loop_breaking?(stmt.else_statement)
|
|
2193
|
+
end
|
|
2194
|
+
end
|
|
2195
|
+
|
|
2196
|
+
def contain_loop_breaking?(node)
|
|
2197
|
+
items = node.kind_of?(CompoundStatement) ? node.block_items : [node]
|
|
2198
|
+
items.any? do |item|
|
|
2199
|
+
item = item.statement while item.kind_of?(GenericLabeledStatement)
|
|
2200
|
+
case item
|
|
2201
|
+
when GotoStatement
|
|
2202
|
+
# FIXME: Must check whether the goto-statement goes outside of the
|
|
2203
|
+
# loop or not.
|
|
2204
|
+
true
|
|
2205
|
+
when BreakStatement
|
|
2206
|
+
true
|
|
2207
|
+
when ReturnStatement
|
|
2208
|
+
true
|
|
2209
|
+
else
|
|
2210
|
+
false
|
|
2211
|
+
end
|
|
2212
|
+
end
|
|
2213
|
+
end
|
|
2214
|
+
|
|
2215
|
+
def collect_varying_variable_names(node)
|
|
2216
|
+
collect_varying_variable_names_in_binary_expression(node) +
|
|
2217
|
+
collect_varying_variable_names_in_unary_expression(node)
|
|
2218
|
+
end
|
|
2219
|
+
|
|
2220
|
+
def collect_varying_variable_names_in_binary_expression(node)
|
|
2221
|
+
collect_varying_binary_expressions(node).map do |expr|
|
|
2222
|
+
expr.lhs_operand.identifier.value
|
|
2223
|
+
end
|
|
2224
|
+
end
|
|
2225
|
+
|
|
2226
|
+
def collect_varying_binary_expressions(node)
|
|
2227
|
+
all_varying_binary_exprs =
|
|
2228
|
+
collect_simple_assignment_expressions(node) +
|
|
2229
|
+
collect_compound_assignment_expressions(node)
|
|
2230
|
+
|
|
2231
|
+
all_varying_binary_exprs.select do |expr|
|
|
2232
|
+
expr.lhs_operand.kind_of?(ObjectSpecifier)
|
|
2233
|
+
end
|
|
2234
|
+
end
|
|
2235
|
+
memoize :collect_varying_binary_expressions
|
|
2236
|
+
|
|
2237
|
+
def collect_varying_variable_names_in_unary_expression(node)
|
|
2238
|
+
collect_varying_unary_expressions(node).map do |expr|
|
|
2239
|
+
expr.operand.identifier.value
|
|
2240
|
+
end
|
|
2241
|
+
end
|
|
2242
|
+
|
|
2243
|
+
def collect_varying_unary_expressions(node)
|
|
2244
|
+
all_varying_unary_exprs =
|
|
2245
|
+
collect_prefix_increment_expressions(node) +
|
|
2246
|
+
collect_prefix_decrement_expressions(node) +
|
|
2247
|
+
collect_postfix_increment_expressions(node) +
|
|
2248
|
+
collect_postfix_decrement_expressions(node)
|
|
2249
|
+
|
|
2250
|
+
all_varying_unary_exprs.select do |expr|
|
|
2251
|
+
expr.operand.kind_of?(ObjectSpecifier)
|
|
2252
|
+
end
|
|
2253
|
+
end
|
|
2254
|
+
memoize :collect_varying_unary_expressions
|
|
2255
|
+
end
|
|
2256
|
+
|
|
2257
|
+
class WhileStatement < IterationStatement
|
|
2258
|
+
def initialize(expression, statement, header_terminator)
|
|
2259
|
+
super()
|
|
2260
|
+
@expression = expression
|
|
2261
|
+
@statement = statement
|
|
2262
|
+
@header_terminator = header_terminator
|
|
2263
|
+
end
|
|
2264
|
+
|
|
2265
|
+
attr_reader :expression
|
|
2266
|
+
attr_reader :statement
|
|
2267
|
+
attr_reader :header_terminator
|
|
2268
|
+
|
|
2269
|
+
def location
|
|
2270
|
+
head_location
|
|
2271
|
+
end
|
|
2272
|
+
|
|
2273
|
+
def deduct_controlling_expression
|
|
2274
|
+
selection_stmts = collect_loop_breaking_selection_statements(@statement)
|
|
2275
|
+
expressions = [
|
|
2276
|
+
@expression,
|
|
2277
|
+
*selection_stmts.map { |stmt| stmt.expression }
|
|
2278
|
+
]
|
|
2279
|
+
|
|
2280
|
+
# FIXME: When many loop breaking selection-statements are found, how can
|
|
2281
|
+
# I select one selection-statement?
|
|
2282
|
+
# FIXME: When the loop breaking selection-statement is a
|
|
2283
|
+
# if-else-statement and the loop breaking is in the else branch,
|
|
2284
|
+
# the controlling expression should be inverted.
|
|
2285
|
+
deduct_controlling_expression_candidates(expressions).first
|
|
2286
|
+
end
|
|
2287
|
+
|
|
2288
|
+
def inspect(indent = 0)
|
|
2289
|
+
" " * indent + "#{short_class_name}\n" +
|
|
2290
|
+
@expression.inspect(indent + 1) + "\n" +
|
|
2291
|
+
@statement.inspect(indent + 1)
|
|
2292
|
+
end
|
|
2293
|
+
end
|
|
2294
|
+
|
|
2295
|
+
class DoStatement < IterationStatement
|
|
2296
|
+
def initialize(statement, expression, header_terminator, footer_initiator)
|
|
2297
|
+
super()
|
|
2298
|
+
@statement = statement
|
|
2299
|
+
@expression = expression
|
|
2300
|
+
@header_terminator = header_terminator
|
|
2301
|
+
@footer_initiator = footer_initiator
|
|
2302
|
+
end
|
|
2303
|
+
|
|
2304
|
+
attr_reader :statement
|
|
2305
|
+
attr_reader :expression
|
|
2306
|
+
attr_reader :header_terminator
|
|
2307
|
+
attr_reader :footer_initiator
|
|
2308
|
+
|
|
2309
|
+
def location
|
|
2310
|
+
head_location
|
|
2311
|
+
end
|
|
2312
|
+
|
|
2313
|
+
def deduct_controlling_expression
|
|
2314
|
+
selection_stmts = collect_loop_breaking_selection_statements(@statement)
|
|
2315
|
+
expressions = [
|
|
2316
|
+
@expression,
|
|
2317
|
+
*selection_stmts.map { |stmt| stmt.expression }
|
|
2318
|
+
]
|
|
2319
|
+
|
|
2320
|
+
# FIXME: When many loop breaking selection-statements are found, how can
|
|
2321
|
+
# I select one selection-statement?
|
|
2322
|
+
# FIXME: When the loop breaking selection-statement is a
|
|
2323
|
+
# if-else-statement and the loop breaking is in the else branch,
|
|
2324
|
+
# the controlling expression should be inverted.
|
|
2325
|
+
deduct_controlling_expression_candidates(expressions).first
|
|
2326
|
+
end
|
|
2327
|
+
|
|
2328
|
+
def inspect(indent = 0)
|
|
2329
|
+
" " * indent + "#{short_class_name}\n" +
|
|
2330
|
+
@statement.inspect(indent + 1) + "\n" +
|
|
2331
|
+
@expression.inspect(indent + 1)
|
|
2332
|
+
end
|
|
2333
|
+
end
|
|
2334
|
+
|
|
2335
|
+
class ForStatement < IterationStatement
|
|
2336
|
+
def initialize(initial_statement, condition_statement, expression,
|
|
2337
|
+
body_statement, header_terminator)
|
|
2338
|
+
super()
|
|
2339
|
+
@initial_statement = initial_statement
|
|
2340
|
+
@condition_statement = condition_statement
|
|
2341
|
+
@expression = expression
|
|
2342
|
+
@body_statement = body_statement
|
|
2343
|
+
@header_terminator = header_terminator
|
|
2344
|
+
end
|
|
2345
|
+
|
|
2346
|
+
attr_reader :initial_statement
|
|
2347
|
+
attr_reader :condition_statement
|
|
2348
|
+
attr_reader :expression
|
|
2349
|
+
attr_reader :body_statement
|
|
2350
|
+
attr_reader :header_terminator
|
|
2351
|
+
|
|
2352
|
+
def location
|
|
2353
|
+
head_location
|
|
2354
|
+
end
|
|
2355
|
+
|
|
2356
|
+
def deduct_controlling_expression
|
|
2357
|
+
selection_stmts =
|
|
2358
|
+
collect_loop_breaking_selection_statements(@body_statement)
|
|
2359
|
+
expressions = [
|
|
2360
|
+
@condition_statement.expression,
|
|
2361
|
+
*selection_stmts.map { |stmt| stmt.expression }
|
|
2362
|
+
]
|
|
2363
|
+
|
|
2364
|
+
# FIXME: When many loop breaking selection-statements are found, how can
|
|
2365
|
+
# I select one selection-statement?
|
|
2366
|
+
# FIXME: When the loop breaking selection-statement is a
|
|
2367
|
+
# if-else-statement and the loop breaking is in the else branch,
|
|
2368
|
+
# the controlling expression should be inverted.
|
|
2369
|
+
deduct_controlling_expression_candidates(expressions).first
|
|
2370
|
+
end
|
|
2371
|
+
|
|
2372
|
+
def inspect(indent = 0)
|
|
2373
|
+
" " * indent + "#{short_class_name}\n" +
|
|
2374
|
+
@initial_statement.inspect(indent + 1) + "\n" +
|
|
2375
|
+
@condition_statement.inspect(indent + 1) +
|
|
2376
|
+
(@expression ? "\n#{@expression.inspect(indent + 1)}" : "") +
|
|
2377
|
+
"\n" + @body_statement.inspect(indent + 1)
|
|
2378
|
+
end
|
|
2379
|
+
end
|
|
2380
|
+
|
|
2381
|
+
class C99ForStatement < IterationStatement
|
|
2382
|
+
def initialize(declaration, condition_statement, expression,
|
|
2383
|
+
body_statement, header_terminator)
|
|
2384
|
+
super()
|
|
2385
|
+
@declaration = declaration
|
|
2386
|
+
@condition_statement = condition_statement
|
|
2387
|
+
@expression = expression
|
|
2388
|
+
@body_statement = body_statement
|
|
2389
|
+
@header_terminator = header_terminator
|
|
2390
|
+
end
|
|
2391
|
+
|
|
2392
|
+
attr_reader :declaration
|
|
2393
|
+
attr_reader :condition_statement
|
|
2394
|
+
attr_reader :expression
|
|
2395
|
+
attr_reader :body_statement
|
|
2396
|
+
attr_reader :header_terminator
|
|
2397
|
+
|
|
2398
|
+
def location
|
|
2399
|
+
head_location
|
|
2400
|
+
end
|
|
2401
|
+
|
|
2402
|
+
def deduct_controlling_expression
|
|
2403
|
+
selection_stmts =
|
|
2404
|
+
collect_loop_breaking_selection_statements(@body_statement)
|
|
2405
|
+
expressions = [
|
|
2406
|
+
@condition_statement.expression,
|
|
2407
|
+
*selection_stmts.map { |stmt| stmt.expression }
|
|
2408
|
+
]
|
|
2409
|
+
|
|
2410
|
+
# FIXME: When many loop breaking selection-statements are found, how can
|
|
2411
|
+
# I select one selection-statement?
|
|
2412
|
+
# FIXME: When the loop breaking selection-statement is a
|
|
2413
|
+
# if-else-statement and the loop breaking is in the else branch,
|
|
2414
|
+
# the controlling expression should be inverted.
|
|
2415
|
+
deduct_controlling_expression_candidates(expressions).first
|
|
2416
|
+
end
|
|
2417
|
+
|
|
2418
|
+
def inspect(indent = 0)
|
|
2419
|
+
" " * indent + "#{short_class_name}\n" +
|
|
2420
|
+
@declaration.inspect(indent + 1) + "\n" +
|
|
2421
|
+
@condition_statement.inspect(indent + 1) +
|
|
2422
|
+
(@expression ? "\n#{@expression.inspect(indent + 1)}" : "") +
|
|
2423
|
+
"\n" + @body_statement.inspect(indent + 1)
|
|
2424
|
+
end
|
|
2425
|
+
end
|
|
2426
|
+
|
|
2427
|
+
class JumpStatement < Statement
|
|
2428
|
+
def location
|
|
2429
|
+
head_location
|
|
2430
|
+
end
|
|
2431
|
+
end
|
|
2432
|
+
|
|
2433
|
+
class GotoStatement < JumpStatement
|
|
2434
|
+
def initialize(identifier)
|
|
2435
|
+
super()
|
|
2436
|
+
@identifier = identifier
|
|
2437
|
+
end
|
|
2438
|
+
|
|
2439
|
+
attr_reader :identifier
|
|
2440
|
+
|
|
2441
|
+
def inspect(indent = 0)
|
|
2442
|
+
" " * indent + "#{short_class_name} (#{@identifier.inspect})"
|
|
2443
|
+
end
|
|
2444
|
+
end
|
|
2445
|
+
|
|
2446
|
+
class ContinueStatement < JumpStatement
|
|
2447
|
+
def inspect(indent = 0)
|
|
2448
|
+
" " * indent + "#{short_class_name} (#{location.inspect})"
|
|
2449
|
+
end
|
|
2450
|
+
end
|
|
2451
|
+
|
|
2452
|
+
class BreakStatement < JumpStatement
|
|
2453
|
+
def inspect(indent = 0)
|
|
2454
|
+
" " * indent + "#{short_class_name} (#{location.inspect})"
|
|
2455
|
+
end
|
|
2456
|
+
end
|
|
2457
|
+
|
|
2458
|
+
class ReturnStatement < JumpStatement
|
|
2459
|
+
def initialize(expression)
|
|
2460
|
+
super()
|
|
2461
|
+
@expression = expression
|
|
2462
|
+
end
|
|
2463
|
+
|
|
2464
|
+
attr_reader :expression
|
|
2465
|
+
|
|
2466
|
+
def inspect(indent = 0)
|
|
2467
|
+
" " * indent + "#{short_class_name} (#{location.inspect})" +
|
|
2468
|
+
(@expression ? "\n#{@expression.inspect(indent + 1)}" : "")
|
|
2469
|
+
end
|
|
2470
|
+
end
|
|
2471
|
+
|
|
2472
|
+
class TranslationUnit < SyntaxNode
|
|
2473
|
+
def initialize
|
|
2474
|
+
super()
|
|
2475
|
+
@external_declarations = []
|
|
2476
|
+
end
|
|
2477
|
+
|
|
2478
|
+
attr_reader :external_declarations
|
|
2479
|
+
|
|
2480
|
+
def push(external_declaration)
|
|
2481
|
+
@external_declarations.push(external_declaration)
|
|
2482
|
+
self
|
|
2483
|
+
end
|
|
2484
|
+
|
|
2485
|
+
def location
|
|
2486
|
+
head_location ? head_location : Location.new
|
|
2487
|
+
end
|
|
2488
|
+
|
|
2489
|
+
def inspect(indent = 0)
|
|
2490
|
+
([" " * indent + short_class_name] +
|
|
2491
|
+
@external_declarations.map { |d| d.inspect(indent + 1) }).join("\n")
|
|
2492
|
+
end
|
|
2493
|
+
end
|
|
2494
|
+
|
|
2495
|
+
class FunctionDefinition < Definition
|
|
2496
|
+
include SymbolicElement
|
|
2497
|
+
include SyntaxNodeCollector
|
|
2498
|
+
|
|
2499
|
+
def initialize(declaration_specifiers, declarator, parameter_definitions,
|
|
2500
|
+
compound_statement, symbol_table)
|
|
2501
|
+
super()
|
|
2502
|
+
@declaration_specifiers = declaration_specifiers
|
|
2503
|
+
@declarator = declarator
|
|
2504
|
+
@parameter_definitions = parameter_definitions
|
|
2505
|
+
@function_body = compound_statement
|
|
2506
|
+
@symbol = symbol_table.create_new_symbol(ObjectName, identifier)
|
|
2507
|
+
@type = nil
|
|
2508
|
+
@type_declaration = build_type_declaration(declaration_specifiers,
|
|
2509
|
+
symbol_table)
|
|
2510
|
+
build_label_references(compound_statement)
|
|
2511
|
+
end
|
|
2512
|
+
|
|
2513
|
+
attr_reader :declaration_specifiers
|
|
2514
|
+
attr_reader :declarator
|
|
2515
|
+
attr_reader :parameter_definitions
|
|
2516
|
+
attr_reader :function_body
|
|
2517
|
+
attr_reader :symbol
|
|
2518
|
+
attr_accessor :type
|
|
2519
|
+
attr_reader :type_declaration
|
|
2520
|
+
|
|
2521
|
+
def storage_class_specifier
|
|
2522
|
+
@declaration_specifiers ?
|
|
2523
|
+
@declaration_specifiers.storage_class_specifier : nil
|
|
2524
|
+
end
|
|
2525
|
+
|
|
2526
|
+
def function_specifier
|
|
2527
|
+
@declaration_specifiers ?
|
|
2528
|
+
@declaration_specifiers.function_specifier : nil
|
|
2529
|
+
end
|
|
2530
|
+
|
|
2531
|
+
def identifier
|
|
2532
|
+
@declarator.identifier
|
|
2533
|
+
end
|
|
2534
|
+
|
|
2535
|
+
def signature
|
|
2536
|
+
FunctionSignature.new(identifier, @type)
|
|
2537
|
+
end
|
|
2538
|
+
|
|
2539
|
+
def function_declarator
|
|
2540
|
+
collect_function_declarators(@declarator).first
|
|
2541
|
+
end
|
|
2542
|
+
|
|
2543
|
+
def lines
|
|
2544
|
+
start_line = identifier.location.line_no
|
|
2545
|
+
end_line = @function_body.tail_location.line_no
|
|
2546
|
+
end_line - start_line + 1
|
|
2547
|
+
end
|
|
2548
|
+
|
|
2549
|
+
def location
|
|
2550
|
+
identifier.location
|
|
2551
|
+
end
|
|
2552
|
+
|
|
2553
|
+
def inspect(indent = 0)
|
|
2554
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
2555
|
+
(storage_class_specifier ? "#{storage_class_specifier.value} " : "") +
|
|
2556
|
+
(function_specifier ? "#{function_specifier.value} " : "") +
|
|
2557
|
+
"#{identifier.value}\n" +
|
|
2558
|
+
@parameter_definitions.map { |p| p.inspect(indent + 1) }.join("\n") +
|
|
2559
|
+
"\n#{@function_body.inspect(indent + 1)}"
|
|
2560
|
+
end
|
|
2561
|
+
|
|
2562
|
+
private
|
|
2563
|
+
def build_type_declaration(declaration_specifiers, symbol_table)
|
|
2564
|
+
return nil unless declaration_specifiers
|
|
2565
|
+
declaration_specifiers.type_specifiers.each do |type_specifier|
|
|
2566
|
+
visitor = TypeDeclarationBuilder.new(symbol_table)
|
|
2567
|
+
type_specifier.accept(visitor)
|
|
2568
|
+
unless visitor.type_declarations.empty?
|
|
2569
|
+
return visitor.type_declarations.first
|
|
2570
|
+
end
|
|
2571
|
+
end
|
|
2572
|
+
nil
|
|
2573
|
+
end
|
|
2574
|
+
|
|
2575
|
+
def build_label_references(compound_statement)
|
|
2576
|
+
labels = collect_generic_labeled_statements(compound_statement)
|
|
2577
|
+
|
|
2578
|
+
gotos = collect_goto_statements(compound_statement)
|
|
2579
|
+
|
|
2580
|
+
labels.each do |generic_labeled_statement|
|
|
2581
|
+
label_name = generic_labeled_statement.label.value
|
|
2582
|
+
gotos.select { |goto_statement|
|
|
2583
|
+
goto_statement.identifier.value == label_name
|
|
2584
|
+
}.each do |goto_statement|
|
|
2585
|
+
generic_labeled_statement.referrers.push(goto_statement)
|
|
2586
|
+
end
|
|
2587
|
+
end
|
|
2588
|
+
end
|
|
2589
|
+
end
|
|
2590
|
+
|
|
2591
|
+
class KandRFunctionDefinition < FunctionDefinition
|
|
2592
|
+
def initialize(declaration_specifiers, declarator, declarations,
|
|
2593
|
+
compound_statement, symbol_table)
|
|
2594
|
+
parameter_definitions = create_parameters(declarator.identifier_list,
|
|
2595
|
+
declarations, symbol_table)
|
|
2596
|
+
super(declaration_specifiers, declarator, parameter_definitions,
|
|
2597
|
+
compound_statement, symbol_table)
|
|
2598
|
+
end
|
|
2599
|
+
|
|
2600
|
+
def identifier_list
|
|
2601
|
+
declarator.identifier_list
|
|
2602
|
+
end
|
|
2603
|
+
|
|
2604
|
+
private
|
|
2605
|
+
def create_parameters(parameter_names, declarations, symbol_table)
|
|
2606
|
+
return [] unless parameter_names
|
|
2607
|
+
|
|
2608
|
+
result = []
|
|
2609
|
+
parameter_names.each do |name|
|
|
2610
|
+
variable_definition =
|
|
2611
|
+
find_variable_definition(declarations, name, symbol_table)
|
|
2612
|
+
result.push(
|
|
2613
|
+
variable_definition_to_parameter_definition(variable_definition))
|
|
2614
|
+
end
|
|
2615
|
+
result
|
|
2616
|
+
end
|
|
2617
|
+
|
|
2618
|
+
def find_variable_definition(declarations, name, symbol_table)
|
|
2619
|
+
declarations.each do |declaration|
|
|
2620
|
+
declaration.items.select { |item|
|
|
2621
|
+
item.kind_of?(VariableDefinition)
|
|
2622
|
+
}.each do |definition|
|
|
2623
|
+
return definition if definition.identifier.value == name.value
|
|
2624
|
+
end
|
|
2625
|
+
end
|
|
2626
|
+
|
|
2627
|
+
declaration = implicit_parameter_definition(name, symbol_table)
|
|
2628
|
+
declarations.push(declaration)
|
|
2629
|
+
declaration.items.first
|
|
2630
|
+
end
|
|
2631
|
+
|
|
2632
|
+
def variable_definition_to_parameter_definition(variable_definition)
|
|
2633
|
+
declaration_specifiers = variable_definition.declaration_specifiers
|
|
2634
|
+
declarator = variable_definition.init_declarator.declarator
|
|
2635
|
+
pdef = ParameterDefinition.new(declaration_specifiers, declarator)
|
|
2636
|
+
|
|
2637
|
+
unless declaration_specifiers
|
|
2638
|
+
pdef.head_token = declarator.head_token
|
|
2639
|
+
pdef.tail_token = declarator.tail_token
|
|
2640
|
+
end
|
|
2641
|
+
|
|
2642
|
+
unless declarator
|
|
2643
|
+
pdef.head_token = declaration_specifiers.head_token
|
|
2644
|
+
pdef.tail_token = declaration_specifiers.tail_token
|
|
2645
|
+
end
|
|
2646
|
+
|
|
2647
|
+
pdef
|
|
2648
|
+
end
|
|
2649
|
+
|
|
2650
|
+
def implicit_parameter_definition(identifier, symbol_table)
|
|
2651
|
+
init_declarator =
|
|
2652
|
+
InitDeclarator.new(IdentifierDeclarator.new(identifier), nil)
|
|
2653
|
+
Declaration.new(nil, [init_declarator], symbol_table)
|
|
2654
|
+
end
|
|
2655
|
+
end
|
|
2656
|
+
|
|
2657
|
+
class AnsiFunctionDefinition < FunctionDefinition
|
|
2658
|
+
def initialize(declaration_specifiers, declarator,
|
|
2659
|
+
compound_statement, symbol_table)
|
|
2660
|
+
super(declaration_specifiers, declarator,
|
|
2661
|
+
create_parameters(declarator.parameter_type_list),
|
|
2662
|
+
compound_statement, symbol_table)
|
|
2663
|
+
end
|
|
2664
|
+
|
|
2665
|
+
def parameter_type_list
|
|
2666
|
+
declarator.parameter_type_list
|
|
2667
|
+
end
|
|
2668
|
+
|
|
2669
|
+
private
|
|
2670
|
+
def create_parameters(parameter_type_list)
|
|
2671
|
+
return [] unless parameter_type_list
|
|
2672
|
+
parameter_type_list.parameters.map do |parameter_declaration|
|
|
2673
|
+
declaration_specifiers = parameter_declaration.declaration_specifiers
|
|
2674
|
+
declarator = parameter_declaration.declarator
|
|
2675
|
+
pdef = ParameterDefinition.new(declaration_specifiers, declarator)
|
|
2676
|
+
|
|
2677
|
+
unless declaration_specifiers
|
|
2678
|
+
pdef.head_token = declarator.head_token
|
|
2679
|
+
pdef.tail_token = declarator.tail_token
|
|
2680
|
+
end
|
|
2681
|
+
|
|
2682
|
+
unless declarator
|
|
2683
|
+
pdef.head_token = declaration_specifiers.head_token
|
|
2684
|
+
pdef.tail_token = declaration_specifiers.tail_token
|
|
2685
|
+
end
|
|
2686
|
+
|
|
2687
|
+
pdef
|
|
2688
|
+
end
|
|
2689
|
+
end
|
|
2690
|
+
end
|
|
2691
|
+
|
|
2692
|
+
class ParameterDefinition < Definition
|
|
2693
|
+
def initialize(declaration_specifiers, declarator)
|
|
2694
|
+
super()
|
|
2695
|
+
@declaration_specifiers = declaration_specifiers
|
|
2696
|
+
@declarator = declarator
|
|
2697
|
+
@type = nil
|
|
2698
|
+
end
|
|
2699
|
+
|
|
2700
|
+
attr_reader :declaration_specifiers
|
|
2701
|
+
attr_reader :declarator
|
|
2702
|
+
attr_accessor :type
|
|
2703
|
+
|
|
2704
|
+
def identifier
|
|
2705
|
+
if @declarator
|
|
2706
|
+
if @declarator.abstract?
|
|
2707
|
+
nil
|
|
2708
|
+
else
|
|
2709
|
+
@declarator.identifier
|
|
2710
|
+
end
|
|
2711
|
+
else
|
|
2712
|
+
nil
|
|
2713
|
+
end
|
|
2714
|
+
end
|
|
2715
|
+
|
|
2716
|
+
def storage_class_specifier
|
|
2717
|
+
@declaration_specifiers ?
|
|
2718
|
+
@declaration_specifiers.storage_class_specifier : nil
|
|
2719
|
+
end
|
|
2720
|
+
|
|
2721
|
+
def location
|
|
2722
|
+
identifier ? identifier.location : nil
|
|
2723
|
+
end
|
|
2724
|
+
|
|
2725
|
+
def to_variable_definition
|
|
2726
|
+
PseudoVariableDefinition.new(@declaration_specifiers,
|
|
2727
|
+
InitDeclarator.new(@declarator, nil),
|
|
2728
|
+
@type)
|
|
2729
|
+
end
|
|
2730
|
+
|
|
2731
|
+
def inspect(indent = 0)
|
|
2732
|
+
" " * indent + "#{short_class_name} (#{location.inspect}) " +
|
|
2733
|
+
(storage_class_specifier ? storage_class_specifier.inspect : "") +
|
|
2734
|
+
(identifier ? identifier.value : "")
|
|
2735
|
+
end
|
|
2736
|
+
end
|
|
2737
|
+
|
|
2738
|
+
class PseudoVariableDefinition < VariableDefinition
|
|
2739
|
+
def initialize(declaration_specifiers, init_declarator, type)
|
|
2740
|
+
super(declaration_specifiers, init_declarator, nil)
|
|
2741
|
+
@type = type
|
|
2742
|
+
end
|
|
2743
|
+
|
|
2744
|
+
def mark_as_referred_by(token) end
|
|
2745
|
+
end
|
|
2746
|
+
|
|
2747
|
+
class TypeName < SyntaxNode
|
|
2748
|
+
def initialize(specifier_qualifier_list, abstract_declarator, symbol_table)
|
|
2749
|
+
super()
|
|
2750
|
+
@specifier_qualifier_list = specifier_qualifier_list
|
|
2751
|
+
@abstract_declarator = abstract_declarator
|
|
2752
|
+
@type = nil
|
|
2753
|
+
@type_declaration = build_type_declaration(specifier_qualifier_list,
|
|
2754
|
+
symbol_table)
|
|
2755
|
+
end
|
|
2756
|
+
|
|
2757
|
+
attr_reader :specifier_qualifier_list
|
|
2758
|
+
attr_reader :abstract_declarator
|
|
2759
|
+
attr_accessor :type
|
|
2760
|
+
attr_reader :type_declaration
|
|
2761
|
+
|
|
2762
|
+
def location
|
|
2763
|
+
@specifier_qualifier_list.location
|
|
2764
|
+
end
|
|
2765
|
+
|
|
2766
|
+
def to_s
|
|
2767
|
+
@type.image
|
|
2768
|
+
end
|
|
2769
|
+
|
|
2770
|
+
def inspect(indent = 0)
|
|
2771
|
+
" " * indent + short_class_name + " (#{@type ? @type.image : "nil"})"
|
|
2772
|
+
end
|
|
2773
|
+
|
|
2774
|
+
private
|
|
2775
|
+
def build_type_declaration(specifier_qualifier_list, symbol_table)
|
|
2776
|
+
specifier_qualifier_list.type_specifiers.each do |type_specifier|
|
|
2777
|
+
visitor = TypeDeclarationBuilder.new(symbol_table)
|
|
2778
|
+
type_specifier.accept(visitor)
|
|
2779
|
+
unless visitor.type_declarations.empty?
|
|
2780
|
+
return visitor.type_declarations.first
|
|
2781
|
+
end
|
|
2782
|
+
end
|
|
2783
|
+
nil
|
|
2784
|
+
end
|
|
2785
|
+
end
|
|
2786
|
+
|
|
2787
|
+
class AbstractDeclarator < Declarator
|
|
2788
|
+
def identifier
|
|
2789
|
+
nil
|
|
2790
|
+
end
|
|
2791
|
+
|
|
2792
|
+
def abstract?
|
|
2793
|
+
true
|
|
2794
|
+
end
|
|
2795
|
+
end
|
|
2796
|
+
|
|
2797
|
+
class PointerAbstractDeclarator < AbstractDeclarator
|
|
2798
|
+
def initialize(abstract_declarator, pointer)
|
|
2799
|
+
super()
|
|
2800
|
+
@base = abstract_declarator
|
|
2801
|
+
@pointer = pointer
|
|
2802
|
+
end
|
|
2803
|
+
|
|
2804
|
+
attr_reader :base
|
|
2805
|
+
|
|
2806
|
+
def location
|
|
2807
|
+
head_location
|
|
2808
|
+
end
|
|
2809
|
+
|
|
2810
|
+
def function?(stack = [])
|
|
2811
|
+
stack.push(:pointer)
|
|
2812
|
+
@base.function?(stack) if @base
|
|
2813
|
+
stack.last == :function
|
|
2814
|
+
end
|
|
2815
|
+
|
|
2816
|
+
def inspect(indent = 0)
|
|
2817
|
+
" " * indent + short_class_name
|
|
2818
|
+
end
|
|
2819
|
+
end
|
|
2820
|
+
|
|
2821
|
+
class GroupedAbstractDeclarator < AbstractDeclarator
|
|
2822
|
+
def initialize(abstract_declarator)
|
|
2823
|
+
super()
|
|
2824
|
+
@base = abstract_declarator
|
|
2825
|
+
end
|
|
2826
|
+
|
|
2827
|
+
attr_reader :base
|
|
2828
|
+
|
|
2829
|
+
def location
|
|
2830
|
+
@base.location
|
|
2831
|
+
end
|
|
2832
|
+
|
|
2833
|
+
def function?
|
|
2834
|
+
@base.function?
|
|
2835
|
+
end
|
|
2836
|
+
|
|
2837
|
+
def inspect(indent = 0)
|
|
2838
|
+
" " * indent + short_class_name
|
|
2839
|
+
end
|
|
2840
|
+
end
|
|
2841
|
+
|
|
2842
|
+
class ArrayAbstractDeclarator < AbstractDeclarator
|
|
2843
|
+
def initialize(abstract_declarator, size_expression)
|
|
2844
|
+
super()
|
|
2845
|
+
@base = abstract_declarator
|
|
2846
|
+
@size_expression = size_expression
|
|
2847
|
+
end
|
|
2848
|
+
|
|
2849
|
+
attr_reader :base
|
|
2850
|
+
attr_reader :size_expression
|
|
2851
|
+
|
|
2852
|
+
def location
|
|
2853
|
+
return @base.location if @base
|
|
2854
|
+
return @size_expression.location if @size_expression
|
|
2855
|
+
nil
|
|
2856
|
+
end
|
|
2857
|
+
|
|
2858
|
+
def function?(stack = [])
|
|
2859
|
+
stack.push(:array)
|
|
2860
|
+
@base.function?(stack) if @base
|
|
2861
|
+
stack.last == :function
|
|
2862
|
+
end
|
|
2863
|
+
|
|
2864
|
+
def inspect(indent = 0)
|
|
2865
|
+
" " * indent + short_class_name
|
|
2866
|
+
end
|
|
2867
|
+
end
|
|
2868
|
+
|
|
2869
|
+
class FunctionAbstractDeclarator < AbstractDeclarator
|
|
2870
|
+
def initialize(abstract_declarator, parameter_type_list)
|
|
2871
|
+
super()
|
|
2872
|
+
@base = abstract_declarator
|
|
2873
|
+
@parameter_type_list = parameter_type_list
|
|
2874
|
+
end
|
|
2875
|
+
|
|
2876
|
+
attr_reader :base
|
|
2877
|
+
attr_reader :parameter_type_list
|
|
2878
|
+
|
|
2879
|
+
def location
|
|
2880
|
+
return @base.location if @base
|
|
2881
|
+
return @parameter_type_list.location if @parameter_type_list
|
|
2882
|
+
nil
|
|
2883
|
+
end
|
|
2884
|
+
|
|
2885
|
+
def function?(stack = [])
|
|
2886
|
+
stack.push(:function)
|
|
2887
|
+
@base.function?(stack) if @base
|
|
2888
|
+
stack.last == :function
|
|
2889
|
+
end
|
|
2890
|
+
|
|
2891
|
+
def inspect(indent = 0)
|
|
2892
|
+
" " * indent + short_class_name
|
|
2893
|
+
end
|
|
2894
|
+
end
|
|
2895
|
+
|
|
2896
|
+
class Initializer < SyntaxNode
|
|
2897
|
+
def initialize(expression, initializers)
|
|
2898
|
+
super()
|
|
2899
|
+
@expression = expression
|
|
2900
|
+
@initializers = initializers
|
|
2901
|
+
end
|
|
2902
|
+
|
|
2903
|
+
attr_reader :expression
|
|
2904
|
+
attr_reader :initializers
|
|
2905
|
+
|
|
2906
|
+
def location
|
|
2907
|
+
head_location
|
|
2908
|
+
end
|
|
2909
|
+
|
|
2910
|
+
def to_s
|
|
2911
|
+
case
|
|
2912
|
+
when @expression
|
|
2913
|
+
@expression.to_s
|
|
2914
|
+
when @initializers
|
|
2915
|
+
"{#{@initializers.map { |ini| ini.to_s }.join(",")}}"
|
|
2916
|
+
else
|
|
2917
|
+
"{}"
|
|
2918
|
+
end
|
|
2919
|
+
end
|
|
2920
|
+
|
|
2921
|
+
def inspect(indent = 0)
|
|
2922
|
+
" " * indent + short_class_name
|
|
2923
|
+
end
|
|
2924
|
+
end
|
|
2925
|
+
|
|
2926
|
+
class FunctionSignature
|
|
2927
|
+
def initialize(name, type)
|
|
2928
|
+
@name = name
|
|
2929
|
+
@type = type
|
|
2930
|
+
end
|
|
2931
|
+
|
|
2932
|
+
attr_reader :name
|
|
2933
|
+
|
|
2934
|
+
def ==(rhs)
|
|
2935
|
+
if @type.parameter_types.empty? || rhs.type.parameter_types.empty?
|
|
2936
|
+
@name.value == rhs.name.value
|
|
2937
|
+
else
|
|
2938
|
+
@name.value == rhs.name.value && @type == rhs.type
|
|
2939
|
+
end
|
|
2940
|
+
end
|
|
2941
|
+
|
|
2942
|
+
def to_s
|
|
2943
|
+
"#{@type.return_type.brief_image} #{@name.value}(" +
|
|
2944
|
+
@type.parameter_types.map { |t| t.brief_image }.join(",") +
|
|
2945
|
+
(@type.have_va_list? ? ",...)" : ")")
|
|
2946
|
+
end
|
|
2947
|
+
|
|
2948
|
+
protected
|
|
2949
|
+
attr_reader :type
|
|
2950
|
+
end
|
|
2951
|
+
|
|
2952
|
+
class TypeDeclarationBuilder
|
|
2953
|
+
def initialize(symbol_table)
|
|
2954
|
+
@symbol_table = symbol_table
|
|
2955
|
+
@type_declarations = []
|
|
2956
|
+
end
|
|
2957
|
+
|
|
2958
|
+
attr_reader :type_declarations
|
|
2959
|
+
|
|
2960
|
+
def visit_standard_type_specifier(node)
|
|
2961
|
+
end
|
|
2962
|
+
|
|
2963
|
+
def visit_typedef_type_specifier(node)
|
|
2964
|
+
end
|
|
2965
|
+
|
|
2966
|
+
def visit_struct_specifier(node)
|
|
2967
|
+
if node.struct_declarations
|
|
2968
|
+
node.struct_declarations.each { |child| child.accept(self) }
|
|
2969
|
+
symbol = @symbol_table.create_new_symbol(StructTag, node.identifier)
|
|
2970
|
+
@type_declarations.push(StructTypeDeclaration.new(node, symbol))
|
|
2971
|
+
end
|
|
2972
|
+
end
|
|
2973
|
+
|
|
2974
|
+
def visit_union_specifier(node)
|
|
2975
|
+
if node.struct_declarations
|
|
2976
|
+
node.struct_declarations.each { |child| child.accept(self) }
|
|
2977
|
+
symbol = @symbol_table.create_new_symbol(UnionTag, node.identifier)
|
|
2978
|
+
@type_declarations.push(UnionTypeDeclaration.new(node, symbol))
|
|
2979
|
+
end
|
|
2980
|
+
end
|
|
2981
|
+
|
|
2982
|
+
def visit_enum_specifier(node)
|
|
2983
|
+
if node.enumerators
|
|
2984
|
+
symbol = @symbol_table.create_new_symbol(EnumTag, node.identifier)
|
|
2985
|
+
@type_declarations.push(EnumTypeDeclaration.new(node, symbol))
|
|
2986
|
+
end
|
|
2987
|
+
end
|
|
2988
|
+
|
|
2989
|
+
def visit_typeof_type_specifier(node)
|
|
2990
|
+
end
|
|
2991
|
+
|
|
2992
|
+
def visit_struct_declaration(node)
|
|
2993
|
+
node.specifier_qualifier_list.accept(self)
|
|
2994
|
+
end
|
|
2995
|
+
|
|
2996
|
+
def visit_specifier_qualifier_list(node)
|
|
2997
|
+
node.type_specifiers.each { |child| child.accept(self) }
|
|
2998
|
+
end
|
|
2999
|
+
end
|
|
3000
|
+
|
|
3001
|
+
class SyntaxTreeVisitor
|
|
3002
|
+
def visit_error_expression(node)
|
|
3003
|
+
end
|
|
3004
|
+
|
|
3005
|
+
def visit_object_specifier(node)
|
|
3006
|
+
end
|
|
3007
|
+
|
|
3008
|
+
def visit_constant_specifier(node)
|
|
3009
|
+
end
|
|
3010
|
+
|
|
3011
|
+
def visit_string_literal_specifier(node)
|
|
3012
|
+
end
|
|
3013
|
+
|
|
3014
|
+
def visit_null_constant_specifier(node)
|
|
3015
|
+
end
|
|
3016
|
+
|
|
3017
|
+
def visit_grouped_expression(node)
|
|
3018
|
+
node.expression.accept(self)
|
|
3019
|
+
end
|
|
3020
|
+
|
|
3021
|
+
def visit_array_subscript_expression(node)
|
|
3022
|
+
node.expression.accept(self)
|
|
3023
|
+
node.array_subscript.accept(self)
|
|
3024
|
+
end
|
|
3025
|
+
|
|
3026
|
+
def visit_function_call_expression(node)
|
|
3027
|
+
node.expression.accept(self)
|
|
3028
|
+
node.argument_expressions.each { |expr| expr.accept(self) }
|
|
3029
|
+
end
|
|
3030
|
+
|
|
3031
|
+
def visit_member_access_by_value_expression(node)
|
|
3032
|
+
node.expression.accept(self)
|
|
3033
|
+
end
|
|
3034
|
+
|
|
3035
|
+
def visit_member_access_by_pointer_expression(node)
|
|
3036
|
+
node.expression.accept(self)
|
|
3037
|
+
end
|
|
3038
|
+
|
|
3039
|
+
def visit_bit_access_by_value_expression(node)
|
|
3040
|
+
node.expression.accept(self)
|
|
3041
|
+
end
|
|
3042
|
+
|
|
3043
|
+
def visit_bit_access_by_pointer_expression(node)
|
|
3044
|
+
node.expression.accept(self)
|
|
3045
|
+
end
|
|
3046
|
+
|
|
3047
|
+
def visit_postfix_increment_expression(node)
|
|
3048
|
+
node.operand.accept(self)
|
|
3049
|
+
end
|
|
3050
|
+
|
|
3051
|
+
def visit_postfix_decrement_expression(node)
|
|
3052
|
+
node.operand.accept(self)
|
|
3053
|
+
end
|
|
3054
|
+
|
|
3055
|
+
def visit_compound_literal_expression(node)
|
|
3056
|
+
node.type_name.accept(self) if node.type_name
|
|
3057
|
+
node.initializers.each { |ini| ini.accept(self) }
|
|
3058
|
+
end
|
|
3059
|
+
|
|
3060
|
+
def visit_prefix_increment_expression(node)
|
|
3061
|
+
node.operand.accept(self)
|
|
3062
|
+
end
|
|
3063
|
+
|
|
3064
|
+
def visit_prefix_decrement_expression(node)
|
|
3065
|
+
node.operand.accept(self)
|
|
3066
|
+
end
|
|
3067
|
+
|
|
3068
|
+
def visit_address_expression(node)
|
|
3069
|
+
node.operand.accept(self)
|
|
3070
|
+
end
|
|
3071
|
+
|
|
3072
|
+
def visit_indirection_expression(node)
|
|
3073
|
+
node.operand.accept(self)
|
|
3074
|
+
end
|
|
3075
|
+
|
|
3076
|
+
def visit_unary_arithmetic_expression(node)
|
|
3077
|
+
node.operand.accept(self)
|
|
3078
|
+
end
|
|
3079
|
+
|
|
3080
|
+
def visit_sizeof_expression(node)
|
|
3081
|
+
node.operand.accept(self)
|
|
3082
|
+
end
|
|
3083
|
+
|
|
3084
|
+
def visit_sizeof_type_expression(node)
|
|
3085
|
+
node.operand.accept(self)
|
|
3086
|
+
end
|
|
3087
|
+
|
|
3088
|
+
def visit_alignof_expression(node)
|
|
3089
|
+
node.operand.accept(self)
|
|
3090
|
+
end
|
|
3091
|
+
|
|
3092
|
+
def visit_alignof_type_expression(node)
|
|
3093
|
+
node.operand.accept(self)
|
|
3094
|
+
end
|
|
3095
|
+
|
|
3096
|
+
def visit_cast_expression(node)
|
|
3097
|
+
node.type_name.accept(self)
|
|
3098
|
+
node.operand.accept(self)
|
|
3099
|
+
end
|
|
3100
|
+
|
|
3101
|
+
def visit_multiplicative_expression(node)
|
|
3102
|
+
node.lhs_operand.accept(self)
|
|
3103
|
+
node.rhs_operand.accept(self)
|
|
3104
|
+
end
|
|
3105
|
+
|
|
3106
|
+
def visit_additive_expression(node)
|
|
3107
|
+
node.lhs_operand.accept(self)
|
|
3108
|
+
node.rhs_operand.accept(self)
|
|
3109
|
+
end
|
|
3110
|
+
|
|
3111
|
+
def visit_shift_expression(node)
|
|
3112
|
+
node.lhs_operand.accept(self)
|
|
3113
|
+
node.rhs_operand.accept(self)
|
|
3114
|
+
end
|
|
3115
|
+
|
|
3116
|
+
def visit_relational_expression(node)
|
|
3117
|
+
node.lhs_operand.accept(self)
|
|
3118
|
+
node.rhs_operand.accept(self)
|
|
3119
|
+
end
|
|
3120
|
+
|
|
3121
|
+
def visit_equality_expression(node)
|
|
3122
|
+
node.lhs_operand.accept(self)
|
|
3123
|
+
node.rhs_operand.accept(self)
|
|
3124
|
+
end
|
|
3125
|
+
|
|
3126
|
+
def visit_and_expression(node)
|
|
3127
|
+
node.lhs_operand.accept(self)
|
|
3128
|
+
node.rhs_operand.accept(self)
|
|
3129
|
+
end
|
|
3130
|
+
|
|
3131
|
+
def visit_exclusive_or_expression(node)
|
|
3132
|
+
node.lhs_operand.accept(self)
|
|
3133
|
+
node.rhs_operand.accept(self)
|
|
3134
|
+
end
|
|
3135
|
+
|
|
3136
|
+
def visit_inclusive_or_expression(node)
|
|
3137
|
+
node.lhs_operand.accept(self)
|
|
3138
|
+
node.rhs_operand.accept(self)
|
|
3139
|
+
end
|
|
3140
|
+
|
|
3141
|
+
def visit_logical_and_expression(node)
|
|
3142
|
+
node.lhs_operand.accept(self)
|
|
3143
|
+
node.rhs_operand.accept(self)
|
|
3144
|
+
end
|
|
3145
|
+
|
|
3146
|
+
def visit_logical_or_expression(node)
|
|
3147
|
+
node.lhs_operand.accept(self)
|
|
3148
|
+
node.rhs_operand.accept(self)
|
|
3149
|
+
end
|
|
3150
|
+
|
|
3151
|
+
def visit_conditional_expression(node)
|
|
3152
|
+
node.condition.accept(self)
|
|
3153
|
+
node.then_expression.accept(self)
|
|
3154
|
+
node.else_expression.accept(self)
|
|
3155
|
+
end
|
|
3156
|
+
|
|
3157
|
+
def visit_simple_assignment_expression(node)
|
|
3158
|
+
node.lhs_operand.accept(self)
|
|
3159
|
+
node.rhs_operand.accept(self)
|
|
3160
|
+
end
|
|
3161
|
+
|
|
3162
|
+
def visit_compound_assignment_expression(node)
|
|
3163
|
+
node.lhs_operand.accept(self)
|
|
3164
|
+
node.rhs_operand.accept(self)
|
|
3165
|
+
end
|
|
3166
|
+
|
|
3167
|
+
def visit_comma_separated_expression(node)
|
|
3168
|
+
node.expressions.each { |expr| expr.accept(self) }
|
|
3169
|
+
end
|
|
3170
|
+
|
|
3171
|
+
def visit_declaration(node)
|
|
3172
|
+
node.declaration_specifiers.accept(self) if node.declaration_specifiers
|
|
3173
|
+
node.init_declarators.each { |decl| decl.accept(self) }
|
|
3174
|
+
node.items.each { |item| item.accept(self) }
|
|
3175
|
+
end
|
|
3176
|
+
|
|
3177
|
+
def visit_function_declaration(node)
|
|
3178
|
+
end
|
|
3179
|
+
|
|
3180
|
+
def visit_variable_declaration(node)
|
|
3181
|
+
end
|
|
3182
|
+
|
|
3183
|
+
def visit_variable_definition(node)
|
|
3184
|
+
end
|
|
3185
|
+
|
|
3186
|
+
def visit_typedef_declaration(node)
|
|
3187
|
+
end
|
|
3188
|
+
|
|
3189
|
+
def visit_struct_type_declaration(node)
|
|
3190
|
+
end
|
|
3191
|
+
|
|
3192
|
+
def visit_union_type_declaration(node)
|
|
3193
|
+
end
|
|
3194
|
+
|
|
3195
|
+
def visit_enum_type_declaration(node)
|
|
3196
|
+
end
|
|
3197
|
+
|
|
3198
|
+
def visit_declaration_specifiers(node)
|
|
3199
|
+
node.type_specifiers.each { |ts| ts.accept(self) }
|
|
3200
|
+
end
|
|
3201
|
+
|
|
3202
|
+
def visit_init_declarator(node)
|
|
3203
|
+
node.declarator.accept(self)
|
|
3204
|
+
node.initializer.accept(self) if node.initializer
|
|
3205
|
+
end
|
|
3206
|
+
|
|
3207
|
+
def visit_standard_type_specifier(node)
|
|
3208
|
+
end
|
|
3209
|
+
|
|
3210
|
+
def visit_typedef_type_specifier(node)
|
|
3211
|
+
end
|
|
3212
|
+
|
|
3213
|
+
def visit_struct_specifier(node)
|
|
3214
|
+
if node.struct_declarations
|
|
3215
|
+
node.struct_declarations.each { |decl| decl.accept(self) }
|
|
3216
|
+
end
|
|
3217
|
+
end
|
|
3218
|
+
|
|
3219
|
+
def visit_union_specifier(node)
|
|
3220
|
+
if node.struct_declarations
|
|
3221
|
+
node.struct_declarations.each { |decl| decl.accept(self) }
|
|
3222
|
+
end
|
|
3223
|
+
end
|
|
3224
|
+
|
|
3225
|
+
def visit_struct_declaration(node)
|
|
3226
|
+
node.specifier_qualifier_list.accept(self)
|
|
3227
|
+
node.struct_declarators.each { |decl| decl.accept(self) }
|
|
3228
|
+
node.items.each { |item| item.accept(self) }
|
|
3229
|
+
end
|
|
3230
|
+
|
|
3231
|
+
def visit_member_declaration(node)
|
|
3232
|
+
end
|
|
3233
|
+
|
|
3234
|
+
def visit_specifier_qualifier_list(node)
|
|
3235
|
+
node.type_specifiers.each { |ts| ts.accept(self) }
|
|
3236
|
+
end
|
|
3237
|
+
|
|
3238
|
+
def visit_struct_declarator(node)
|
|
3239
|
+
node.declarator.accept(self) if node.declarator
|
|
3240
|
+
node.expression.accept(self) if node.expression
|
|
3241
|
+
end
|
|
3242
|
+
|
|
3243
|
+
def visit_enum_specifier(node)
|
|
3244
|
+
if node.enumerators
|
|
3245
|
+
node.enumerators.each { |enum| enum.accept(self) }
|
|
3246
|
+
end
|
|
3247
|
+
end
|
|
3248
|
+
|
|
3249
|
+
def visit_enumerator(node)
|
|
3250
|
+
node.expression.accept(self) if node.expression
|
|
3251
|
+
end
|
|
3252
|
+
|
|
3253
|
+
def visit_typeof_type_specifier(node)
|
|
3254
|
+
node.expression.accept(self) if node.expression
|
|
3255
|
+
node.type_name.accept(self) if node.type_name
|
|
3256
|
+
end
|
|
3257
|
+
|
|
3258
|
+
def visit_identifier_declarator(node)
|
|
3259
|
+
end
|
|
3260
|
+
|
|
3261
|
+
def visit_grouped_declarator(node)
|
|
3262
|
+
node.base.accept(self)
|
|
3263
|
+
end
|
|
3264
|
+
|
|
3265
|
+
def visit_array_declarator(node)
|
|
3266
|
+
node.base.accept(self)
|
|
3267
|
+
node.size_expression.accept(self) if node.size_expression
|
|
3268
|
+
end
|
|
3269
|
+
|
|
3270
|
+
def visit_ansi_function_declarator(node)
|
|
3271
|
+
node.base.accept(self)
|
|
3272
|
+
node.parameter_type_list.accept(self)
|
|
3273
|
+
end
|
|
3274
|
+
|
|
3275
|
+
def visit_kandr_function_declarator(node)
|
|
3276
|
+
node.base.accept(self)
|
|
3277
|
+
end
|
|
3278
|
+
|
|
3279
|
+
def visit_abbreviated_function_declarator(node)
|
|
3280
|
+
node.base.accept(self)
|
|
3281
|
+
end
|
|
3282
|
+
|
|
3283
|
+
def visit_parameter_type_list(node)
|
|
3284
|
+
node.parameters.each { |param| param.accept(self) }
|
|
3285
|
+
end
|
|
3286
|
+
|
|
3287
|
+
def visit_parameter_declaration(node)
|
|
3288
|
+
node.declaration_specifiers.accept(self)
|
|
3289
|
+
node.declarator.accept(self) if node.declarator
|
|
3290
|
+
end
|
|
3291
|
+
|
|
3292
|
+
def visit_error_statement(node)
|
|
3293
|
+
end
|
|
3294
|
+
|
|
3295
|
+
def visit_generic_labeled_statement(node)
|
|
3296
|
+
node.statement.accept(self)
|
|
3297
|
+
end
|
|
3298
|
+
|
|
3299
|
+
def visit_case_labeled_statement(node)
|
|
3300
|
+
node.expression.accept(self)
|
|
3301
|
+
node.statement.accept(self)
|
|
3302
|
+
end
|
|
3303
|
+
|
|
3304
|
+
def visit_default_labeled_statement(node)
|
|
3305
|
+
node.statement.accept(self)
|
|
3306
|
+
end
|
|
3307
|
+
|
|
3308
|
+
def visit_compound_statement(node)
|
|
3309
|
+
node.block_items.each { |item| item.accept(self) }
|
|
3310
|
+
end
|
|
3311
|
+
|
|
3312
|
+
def visit_expression_statement(node)
|
|
3313
|
+
node.expression.accept(self) if node.expression
|
|
3314
|
+
end
|
|
3315
|
+
|
|
3316
|
+
def visit_if_statement(node)
|
|
3317
|
+
node.expression.accept(self)
|
|
3318
|
+
node.statement.accept(self)
|
|
3319
|
+
end
|
|
3320
|
+
|
|
3321
|
+
def visit_if_else_statement(node)
|
|
3322
|
+
node.expression.accept(self)
|
|
3323
|
+
node.then_statement.accept(self)
|
|
3324
|
+
node.else_statement.accept(self)
|
|
3325
|
+
end
|
|
3326
|
+
|
|
3327
|
+
def visit_switch_statement(node)
|
|
3328
|
+
node.expression.accept(self)
|
|
3329
|
+
node.statement.accept(self)
|
|
3330
|
+
end
|
|
3331
|
+
|
|
3332
|
+
def visit_while_statement(node)
|
|
3333
|
+
node.expression.accept(self)
|
|
3334
|
+
node.statement.accept(self)
|
|
3335
|
+
end
|
|
3336
|
+
|
|
3337
|
+
def visit_do_statement(node)
|
|
3338
|
+
node.statement.accept(self)
|
|
3339
|
+
node.expression.accept(self)
|
|
3340
|
+
end
|
|
3341
|
+
|
|
3342
|
+
def visit_for_statement(node)
|
|
3343
|
+
node.initial_statement.accept(self)
|
|
3344
|
+
node.condition_statement.accept(self)
|
|
3345
|
+
node.expression.accept(self) if node.expression
|
|
3346
|
+
node.body_statement.accept(self)
|
|
3347
|
+
end
|
|
3348
|
+
|
|
3349
|
+
def visit_c99_for_statement(node)
|
|
3350
|
+
node.declaration.accept(self)
|
|
3351
|
+
node.condition_statement.accept(self)
|
|
3352
|
+
node.expression.accept(self) if node.expression
|
|
3353
|
+
node.body_statement.accept(self)
|
|
3354
|
+
end
|
|
3355
|
+
|
|
3356
|
+
def visit_goto_statement(node)
|
|
3357
|
+
end
|
|
3358
|
+
|
|
3359
|
+
def visit_continue_statement(node)
|
|
3360
|
+
end
|
|
3361
|
+
|
|
3362
|
+
def visit_break_statement(node)
|
|
3363
|
+
end
|
|
3364
|
+
|
|
3365
|
+
def visit_return_statement(node)
|
|
3366
|
+
node.expression.accept(self) if node.expression
|
|
3367
|
+
end
|
|
3368
|
+
|
|
3369
|
+
def visit_translation_unit(node)
|
|
3370
|
+
node.external_declarations.each { |decl| decl.accept(self) }
|
|
3371
|
+
end
|
|
3372
|
+
|
|
3373
|
+
def visit_kandr_function_definition(node)
|
|
3374
|
+
node.declaration_specifiers.accept(self) if node.declaration_specifiers
|
|
3375
|
+
node.declarator.accept(self)
|
|
3376
|
+
node.parameter_definitions.each { |pdef| pdef.accept(self) }
|
|
3377
|
+
node.function_body.accept(self)
|
|
3378
|
+
node.type_declaration.accept(self) if node.type_declaration
|
|
3379
|
+
end
|
|
3380
|
+
|
|
3381
|
+
def visit_ansi_function_definition(node)
|
|
3382
|
+
node.declaration_specifiers.accept(self) if node.declaration_specifiers
|
|
3383
|
+
node.declarator.accept(self)
|
|
3384
|
+
node.parameter_definitions.each { |pdef| pdef.accept(self) }
|
|
3385
|
+
node.function_body.accept(self)
|
|
3386
|
+
node.type_declaration.accept(self) if node.type_declaration
|
|
3387
|
+
end
|
|
3388
|
+
|
|
3389
|
+
def visit_parameter_definition(node)
|
|
3390
|
+
end
|
|
3391
|
+
|
|
3392
|
+
def visit_type_name(node)
|
|
3393
|
+
node.specifier_qualifier_list.accept(self)
|
|
3394
|
+
node.abstract_declarator.accept(self) if node.abstract_declarator
|
|
3395
|
+
node.type_declaration.accept(self) if node.type_declaration
|
|
3396
|
+
end
|
|
3397
|
+
|
|
3398
|
+
def visit_pointer_abstract_declarator(node)
|
|
3399
|
+
node.base.accept(self) if node.base
|
|
3400
|
+
end
|
|
3401
|
+
|
|
3402
|
+
def visit_grouped_abstract_declarator(node)
|
|
3403
|
+
node.base.accept(self)
|
|
3404
|
+
end
|
|
3405
|
+
|
|
3406
|
+
def visit_array_abstract_declarator(node)
|
|
3407
|
+
node.base.accept(self) if node.base
|
|
3408
|
+
node.size_expression.accept(self) if node.size_expression
|
|
3409
|
+
end
|
|
3410
|
+
|
|
3411
|
+
def visit_function_abstract_declarator(node)
|
|
3412
|
+
node.base.accept(self) if node.base
|
|
3413
|
+
node.parameter_type_list.accept(self) if node.parameter_type_list
|
|
3414
|
+
end
|
|
3415
|
+
|
|
3416
|
+
def visit_initializer(node)
|
|
3417
|
+
case
|
|
3418
|
+
when node.expression
|
|
3419
|
+
node.expression.accept(self)
|
|
3420
|
+
when node.initializers
|
|
3421
|
+
node.initializers.each { |ini| ini.accept(self) }
|
|
3422
|
+
end
|
|
3423
|
+
end
|
|
3424
|
+
end
|
|
3425
|
+
|
|
3426
|
+
class SyntaxTreeMulticastVisitor < SyntaxTreeVisitor
|
|
3427
|
+
extend Pluggable
|
|
3428
|
+
|
|
3429
|
+
def_plugin :enter_error_expression
|
|
3430
|
+
def_plugin :leave_error_expression
|
|
3431
|
+
def_plugin :enter_object_specifier
|
|
3432
|
+
def_plugin :leave_object_specifier
|
|
3433
|
+
def_plugin :enter_constant_specifier
|
|
3434
|
+
def_plugin :leave_constant_specifier
|
|
3435
|
+
def_plugin :enter_string_literal_specifier
|
|
3436
|
+
def_plugin :leave_string_literal_specifier
|
|
3437
|
+
def_plugin :enter_null_constant_specifier
|
|
3438
|
+
def_plugin :leave_null_constant_specifier
|
|
3439
|
+
def_plugin :enter_grouped_expression
|
|
3440
|
+
def_plugin :leave_grouped_expression
|
|
3441
|
+
def_plugin :enter_array_subscript_expression
|
|
3442
|
+
def_plugin :leave_array_subscript_expression
|
|
3443
|
+
def_plugin :enter_function_call_expression
|
|
3444
|
+
def_plugin :leave_function_call_expression
|
|
3445
|
+
def_plugin :enter_member_access_by_value_expression
|
|
3446
|
+
def_plugin :leave_member_access_by_value_expression
|
|
3447
|
+
def_plugin :enter_member_access_by_pointer_expression
|
|
3448
|
+
def_plugin :leave_member_access_by_pointer_expression
|
|
3449
|
+
def_plugin :enter_bit_access_by_value_expression
|
|
3450
|
+
def_plugin :leave_bit_access_by_value_expression
|
|
3451
|
+
def_plugin :enter_bit_access_by_pointer_expression
|
|
3452
|
+
def_plugin :leave_bit_access_by_pointer_expression
|
|
3453
|
+
def_plugin :enter_postfix_increment_expression
|
|
3454
|
+
def_plugin :leave_postfix_increment_expression
|
|
3455
|
+
def_plugin :enter_postfix_decrement_expression
|
|
3456
|
+
def_plugin :leave_postfix_decrement_expression
|
|
3457
|
+
def_plugin :enter_compound_literal_expression
|
|
3458
|
+
def_plugin :leave_compound_literal_expression
|
|
3459
|
+
def_plugin :enter_prefix_increment_expression
|
|
3460
|
+
def_plugin :leave_prefix_increment_expression
|
|
3461
|
+
def_plugin :enter_prefix_decrement_expression
|
|
3462
|
+
def_plugin :leave_prefix_decrement_expression
|
|
3463
|
+
def_plugin :enter_address_expression
|
|
3464
|
+
def_plugin :leave_address_expression
|
|
3465
|
+
def_plugin :enter_indirection_expression
|
|
3466
|
+
def_plugin :leave_indirection_expression
|
|
3467
|
+
def_plugin :enter_unary_arithmetic_expression
|
|
3468
|
+
def_plugin :leave_unary_arithmetic_expression
|
|
3469
|
+
def_plugin :enter_sizeof_expression
|
|
3470
|
+
def_plugin :leave_sizeof_expression
|
|
3471
|
+
def_plugin :enter_sizeof_type_expression
|
|
3472
|
+
def_plugin :leave_sizeof_type_expression
|
|
3473
|
+
def_plugin :enter_alignof_expression
|
|
3474
|
+
def_plugin :leave_alignof_expression
|
|
3475
|
+
def_plugin :enter_alignof_type_expression
|
|
3476
|
+
def_plugin :leave_alignof_type_expression
|
|
3477
|
+
def_plugin :enter_cast_expression
|
|
3478
|
+
def_plugin :leave_cast_expression
|
|
3479
|
+
def_plugin :enter_multiplicative_expression
|
|
3480
|
+
def_plugin :leave_multiplicative_expression
|
|
3481
|
+
def_plugin :enter_additive_expression
|
|
3482
|
+
def_plugin :leave_additive_expression
|
|
3483
|
+
def_plugin :enter_shift_expression
|
|
3484
|
+
def_plugin :leave_shift_expression
|
|
3485
|
+
def_plugin :enter_relational_expression
|
|
3486
|
+
def_plugin :leave_relational_expression
|
|
3487
|
+
def_plugin :enter_equality_expression
|
|
3488
|
+
def_plugin :leave_equality_expression
|
|
3489
|
+
def_plugin :enter_and_expression
|
|
3490
|
+
def_plugin :leave_and_expression
|
|
3491
|
+
def_plugin :enter_exclusive_or_expression
|
|
3492
|
+
def_plugin :leave_exclusive_or_expression
|
|
3493
|
+
def_plugin :enter_inclusive_or_expression
|
|
3494
|
+
def_plugin :leave_inclusive_or_expression
|
|
3495
|
+
def_plugin :enter_logical_and_expression
|
|
3496
|
+
def_plugin :leave_logical_and_expression
|
|
3497
|
+
def_plugin :enter_logical_or_expression
|
|
3498
|
+
def_plugin :leave_logical_or_expression
|
|
3499
|
+
def_plugin :enter_conditional_expression
|
|
3500
|
+
def_plugin :leave_conditional_expression
|
|
3501
|
+
def_plugin :enter_simple_assignment_expression
|
|
3502
|
+
def_plugin :leave_simple_assignment_expression
|
|
3503
|
+
def_plugin :enter_compound_assignment_expression
|
|
3504
|
+
def_plugin :leave_compound_assignment_expression
|
|
3505
|
+
def_plugin :enter_comma_separated_expression
|
|
3506
|
+
def_plugin :leave_comma_separated_expression
|
|
3507
|
+
def_plugin :enter_declaration
|
|
3508
|
+
def_plugin :leave_declaration
|
|
3509
|
+
def_plugin :enter_function_declaration
|
|
3510
|
+
def_plugin :leave_function_declaration
|
|
3511
|
+
def_plugin :enter_variable_declaration
|
|
3512
|
+
def_plugin :leave_variable_declaration
|
|
3513
|
+
def_plugin :enter_variable_definition
|
|
3514
|
+
def_plugin :leave_variable_definition
|
|
3515
|
+
def_plugin :enter_typedef_declaration
|
|
3516
|
+
def_plugin :leave_typedef_declaration
|
|
3517
|
+
def_plugin :enter_struct_type_declaration
|
|
3518
|
+
def_plugin :leave_struct_type_declaration
|
|
3519
|
+
def_plugin :enter_union_type_declaration
|
|
3520
|
+
def_plugin :leave_union_type_declaration
|
|
3521
|
+
def_plugin :enter_enum_type_declaration
|
|
3522
|
+
def_plugin :leave_enum_type_declaration
|
|
3523
|
+
def_plugin :enter_declaration_specifiers
|
|
3524
|
+
def_plugin :leave_declaration_specifiers
|
|
3525
|
+
def_plugin :enter_init_declarator
|
|
3526
|
+
def_plugin :leave_init_declarator
|
|
3527
|
+
def_plugin :enter_standard_type_specifier
|
|
3528
|
+
def_plugin :leave_standard_type_specifier
|
|
3529
|
+
def_plugin :enter_typedef_type_specifier
|
|
3530
|
+
def_plugin :leave_typedef_type_specifier
|
|
3531
|
+
def_plugin :enter_struct_specifier
|
|
3532
|
+
def_plugin :leave_struct_specifier
|
|
3533
|
+
def_plugin :enter_union_specifier
|
|
3534
|
+
def_plugin :leave_union_specifier
|
|
3535
|
+
def_plugin :enter_struct_declaration
|
|
3536
|
+
def_plugin :leave_struct_declaration
|
|
3537
|
+
def_plugin :enter_member_declaration
|
|
3538
|
+
def_plugin :leave_member_declaration
|
|
3539
|
+
def_plugin :enter_specifier_qualifier_list
|
|
3540
|
+
def_plugin :leave_specifier_qualifier_list
|
|
3541
|
+
def_plugin :enter_struct_declarator
|
|
3542
|
+
def_plugin :leave_struct_declarator
|
|
3543
|
+
def_plugin :enter_enum_specifier
|
|
3544
|
+
def_plugin :leave_enum_specifier
|
|
3545
|
+
def_plugin :enter_enumerator
|
|
3546
|
+
def_plugin :leave_enumerator
|
|
3547
|
+
def_plugin :enter_typeof_type_specifier
|
|
3548
|
+
def_plugin :leave_typeof_type_specifier
|
|
3549
|
+
def_plugin :enter_identifier_declarator
|
|
3550
|
+
def_plugin :leave_identifier_declarator
|
|
3551
|
+
def_plugin :enter_grouped_declarator
|
|
3552
|
+
def_plugin :leave_grouped_declarator
|
|
3553
|
+
def_plugin :enter_array_declarator
|
|
3554
|
+
def_plugin :leave_array_declarator
|
|
3555
|
+
def_plugin :enter_ansi_function_declarator
|
|
3556
|
+
def_plugin :leave_ansi_function_declarator
|
|
3557
|
+
def_plugin :enter_kandr_function_declarator
|
|
3558
|
+
def_plugin :leave_kandr_function_declarator
|
|
3559
|
+
def_plugin :enter_abbreviated_function_declarator
|
|
3560
|
+
def_plugin :leave_abbreviated_function_declarator
|
|
3561
|
+
def_plugin :enter_parameter_type_list
|
|
3562
|
+
def_plugin :leave_parameter_type_list
|
|
3563
|
+
def_plugin :enter_parameter_declaration
|
|
3564
|
+
def_plugin :leave_parameter_declaration
|
|
3565
|
+
def_plugin :enter_error_statement
|
|
3566
|
+
def_plugin :leave_error_statement
|
|
3567
|
+
def_plugin :enter_generic_labeled_statement
|
|
3568
|
+
def_plugin :leave_generic_labeled_statement
|
|
3569
|
+
def_plugin :enter_case_labeled_statement
|
|
3570
|
+
def_plugin :leave_case_labeled_statement
|
|
3571
|
+
def_plugin :enter_default_labeled_statement
|
|
3572
|
+
def_plugin :leave_default_labeled_statement
|
|
3573
|
+
def_plugin :enter_compound_statement
|
|
3574
|
+
def_plugin :leave_compound_statement
|
|
3575
|
+
def_plugin :enter_expression_statement
|
|
3576
|
+
def_plugin :leave_expression_statement
|
|
3577
|
+
def_plugin :enter_if_statement
|
|
3578
|
+
def_plugin :leave_if_statement
|
|
3579
|
+
def_plugin :enter_if_else_statement
|
|
3580
|
+
def_plugin :leave_if_else_statement
|
|
3581
|
+
def_plugin :enter_switch_statement
|
|
3582
|
+
def_plugin :leave_switch_statement
|
|
3583
|
+
def_plugin :enter_while_statement
|
|
3584
|
+
def_plugin :leave_while_statement
|
|
3585
|
+
def_plugin :enter_do_statement
|
|
3586
|
+
def_plugin :leave_do_statement
|
|
3587
|
+
def_plugin :enter_for_statement
|
|
3588
|
+
def_plugin :leave_for_statement
|
|
3589
|
+
def_plugin :enter_c99_for_statement
|
|
3590
|
+
def_plugin :leave_c99_for_statement
|
|
3591
|
+
def_plugin :enter_goto_statement
|
|
3592
|
+
def_plugin :leave_goto_statement
|
|
3593
|
+
def_plugin :enter_continue_statement
|
|
3594
|
+
def_plugin :leave_continue_statement
|
|
3595
|
+
def_plugin :enter_break_statement
|
|
3596
|
+
def_plugin :leave_break_statement
|
|
3597
|
+
def_plugin :enter_return_statement
|
|
3598
|
+
def_plugin :leave_return_statement
|
|
3599
|
+
def_plugin :enter_translation_unit
|
|
3600
|
+
def_plugin :leave_translation_unit
|
|
3601
|
+
def_plugin :enter_kandr_function_definition
|
|
3602
|
+
def_plugin :leave_kandr_function_definition
|
|
3603
|
+
def_plugin :enter_ansi_function_definition
|
|
3604
|
+
def_plugin :leave_ansi_function_definition
|
|
3605
|
+
def_plugin :enter_parameter_definition
|
|
3606
|
+
def_plugin :leave_parameter_definition
|
|
3607
|
+
def_plugin :enter_type_name
|
|
3608
|
+
def_plugin :leave_type_name
|
|
3609
|
+
def_plugin :enter_pointer_abstract_declarator
|
|
3610
|
+
def_plugin :leave_pointer_abstract_declarator
|
|
3611
|
+
def_plugin :enter_grouped_abstract_declarator
|
|
3612
|
+
def_plugin :leave_grouped_abstract_declarator
|
|
3613
|
+
def_plugin :enter_array_abstract_declarator
|
|
3614
|
+
def_plugin :leave_array_abstract_declarator
|
|
3615
|
+
def_plugin :enter_function_abstract_declarator
|
|
3616
|
+
def_plugin :leave_function_abstract_declarator
|
|
3617
|
+
def_plugin :enter_initializer
|
|
3618
|
+
def_plugin :leave_initializer
|
|
3619
|
+
|
|
3620
|
+
def visit_error_expression(node)
|
|
3621
|
+
visit_with_notifying(__method__, node) { super }
|
|
3622
|
+
end
|
|
3623
|
+
|
|
3624
|
+
def visit_object_specifier(node)
|
|
3625
|
+
visit_with_notifying(__method__, node) { super }
|
|
3626
|
+
end
|
|
3627
|
+
|
|
3628
|
+
def visit_constant_specifier(node)
|
|
3629
|
+
visit_with_notifying(__method__, node) { super }
|
|
3630
|
+
end
|
|
3631
|
+
|
|
3632
|
+
def visit_string_literal_specifier(node)
|
|
3633
|
+
visit_with_notifying(__method__, node) { super }
|
|
3634
|
+
end
|
|
3635
|
+
|
|
3636
|
+
def visit_null_constant_specifier(node)
|
|
3637
|
+
visit_with_notifying(__method__, node) { super }
|
|
3638
|
+
end
|
|
3639
|
+
|
|
3640
|
+
def visit_grouped_expression(node)
|
|
3641
|
+
visit_with_notifying(__method__, node) { super }
|
|
3642
|
+
end
|
|
3643
|
+
|
|
3644
|
+
def visit_array_subscript_expression(node)
|
|
3645
|
+
visit_with_notifying(__method__, node) { super }
|
|
3646
|
+
end
|
|
3647
|
+
|
|
3648
|
+
def visit_function_call_expression(node)
|
|
3649
|
+
visit_with_notifying(__method__, node) { super }
|
|
3650
|
+
end
|
|
3651
|
+
|
|
3652
|
+
def visit_member_access_by_value_expression(node)
|
|
3653
|
+
visit_with_notifying(__method__, node) { super }
|
|
3654
|
+
end
|
|
3655
|
+
|
|
3656
|
+
def visit_member_access_by_pointer_expression(node)
|
|
3657
|
+
visit_with_notifying(__method__, node) { super }
|
|
3658
|
+
end
|
|
3659
|
+
|
|
3660
|
+
def visit_bit_access_by_value_expression(node)
|
|
3661
|
+
visit_with_notifying(__method__, node) { super }
|
|
3662
|
+
end
|
|
3663
|
+
|
|
3664
|
+
def visit_bit_access_by_pointer_expression(node)
|
|
3665
|
+
visit_with_notifying(__method__, node) { super }
|
|
3666
|
+
end
|
|
3667
|
+
|
|
3668
|
+
def visit_postfix_increment_expression(node)
|
|
3669
|
+
visit_with_notifying(__method__, node) { super }
|
|
3670
|
+
end
|
|
3671
|
+
|
|
3672
|
+
def visit_postfix_decrement_expression(node)
|
|
3673
|
+
visit_with_notifying(__method__, node) { super }
|
|
3674
|
+
end
|
|
3675
|
+
|
|
3676
|
+
def visit_compound_literal_expression(node)
|
|
3677
|
+
visit_with_notifying(__method__, node) { super }
|
|
3678
|
+
end
|
|
3679
|
+
|
|
3680
|
+
def visit_prefix_increment_expression(node)
|
|
3681
|
+
visit_with_notifying(__method__, node) { super }
|
|
3682
|
+
end
|
|
3683
|
+
|
|
3684
|
+
def visit_prefix_decrement_expression(node)
|
|
3685
|
+
visit_with_notifying(__method__, node) { super }
|
|
3686
|
+
end
|
|
3687
|
+
|
|
3688
|
+
def visit_address_expression(node)
|
|
3689
|
+
visit_with_notifying(__method__, node) { super }
|
|
3690
|
+
end
|
|
3691
|
+
|
|
3692
|
+
def visit_indirection_expression(node)
|
|
3693
|
+
visit_with_notifying(__method__, node) { super }
|
|
3694
|
+
end
|
|
3695
|
+
|
|
3696
|
+
def visit_unary_arithmetic_expression(node)
|
|
3697
|
+
visit_with_notifying(__method__, node) { super }
|
|
3698
|
+
end
|
|
3699
|
+
|
|
3700
|
+
def visit_sizeof_expression(node)
|
|
3701
|
+
visit_with_notifying(__method__, node) { super }
|
|
3702
|
+
end
|
|
3703
|
+
|
|
3704
|
+
def visit_sizeof_type_expression(node)
|
|
3705
|
+
visit_with_notifying(__method__, node) { super }
|
|
3706
|
+
end
|
|
3707
|
+
|
|
3708
|
+
def visit_alignof_expression(node)
|
|
3709
|
+
visit_with_notifying(__method__, node) { super }
|
|
3710
|
+
end
|
|
3711
|
+
|
|
3712
|
+
def visit_alignof_type_expression(node)
|
|
3713
|
+
visit_with_notifying(__method__, node) { super }
|
|
3714
|
+
end
|
|
3715
|
+
|
|
3716
|
+
def visit_cast_expression(node)
|
|
3717
|
+
visit_with_notifying(__method__, node) { super }
|
|
3718
|
+
end
|
|
3719
|
+
|
|
3720
|
+
def visit_multiplicative_expression(node)
|
|
3721
|
+
visit_with_notifying(__method__, node) { super }
|
|
3722
|
+
end
|
|
3723
|
+
|
|
3724
|
+
def visit_additive_expression(node)
|
|
3725
|
+
visit_with_notifying(__method__, node) { super }
|
|
3726
|
+
end
|
|
3727
|
+
|
|
3728
|
+
def visit_shift_expression(node)
|
|
3729
|
+
visit_with_notifying(__method__, node) { super }
|
|
3730
|
+
end
|
|
3731
|
+
|
|
3732
|
+
def visit_relational_expression(node)
|
|
3733
|
+
visit_with_notifying(__method__, node) { super }
|
|
3734
|
+
end
|
|
3735
|
+
|
|
3736
|
+
def visit_equality_expression(node)
|
|
3737
|
+
visit_with_notifying(__method__, node) { super }
|
|
3738
|
+
end
|
|
3739
|
+
|
|
3740
|
+
def visit_and_expression(node)
|
|
3741
|
+
visit_with_notifying(__method__, node) { super }
|
|
3742
|
+
end
|
|
3743
|
+
|
|
3744
|
+
def visit_exclusive_or_expression(node)
|
|
3745
|
+
visit_with_notifying(__method__, node) { super }
|
|
3746
|
+
end
|
|
3747
|
+
|
|
3748
|
+
def visit_inclusive_or_expression(node)
|
|
3749
|
+
visit_with_notifying(__method__, node) { super }
|
|
3750
|
+
end
|
|
3751
|
+
|
|
3752
|
+
def visit_logical_and_expression(node)
|
|
3753
|
+
visit_with_notifying(__method__, node) { super }
|
|
3754
|
+
end
|
|
3755
|
+
|
|
3756
|
+
def visit_logical_or_expression(node)
|
|
3757
|
+
visit_with_notifying(__method__, node) { super }
|
|
3758
|
+
end
|
|
3759
|
+
|
|
3760
|
+
def visit_conditional_expression(node)
|
|
3761
|
+
visit_with_notifying(__method__, node) { super }
|
|
3762
|
+
end
|
|
3763
|
+
|
|
3764
|
+
def visit_simple_assignment_expression(node)
|
|
3765
|
+
visit_with_notifying(__method__, node) { super }
|
|
3766
|
+
end
|
|
3767
|
+
|
|
3768
|
+
def visit_compound_assignment_expression(node)
|
|
3769
|
+
visit_with_notifying(__method__, node) { super }
|
|
3770
|
+
end
|
|
3771
|
+
|
|
3772
|
+
def visit_comma_separated_expression(node)
|
|
3773
|
+
visit_with_notifying(__method__, node) { super }
|
|
3774
|
+
end
|
|
3775
|
+
|
|
3776
|
+
def visit_declaration(node)
|
|
3777
|
+
visit_with_notifying(__method__, node) { super }
|
|
3778
|
+
end
|
|
3779
|
+
|
|
3780
|
+
def visit_function_declaration(node)
|
|
3781
|
+
visit_with_notifying(__method__, node) { super }
|
|
3782
|
+
end
|
|
3783
|
+
|
|
3784
|
+
def visit_variable_declaration(node)
|
|
3785
|
+
visit_with_notifying(__method__, node) { super }
|
|
3786
|
+
end
|
|
3787
|
+
|
|
3788
|
+
def visit_variable_definition(node)
|
|
3789
|
+
visit_with_notifying(__method__, node) { super }
|
|
3790
|
+
end
|
|
3791
|
+
|
|
3792
|
+
def visit_typedef_declaration(node)
|
|
3793
|
+
visit_with_notifying(__method__, node) { super }
|
|
3794
|
+
end
|
|
3795
|
+
|
|
3796
|
+
def visit_struct_type_declaration(node)
|
|
3797
|
+
visit_with_notifying(__method__, node) { super }
|
|
3798
|
+
end
|
|
3799
|
+
|
|
3800
|
+
def visit_union_type_declaration(node)
|
|
3801
|
+
visit_with_notifying(__method__, node) { super }
|
|
3802
|
+
end
|
|
3803
|
+
|
|
3804
|
+
def visit_enum_type_declaration(node)
|
|
3805
|
+
visit_with_notifying(__method__, node) { super }
|
|
3806
|
+
end
|
|
3807
|
+
|
|
3808
|
+
def visit_declaration_specifiers(node)
|
|
3809
|
+
visit_with_notifying(__method__, node) { super }
|
|
3810
|
+
end
|
|
3811
|
+
|
|
3812
|
+
def visit_init_declarator(node)
|
|
3813
|
+
visit_with_notifying(__method__, node) { super }
|
|
3814
|
+
end
|
|
3815
|
+
|
|
3816
|
+
def visit_standard_type_specifier(node)
|
|
3817
|
+
visit_with_notifying(__method__, node) { super }
|
|
3818
|
+
end
|
|
3819
|
+
|
|
3820
|
+
def visit_typedef_type_specifier(node)
|
|
3821
|
+
visit_with_notifying(__method__, node) { super }
|
|
3822
|
+
end
|
|
3823
|
+
|
|
3824
|
+
def visit_struct_specifier(node)
|
|
3825
|
+
visit_with_notifying(__method__, node) { super }
|
|
3826
|
+
end
|
|
3827
|
+
|
|
3828
|
+
def visit_union_specifier(node)
|
|
3829
|
+
visit_with_notifying(__method__, node) { super }
|
|
3830
|
+
end
|
|
3831
|
+
|
|
3832
|
+
def visit_struct_declaration(node)
|
|
3833
|
+
visit_with_notifying(__method__, node) { super }
|
|
3834
|
+
end
|
|
3835
|
+
|
|
3836
|
+
def visit_member_declaration(node)
|
|
3837
|
+
visit_with_notifying(__method__, node) { super }
|
|
3838
|
+
end
|
|
3839
|
+
|
|
3840
|
+
def visit_specifier_qualifier_list(node)
|
|
3841
|
+
visit_with_notifying(__method__, node) { super }
|
|
3842
|
+
end
|
|
3843
|
+
|
|
3844
|
+
def visit_struct_declarator(node)
|
|
3845
|
+
visit_with_notifying(__method__, node) { super }
|
|
3846
|
+
end
|
|
3847
|
+
|
|
3848
|
+
def visit_enum_specifier(node)
|
|
3849
|
+
visit_with_notifying(__method__, node) { super }
|
|
3850
|
+
end
|
|
3851
|
+
|
|
3852
|
+
def visit_enumerator(node)
|
|
3853
|
+
visit_with_notifying(__method__, node) { super }
|
|
3854
|
+
end
|
|
3855
|
+
|
|
3856
|
+
def visit_typeof_type_specifier(node)
|
|
3857
|
+
visit_with_notifying(__method__, node) { super }
|
|
3858
|
+
end
|
|
3859
|
+
|
|
3860
|
+
def visit_identifier_declarator(node)
|
|
3861
|
+
visit_with_notifying(__method__, node) { super }
|
|
3862
|
+
end
|
|
3863
|
+
|
|
3864
|
+
def visit_grouped_declarator(node)
|
|
3865
|
+
visit_with_notifying(__method__, node) { super }
|
|
3866
|
+
end
|
|
3867
|
+
|
|
3868
|
+
def visit_array_declarator(node)
|
|
3869
|
+
visit_with_notifying(__method__, node) { super }
|
|
3870
|
+
end
|
|
3871
|
+
|
|
3872
|
+
def visit_ansi_function_declarator(node)
|
|
3873
|
+
visit_with_notifying(__method__, node) { super }
|
|
3874
|
+
end
|
|
3875
|
+
|
|
3876
|
+
def visit_kandr_function_declarator(node)
|
|
3877
|
+
visit_with_notifying(__method__, node) { super }
|
|
3878
|
+
end
|
|
3879
|
+
|
|
3880
|
+
def visit_abbreviated_function_declarator(node)
|
|
3881
|
+
visit_with_notifying(__method__, node) { super }
|
|
3882
|
+
end
|
|
3883
|
+
|
|
3884
|
+
def visit_parameter_type_list(node)
|
|
3885
|
+
visit_with_notifying(__method__, node) { super }
|
|
3886
|
+
end
|
|
3887
|
+
|
|
3888
|
+
def visit_parameter_declaration(node)
|
|
3889
|
+
visit_with_notifying(__method__, node) { super }
|
|
3890
|
+
end
|
|
3891
|
+
|
|
3892
|
+
def visit_error_statement(node)
|
|
3893
|
+
visit_with_notifying(__method__, node) { super }
|
|
3894
|
+
end
|
|
3895
|
+
|
|
3896
|
+
def visit_generic_labeled_statement(node)
|
|
3897
|
+
visit_with_notifying(__method__, node) { super }
|
|
3898
|
+
end
|
|
3899
|
+
|
|
3900
|
+
def visit_case_labeled_statement(node)
|
|
3901
|
+
visit_with_notifying(__method__, node) { super }
|
|
3902
|
+
end
|
|
3903
|
+
|
|
3904
|
+
def visit_default_labeled_statement(node)
|
|
3905
|
+
visit_with_notifying(__method__, node) { super }
|
|
3906
|
+
end
|
|
3907
|
+
|
|
3908
|
+
def visit_compound_statement(node)
|
|
3909
|
+
visit_with_notifying(__method__, node) { super }
|
|
3910
|
+
end
|
|
3911
|
+
|
|
3912
|
+
def visit_expression_statement(node)
|
|
3913
|
+
visit_with_notifying(__method__, node) { super }
|
|
3914
|
+
end
|
|
3915
|
+
|
|
3916
|
+
def visit_if_statement(node)
|
|
3917
|
+
visit_with_notifying(__method__, node) { super }
|
|
3918
|
+
end
|
|
3919
|
+
|
|
3920
|
+
def visit_if_else_statement(node)
|
|
3921
|
+
visit_with_notifying(__method__, node) { super }
|
|
3922
|
+
end
|
|
3923
|
+
|
|
3924
|
+
def visit_switch_statement(node)
|
|
3925
|
+
visit_with_notifying(__method__, node) { super }
|
|
3926
|
+
end
|
|
3927
|
+
|
|
3928
|
+
def visit_while_statement(node)
|
|
3929
|
+
visit_with_notifying(__method__, node) { super }
|
|
3930
|
+
end
|
|
3931
|
+
|
|
3932
|
+
def visit_do_statement(node)
|
|
3933
|
+
visit_with_notifying(__method__, node) { super }
|
|
3934
|
+
end
|
|
3935
|
+
|
|
3936
|
+
def visit_for_statement(node)
|
|
3937
|
+
visit_with_notifying(__method__, node) { super }
|
|
3938
|
+
end
|
|
3939
|
+
|
|
3940
|
+
def visit_c99_for_statement(node)
|
|
3941
|
+
visit_with_notifying(__method__, node) { super }
|
|
3942
|
+
end
|
|
3943
|
+
|
|
3944
|
+
def visit_goto_statement(node)
|
|
3945
|
+
visit_with_notifying(__method__, node) { super }
|
|
3946
|
+
end
|
|
3947
|
+
|
|
3948
|
+
def visit_continue_statement(node)
|
|
3949
|
+
visit_with_notifying(__method__, node) { super }
|
|
3950
|
+
end
|
|
3951
|
+
|
|
3952
|
+
def visit_break_statement(node)
|
|
3953
|
+
visit_with_notifying(__method__, node) { super }
|
|
3954
|
+
end
|
|
3955
|
+
|
|
3956
|
+
def visit_return_statement(node)
|
|
3957
|
+
visit_with_notifying(__method__, node) { super }
|
|
3958
|
+
end
|
|
3959
|
+
|
|
3960
|
+
def visit_translation_unit(node)
|
|
3961
|
+
visit_with_notifying(__method__, node) { super }
|
|
3962
|
+
end
|
|
3963
|
+
|
|
3964
|
+
def visit_kandr_function_definition(node)
|
|
3965
|
+
visit_with_notifying(__method__, node) { super }
|
|
3966
|
+
end
|
|
3967
|
+
|
|
3968
|
+
def visit_ansi_function_definition(node)
|
|
3969
|
+
visit_with_notifying(__method__, node) { super }
|
|
3970
|
+
end
|
|
3971
|
+
|
|
3972
|
+
def visit_parameter_definition(node)
|
|
3973
|
+
visit_with_notifying(__method__, node) { super }
|
|
3974
|
+
end
|
|
3975
|
+
|
|
3976
|
+
def visit_type_name(node)
|
|
3977
|
+
visit_with_notifying(__method__, node) { super }
|
|
3978
|
+
end
|
|
3979
|
+
|
|
3980
|
+
def visit_pointer_abstract_declarator(node)
|
|
3981
|
+
visit_with_notifying(__method__, node) { super }
|
|
3982
|
+
end
|
|
3983
|
+
|
|
3984
|
+
def visit_grouped_abstract_declarator(node)
|
|
3985
|
+
visit_with_notifying(__method__, node) { super }
|
|
3986
|
+
end
|
|
3987
|
+
|
|
3988
|
+
def visit_array_abstract_declarator(node)
|
|
3989
|
+
visit_with_notifying(__method__, node) { super }
|
|
3990
|
+
end
|
|
3991
|
+
|
|
3992
|
+
def visit_function_abstract_declarator(node)
|
|
3993
|
+
visit_with_notifying(__method__, node) { super }
|
|
3994
|
+
end
|
|
3995
|
+
|
|
3996
|
+
def visit_initializer(node)
|
|
3997
|
+
visit_with_notifying(__method__, node) { super }
|
|
3998
|
+
end
|
|
3999
|
+
|
|
4000
|
+
private
|
|
4001
|
+
def visit_with_notifying(caller_method, node, &block)
|
|
4002
|
+
suffix = caller_method.to_s.sub(/\Avisit_/, "")
|
|
4003
|
+
__send__("enter_#{suffix}").invoke(node)
|
|
4004
|
+
yield
|
|
4005
|
+
__send__("leave_#{suffix}").invoke(node)
|
|
4006
|
+
end
|
|
4007
|
+
end
|
|
4008
|
+
|
|
4009
|
+
class ObjectSpecifierCollector < SyntaxTreeVisitor
|
|
4010
|
+
def initialize
|
|
4011
|
+
@object_specifiers = []
|
|
4012
|
+
end
|
|
4013
|
+
|
|
4014
|
+
attr_reader :object_specifiers
|
|
4015
|
+
|
|
4016
|
+
def visit_object_specifier(node)
|
|
4017
|
+
super
|
|
4018
|
+
@object_specifiers.push(node)
|
|
4019
|
+
end
|
|
4020
|
+
end
|
|
4021
|
+
|
|
4022
|
+
class IdentifierDeclaratorCollector < SyntaxTreeVisitor
|
|
4023
|
+
def initialize
|
|
4024
|
+
@identifier_declarators = []
|
|
4025
|
+
end
|
|
4026
|
+
|
|
4027
|
+
attr_reader :identifier_declarators
|
|
4028
|
+
|
|
4029
|
+
def visit_identifier_declarator(node)
|
|
4030
|
+
super
|
|
4031
|
+
@identifier_declarators.push(node)
|
|
4032
|
+
end
|
|
4033
|
+
end
|
|
4034
|
+
|
|
4035
|
+
class FunctionDeclaratorCollector < SyntaxTreeVisitor
|
|
4036
|
+
def initialize
|
|
4037
|
+
@function_declarators = []
|
|
4038
|
+
end
|
|
4039
|
+
|
|
4040
|
+
attr_reader :function_declarators
|
|
4041
|
+
|
|
4042
|
+
def visit_ansi_function_declarator(node)
|
|
4043
|
+
@function_declarators.push(node)
|
|
4044
|
+
super
|
|
4045
|
+
end
|
|
4046
|
+
|
|
4047
|
+
def visit_kandr_function_declarator(node)
|
|
4048
|
+
@function_declarators.push(node)
|
|
4049
|
+
super
|
|
4050
|
+
end
|
|
4051
|
+
end
|
|
4052
|
+
|
|
4053
|
+
class SimpleAssignmentExpressionCollector < SyntaxTreeVisitor
|
|
4054
|
+
def initialize
|
|
4055
|
+
@simple_assignment_expressions = []
|
|
4056
|
+
end
|
|
4057
|
+
|
|
4058
|
+
attr_reader :simple_assignment_expressions
|
|
4059
|
+
|
|
4060
|
+
def visit_simple_assignment_expression(node)
|
|
4061
|
+
super
|
|
4062
|
+
@simple_assignment_expressions.push(node)
|
|
4063
|
+
end
|
|
4064
|
+
end
|
|
4065
|
+
|
|
4066
|
+
class CompoundAssignmentExpressionCollector < SyntaxTreeVisitor
|
|
4067
|
+
def initialize
|
|
4068
|
+
@compound_assignment_expressions = []
|
|
4069
|
+
end
|
|
4070
|
+
|
|
4071
|
+
attr_reader :compound_assignment_expressions
|
|
4072
|
+
|
|
4073
|
+
def visit_compound_assignment_expression(node)
|
|
4074
|
+
super
|
|
4075
|
+
@compound_assignment_expressions.push(node)
|
|
4076
|
+
end
|
|
4077
|
+
end
|
|
4078
|
+
|
|
4079
|
+
class PrefixIncrementExpressionCollector < SyntaxTreeVisitor
|
|
4080
|
+
def initialize
|
|
4081
|
+
@prefix_increment_expressions = []
|
|
4082
|
+
end
|
|
4083
|
+
|
|
4084
|
+
attr_reader :prefix_increment_expressions
|
|
4085
|
+
|
|
4086
|
+
def visit_prefix_increment_expression(node)
|
|
4087
|
+
super
|
|
4088
|
+
@prefix_increment_expressions.push(node)
|
|
4089
|
+
end
|
|
4090
|
+
end
|
|
4091
|
+
|
|
4092
|
+
class PrefixDecrementExpressionCollector < SyntaxTreeVisitor
|
|
4093
|
+
def initialize
|
|
4094
|
+
@prefix_decrement_expressions = []
|
|
4095
|
+
end
|
|
4096
|
+
|
|
4097
|
+
attr_reader :prefix_decrement_expressions
|
|
4098
|
+
|
|
4099
|
+
def visit_prefix_decrement_expression(node)
|
|
4100
|
+
super
|
|
4101
|
+
@prefix_decrement_expressions.push(node)
|
|
4102
|
+
end
|
|
4103
|
+
end
|
|
4104
|
+
|
|
4105
|
+
class PostfixIncrementExpressionCollector < SyntaxTreeVisitor
|
|
4106
|
+
def initialize
|
|
4107
|
+
@postfix_increment_expressions = []
|
|
4108
|
+
end
|
|
4109
|
+
|
|
4110
|
+
attr_reader :postfix_increment_expressions
|
|
4111
|
+
|
|
4112
|
+
def visit_postfix_increment_expression(node)
|
|
4113
|
+
super
|
|
4114
|
+
@postfix_increment_expressions.push(node)
|
|
4115
|
+
end
|
|
4116
|
+
end
|
|
4117
|
+
|
|
4118
|
+
class PostfixDecrementExpressionCollector < SyntaxTreeVisitor
|
|
4119
|
+
def initialize
|
|
4120
|
+
@postfix_decrement_expressions = []
|
|
4121
|
+
end
|
|
4122
|
+
|
|
4123
|
+
attr_reader :postfix_decrement_expressions
|
|
4124
|
+
|
|
4125
|
+
def visit_postfix_decrement_expression(node)
|
|
4126
|
+
super
|
|
4127
|
+
@postfix_decrement_expressions.push(node)
|
|
4128
|
+
end
|
|
4129
|
+
end
|
|
4130
|
+
|
|
4131
|
+
class AdditiveExpressionCollector < SyntaxTreeVisitor
|
|
4132
|
+
def initialize
|
|
4133
|
+
@additive_expressions = []
|
|
4134
|
+
end
|
|
4135
|
+
|
|
4136
|
+
attr_reader :additive_expressions
|
|
4137
|
+
|
|
4138
|
+
def visit_additive_expression(node)
|
|
4139
|
+
super
|
|
4140
|
+
@additive_expressions.push(node)
|
|
4141
|
+
end
|
|
4142
|
+
end
|
|
4143
|
+
|
|
4144
|
+
class GenericLabeledStatementCollector < SyntaxTreeVisitor
|
|
4145
|
+
def initialize
|
|
4146
|
+
@generic_labeled_statements = []
|
|
4147
|
+
end
|
|
4148
|
+
|
|
4149
|
+
attr_reader :generic_labeled_statements
|
|
4150
|
+
|
|
4151
|
+
def visit_generic_labeled_statement(node)
|
|
4152
|
+
super
|
|
4153
|
+
@generic_labeled_statements.push(node)
|
|
4154
|
+
end
|
|
4155
|
+
end
|
|
4156
|
+
|
|
4157
|
+
class IfStatementCollector < SyntaxTreeVisitor
|
|
4158
|
+
def initialize
|
|
4159
|
+
@if_statements = []
|
|
4160
|
+
end
|
|
4161
|
+
|
|
4162
|
+
attr_reader :if_statements
|
|
4163
|
+
|
|
4164
|
+
def visit_if_statement(node)
|
|
4165
|
+
super
|
|
4166
|
+
@if_statements.push(node)
|
|
4167
|
+
end
|
|
4168
|
+
end
|
|
4169
|
+
|
|
4170
|
+
class IfElseStatementCollector < SyntaxTreeVisitor
|
|
4171
|
+
def initialize
|
|
4172
|
+
@if_else_statements = []
|
|
4173
|
+
end
|
|
4174
|
+
|
|
4175
|
+
attr_reader :if_else_statements
|
|
4176
|
+
|
|
4177
|
+
def visit_if_else_statement(node)
|
|
4178
|
+
super
|
|
4179
|
+
@if_else_statements.push(node)
|
|
4180
|
+
end
|
|
4181
|
+
end
|
|
4182
|
+
|
|
4183
|
+
class GotoStatementCollector < SyntaxTreeVisitor
|
|
4184
|
+
def initialize
|
|
4185
|
+
@goto_statements = []
|
|
4186
|
+
end
|
|
4187
|
+
|
|
4188
|
+
attr_reader :goto_statements
|
|
4189
|
+
|
|
4190
|
+
def visit_goto_statement(node)
|
|
4191
|
+
@goto_statements.push(node)
|
|
4192
|
+
end
|
|
4193
|
+
end
|
|
4194
|
+
|
|
4195
|
+
class ArrayDeclaratorCollector < SyntaxTreeVisitor
|
|
4196
|
+
def initialize
|
|
4197
|
+
@array_declarators = []
|
|
4198
|
+
end
|
|
4199
|
+
|
|
4200
|
+
attr_reader :array_declarators
|
|
4201
|
+
|
|
4202
|
+
def visit_array_declarator(node)
|
|
4203
|
+
@array_declarators.push(node)
|
|
4204
|
+
super
|
|
4205
|
+
end
|
|
4206
|
+
end
|
|
4207
|
+
|
|
4208
|
+
class ConstantSpecifierCollector < SyntaxTreeVisitor
|
|
4209
|
+
def initialize
|
|
4210
|
+
@constant_specifiers = []
|
|
4211
|
+
end
|
|
4212
|
+
|
|
4213
|
+
attr_reader :constant_specifiers
|
|
4214
|
+
|
|
4215
|
+
def visit_constant_specifier(node)
|
|
4216
|
+
@constant_specifiers.push(node)
|
|
4217
|
+
end
|
|
4218
|
+
end
|
|
4219
|
+
|
|
4220
|
+
class ExpressionExtractor < SyntaxTreeVisitor
|
|
4221
|
+
def initialize
|
|
4222
|
+
@expressions = []
|
|
4223
|
+
end
|
|
4224
|
+
|
|
4225
|
+
attr_reader :expressions
|
|
4226
|
+
|
|
4227
|
+
def push_expression(expression)
|
|
4228
|
+
@expressions.push(expression)
|
|
4229
|
+
end
|
|
4230
|
+
|
|
4231
|
+
alias :visit_grouped_expression :push_expression
|
|
4232
|
+
alias :visit_array_subscript_expression :push_expression
|
|
4233
|
+
alias :visit_function_call_expression :push_expression
|
|
4234
|
+
alias :visit_member_access_by_value_expression :push_expression
|
|
4235
|
+
alias :visit_member_access_by_pointer_expression :push_expression
|
|
4236
|
+
alias :visit_bit_access_by_value_expression :push_expression
|
|
4237
|
+
alias :visit_bit_access_by_pointer_expression :push_expression
|
|
4238
|
+
alias :visit_postfix_increment_expression :push_expression
|
|
4239
|
+
alias :visit_postfix_decrement_expression :push_expression
|
|
4240
|
+
alias :visit_compound_literal_expression :push_expression
|
|
4241
|
+
alias :visit_prefix_increment_expression :push_expression
|
|
4242
|
+
alias :visit_prefix_decrement_expression :push_expression
|
|
4243
|
+
alias :visit_address_expression :push_expression
|
|
4244
|
+
alias :visit_indirection_expression :push_expression
|
|
4245
|
+
alias :visit_unary_arithmetic_expression :push_expression
|
|
4246
|
+
alias :visit_sizeof_expression :push_expression
|
|
4247
|
+
alias :visit_alignof_expression :push_expression
|
|
4248
|
+
alias :visit_cast_expression :push_expression
|
|
4249
|
+
alias :visit_multiplicative_expression :push_expression
|
|
4250
|
+
alias :visit_additive_expression :push_expression
|
|
4251
|
+
alias :visit_shift_expression :push_expression
|
|
4252
|
+
alias :visit_relational_expression :push_expression
|
|
4253
|
+
alias :visit_equality_expression :push_expression
|
|
4254
|
+
alias :visit_and_expression :push_expression
|
|
4255
|
+
alias :visit_exclusive_or_expression :push_expression
|
|
4256
|
+
alias :visit_inclusive_or_expression :push_expression
|
|
4257
|
+
alias :visit_logical_and_expression :push_expression
|
|
4258
|
+
alias :visit_logical_or_expression :push_expression
|
|
4259
|
+
alias :visit_conditional_expression :push_expression
|
|
4260
|
+
alias :visit_simple_assignment_expression :push_expression
|
|
4261
|
+
alias :visit_compound_assignment_expression :push_expression
|
|
4262
|
+
|
|
4263
|
+
private :push_expression
|
|
4264
|
+
end
|
|
4265
|
+
|
|
4266
|
+
class ConditionalExpressionExtractor < SyntaxTreeVisitor
|
|
4267
|
+
def initialize
|
|
4268
|
+
@expressions = []
|
|
4269
|
+
end
|
|
4270
|
+
|
|
4271
|
+
attr_reader :expressions
|
|
4272
|
+
|
|
4273
|
+
def visit_conditional_expression(node)
|
|
4274
|
+
@expressions.push(node)
|
|
4275
|
+
end
|
|
4276
|
+
end
|
|
4277
|
+
|
|
4278
|
+
end
|
|
4279
|
+
end
|