Remove remaining usage of old style attributes declarations `var _foo`.
Also remove the annotation `old_style_init` in the parser.
Pull-Request: #712
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
# A version of the naive Nit interpreter for PNaCl.
module pnacl_nit
-import naive_interpreter
-import debugger
+import interpreter::naive_interpreter
+import interpreter::debugger
import pnacl
intrude import toolcontext
intrude import modelbuilder
# Management and utilities on annotations
module annotation
-import parser
import modelbuilder
-import literal
+private import literal
import model::mmodule_data
redef class Prod
# Instantiation and transformation of semantic nodes in the AST of expressions and statements
module astbuilder
-intrude import typing
-intrude import literal
-intrude import parser
-intrude import scope
+intrude import semantize::typing
+intrude import semantize::literal
+intrude import semantize::parser
+intrude import semantize::scope
# General factory to build semantic nodes in the AST of expressions
class ASTBuilder
# print AST in an human form
module astprinter
-import typing
-import phase
+import semantize
intrude import parser
-import literal
+private import literal
private class ASTPrinterVisitor
super Visitor
# Check the consitency of AST
module astvalidation
-private import typing
intrude import parser
import astbuilder
# to wrap foreign code in Nit methods.
module common_ffi
-import parser
import modelbuilder
import nitni
import c
private import annotation
+private import literal
redef class ToolContext
var pkgconfig_phase: Phase = new PkgconfigPhase(self, [literal_phase])
module abstract_compiler
import literal
-import typing
-import auto_super_init
+import semantize
import platform
import c_tools
if f.compiles_to_o_file then ofiles.add(o)
if f.add_to_jar then java_files.add(f)
end
-
+
if not java_files.is_empty then
var jar_file = "{outpath}.jar"
end
# Generate the main C function.
+ #
# This function:
- # * allocate the Sys object if it exists
- # * call init if is exists
- # * call main if it exists
+ #
+ # * allocate the Sys object if it exists
+ # * call init if is exists
+ # * call main if it exists
fun compile_main_function
do
var v = self.new_visitor
end
# Display stats about compilation process
+ #
# Metrics used:
- # * type tests against resolved types (`x isa Collection[Animal]`)
- # * type tests against unresolved types (`x isa Collection[E]`)
- # * type tests skipped
- # * type tests total
- # *
+ #
+ # * type tests against resolved types (`x isa Collection[Animal]`)
+ # * type tests against unresolved types (`x isa Collection[E]`)
+ # * type tests skipped
+ # * type tests total
fun display_stats
do
if self.modelbuilder.toolcontext.opt_typing_test_metrics.value then
private var escapemark_names = new HashMap[EscapeMark, String]
# Return a "const char*" variable associated to the classname of the dynamic type of an object
- # NOTE: we do not return a `RuntimeVariable` "NativeString" as the class may not exist in the module/program
+ # NOTE: we do not return a `RuntimeVariable` "NativeString" as the class may not exist in the module/program
fun class_name_string(value: RuntimeVariable): String is abstract
# Variables handling
var mtype = recv.mtype
var finalizable_type = compiler.mainmodule.finalizable_type
if finalizable_type != null and not mtype.need_anchor and
- mtype.is_subtype(compiler.mainmodule, null, finalizable_type) then
+ mtype.is_subtype(compiler.mainmodule, null, finalizable_type) then
add "gc_register_finalizer({recv});"
end
end
end
toolcontext.run_global_phases(ms)
end
-
# by calling `ModelBuilder::android_project_for`.
module android_annotations
-import parser_util
-import modelbuilder
-import modelize_property
+private import parser_util
+import modelize
import literal
-import typing
+import semantize
private import annotation
# Metadata associated to an Android project
else
for arg in args do
var format_error = "Annotation error: \"{name}\" expects its arguments to be of type Int or a call to `git_revision`"
-
+
var value
value = arg.as_int
if value != null then
+# This file is part of NIT ( http://www.nitlanguage.org ).
#
# Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
#
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Compilation to C
+module compiler
+
+import separate_erasure_compiler
+import global_compiler
+import compiler_ffi
+
+import android_platform
+import pnacl_platform
+import emscripten_platform
var base_cname = "null_{mtype.mangled_cname}"
var full_cname = "NIT_NULL___{base_cname}"
- # In nitni files, declare internal function as extern
+ # In nitni files, declare internal function as extern
var full_friendly_csignature = "{cname_blind} {full_cname}()"
ccu.header_decl.add("extern {full_friendly_csignature};\n")
var mproperty = mproperty
assert mproperty isa MMethod
- # In nitni files, declare internal function as extern
+ # In nitni files, declare internal function as extern
var full_friendly_csignature = mproperty.build_csignature(recv_mtype, v.compiler.mainmodule, null, long_signature, internal_call_context)
ccu.header_decl.add("extern {full_friendly_csignature};\n")
## check type
#
- # In nitni files, declare internal function as extern
+ # In nitni files, declare internal function as extern
var full_friendly_csignature = "int {v.compiler.mainmodule.name }___{from.mangled_cname}_is_a_{to.mangled_cname}({from.cname_blind})"
ccu.header_decl.add("extern {full_friendly_csignature};\n")
# complex annotation that modify both the model and the AST of a Nit program
module cached
-import modelize_property
-import parser_util
+import modelize
+private import parser_util
import simple_misc_analysis
private import annotation
module check_annotation
import phase
-import annotation
+private import annotation
redef class ToolContext
var check_annotation_phase: Phase = new CheckAnnotationPhase(self, null)
# This module is only an example of how to implements a simple phase in the nit tools
module div_by_zero
-import phase
import literal # Because we need the real value of literal in the AST
-import typing # Because we need the static type of receivers
+import semantize # Because we need the static type of receivers
# Note, `ToolContext` is the main overlord class
# Among its jobs, it orchestrates and executes the various phases
# Collect and orchestration of main frontend phases
module frontend
-import phase
import simple_misc_analysis
import literal
-import scope
-import flow
-import local_var_init
-import typing
-import auto_super_init
+import modelize
+import semantize
import div_by_zero
import cached
import serialization_phase
# Phase generating methods to serialize Nit objects to different formats
module serialization_phase
-import phase
-import parser_util
-import modelize_property
-intrude import modelize_class
+private import parser_util
+import modelize
+private import annotation
redef class ToolContext
var serialization_phase_pre_model: Phase = new SerializationPhasePreModel(self, null)
# * use of "while true" instead of "loop"
module simple_misc_analysis
-import toolcontext
-import parser
import phase
redef class ToolContext
# Highliting of Nit AST
module highlight
-import modelize_property
import frontend
import html
import pipeline
import breakpoint
intrude import naive_interpreter
import nitx
-intrude import local_var_init
-intrude import scope
+intrude import semantize::local_var_init
+intrude import semantize::scope
intrude import toolcontext
+private import parser_util
redef class Model
# Cleans the model to remove a module and what it defines when semantic analysis fails on injected code
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Interpretation of Nit programs
+module interpreter
+
+import naive_interpreter
+import debugger
+import debugger_socket
module naive_interpreter
import literal
-import typing
-import auto_super_init
-import frontend
-import common_ffi
+import semantize
private import parser::tables
redef class ToolContext
# Parsing of literal values in the abstract syntax tree.
module literal
-import parser
-import toolcontext
import phase
redef class ToolContext
private import parser
import html
private import highlight
+private import parser_util
# The class that does the convertion from a `ADoc` to HTML
private class Doc2Mdwn
# Metrics about the nodes and identifiers in the AST
module ast_metrics
-import modelbuilder
-private import metrics_base
-import frontend
+import metrics_base
redef class ToolContext
var ast_metrics_phase: Phase = new AstMetricsPhase(self, null)
# See graphviz http://www.graphviz.org/
module generate_hierarchies
-import model
-private import metrics_base
-import frontend
-import model_viz
+import metrics_base
+import model::model_viz
redef class ToolContext
var generate_hierarchies_phase: Phase = new GenerateHierarchyPhase(self, null)
# Collect metrics about inheritance usage
module inheritance_metrics
-import model
+import metrics_base
import mmodules_metrics
import mclasses_metrics
-import phase
-import frontend
redef class ToolContext
var inheritance_metrics_phase: Phase = new InheritanceMetricsPhase(self, null)
# Collect common metrics about mclasses
module mclasses_metrics
-import model
import metrics_base
-import phase
-import frontend
redef class ToolContext
var mclasses_metrics_phase: Phase = new MClassesMetricsPhase(self, null)
# in Proceedings of the 16th IEEE International Conference on Program Comprehension (OCPC'08)
module mendel_metrics
-import model
import metrics_base
import mclasses_metrics
-import phase
-import frontend
+import modelize
redef class ToolContext
var mendel_metrics_phase: Phase = new MendelMetricsPhase(self, null)
# Collect common metrics about modules
module mmodules_metrics
-import model
import metrics_base
-import phase
-import frontend
redef class ToolContext
var mmodules_metrics_phase: Phase = new MModulesMetricsPhase(self, null)
# Dump of Nit model into hypertext human-readable format.
module model_hyperdoc
-import model
import metrics_base
-import phase
-import frontend
redef class ToolContext
var model_hyperdoc_phase: Phase = new ModelHyperdocPhase(self, null)
# Statistics about the usage of nullables
module nullables_metrics
-import modelbuilder
-private import typing
-import model_utils
+import metrics_base
import mclasses_metrics
-import frontend
+import semantize
redef class ToolContext
var nullables_metrics_phase: Phase = new NullablesMetricsPhase(self, null)
# Metrics about the various posets of the model of a Nit program
module poset_metrics
-import poset
import metrics_base
-import frontend
redef class ToolContext
var poset_metrics_phase: Phase = new PosetMetricsPhase(self, null)
module refinement_metrics
import model
-private import metrics_base
-import frontend
+import metrics_base
redef class ToolContext
var refinement_metrics_phase: Phase = new RefinementMetricsPhase(self, null)
# Metrics from RTA
module rta_metrics
-import modelbuilder
private import rapid_type_analysis
-private import metrics_base
+import metrics_base
import mmodules_metrics
import mclasses_metrics
-import frontend
redef class ToolContext
var rta_metrics_phase: Phase = new RTAMetricsPhase(self, null)
# Metrics about the usage of explicit and implicit self
module self_metrics
-import modelbuilder
-private import metrics_base
-import frontend
+
+import metrics_base
redef class ToolContext
var self_metrics_phase: Phase = new SelfMetricsPhase(self, null)
# Metrics on the usage of explicit static types.
module static_types_metrics
-private import metrics_base
-import modelbuilder
-import modelize_class
-import frontend
+import metrics_base
+import modelize
redef class ToolContext
var static_types_metrics_phase: Phase = new StaticTypesMetricsPhase(self, null)
# Metrics on table generation
module tables_metrics
-import model
-private import metrics_base
-import frontend
+import metrics_base
redef class ToolContext
var tables_metrics_phase: Phase = new TablesMetricsPhase(self, null)
# FIXME: better handling of the types
module model
-import poset
-import location
import mmodule
import mdoc
import ordered_tree
# FIXME add missing error checks
module modelbuilder
-import parser
import model
-import poset
-import opts
-import toolcontext
import phase
private import more_collections
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Create a model from nit source files
+module modelize
+
+import modelize_property
module modelize_property
import modelize_class
-import annotation
+private import annotation
redef class ToolContext
var modelize_property_phase: Phase = new ModelizePropertyPhase(self, [modelize_class_phase])
# A naive Nit interpreter
module nit
-import naive_interpreter
-import debugger
-import debugger_socket
+import interpreter
+import frontend
# Create a tool context to handle options and paths
var toolcontext = new ToolContext
# A global Nit compiler
module nitg
-import modelbuilder
import frontend
+import compiler
import transform
-import rapid_type_analysis
-import global_compiler
-import separate_erasure_compiler
-import separate_compiler
-import android_platform
-import compiler_ffi
-import pnacl_platform
-import emscripten_platform
redef class ToolContext
redef fun process_options(args)
# A ligHt Nit compiler
module nith
-import phase
-import literal
-import scope
-import flow
-import local_var_init
-import typing
-import auto_super_init
-import modelbuilder
-import rapid_type_analysis
-import separate_erasure_compiler
+import modelize
import transform
+import rapid_type_analysis
+import compiler::separate_erasure_compiler
+
redef class ToolContext
redef fun process_options(args)
do
module nitvm
import vm
+import frontend
# Create a tool context to handle options and paths
var toolcontext = new ToolContext
module nitx
import model_utils
-import modelize_property
+import modelize
# Main class of the nit index tool
# NitIndex build the model using the toolcontext argument
# to the target platform. Also detects conflicts between targetted platforms.
module platform
-import modelize_property
-import parser_util
-import modelbuilder
+import modelize
+private import parser_util
private import annotation
redef class ToolContext
# It is quite efficient but the type set is global and pollutes each call site.
module rapid_type_analysis
-import model
-import modelbuilder
-import typing
-import auto_super_init
+import semantize
-import csv # for live_types_to_csv
-import ordered_tree # for live_methods_to_tree
+private import csv # for live_types_to_csv
+private import ordered_tree # for live_methods_to_tree
private import more_collections
module auto_super_init
import typing
-import modelbuilder
-import phase
+private import annotation
redef class ToolContext
var auto_super_init_phase: Phase = new AutoSuperInitPhase(self, [typing_phase])
# Intraprocedural static flow.
module flow
-import parser
-import toolcontext
import scope
-import phase
redef class ToolContext
var flow_phase: Phase = new FlowPhase(self, [scope_phase])
# Require that the scope and the flow analaysis are already performed
module local_var_init
-import scope
import flow
-import phase
redef class ToolContext
var local_var_init_phase: Phase = new LocalVarInitPhase(self, [flow_phase])
# Identification and scping of local variables and labels.
module scope
-import parser
-import toolcontext
import phase
redef class ToolContext
--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Process bodies of methods in regard with the model.
+module semantize
+
+import auto_super_init
# By OO-services we mean message sending, attribute access, instantiation, etc.
module typing
-import flow
-import modelize_property
-import phase
+import modelize
import local_var_init
redef class ToolContext
# Program to test the `markdown` module on real source files.
module test_markdown
-import modelize_property
+import modelize
import highlight
import markdown
# Base options for testing tools.
module testing_base
-import modelize_property
-import parser_util
+import modelize
+private import parser_util
redef class ToolContext
# opt --full
import testing_base
import html
+private import annotation
redef class ToolContext
# -- target-file
module transform
import astbuilder
-import auto_super_init
import astvalidation
+import semantize
redef class ToolContext
var transform_phase: Phase = new TransformPhase(self, [typing_phase, auto_super_init_phase])
# Implementation of the Nit virtual machine
module vm
-intrude import naive_interpreter
+intrude import interpreter::naive_interpreter
import model_utils
import perfect_hashing
Number of redefined properties: 1 (5.55%)
Average number of property redefinitions by property: 0.11
Average number of property redefinitions by redefined property: 2.00
---- Metrics of the explitic static types ---
-Total number of explicit static types: 9
-Statistics of type usage:
- population: 4
- minimum value: 1
- maximum value: 6
- total value: 9
- average value: 2.25
- distribution:
- <=1: sub-population=3 (75.00%); cumulated value=3 (33.33%)
- <=8: sub-population=1 (25.00%); cumulated value=6 (66.66%)
- list:
- Int: 6 (66.66%)
- C: 1 (11.11%)
- B: 1 (11.11%)
- A: 1 (11.11%)
--- Explicit vs. Implicit Self ---
Total number of self: 5
Total number of implicit self: 4 (80.00%)
Total size of tables (classes and instances): 38 (not including stuff like info for subtyping or call-next-method)
Average size of table by runtime class: 6.33
Values never redefined: 32 (84.21%)
-
-# Mendel metrics
- large mclasses (threshold: 2.291)
- B: 3
- C: 3
- budding mclasses (threshold: 0.693)
- B: 0.75
- C: 0.75
- blooming mclasses (threshold: 1.935)
- B: 2.25
- C: 2.25
- blooming mclasses (threshold: 1.935)
- B: 2.25
- C: 2.25
generating out/nitmetrics_args1.write/project_hierarchy.dot
generating out/nitmetrics_args1.write/module_hierarchy.dot
-# Nullable metrics
-
- ## project base_simple3
- `- group base_simple3
- cnba: number of accessible attributes (inherited + local)
- avg: 0.0
- max: C (2)
- min: Object (0)
- std: 0.845
- sum: 3
- cnbna: number of accessible nullable attributes (inherited + local) -- nothing
- sum: 0
-
- ## global metrics
- cnba: number of accessible attributes (inherited + local)
- avg: 0.0
- max: C (2)
- min: Object (0)
- std: 0.845
- sum: 3
- cnbna: number of accessible nullable attributes (inherited + local) -- nothing
- sum: 0
---- Sends on Nullable Receiver ---
-Total number of sends: 19
-Number of sends on a nullable receiver: 0 (0.0%)
-Number of buggy sends (cannot determine the type of the receiver): 0 (0.0%)
-
# Inheritance metrics
## project base_simple3
min: base_simple3 (0.143)
std: 0.0
sum: 0.143
+--- Metrics of the explitic static types ---
+Total number of explicit static types: 9
+Statistics of type usage:
+ population: 4
+ minimum value: 1
+ maximum value: 6
+ total value: 9
+ average value: 2.25
+ distribution:
+ <=1: sub-population=3 (75.00%); cumulated value=3 (33.33%)
+ <=8: sub-population=1 (25.00%); cumulated value=6 (66.66%)
+ list:
+ Int: 6 (66.66%)
+ C: 1 (11.11%)
+ B: 1 (11.11%)
+ A: 1 (11.11%)
+
+# Mendel metrics
+ large mclasses (threshold: 2.291)
+ B: 3
+ C: 3
+ budding mclasses (threshold: 0.693)
+ B: 0.75
+ C: 0.75
+ blooming mclasses (threshold: 1.935)
+ B: 2.25
+ C: 2.25
+ blooming mclasses (threshold: 1.935)
+ B: 2.25
+ C: 2.25
+
+# Nullable metrics
+
+ ## project base_simple3
+ `- group base_simple3
+ cnba: number of accessible attributes (inherited + local)
+ avg: 0.0
+ max: C (2)
+ min: Object (0)
+ std: 0.845
+ sum: 3
+ cnbna: number of accessible nullable attributes (inherited + local) -- nothing
+ sum: 0
+
+ ## global metrics
+ cnba: number of accessible attributes (inherited + local)
+ avg: 0.0
+ max: C (2)
+ min: Object (0)
+ std: 0.845
+ sum: 3
+ cnbna: number of accessible nullable attributes (inherited + local) -- nothing
+ sum: 0
+--- Sends on Nullable Receiver ---
+Total number of sends: 19
+Number of sends on a nullable receiver: 0 (0.0%)
+Number of buggy sends (cannot determine the type of the receiver): 0 (0.0%)
# RTA metrics