if args != null then
self.n_args.n_exprs.add_all(args)
end
- var mtype = recv.mtype.as(not null)
self.callsite = callsite
self.mtype = callsite.msignature.return_mtype
self.is_typed = true
# Add compiling options
redef class ToolContext
# --output
- var opt_output: OptionString = new OptionString("Output file", "-o", "--output")
+ var opt_output = new OptionString("Output file", "-o", "--output")
# --dir
- var opt_dir: OptionString = new OptionString("Output directory", "--dir")
+ var opt_dir = new OptionString("Output directory", "--dir")
# --no-cc
- var opt_no_cc: OptionBool = new OptionBool("Do not invoke C compiler", "--no-cc")
+ var opt_no_cc = new OptionBool("Do not invoke C compiler", "--no-cc")
# --no-main
- var opt_no_main: OptionBool = new OptionBool("Do not generate main entry point", "--no-main")
+ var opt_no_main = new OptionBool("Do not generate main entry point", "--no-main")
# --cc-paths
- var opt_cc_path: OptionArray = new OptionArray("Set include path for C header files (may be used more than once)", "--cc-path")
+ var opt_cc_path = new OptionArray("Set include path for C header files (may be used more than once)", "--cc-path")
# --make-flags
- var opt_make_flags: OptionString = new OptionString("Additional options to make", "--make-flags")
+ var opt_make_flags = new OptionString("Additional options to make", "--make-flags")
# --compile-dir
- var opt_compile_dir: OptionString = new OptionString("Directory used to generate temporary files", "--compile-dir")
+ var opt_compile_dir = new OptionString("Directory used to generate temporary files", "--compile-dir")
# --hardening
- var opt_hardening: OptionBool = new OptionBool("Generate contracts in the C code against bugs in the compiler", "--hardening")
+ var opt_hardening = new OptionBool("Generate contracts in the C code against bugs in the compiler", "--hardening")
# --no-shortcut-range
- var opt_no_shortcut_range: OptionBool = new OptionBool("Always insantiate a range and its iterator on 'for' loops", "--no-shortcut-range")
+ var opt_no_shortcut_range = new OptionBool("Always insantiate a range and its iterator on 'for' loops", "--no-shortcut-range")
# --no-check-covariance
- var opt_no_check_covariance: OptionBool = new OptionBool("Disable type tests of covariant parameters (dangerous)", "--no-check-covariance")
+ var opt_no_check_covariance = new OptionBool("Disable type tests of covariant parameters (dangerous)", "--no-check-covariance")
# --no-check-attr-isset
- var opt_no_check_attr_isset: OptionBool = new OptionBool("Disable isset tests before each attribute access (dangerous)", "--no-check-attr-isset")
+ var opt_no_check_attr_isset = new OptionBool("Disable isset tests before each attribute access (dangerous)", "--no-check-attr-isset")
# --no-check-assert
- var opt_no_check_assert: OptionBool = new OptionBool("Disable the evaluation of explicit 'assert' and 'as' (dangerous)", "--no-check-assert")
+ var opt_no_check_assert = new OptionBool("Disable the evaluation of explicit 'assert' and 'as' (dangerous)", "--no-check-assert")
# --no-check-autocast
- var opt_no_check_autocast: OptionBool = new OptionBool("Disable implicit casts on unsafe expression usage (dangerous)", "--no-check-autocast")
+ var opt_no_check_autocast = new OptionBool("Disable implicit casts on unsafe expression usage (dangerous)", "--no-check-autocast")
# --no-check-null
- var opt_no_check_null: OptionBool = new OptionBool("Disable tests of null receiver (dangerous)", "--no-check-null")
+ var opt_no_check_null = new OptionBool("Disable tests of null receiver (dangerous)", "--no-check-null")
# --no-check-all
- var opt_no_check_all: OptionBool = new OptionBool("Disable all tests (dangerous)", "--no-check-all")
+ var opt_no_check_all = new OptionBool("Disable all tests (dangerous)", "--no-check-all")
# --typing-test-metrics
- var opt_typing_test_metrics: OptionBool = new OptionBool("Enable static and dynamic count of all type tests", "--typing-test-metrics")
+ var opt_typing_test_metrics = new OptionBool("Enable static and dynamic count of all type tests", "--typing-test-metrics")
# --invocation-metrics
- var opt_invocation_metrics: OptionBool = new OptionBool("Enable static and dynamic count of all method invocations", "--invocation-metrics")
+ var opt_invocation_metrics = new OptionBool("Enable static and dynamic count of all method invocations", "--invocation-metrics")
# --isset-checks-metrics
- var opt_isset_checks_metrics: OptionBool = new OptionBool("Enable static and dynamic count of isset checks before attributes access", "--isset-checks-metrics")
+ var opt_isset_checks_metrics = new OptionBool("Enable static and dynamic count of isset checks before attributes access", "--isset-checks-metrics")
# --stacktrace
- var opt_stacktrace: OptionString = new OptionString("Control the generation of stack traces", "--stacktrace")
+ var opt_stacktrace = new OptionString("Control the generation of stack traces", "--stacktrace")
# --no-gcc-directives
var opt_no_gcc_directive = new OptionArray("Disable a advanced gcc directives for optimization", "--no-gcc-directive")
# --release
do
gather_cc_paths
- var mainmodule = compiler.mainmodule
var compile_dir = compile_dir
# Generate the .h and .c files
compiler.files_to_copy.add "{cc_paths.first}/gc_chooser.h"
# FFI
- var m2m = toolcontext.modelbuilder.mmodule2nmodule
for m in compiler.mainmodule.in_importation.greaters do
compiler.finalize_ffi_for_module(m)
end
end
var linker_options = new HashSet[String]
- var m2m = toolcontext.modelbuilder.mmodule2nmodule
for m in mainmodule.in_importation.greaters do
var libs = m.collect_linker_libs
if libs != null then linker_options.add_all(libs)
# The real main module of the program
var realmainmodule: MModule
- # The modeulbuilder used to know the model and the AST
+ # The modelbuilder used to know the model and the AST
var modelbuilder: ModelBuilder is protected writable
# Is hardening asked? (see --hardening)
# The list of all associated files
# Used to generate .c files
- var files: List[CodeFile] = new List[CodeFile]
+ var files = new List[CodeFile]
# Initialize a visitor specific for a compiler engine
fun new_visitor: VISITOR is abstract
# Compile C headers
# This method call compile_header_strucs method that has to be refined
fun compile_header do
- var v = self.header
- var toolctx = modelbuilder.toolcontext
self.header.add_decl("#include <stdlib.h>")
self.header.add_decl("#include <stdio.h>")
self.header.add_decl("#include <string.h>")
# Checks
- # Add a check and an abort for a null reciever if needed
+ # Add a check and an abort for a null receiver if needed
fun check_recv_notnull(recv: RuntimeVariable)
do
if self.compiler.modelbuilder.toolcontext.opt_no_check_null.value then return
# Names handling
- private var names: HashSet[String] = new HashSet[String]
+ private var names = new HashSet[String]
private var last: Int = 0
# Return a new name based on `s` and unique in the visitor
# Variables handling
- protected var variables: HashMap[Variable, RuntimeVariable] = new HashMap[Variable, RuntimeVariable]
+ protected var variables = new HashMap[Variable, RuntimeVariable]
# Return the local runtime_variable associated to a Nit local variable
fun variable(variable: Variable): RuntimeVariable
var i2 = v.expr(self.n_expr2, null)
var mtype = self.mtype.as(MClassType)
var res = v.init_instance(mtype)
- var it = v.compile_callsite(init_callsite.as(not null), [res, i1, i2])
+ v.compile_callsite(init_callsite.as(not null), [res, i1, i2])
return res
end
end
var i2 = v.expr(self.n_expr2, null)
var mtype = self.mtype.as(MClassType)
var res = v.init_instance(mtype)
- var it = v.compile_callsite(init_callsite.as(not null), [res, i1, i2])
+ v.compile_callsite(init_callsite.as(not null), [res, i1, i2])
return res
end
end
# revision number. If the working tree is dirty, it will append another field with "d" for dirty.
private fun as_version(modelbuilder: ModelBuilder): String
do
- var annotation_name = n_atid.n_id.text
var version_fields = new Array[Object]
var args = n_args
- var platform_name
if args.length < 1 then
modelbuilder.error(self, "Annotation error: \"{name}\" expects at least a single argument.")
return ""
private var colors = new HashMap[E, Int]
private var conflicts = new HashMap[E, Set[E]]
- init do end
-
# Start bucket coloring
fun colorize(buckets: Map[H, Set[E]]): Map[E, Int] do
compute_conflicts(buckets)
return res
end
- private var compiled_callbacks: Array[NitniCallback] = new Array[NitniCallback]
+ private var compiled_callbacks = new Array[NitniCallback]
# Returns true if callbacks has yet to be generated and register it as being generated
private fun check_callback_compilation(cb: NitniCallback): Bool
do
var mmodule = mpropdef.mclassdef.mmodule
var mainmodule = v.compiler.mainmodule
- var amainmodule = v.compiler.modelbuilder.mmodule2nmodule[mainmodule]
var amodule = v.compiler.modelbuilder.mmodule2nmodule[mmodule]
var mclass_type = mpropdef.mclassdef.bound_mtype
var mproperty = from.mproperty
assert mproperty isa MMethod
var mclass_type = from.mclassdef.mclass.mclass_type
- var mmodule = from.mclassdef.mmodule
# In nitni files, declare internal function as extern
var internal_csignature = mproperty.build_csignature(mclass_type, v.compiler.mainmodule, "___super", long_signature, internal_call_context)
# Add separate compiler specific options
redef class ToolContext
# --separate
- var opt_separate: OptionBool = new OptionBool("Use separate compilation", "--separate")
+ var opt_separate = new OptionBool("Use separate compilation", "--separate")
# --no-inline-intern
- var opt_no_inline_intern: OptionBool = new OptionBool("Do not inline call to intern methods", "--no-inline-intern")
+ var opt_no_inline_intern = new OptionBool("Do not inline call to intern methods", "--no-inline-intern")
# --no-union-attribute
- var opt_no_union_attribute: OptionBool = new OptionBool("Put primitive attibutes in a box instead of an union", "--no-union-attribute")
+ var opt_no_union_attribute = new OptionBool("Put primitive attibutes in a box instead of an union", "--no-union-attribute")
# --no-shortcut-equate
- var opt_no_shortcut_equate: OptionBool = new OptionBool("Always call == in a polymorphic way", "--no-shortcut-equal")
+ var opt_no_shortcut_equate = new OptionBool("Always call == in a polymorphic way", "--no-shortcut-equal")
# --inline-coloring-numbers
- var opt_inline_coloring_numbers: OptionBool = new OptionBool("Inline colors and ids (semi-global)", "--inline-coloring-numbers")
+ var opt_inline_coloring_numbers = new OptionBool("Inline colors and ids (semi-global)", "--inline-coloring-numbers")
# --inline-some-methods
- var opt_inline_some_methods: OptionBool = new OptionBool("Allow the separate compiler to inline some methods (semi-global)", "--inline-some-methods")
+ var opt_inline_some_methods = new OptionBool("Allow the separate compiler to inline some methods (semi-global)", "--inline-some-methods")
# --direct-call-monomorph
- var opt_direct_call_monomorph: OptionBool = new OptionBool("Allow the separate compiler to direct call monomorph sites (semi-global)", "--direct-call-monomorph")
+ var opt_direct_call_monomorph = new OptionBool("Allow the separate compiler to direct call monomorph sites (semi-global)", "--direct-call-monomorph")
# --skip-dead-methods
var opt_skip_dead_methods = new OptionBool("Do not compile dead methods (semi-global)", "--skip-dead-methods")
# --semi-global
# --no-colo-dead-methods
var opt_colo_dead_methods = new OptionBool("Force colorization of dead methods", "--colo-dead-methods")
# --tables-metrics
- var opt_tables_metrics: OptionBool = new OptionBool("Enable static size measuring of tables used for vft, typing and resolution", "--tables-metrics")
+ var opt_tables_metrics = new OptionBool("Enable static size measuring of tables used for vft, typing and resolution", "--tables-metrics")
redef init
do
redef fun unbox_signature_extern(m, args)
do
var msignature = m.msignature.resolve_for(m.mclassdef.bound_mtype, m.mclassdef.bound_mtype, m.mclassdef.mmodule, true)
- var recv = args.first
if not m.mproperty.is_init and m.is_extern then
args.first = self.unbox_extern(args.first, m.mclassdef.mclass.mclass_type)
end
redef fun compile_callsite(callsite, args)
do
var rta = compiler.runtime_type_analysis
- var recv = args.first.mtype
var mmethod = callsite.mproperty
# TODO: Inlining of new-style constructors
if compiler.modelbuilder.toolcontext.opt_direct_call_monomorph.value and rta != null and not mmethod.is_root_init then
# Add separate erased compiler specific options
redef class ToolContext
# --erasure
- var opt_erasure: OptionBool = new OptionBool("Erase generic types", "--erasure")
+ var opt_erasure = new OptionBool("Erase generic types", "--erasure")
# --rta
var opt_rta = new OptionBool("Activate RTA (implicit with --global and --separate)", "--rta")
# --no-check-erasure-cast
- var opt_no_check_erasure_cast: OptionBool = new OptionBool("Disable implicit casts on unsafe return with erasure-typing policy (dangerous)", "--no-check-erasure-cast")
+ var opt_no_check_erasure_cast = new OptionBool("Disable implicit casts on unsafe return with erasure-typing policy (dangerous)", "--no-check-erasure-cast")
redef init
do
end
var class_ptr
- var type_table
if value.mtype.ctype == "val*" then
class_ptr = "{value}->class->"
else
var jni_signature_alt
var return_type
- var c_return_type
var params = new Array[String]
params.add "nit_ffi_jni_env"
params.add "java_class"
if mproperty.is_init then
jni_signature_alt = mclass_type.jni_signature_alt
return_type = mclass_type
- c_return_type = mclass_type.cname
else
params.add "recv"
if signature.return_mtype != null then
var ret_mtype = signature.return_mtype
ret_mtype = ret_mtype.resolve_for(mclass_type, mclass_type, mmodule, true)
return_type = signature.return_mtype
- c_return_type = mclass_type.cname
jni_signature_alt = return_type.jni_signature_alt
else
jni_signature_alt = "Void"
return_type = null
- c_return_type = null
end
end
end
end
- # Insert additionnal explicit calls to get the current `JNIEnv`
+ # Insert additional explicit calls to get the current `JNIEnv`
#
# This forces declaration of callbacks to Nit. The callbacks will be available in Java
# but will be used mainly by the FFI itself.
#
- # The developper can aso customize the JNIEnv used by the FFI by redefing `Sys::jni_env`.
+ # The developer can also customize the JNIEnv used by the FFI by redefining `Sys::jni_env`.
private fun insert_artificial_callbacks(toolcontext: ToolContext)
do
var fcc = foreign_callbacks
# Type name in Java
#
# * Primitives common to both languages use their Java primitive type
- # * Nit extern Java classes are reprensented by their full Java type
+ # * Nit extern Java classes are represented by their full Java type
# * Other Nit objects are represented by `int` in Java. It holds the
# pointer to the underlying C structure.
# TODO create static Java types to store and hide the pointer
do
var ftype = mclass.ftype
if ftype isa ForeignJavaType then
- var ori_jni_type = jni_type
var jni_type = ftype.java_type.
replace('.', "/").replace(' ', "").replace('\n', "")
do
var stack2 = new Array[HTMLTag]
var stack = new Array[Prod]
- var closes = new Array[Prod]
var line = 0
var c: nullable Token = first_token
var hv = new HighlightVisitor
return t.infobox(v)
end
end
-
end
# -d
- var opt_debugger_mode: OptionBool = new OptionBool("Launches the target program with the debugger attached to it", "-d")
+ var opt_debugger_mode = new OptionBool("Launches the target program with the debugger attached to it", "-d")
# -c
- var opt_debugger_autorun: OptionBool = new OptionBool("Launches the target program with the interpreter, such as when the program fails, the debugging prompt is summoned", "-c")
+ var opt_debugger_autorun = new OptionBool("Launches the target program with the interpreter, such as when the program fails, the debugging prompt is summoned", "-c")
redef init
do
var mmod = e.mmodule
if mmod != null then
self.mainmodule = mmod
- var local_classdefs = mmod.mclassdefs
var sys_type = mmod.sys_type
if sys_type == null then
print "Fatal error, cannot find Class Sys !\nAborting"
var identifiers_in_instruction = get_identifiers_in_current_instruction(n.location.text)
for i in identifiers_in_instruction do
- var variable = seek_variable(i, frame)
for j in self.traces do
if j.is_variable_traced_in_frame(i, frame) then
n.debug("Traced variable {i} used")
if parts_of_command[1] == "*" then
var map_of_instances = frame.map
- var keys = map_of_instances.iterator
-
var self_var = seek_variable("self", frame)
print "self: {self_var.to_s}"
var trigger_char_escape = false
var trigger_string_escape = false
- var trigger_concat_in_string = false
for i in instruction.chars do
if trigger_char_escape then
if i == '\'' then trigger_char_escape = false
else if trigger_string_escape then
if i == '{' then
- trigger_concat_in_string = true
trigger_string_escape = false
else if i == '\"' then trigger_string_escape = false
else
else if i == '\"' then
trigger_string_escape = true
else if i == '}' then
- trigger_concat_in_string = false
trigger_string_escape = true
else
if instruction_buffer.length > 0 and not instruction_buffer.is_numeric and not (instruction_buffer.chars[0] >= 'A' and instruction_buffer.chars[0] <= 'Z') then result_array.push(instruction_buffer.to_s)
do
var collection_length_attribute = get_attribute_in_mutable_instance(collection, "length")
- var real_collection_length: nullable Int = null
-
if collection_length_attribute != null then
var primitive_length_instance = collection.attributes[collection_length_attribute]
if primitive_length_instance isa PrimitiveInstance[Int] then
redef class ToolContext
# --discover-call-trace
- var opt_discover_call_trace: OptionBool = new OptionBool("Trace calls of the first invocation of a method", "--discover-call-trace")
+ var opt_discover_call_trace = new OptionBool("Trace calls of the first invocation of a method", "--discover-call-trace")
redef init
do
# The modelbuilder that know the AST and its associations with the model
var modelbuilder: ModelBuilder
- # The main moduleof the program (used to lookup methoda
+ # The main module of the program (used to lookup method)
var mainmodule: MModule
# The command line arguments of the interpreted program
# arguments[1] is the first argument
var arguments: Array[String]
+ # The main Sys instance
var mainobj: nullable Instance
init(modelbuilder: ModelBuilder, mainmodule: MModule, arguments: Array[String])
return new PrimitiveInstance[Float](ic.mclass_type, val)
end
- # The unique intance of the `true` value.
+ # The unique instance of the `true` value.
var true_instance: Instance
- # The unique intance of the `false` value.
+ # The unique instance of the `false` value.
var false_instance: Instance
- # The unique intance of the `null` value.
+ # The unique instance of the `null` value.
var null_instance: Instance
# Return a new array made of `values`.
fun frame: Frame do return frames.first
# The stack of all frames. The first one is the current one.
- var frames: List[Frame] = new List[Frame]
+ var frames = new List[Frame]
- # Return a stack stace. One line per function
+ # Return a stack trace. One line per function
fun stack_trace: String
do
var b = new FlatBuffer
f.map[v] = value
end
- # Store known method, used to trace methods as thez are reached
+ # Store known methods, used to trace methods as they are reached
var discover_call_trace: Set[MMethodDef] = new HashSet[MMethodDef]
# Common code for calls to injected methods and normal methods
end
# Execute `mpropdef` for a `args` (where `args[0]` is the receiver).
- # Return a falue if `mpropdef` is a function, or null if it is a procedure.
- # The call is direct/static. There is no message-seding/late-binding.
+ # Return a value if `mpropdef` is a function, or null if it is a procedure.
+ # The call is direct/static. There is no message-sending/late-binding.
fun call(mpropdef: MMethodDef, args: Array[Instance]): nullable Instance
do
args = call_commons(mpropdef, args)
end
# Execute a full `callsite` for given `args`
- # Use this method, instead of `send` to execute and control the aditionnal behavior of the call-sites
+ # Use this method, instead of `send` to execute and control the additional behavior of the call-sites
fun callsite(callsite: nullable CallSite, arguments: Array[Instance]): nullable Instance
do
var initializers = callsite.mpropdef.initializers
end
# Execute `mproperty` for a `args` (where `args[0]` is the receiver).
- # Return a falue if `mproperty` is a function, or null if it is a procedure.
- # The call is polimotphic. There is a message-seding/late-bindng according to te receiver (args[0]).
+ # Return a value if `mproperty` is a function, or null if it is a procedure.
+ # The call is polymorphic. There is a message-sending/late-binding according to the receiver (args[0]).
fun send(mproperty: MMethod, args: Array[Instance]): nullable Instance
do
var recv = args.first
return res
end
- var collect_attr_propdef_cache = new HashMap[MType, Array[AAttrPropdef]]
+ private var collect_attr_propdef_cache = new HashMap[MType, Array[AAttrPropdef]]
# Fill the initial values of the newly created instance `recv`.
# `recv.mtype` is used to know what must be filled.
var txt = recv.mtype.to_s
return v.native_string_instance(txt)
else if pname == "==" then
- # == is correclt redefined for instances
+ # == is correctly redefined for instances
return v.bool_instance(args[0] == args[1])
else if pname == "!=" then
return v.bool_instance(args[0] != args[1])
do
var i = v.expr(self.n_expr)
if i == null then return null
- var mtype = v.unanchor_type(self.mtype.as(not null))
if i.mtype isa MNullType then
fatal(v, "Cast failed")
end
var callsite = self.callsite
if callsite != null then
- # Add additionnals arguments for the super init call
+ # Add additional arguments for the super init call
if args.length == 1 then
for i in [0..callsite.msignature.arity[ do
args.add(v.frame.arguments[i+1])
args = v.frame.arguments
end
- # stantard call-next-method
+ # standard call-next-method
var mpropdef = self.mpropdef
mpropdef = mpropdef.lookup_next_definition(v.mainmodule, recv.mtype)
var res = v.call_without_varargs(mpropdef, args)
# Print class tables metrics for the classes of the program main
fun compute_tables_metrics(main: MModule)
do
- var model = main.model
-
var nc = 0 # Number of runtime classes
var nl = 0 # Number of usages of class definitions (a class definition can be used more than once)
var nhp = 0 # Number of usages of properties (a property can be used more than once)
super Comparator
redef type COMPARED: MEntity
redef fun compare(a, b) do return a.name <=> b.name
- init do end
end
# Sort MConcerns based on the module importation hierarchy ranking
super Comparator
redef type COMPARED: MConcern
- init do end
-
redef fun compare(a, b) do
if a.concern_rank == b.concern_rank then
return a.name <=> b.name
private fun check_supertypes(nmodule: AModule, nclassdef: AClassdef)
do
var mmodule = nmodule.mmodule.as(not null)
- var objectclass = try_get_mclass_by_name(nmodule, mmodule, "Object")
var mclass = nclassdef.mclass.as(not null)
var mclassdef = nclassdef.mclassdef.as(not null)
# Register the nclassdef associated to each mclassdef
# FIXME: why not refine the `MClassDef` class with a nullable attribute?
- var mclassdef2nclassdef: HashMap[MClassDef, AClassdef] = new HashMap[MClassDef, AClassdef]
+ var mclassdef2nclassdef = new HashMap[MClassDef, AClassdef]
# Return the static type associated to the node `ntype`.
# `mmodule` and `mclassdef` is the context where the call is made (used to understand formal types)
redef class ModelBuilder
# Register the npropdef associated to each mpropdef
# FIXME: why not refine the `MPropDef` class with a nullable attribute?
- var mpropdef2npropdef: HashMap[MPropDef, APropdef] = new HashMap[MPropDef, APropdef]
+ var mpropdef2npropdef = new HashMap[MPropDef, APropdef]
# Build the properties of `nclassdef`.
# REQUIRE: all superclasses are built.
# Extract visibility information of the main part of `mtype`
# It is a case-by case
var vis_type: nullable MVisibility = null # The own visibility of the type
- var mmodule_type: nullable MModule = null # The origial module of the type
+ var mmodule_type: nullable MModule = null # The original module of the type
mtype = mtype.as_notnullable
if mtype isa MClassType then
vis_type = mtype.mclass.visibility
end
redef class AClassdef
- var build_properties_is_done: Bool = false
+ var build_properties_is_done = false
# The free init (implicitely constructed by the class if required)
var mfree_init: nullable MMethodDef = null
var ntype = self.n_type
if ntype != null then
self.ret_type = modelbuilder.resolve_mtype(mmodule, mclassdef, ntype)
- if self.ret_type == null then return false # Skip errir
+ if self.ret_type == null then return false # Skip error
end
self.is_visited = true
# Is the node tagged `noinit`?
var noinit = false
- # Is the node taggeg lazy?
+ # Is the node tagged lazy?
var is_lazy = false
- # The guard associated to a lasy attribute.
+ # The guard associated to a lazy attribute.
# Because some engines does not have a working `isset`,
- # this additionnal attribute is used to guard the lazy initialization.
+ # this additional attribute is used to guard the lazy initialization.
# TODO: to remove once isset is correctly implemented
var mlazypropdef: nullable MAttributeDef
redef fun build_signature(modelbuilder)
do
var mpropdef = self.mpropdef
- if mpropdef == null then return # Error thus skiped
+ if mpropdef == null then return # Error thus skipped
var mclassdef = mpropdef.mclassdef
var mmodule = mclassdef.mmodule
var mtype: nullable MType = null
if mtype == null then return
end
- # Inherit the type from the getter (usually an abstact getter)
+ # Inherit the type from the getter (usually an abstract getter)
if mtype == null and mreadpropdef != null and not mreadpropdef.is_intro then
var msignature = mreadpropdef.mproperty.intro.msignature
- if msignature == null then return # Error, thus skiped
+ if msignature == null then return # Error, thus skipped
mtype = msignature.return_mtype
end
redef fun check_signature(modelbuilder)
do
var mpropdef = self.mpropdef
- if mpropdef == null then return # Error thus skiped
- var mclassdef = mpropdef.mclassdef
- var mmodule = mclassdef.mmodule
+ if mpropdef == null then return # Error thus skipped
var ntype = self.n_type
var mtype = self.mpropdef.static_mtype
- if mtype == null then return # Error thus skiped
+ if mtype == null then return # Error thus skipped
# Lookup for signature in the precursor
# FIXME all precursors should be considered
redef fun build_signature(modelbuilder)
do
var mpropdef = self.mpropdef
- if mpropdef == null then return # Error thus skiped
+ if mpropdef == null then return # Error thus skipped
var mclassdef = mpropdef.mclassdef
var mmodule = mclassdef.mmodule
var mtype: nullable MType = null
redef fun check_signature(modelbuilder)
do
var mpropdef = self.mpropdef
- if mpropdef == null then return # Error thus skiped
+ if mpropdef == null then return # Error thus skipped
var bound = self.mpropdef.bound
- if bound == null then return # Error thus skiped
+ if bound == null then return # Error thus skipped
modelbuilder.check_visibility(n_type, bound, mpropdef)
node.labels.add "MModule"
node["full_name"] = mmodule.full_name
node["location"] = mmodule.location.to_s
- var mgroup = mmodule.mgroup
for parent in mmodule.in_importation.direct_greaters do
node.out_edges.add(new NeoEdge(node, "IMPORTS", to_node(parent)))
end
redef class ASuperstringExpr
redef fun accept_pretty_printer(v) do
- var force_inline = self.force_inline
for n_expr in n_exprs do v.visit n_expr
end
end
end
end
-
- init do end
end
# Each reduce action has its own class, this one is the root of the hierarchy.
private class AutoSuperInitVisitor
super Visitor
- init
- do
- end
-
redef fun visit(n)
do
n.accept_auto_super_init(self)
# The analyzed property
var mpropdef: nullable MPropDef
- var selfvariable: Variable = new Variable("self")
+ var selfvariable = new Variable("self")
# Is `self` use restricted?
# * no explicit `self`
fun merge_types(node: ANode, col: Array[nullable MType]): nullable MType
do
if col.length == 1 then return col.first
- var res = new Array[nullable MType]
for t1 in col do
if t1 == null then continue # return null
var found = true
redef class FlowContext
# Store changes of types because of type evolution
- private var vars: HashMap[Variable, nullable MType] = new HashMap[Variable, nullable MType]
- private var cache: HashMap[Variable, nullable Array[nullable MType]] = new HashMap[Variable, nullable Array[nullable MType]]
+ private var vars = new HashMap[Variable, nullable MType]
+ private var cache = new HashMap[Variable, nullable Array[nullable MType]]
# Adapt the variable to a static type
# Warning1: do not modify vars directly.
do
var nexpr = self.n_expr
if nexpr != null then
- var mtype = v.visit_expr(nexpr)
+ v.visit_expr(nexpr)
end
self.is_typed = true
end
do
var nexpr = self.n_expr
if nexpr != null then
- var mtype = v.visit_expr(nexpr)
+ v.visit_expr(nexpr)
end
self.is_typed = true
end
var ret_type = v.mpropdef.as(MMethodDef).msignature.return_mtype
if nexpr != null then
if ret_type != null then
- var mtype = v.visit_expr_subtype(nexpr, ret_type)
+ v.visit_expr_subtype(nexpr, ret_type)
else
- var mtype = v.visit_expr(nexpr)
+ v.visit_expr(nexpr)
v.error(self, "Error: Return with value in a procedure.")
end
else if ret_type != null then
var variable = self.n_expr.its_variable
if variable != null then
- var orig = self.n_expr.mtype
- var from = if orig != null then orig.to_s else "invalid"
- var to = if mtype != null then mtype.to_s else "invalid"
+ #var orig = self.n_expr.mtype
+ #var from = if orig != null then orig.to_s else "invalid"
+ #var to = if mtype != null then mtype.to_s else "invalid"
#debug("adapt {variable}: {from} -> {to}")
self.after_flow_context.when_true.set_var(variable, mtype)
end