2012年3月16日金曜日

AdLintを読む その3

ちょっと開いたけど、続けてSingleModuleAnalyzer#executeを読んでいく。

executeは他のSingleModuleAnalyzerクラスのメソッド同様、analyzer.rbにある。

まずLanguage#ofを呼んで、言語を設定している。ここで言っているのは日本語とか英語とかのことではなく、CとC++の切り替えだ。Languageクラスはlang.rb内にあり、ofは現状ハードコードでCを指定している。まぁC++のパースとか大変だもんな……
実際に返しているのは以下のようなもの。
class C
include AdLint::C::ScannerConstants
extend AdLint::C::Scanner
class << self
def single_module_phases
[
AdLint::Cpp::PreparePhase,
       # Snip...
].freeze
end
def check_phases
[
AdLint::Cpp::PreparePhase,
       # Snip...
].freeze
end
end
end
view raw gistfile1.rb hosted with ❤ by GitHub

続けてProgressMonitorのインスタンスを用意しReport#newにブロックを渡して内部で処理をやっている。PhaseContextのインスタンスを作り、ソースのパスとシンボルテーブルを用意してから、Langから取得したモジュール群を、次のようなコードで順にexecuteしていっている。
begin
lang.single_module_phases.each do |phase_class|
phase_class.new(context).execute
end
ensure
# snip...
end
view raw gistfile1.rb hosted with ❤ by GitHub

なかなか実際の中身に入れんなー。

0 件のコメント:

コメントを投稿