1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2006-2008 Floréal Morandat <morandat@lirmm.fr>
4 # Copyright 2008 Jean Privat <jean@pryen.org>
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
19 # Base module for nit tools that load, manipulate or transform NIT models
25 class AbstractCompiler
28 init(tool_name
: String)
30 _tool_name
= tool_name
32 register_loader
(new SrcModuleLoader)
35 # The name of the tool
36 # Used in help messages for instance
37 readable attr _tool_name
: String
43 if opt_help
.value
then
44 print
"usage: {tool_name} [options] file..."
49 if option_context
.rest
.length
== 0 then
50 print
"usage: {tool_name} [options] file..."
55 var rest
= option_context
.rest
56 var to_do
= new Array[MMModule]
57 for i
in [0..rest
.length
[ do
58 var mod
= get_module_from_filename
(rest
[i
])
65 if not to_do
.is_empty
and not opt_only_metamodel
.value
and not opt_only_parse
.value
then
70 meth perform_work
(mods
: Array[MMModule]) is abstract
72 meth dump_context_info
74 for mod
in module_hierarchy
do
77 var tab
= new Array[MMModule]
78 tab
.add_all
(module_hierarchy
)
79 var name
= module_hierarchy
.select_smallests
(tab
).join
("-")
81 var f
= new OFStream.open
("{name}.full_class_hierarchy.new.dot")
82 f
.write
(class_hierarchy
.to_dot
)
85 f
= new OFStream.open
("{name}.module_hierarchy.new.dot")
86 f
.write
(module_hierarchy
.to_dot
)
94 var p
= filename
.file_path
95 var fname
= "{p}/{name}"
96 var f
= new OFStream.open
("{fname}.class_hierarchy.new.dot")
97 f
.write
(class_specialization_hierarchy
.to_dot
)
100 f
= new OFStream.open
("{fname}.properties.log")
101 for cla
in local_classes
do
102 cla
.dump_properties
(f
)
109 redef class MMLocalClass
110 meth dump_properties
(file
: OStream)
112 file
.write
("class {self}\n")
113 for p
in global_properties
do
115 file
.write
("\t{lp}{lp.signature_for(get_type)}\n")
117 file
.write
("end # {self}\n")