end
end
-# A model builder know how to load nit source files and build the associated model
+# A model builder knows how to load nit source files and build the associated model
# The important function is `parse_and_build' that does all the job.
# The others function can be used for specific tasks
class ModelBuilder
# limitations under the License.
# Interpretation of a Nit program directly on the AST
-module naiveinterpreter
+module naive_interpreter
import literal
import typing
import modelbuilder
import exprbuilder
-import naiveinterpreter
+import naive_interpreter
# Create a tool context to handle options and paths
var toolcontext = new ToolContext
# See the License for the specific language governing permissions and
# limitations under the License.
-# Program that collect various data about nit programs and libraries
+# A program that collects various data about nit programs and libraries
module nitstats
+# Collected datas are :
+# * number of modules
+# * number of classes (interface, class, enum, extern, abstract)
+# * number of class definitions and refinments
+# * number of properties
+# * number of used types and runtime classes
import modelbuilder
import exprbuilder
# Rapid type analysis is an analyse that aproximates the set of live classes
# and the set of live methods starting from the entry point of the program.
# These two sets are interdependant and computed together.
-# It is quite efficient but the type set is global such pollute each call site.
+# It is quite efficient but the type set is global and pollutes each call site.
#
# Heterogenous generics means that each intancied generic class is associated
# to a distinct runtime type.
-# Heterogenous generics has the advantage to resolve the the formal generic
+# Heterogenous generics has the advantage to resolve the formal generic
# parameters types but increase the number of types.
# More important, heterogenous generics cannot deal with infinite number of runtime
# types since the analyse tries to list them all (so some programs will be badly refused)
# * `self' is monomorphic
# * virtual types are all resolved
# * live attributes can be determined on each class
-# But the big disavantage to explode the number of runtime method: each method
+# But has the disadvantage to explode the number of runtime method: each method
# definition for each runtime type that need it
module runtime_type
end
end
+# RuntimeTypeAnalysis looks for alive runtime types in application.
+# The entry point of the analysis is the mainmodule of the application.
class RuntimeTypeAnalysis
var modelbuilder: ModelBuilder
var mainmodule: MModule
self.live_cast_types.add(mtype)
end
+ # Start the analysis.
fun run_analysis
do
while not todo.is_empty do
end
# Mark where break and continue will branch.
-# marks are either associated with a label of with a for_loop structure
+# Marks are either associated with a label of with a for_loop structure
class EscapeMark
# The name of the label (unless the mark is an anonymous loop mark)
var name: nullable String
readable var _location: nullable Location
readable var _text: String
+ # Comparisons are made on message locations.
redef fun <(other: OTHER): Bool do
if location == null then return true
if other.location == null then return false
# null if self is a statement of in case of error
var mtype: nullable MType = null
- # Is the statement correctly typed.
+ # Is the statement correctly typed?
# Used to distinguish errors and statements when `mtype' == null
var is_typed: Bool = false