1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Nit Static Analysis Framework client example.
22 redef class ToolContext
25 var opt_analysis
= new OptionEnum(["reaching-defs"], "Analysis to apply", 0, "--analysis")
29 option_context
.add_option
(opt_analysis
)
33 redef fun do_work
(mainmodule
, given_mmodules
, modelbuilder
) do
34 var toolcontext
= modelbuilder
.toolcontext
36 var analysis
: StaticAnalysis
37 var analysis_name
= toolcontext
.opt_analysis
.value_name
38 if analysis_name
== "reaching-defs" then
39 analysis
= new ReachingDefsAnalysis(modelbuilder
)
41 print
"Error: unkown analysis {analysis_name}"
46 var mainnode
= modelbuilder
.mmodule2node
(mainmodule
)
47 if mainnode
== null then return
48 analysis
.start_analysis
(mainnode
)