From: Jean Privat Date: Thu, 30 Jun 2016 18:15:25 +0000 (-0400) Subject: Merge remote-tracking branch 'origin/master' into init_auto X-Git-Url: http://nitlanguage.org?hp=-c Merge remote-tracking branch 'origin/master' into init_auto # Conflicts: # tests/sav/base_init_basic_alt3.res # tests/sav/base_init_super_call2_alt3.res # tests/sav/base_init_super_call2_alt6.res # tests/sav/error_class_glob.res # tests/sav/nitdoc_args4.res # tests/sav/nitlight_args1.res # tests/sav/nitmetrics_args1.res # tests/sav/nituml_args3.res # tests/sav/nituml_args4.res # tests/sav/test_highlight_args1.res --- 93582db8a72ed0dc8662f6fb57feda89a284ad57 diff --combined src/compiler/abstract_compiler.nit index 7d2f983,cddc8d3..9526e0e --- a/src/compiler/abstract_compiler.nit +++ b/src/compiler/abstract_compiler.nit @@@ -577,7 -577,7 +577,7 @@@ abstract class AbstractCompile # The list of all associated files # Used to generate .c files - var files = new List[CodeFile] + var files = new Array[CodeFile] # Initialize a visitor specific for a compiler engine fun new_visitor: VISITOR is abstract @@@ -779,6 -779,20 +779,20 @@@ extern void nitni_global_ref_decr( stru v.add "\}" end + # Hook to add specif piece of code before the the main C function. + # + # Is called by `compile_main_function` + fun compile_before_main(v: VISITOR) + do + end + + # Hook to add specif piece of code at the begin on the main C function. + # + # Is called by `compile_main_function` + fun compile_begin_main(v: VISITOR) + do + end + # Generate the main C function. # # This function: @@@ -876,12 -890,16 +890,16 @@@ v.add_decl("exit(status);") v.add_decl("\}") + compile_before_main(v) + if no_main then v.add_decl("int nit_main(int argc, char** argv) \{") else v.add_decl("int main(int argc, char** argv) \{") end + compile_begin_main(v) + v.add "#if !defined(__ANDROID__) && !defined(TARGET_OS_IPHONE)" v.add("signal(SIGABRT, sig_handler);") v.add("signal(SIGFPE, sig_handler);") @@@ -1127,8 -1145,8 +1145,8 @@@ en # Where to store generated lines class CodeWriter var file: CodeFile - var lines: List[String] = new List[String] - var decl_lines: List[String] = new List[String] + var lines = new Array[String] + var decl_lines = new Array[String] # Add a line in the main part of the generated C fun add(s: String) do self.lines.add(s) @@@ -1180,13 -1198,34 +1198,11 @@@ abstract class AbstractCompilerVisito fun compile_callsite(callsite: CallSite, arguments: Array[RuntimeVariable]): nullable RuntimeVariable do if callsite.is_broken then return null - var initializers = callsite.mpropdef.initializers - if not initializers.is_empty then - var recv = arguments.first - - var i = 1 - for p in initializers do - if p isa MMethod then - var args = [recv] - for x in p.intro.msignature.mparameters do - args.add arguments[i] - i += 1 - end - self.send(p, args) - else if p isa MAttribute then - self.write_attribute(p, recv, arguments[i]) - i += 1 - else abort - end - assert i == arguments.length - - return self.send(callsite.mproperty, [recv]) - end - return self.send(callsite.mproperty, arguments) end fun native_array_instance(elttype: MType, length: RuntimeVariable): RuntimeVariable is abstract - fun calloc_array(ret_type: MType, arguments: Array[RuntimeVariable]) is abstract - fun native_array_def(pname: String, ret_type: nullable MType, arguments: Array[RuntimeVariable]): Bool do return false # Return an element of a native array. @@@ -1197,12 -1236,22 +1213,22 @@@ # The method is unsafe and is just a direct wrapper for the specific implementation of native arrays fun native_array_set(native_array: RuntimeVariable, index: Int, value: RuntimeVariable) is abstract + # Allocate `size` bytes with the low_level `nit_alloc` C function + # + # This method can be redefined to inject statistic or tracing code. + # + # `tag` if any, is used to mark the class of the allocated object. + fun nit_alloc(size: String, tag: nullable String): String + do + return "nit_alloc({size})" + end + # Evaluate `args` as expressions in the call of `mpropdef` on `recv`. # This method is used to manage varargs in signatures and returns the real array # of runtime variables to use in the call. fun varargize(mpropdef: MMethodDef, map: nullable SignatureMap, recv: RuntimeVariable, args: SequenceRead[AExpr]): Array[RuntimeVariable] do - var msignature = mpropdef.new_msignature or else mpropdef.msignature.as(not null) + var msignature = mpropdef.msignature.as(not null) var res = new Array[RuntimeVariable] res.add(recv) @@@ -1629,9 -1678,9 +1655,9 @@@ var native_mtype = mmodule.native_string_type var nat = self.new_var(native_mtype) self.add("{nat} = \"{string.escape_to_c}\";") - var bytelen = self.int_instance(string.bytelen) + var byte_length = self.int_instance(string.byte_length) var unilen = self.int_instance(string.length) - self.add("{res} = {self.send(self.get_property("to_s_full", native_mtype), [nat, bytelen, unilen]).as(not null)};") + self.add("{res} = {self.send(self.get_property("to_s_full", native_mtype), [nat, byte_length, unilen]).as(not null)};") self.add("{name} = {res};") self.add("\}") return res @@@ -2528,7 -2577,8 +2554,8 @@@ redef class AMethPropde v.ret(v.new_expr("!{res}", ret.as(not null))) return true else if pname == "new" then - v.ret(v.new_expr("(char*)nit_alloc({arguments[1]})", ret.as(not null))) + var alloc = v.nit_alloc(arguments[1].to_s, "NativeString") + v.ret(v.new_expr("(char*){alloc}", ret.as(not null))) return true else if pname == "fetch_4_chars" then v.ret(v.new_expr("(long)*((uint32_t*)({arguments[0]} + {arguments[1]}))", ret.as(not null))) @@@ -2981,12 -3031,6 +3008,6 @@@ else if pname == "sys" then v.ret(v.new_expr("glob_sys", ret.as(not null))) return true - else if pname == "calloc_string" then - v.ret(v.new_expr("(char*)nit_alloc({arguments[1]})", ret.as(not null))) - return true - else if pname == "calloc_array" then - v.calloc_array(ret.as(not null), arguments) - return true else if pname == "object_id" then v.ret(v.new_expr("(long){arguments.first}", ret.as(not null))) return true @@@ -3139,7 -3183,7 +3160,7 @@@ redef class AAttrPropde fun init_expr(v: AbstractCompilerVisitor, recv: RuntimeVariable) do - if has_value and not is_lazy and not n_expr isa ANullExpr then evaluate_expr(v, recv) + if has_value and not is_lazy and not is_optional and not n_expr isa ANullExpr then evaluate_expr(v, recv) end # Evaluate, store and return the default value of the attribute @@@ -3205,32 -3249,6 +3226,32 @@@ redef class AClassde v.supercall(mpropdef, arguments.first.mtype.as(MClassType), arguments) end return + else if mclassdef.auto_init == mpropdef then + var recv = arguments.first + var initializers = mpropdef.initializers + var no_init = false + if not initializers.is_empty then + + var i = 1 + for p in initializers do + if p isa MMethod then + var args = [recv] + for x in p.intro.msignature.mparameters do + args.add arguments[i] + i += 1 + end + v.send(p, args) + if p.intro.is_calling_init then no_init = true + else if p isa MAttribute then + v.write_attribute(p, recv, arguments[i]) + i += 1 + else abort + end + assert i == arguments.length + + end + if not no_init then v.send(mclass.the_root_init_mmethod.as(not null), [recv]) + return else abort end @@@ -3948,12 -3966,36 +3969,36 @@@ redef class ANewExp return v.native_array_instance(elttype, l) end - var recv = v.init_instance_or_extern(mtype) - var callsite = self.callsite - if callsite == null then return recv + if callsite == null then return v.init_instance_or_extern(mtype) if callsite.is_broken then return null + var recv + # new factories are badly implemented. + # They assume a stub temporary receiver exists. + # This temporary receiver is required because it + # currently holds the method and the formal types. + # + # However, this object could be reused if the formal types are the same. + # Therefore, the following code will `once` it in these case + if callsite.mproperty.is_new and not mtype.need_anchor then + var name = v.get_name("varoncenew") + var guard = v.get_name(name + "_guard") + v.add_decl("static {mtype.ctype} {name};") + v.add_decl("static int {guard};") + recv = v.new_var(mtype) + v.add("if (likely({guard})) \{") + v.add("{recv} = {name};") + v.add("\} else \{") + var i = v.init_instance_or_extern(mtype) + v.add("{recv} = {i};") + v.add("{name} = {recv};") + v.add("{guard} = 1;") + v.add("\}") + else + recv = v.init_instance_or_extern(mtype) + end + var args = v.varargize(callsite.mpropdef, callsite.signaturemap, recv, self.n_args.n_exprs) var res2 = v.compile_callsite(callsite, args) if res2 != null then diff --combined src/doc/html_templates/model_html.nit index 2d47728,0310a9c..e0dfb95 --- a/src/doc/html_templates/model_html.nit +++ b/src/doc/html_templates/model_html.nit @@@ -32,12 -32,12 +32,12 @@@ redef class MEntit # * MPropdef: `foo(e)` var html_name: String is lazy do return name.html_escape - # MEntity namespace escaped for html. - fun html_raw_namespace: String is abstract + # Returns the MEntity full_name escaped for html. + var html_full_name: String is lazy do return full_name.html_escape # Link to MEntity in the web server. # TODO this should be parameterizable... but how? - fun html_link: Link do return new Link("/doc/{html_raw_namespace}", html_name) + fun html_link: Link do return new Link("/doc/{full_name}", html_name) # Returns the list of keyword used in `self` declaration. fun html_modifiers: Array[String] is abstract @@@ -107,22 -107,12 +107,12 @@@ end redef class MPackage - redef fun html_raw_namespace do return html_name - redef var html_modifiers = ["package"] redef fun html_namespace do return html_link redef var css_classes = ["public"] end redef class MGroup - redef fun html_raw_namespace do - var parent = self.parent - if parent != null then - return "{parent.html_raw_namespace}::{html_name}" - end - return "{mpackage.html_raw_namespace}::{html_name}" - end - redef var html_modifiers = ["group"] # Depends if `self` is root or not. @@@ -161,17 -151,6 +151,6 @@@ redef class MModul return tpl end - redef fun html_raw_namespace do - var mpackage = self.mpackage - var mgroup = self.mgroup - if mgroup != null then - return "{mgroup.html_raw_namespace}::{html_name}" - else if mpackage != null then - return "{mpackage.html_raw_namespace}::{html_name}" - end - return html_name - end - redef var css_classes = ["public"] end @@@ -211,8 -190,6 +190,6 @@@ redef class MClas return tpl end - redef fun html_raw_namespace do return intro.html_raw_namespace - # Returns `intro.html_short_signature`. fun html_short_signature: Template do return intro.html_short_signature @@@ -224,8 -201,6 +201,6 @@@ end redef class MClassDef - redef fun html_raw_namespace do return "{mmodule.html_raw_namespace}::{html_name}" - redef fun mdoc_or_fallback do return mdoc or else mclass.mdoc_or_fallback # Depends if `self` is an intro or not. @@@ -342,8 -317,6 +317,6 @@@ redef class MPropert return tpl end - redef fun html_raw_namespace do return intro.html_raw_namespace - # Returns `intro.html_short_signature`. fun html_short_signature: Template do return intro.html_short_signature @@@ -354,7 -327,6 +327,6 @@@ end redef class MPropDef - redef fun html_raw_namespace do return "{mclassdef.html_raw_namespace}::{html_name}" redef fun mdoc_or_fallback do return mdoc or else mproperty.mdoc_or_fallback # Depends if `self` is an intro or not. @@@ -500,10 -472,18 +472,10 @@@ redef class MMethodDe end redef fun html_short_signature do - var new_msignature = self.new_msignature - if mproperty.is_root_init and new_msignature != null then - return new_msignature.html_short_signature - end return msignature.as(not null).html_short_signature end redef fun html_signature do - var new_msignature = self.new_msignature - if mproperty.is_root_init and new_msignature != null then - return new_msignature.html_signature - end return msignature.as(not null).html_signature end end @@@ -593,12 -573,10 +565,10 @@@ en redef class MParameterType redef fun html_short_signature do return html_link redef fun html_signature do return html_link - redef fun html_raw_namespace do return html_name end redef class MVirtualType redef fun html_signature do return html_link - redef fun html_raw_namespace do return html_name end redef class MSignature diff --combined src/interpreter/naive_interpreter.nit index 7389e2e,6d5ad40..a744fa2 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@@ -117,10 -117,6 +117,6 @@@ class NaiveInterprete # Set this mark to skip the evaluation until a labeled statement catch it with `is_escape` var escapemark: nullable EscapeMark = null - # Is an abort being executed ? - # Set this mark to return to the last `catch` bloc or effectively aborting if there isn't any - var catch_mark = new EscapeMark - # The count of `catch` blocs that have been encountered and can catch an abort var catch_count = 0 @@@ -323,10 -319,10 +319,10 @@@ # Return a new native string initialized with `txt` fun native_string_instance(txt: String): Instance do - var instance = native_string_instance_len(txt.bytelen+1) + var instance = native_string_instance_len(txt.byte_length+1) var val = instance.val - val[txt.bytelen] = 0u8 - txt.to_cstring.copy_to(val, txt.bytelen, 0, 0) + val[txt.byte_length] = 0u8 + txt.to_cstring.copy_to(val, txt.byte_length, 0, 0) return instance end @@@ -356,7 -352,7 +352,7 @@@ fun string_instance(txt: String): Instance do var nat = native_string_instance(txt) - var res = self.send(self.force_get_primitive_method("to_s_full", nat.mtype), [nat, self.int_instance(txt.bytelen), self.int_instance(txt.length)]) + var res = self.send(self.force_get_primitive_method("to_s_full", nat.mtype), [nat, self.int_instance(txt.byte_length), self.int_instance(txt.length)]) assert res != null return res end @@@ -450,7 -446,7 +446,7 @@@ # Return `null` if one of the evaluation of the arguments return null. fun varargize(mpropdef: MMethodDef, map: nullable SignatureMap, recv: Instance, args: SequenceRead[AExpr]): nullable Array[Instance] do - var msignature = mpropdef.new_msignature or else mpropdef.msignature.as(not null) + var msignature = mpropdef.msignature.as(not null) var res = new Array[Instance] res.add(recv) @@@ -582,6 -578,28 +578,6 @@@ fun callsite(callsite: nullable CallSite, arguments: Array[Instance]): nullable Instance do if callsite == null then return null - var initializers = callsite.mpropdef.initializers - if not initializers.is_empty then - var recv = arguments.first - var i = 1 - for p in initializers do - if p isa MMethod then - var args = [recv] - for x in p.intro.msignature.mparameters do - args.add arguments[i] - i += 1 - end - self.send(p, args) - else if p isa MAttribute then - assert recv isa MutableInstance - write_attribute(p, recv, arguments[i]) - i += 1 - else abort - end - assert i == arguments.length - - return send(callsite.mproperty, [recv]) - end return send(callsite.mproperty, arguments) end @@@ -1159,8 -1177,6 +1155,6 @@@ redef class AMethPropde else if pname == "utf8_length" then return v.int_instance(args[0].val.as(NativeString).utf8_length(args[1].to_i, args[2].to_i)) end - else if pname == "calloc_string" then - return v.native_string_instance_len(args[1].to_i) else if cname == "NativeArray" then if pname == "new" then var val = new Array[Instance].filled_with(v.null_instance, args[1].to_i) @@@ -1496,7 -1512,7 +1490,7 @@@ redef class AAttrPropde # Evaluate and set the default value of the attribute in `recv` private fun init_expr(v: NaiveInterpreter, recv: Instance) do - if is_lazy then return + if is_lazy or is_optional then return if has_value then var f = v.new_frame(self, mreadpropdef.as(not null), [recv]) evaluate_expr(v, recv, f) @@@ -1551,31 -1567,6 +1545,31 @@@ redef class AClassde v.call(superpd, arguments) end return null + else if mclassdef.auto_init == mpropdef then + var recv = arguments.first + var initializers = mpropdef.initializers + var no_init = false + if not initializers.is_empty then + var i = 1 + for p in initializers do + if p isa MMethod then + var args = [recv] + for x in p.intro.msignature.mparameters do + args.add arguments[i] + i += 1 + end + v.send(p, args) + if p.intro.is_calling_init then no_init = true + else if p isa MAttribute then + assert recv isa MutableInstance + v.write_attribute(p, recv, arguments[i]) + i += 1 + else abort + end + assert i == arguments.length + end + if not no_init then v.send(mclass.the_root_init_mmethod.as(not null), [recv]) + return null else abort end @@@ -1704,8 -1695,7 +1698,7 @@@ redef class AAbortExp fatal(v, "Aborted") exit(1) else - # Abort mode, skipping everything until a `catch` bloc is reached - v.escapemark = v.catch_mark + abort end end end @@@ -1750,14 -1740,23 +1743,23 @@@ en redef class ADoExpr redef fun stmt(v) do - # If this bloc has a catch, register it in the counter - if self.n_catch != null then v.catch_count += 1 - v.stmt(self.n_block) - v.is_escape(self.break_mark) # Clear the break (if any) + # If this bloc has a catch, handle it with a do ... catch ... end if self.n_catch != null then - v.catch_count -= 1 - # Are we in abort mode? then this catch is executing - if v.is_escape(v.catch_mark) then v.stmt(self.n_catch) + var frame = v.frame + v.catch_count += 1 + do + v.stmt(self.n_block) + v.is_escape(self.break_mark) # Clear the break (if any) + v.catch_count -= 1 + catch + # Restore the current frame if needed + while v.frame != frame do v.frames.shift + v.catch_count -= 1 + v.stmt(self.n_catch) + end + else + v.stmt(self.n_block) + v.is_escape(self.break_mark) end end end diff --combined src/model/model.nit index 8207bf0,660de85..730dbd5 --- a/src/model/model.nit +++ b/src/model/model.nit @@@ -30,6 -30,15 +30,15 @@@ import mdo import ordered_tree private import more_collections + redef class MEntity + # The visibility of the MEntity. + # + # MPackages, MGroups and MModules are always public. + # The visibility of `MClass` and `MProperty` is defined by the keyword used. + # `MClassDef` and `MPropDef` return the visibility of `MClass` and `MProperty`. + fun visibility: MVisibility do return public_visibility + end + redef class Model # All known classes var mclasses = new Array[MClass] @@@ -285,8 -294,9 +294,9 @@@ redef class MModul if name == "Bool" and self.model.get_mclasses_by_name("Object") != null then # Bool is injected because it is needed by engine to code the result # of the implicit casts. - var c = new MClass(self, name, null, enum_kind, public_visibility) - var cladef = new MClassDef(self, c.mclass_type, new Location(null, 0,0,0,0)) + var loc = model.no_location + var c = new MClass(self, name, loc, null, enum_kind, public_visibility) + var cladef = new MClassDef(self, c.mclass_type, loc) cladef.set_supertypes([object_type]) cladef.add_in_hierarchy return c @@@ -378,14 -388,17 +388,17 @@@ class MClas super MEntity # The module that introduce the class + # # While classes are not bound to a specific module, - # the introducing module is used for naming an visibility + # the introducing module is used for naming and visibility. var intro_mmodule: MModule # The short name of the class # In Nit, the name of a class cannot evolve in refinements redef var name + redef var location + # The canonical name of the class # # It is the name of the class prefixed by the full_name of the `intro_mmodule` @@@ -462,7 -475,7 +475,7 @@@ # The visibility of the class # In Nit, the visibility of a class cannot evolve in refinements - var visibility: MVisibility + redef var visibility init do @@@ -506,12 -519,12 +519,12 @@@ # The principal static type of the class. # - # For non-generic class, mclass_type is the only `MClassType` based + # For non-generic class, `mclass_type` is the only `MClassType` based # on self. # # For a generic class, the arguments are the formal parameters. - # i.e.: for the class Array[E:Object], the `mclass_type` is Array[E]. - # If you want Array[Object] the see `MClassDef::bound_mtype` + # i.e.: for the class `Array[E:Object]`, the `mclass_type` is `Array[E]`. + # If you want `Array[Object]`, see `MClassDef::bound_mtype`. # # For generic classes, the mclass_type is also the way to get a formal # generic parameter type. @@@ -552,6 -565,8 +565,8 @@@ # Is `self` and abstract class? var is_abstract: Bool is lazy do return kind == abstract_kind + + redef fun mdoc_or_fallback do return intro.mdoc_or_fallback end @@@ -588,11 -603,12 +603,12 @@@ class MClassDe # ENSURE: `bound_mtype.mclass == self.mclass` var bound_mtype: MClassType - # The origin of the definition - var location: Location + redef var location: Location + + redef fun visibility do return mclass.visibility # Internal name combining the module and the class - # Example: "mymodule#MyClass" + # Example: "mymodule$MyClass" redef var to_s is noinit init @@@ -604,34 -620,34 +620,34 @@@ assert not isset mclass._intro mclass.intro = self end - self.to_s = "{mmodule}#{mclass}" + self.to_s = "{mmodule}${mclass}" end # Actually the name of the `mclass` redef fun name do return mclass.name - # The module and class name separated by a '#'. + # The module and class name separated by a '$'. # # The short-name of the class is used for introduction. - # Example: "my_module#MyClass" + # Example: "my_module$MyClass" # # The full-name of the class is used for refinement. - # Example: "my_module#intro_module::MyClass" + # Example: "my_module$intro_module::MyClass" redef var full_name is lazy do if is_intro then - # public gives 'p#A' - # private gives 'p::m#A' - return "{mmodule.namespace_for(mclass.visibility)}#{mclass.name}" + # public gives 'p$A' + # private gives 'p::m$A' + return "{mmodule.namespace_for(mclass.visibility)}${mclass.name}" else if mclass.intro_mmodule.mpackage != mmodule.mpackage then - # public gives 'q::n#p::A' - # private gives 'q::n#p::m::A' - return "{mmodule.full_name}#{mclass.full_name}" + # public gives 'q::n$p::A' + # private gives 'q::n$p::m::A' + return "{mmodule.full_name}${mclass.full_name}" else if mclass.visibility > private_visibility then - # public gives 'p::n#A' - return "{mmodule.full_name}#{mclass.name}" + # public gives 'p::n$A' + return "{mmodule.full_name}${mclass.name}" else - # private gives 'p::n#::m::A' (redundant p is omitted) - return "{mmodule.full_name}#::{mclass.intro_mmodule.name}::{mclass.name}" + # private gives 'p::n$::m::A' (redundant p is omitted) + return "{mmodule.full_name}$::{mclass.intro_mmodule.name}::{mclass.name}" end end @@@ -706,9 -722,6 +722,9 @@@ # All property definitions in the class (introductions and redefinitions) var mpropdefs = new Array[MPropDef] + + # The special autoinit constructor + var auto_init: nullable MMethodDef = null is writable end # A global static type @@@ -1168,6 -1181,8 +1184,8 @@@ class MClassTyp redef fun model do return self.mclass.intro_mmodule.model + redef fun location do return mclass.location + # TODO: private init because strongly bounded to its mclass. see `mclass.mclass_type` # The formal arguments of the type @@@ -1373,6 -1388,8 +1391,8 @@@ class MVirtualTyp # Its the definitions of this property that determine the bound or the virtual type. var mproperty: MVirtualTypeProp + redef fun location do return mproperty.location + redef fun model do return self.mproperty.intro_mclassdef.mmodule.model redef fun lookup_bound(mmodule: MModule, resolved_receiver: MType): MType @@@ -1503,6 -1520,8 +1523,8 @@@ class MParameterTyp redef fun model do return self.mclass.intro_mmodule.model + redef fun location do return mclass.location + # The position of the parameter (0 for the first parameter) # FIXME: is `position` a better name? var rank: Int @@@ -1628,6 -1647,8 +1650,8 @@@ abstract class MProxyTyp # The base type var mtype: MType + redef fun location do return mtype.location + redef fun model do return self.mtype.model redef fun need_anchor do return mtype.need_anchor redef fun as_nullable do return mtype.as_nullable @@@ -1954,12 -1975,27 +1978,27 @@@ abstract class MPropert # The (short) name of the property redef var name + redef var location + + redef fun mdoc_or_fallback do return intro.mdoc_or_fallback + # The canonical name of the property. # - # It is the short-`name` prefixed by the short-name of the class and the full-name of the module. + # It is currently the short-`name` prefixed by the short-name of the class and the full-name of the module. # Example: "my_package::my_module::MyClass::my_method" + # + # The full-name of the module is needed because two distinct modules of the same package can + # still refine the same class and introduce homonym properties. + # + # For public properties not introduced by refinement, the module name is not used. + # + # Example: `my_package::MyClass::My_method` redef var full_name is lazy do - return "{intro_mclassdef.mmodule.namespace_for(visibility)}::{intro_mclassdef.mclass.name}::{name}" + if intro_mclassdef.is_intro then + return "{intro_mclassdef.mmodule.namespace_for(visibility)}::{intro_mclassdef.mclass.name}::{name}" + else + return "{intro_mclassdef.mmodule.full_name}::{intro_mclassdef.mclass.name}::{name}" + end end redef var c_name is lazy do @@@ -1968,7 -2004,7 +2007,7 @@@ end # The visibility of the property - var visibility: MVisibility + redef var visibility # Is the property usable as an initializer? var is_autoinit = false is writable @@@ -2233,8 -2269,9 +2272,9 @@@ abstract class MPropDe # The associated global property var mproperty: MPROPERTY - # The origin of the definition - var location: Location + redef var location: Location + + redef fun visibility do return mproperty.visibility init do @@@ -2244,7 -2281,7 +2284,7 @@@ assert not isset mproperty._intro mproperty.intro = self end - self.to_s = "{mclassdef}#{mproperty}" + self.to_s = "{mclassdef}${mproperty}" end # Actually the name of the `mproperty` @@@ -2258,17 -2295,17 +2298,17 @@@ # * a property "p::m::A::x" # * redefined in a refinement of a class "q::n::B" # * in a module "r::o" - # * so "r::o#q::n::B#p::m::A::x" + # * so "r::o$q::n::B$p::m::A::x" # # Fortunately, the full-name is simplified when entities are repeated. - # For the previous case, the simplest form is "p#A#x". + # For the previous case, the simplest form is "p$A$x". redef var full_name is lazy do var res = new FlatBuffer - # The first part is the mclassdef. Worst case is "r::o#q::n::B" + # The first part is the mclassdef. Worst case is "r::o$q::n::B" res.append mclassdef.full_name - res.append "#" + res.append "$" if mclassdef.mclass == mproperty.intro_mclassdef.mclass then # intro are unambiguous in a class @@@ -2277,7 -2314,7 +2317,7 @@@ # Just try to simplify each part if mclassdef.mmodule.mpackage != mproperty.intro_mclassdef.mmodule.mpackage then # precise "p::m" only if "p" != "r" - res.append mproperty.intro_mclassdef.mmodule.full_name + res.append mproperty.intro_mclassdef.mmodule.namespace_for(mproperty.visibility) res.append "::" else if mproperty.visibility <= private_visibility then # Same package ("p"=="q"), but private visibility, @@@ -2322,7 -2359,7 +2362,7 @@@ redef fun model do return mclassdef.model # Internal name combining the module, the class and the property - # Example: "mymodule#MyClass#mymethod" + # Example: "mymodule$MyClass$mymethod" redef var to_s is noinit # Is self the definition that introduce the property? @@@ -2357,17 -2394,19 +2397,17 @@@ class MMethodDe # The signature attached to the property definition var msignature: nullable MSignature = null is writable # List of initialisers to call in root-inits # # They could be setters or attributes - # - # REQUIRE `mproperty.is_root_init == (new_msignature != null)` var initializers = new Array[MProperty] + # Does the method take the responsibility to call `init`? + # + # If the method is used as an initializer, then + # using this information prevents to call `init` twice. + var is_calling_init = false is writable + # Is the method definition abstract? var is_abstract: Bool = false is writable diff --combined src/modelize/modelize_property.nit index 8c167c6,246e813..98f97e2 --- a/src/modelize/modelize_property.nit +++ b/src/modelize/modelize_property.nit @@@ -55,9 -55,10 +55,9 @@@ redef class ModelBuilde toolcontext.run_phases_on_npropdef(res) return res end - if mpropdef isa MMethodDef and mpropdef.mproperty.is_root_init then - res = mclassdef2nclassdef.get_or_null(mpropdef.mclassdef) - if res != null then return res - end + # Fall back to the class node if any. + res = mclassdef2nclassdef.get_or_null(mpropdef.mclassdef) + if res != null then return res return null end @@@ -144,15 -145,17 +144,15 @@@ # Look for the init in Object, or create it if mclassdef.mclass.name == "Object" and the_root_init_mmethod == null then # Create the implicit root-init method - var mprop = new MMethod(mclassdef, "init", mclassdef.mclass.visibility) + var mprop = new MMethod(mclassdef, "init", nclassdef.location, mclassdef.mclass.visibility) mprop.is_root_init = true var mpropdef = new MMethodDef(mclassdef, mprop, nclassdef.location) var mparameters = new Array[MParameter] var msignature = new MSignature(mparameters, null) mpropdef.msignature = msignature mprop.is_init = true self.toolcontext.info("{mclassdef} gets a free empty constructor {mpropdef}{msignature}", 3) the_root_init_mmethod = mprop - return end # Is there already a constructor defined? @@@ -163,16 -166,12 +163,16 @@@ if mpropdef.mproperty.is_root_init then assert defined_init == null defined_init = mpropdef - else if mpropdef.mproperty.name == "init" then + else if mpropdef.mproperty.name == "autoinit" then # An explicit old-style init named "init", so return return end end + if mclassdef.auto_init != null then + return + end + if not nclassdef isa AStdClassdef then return # Collect undefined attributes @@@ -229,12 -228,10 +229,12 @@@ if the_root_init_mmethod == null then return # Look for most-specific new-stype init definitions - var spropdefs = the_root_init_mmethod.lookup_super_definitions(mclassdef.mmodule, mclassdef.bound_mtype) - if spropdefs.is_empty then - toolcontext.error(nclassdef.location, "Error: `{mclassdef}` does not specialize `{the_root_init_mmethod.intro_mclassdef}`. Possible duplication of the root class `Object`?") - return + var spropdefs = new ArraySet[MMethodDef] + for x in mclassdef.in_hierarchy.direct_greaters do + var y = x.mclass.intro.auto_init + if y == null then continue + if y.is_broken or y.msignature == null then return + spropdefs.add y end # Look at the autoinit class-annotation @@@ -288,31 -285,13 +288,31 @@@ abort end end - else + else if spropdefs.not_empty then + # Search for inherited manual autoinit + var manual = null + for s in spropdefs do + if mpropdef2npropdef.has_key(s) then + self.toolcontext.info("{mclassdef} inherits a manual autoinit {s}", 3) + #mclassdef.autoinit = s + #return + manual = s + end + end + # Search the longest-one and checks for conflict var longest = spropdefs.first if spropdefs.length > 1 then # part 1. find the longest list for spd in spropdefs do if spd.initializers.length > longest.initializers.length then longest = spd + if spd != manual and manual != null then + self.toolcontext.info("{mclassdef} conflict between manual autoinit {manual} and automatic autoinit {spd}.", 3) + end + end + # conflict with manual autoinit? + if longest != manual and manual != null then + self.error(nclassdef, "Error: conflict between manual autoinit {manual} and automatic autoinit {longest}.") end # part 2. compare # Check for conflict in the order of initializers @@@ -345,27 -324,41 +345,27 @@@ mparameters.clear initializers.clear else - # Can we just inherit? - if spropdefs.length == 1 and mparameters.is_empty and defined_init == null then - self.toolcontext.info("{mclassdef} inherits the basic constructor {longest}", 3) - mclassdef.mclass.root_init = longest - return - end - # Combine the inherited list to what is collected if longest.initializers.length > 0 then - mparameters.prepend longest.new_msignature.mparameters + mparameters.prepend longest.msignature.mparameters initializers.prepend longest.initializers end end end - # If we already have a basic init definition, then setup its initializers - if defined_init != null then - defined_init.initializers.add_all(initializers) + # Create a specific new autoinit constructor + do - var mprop = new MMethod(mclassdef, "autoinit", public_visibility) ++ var mprop = new MMethod(mclassdef, "autoinit", nclassdef.location, public_visibility) + mprop.is_init = true + var mpropdef = new MMethodDef(mclassdef, mprop, nclassdef.location) + mpropdef.initializers.add_all(initializers) var msignature = new MSignature(mparameters, null) - defined_init.new_msignature = msignature - self.toolcontext.info("{mclassdef} extends its basic constructor signature to {defined_init}{msignature}", 3) - mclassdef.mclass.root_init = defined_init - return + mpropdef.msignature = msignature + mclassdef.auto_init = mpropdef + self.toolcontext.info("{mclassdef} gets a free auto constructor `{mpropdef}{msignature}`. {spropdefs}", 3) + #mclassdef.mclass.root_init = mpropdef + mclassdef.mclass.the_root_init_mmethod = the_root_init_mmethod end - - # Else create the local implicit basic init definition - var mprop = the_root_init_mmethod - var mpropdef = new MMethodDef(mclassdef, mprop, nclassdef.location) - mpropdef.has_supercall = true - mpropdef.initializers.add_all(initializers) - var msignature = new MSignature(mparameters, null) - mpropdef.new_msignature = msignature - mpropdef.msignature = new MSignature(new Array[MParameter], null) # always an empty real signature - self.toolcontext.info("{mclassdef} gets a free constructor for attributes {mpropdef}{msignature}", 3) - mclassdef.mclass.root_init = mpropdef end # Check the visibility of `mtype` as an element of the signature of `mpropdef`. @@@ -499,15 -492,11 +499,15 @@@ en redef class MClass # The base init of the class. - # Used to get the common new_msignature and initializers # # TODO: Where to put this information is not clear because unlike other # informations, the initialisers are stable in a same class. var root_init: nullable MMethodDef = null + + # The base init of the class. + # + # TODO: merge with `root_init` and `ModelBuilder::the_root_init_mmethod` if possible + var the_root_init_mmethod: nullable MMethod = null end redef class MClassDef @@@ -791,9 -780,6 +791,9 @@@ redef class AMethPropde else if n_kwinit != null then name = "init" name_node = n_kwinit + if self.n_signature.n_params.not_empty or get_single_annotation("old_style_init", modelbuilder) != null then + name = "autoinit" + end else if n_kwnew != null then name = "new" name_node = n_kwnew @@@ -826,7 -812,7 +826,7 @@@ var look_like_a_root_init = look_like_a_root_init(modelbuilder, mclassdef) var mprop: nullable MMethod = null - if not is_init or n_kwredef != null then mprop = modelbuilder.try_get_mproperty_by_name(name_node, mclassdef, name).as(nullable MMethod) + if not is_init or n_kwredef != null or look_like_a_root_init then mprop = modelbuilder.try_get_mproperty_by_name(name_node, mclassdef, name).as(nullable MMethod) if mprop == null and look_like_a_root_init then mprop = modelbuilder.the_root_init_mmethod var nb = n_block @@@ -836,7 -822,7 +836,7 @@@ end if mprop == null then var mvisibility = new_property_visibility(modelbuilder, mclassdef, self.n_visibility) - mprop = new MMethod(mclassdef, name, mvisibility) + mprop = new MMethod(mclassdef, name, self.location, mvisibility) if look_like_a_root_init and modelbuilder.the_root_init_mmethod == null then modelbuilder.the_root_init_mmethod = mprop mprop.is_root_init = true @@@ -850,9 -836,7 +850,7 @@@ return end else - if mprop.is_broken then - return - end + if mprop.is_broken then return if not self.check_redef_keyword(modelbuilder, mclassdef, n_kwredef, not self isa AMainMethPropdef, mprop) then return check_redef_property_visibility(modelbuilder, self.n_visibility, mprop) end @@@ -873,14 -857,6 +871,14 @@@ mclassdef.mprop2npropdef[mprop] = self var mpropdef = new MMethodDef(mclassdef, mprop, self.location) + if mprop.name == "autoinit" and mclassdef.is_intro then + assert mclassdef.auto_init == null + mclassdef.auto_init = mpropdef + if mpropdef.is_intro then + mpropdef.initializers.add mprop + mpropdef.is_calling_init = true + end + end set_doc(mpropdef, modelbuilder) @@@ -905,6 -881,7 +903,6 @@@ var root_init = mclassdef.mclass.root_init if root_init != null then # Inherit the initializers by refinement - mpropdef.new_msignature = root_init.new_msignature assert mpropdef.initializers.is_empty mpropdef.initializers.add_all root_init.initializers end @@@ -1207,7 -1184,7 +1205,7 @@@ redef class AAttrPropde modelbuilder.error(self, "Error: attempt to define attribute `{name}` in the {mclass.kind} `{mclass}`.") end - var mprop = new MAttribute(mclassdef, "_" + name, private_visibility) + var mprop = new MAttribute(mclassdef, "_" + name, self.location, private_visibility) var mpropdef = new MAttributeDef(mclassdef, mprop, self.location) self.mpropdef = mpropdef modelbuilder.mpropdef2npropdef[mpropdef] = self @@@ -1217,9 -1194,13 +1215,13 @@@ var mreadprop = modelbuilder.try_get_mproperty_by_name(nid2, mclassdef, readname).as(nullable MMethod) if mreadprop == null then var mvisibility = new_property_visibility(modelbuilder, mclassdef, self.n_visibility) - mreadprop = new MMethod(mclassdef, readname, mvisibility) - if not self.check_redef_keyword(modelbuilder, mclassdef, n_kwredef, false, mreadprop) then return + mreadprop = new MMethod(mclassdef, readname, self.location, mvisibility) + if not self.check_redef_keyword(modelbuilder, mclassdef, n_kwredef, false, mreadprop) then + mreadprop.is_broken = true + return + end else + if mreadprop.is_broken then return if not self.check_redef_keyword(modelbuilder, mclassdef, n_kwredef, true, mreadprop) then return check_redef_property_visibility(modelbuilder, self.n_visibility, mreadprop) end @@@ -1269,7 -1250,7 +1271,7 @@@ return end is_lazy = true - var mlazyprop = new MAttribute(mclassdef, "lazy _" + name, none_visibility) + var mlazyprop = new MAttribute(mclassdef, "lazy _" + name, self.location, none_visibility) mlazyprop.is_fictive = true var mlazypropdef = new MAttributeDef(mclassdef, mlazyprop, self.location) mlazypropdef.is_fictive = true @@@ -1316,10 -1297,14 +1318,14 @@@ # By default, use protected visibility at most if mvisibility > protected_visibility then mvisibility = protected_visibility end - mwriteprop = new MMethod(mclassdef, writename, mvisibility) - if not self.check_redef_keyword(modelbuilder, mclassdef, nwkwredef, false, mwriteprop) then return + mwriteprop = new MMethod(mclassdef, writename, self.location, mvisibility) + if not self.check_redef_keyword(modelbuilder, mclassdef, nwkwredef, false, mwriteprop) then + mwriteprop.is_broken = true + return + end mwriteprop.deprecation = mreadprop.deprecation else + if mwriteprop.is_broken then return if not self.check_redef_keyword(modelbuilder, mclassdef, nwkwredef or else n_kwredef, true, mwriteprop) then return if atwritable != null then check_redef_property_visibility(modelbuilder, atwritable.n_visibility, mwriteprop) @@@ -1484,7 -1469,7 +1490,7 @@@ var mlazypropdef = self.mlazypropdef if mlazypropdef != null then - mlazypropdef.static_mtype = modelbuilder.model.get_mclasses_by_name("Bool").first.mclass_type + mlazypropdef.static_mtype = mmodule.bool_type end check_repeated_types(modelbuilder) end @@@ -1623,12 -1608,13 +1629,13 @@@ redef class ATypePropde var mprop = modelbuilder.try_get_mproperty_by_name(self.n_qid, mclassdef, name) if mprop == null then var mvisibility = new_property_visibility(modelbuilder, mclassdef, self.n_visibility) - mprop = new MVirtualTypeProp(mclassdef, name, mvisibility) + mprop = new MVirtualTypeProp(mclassdef, name, self.location, mvisibility) for c in name.chars do if c >= 'a' and c<= 'z' then modelbuilder.warning(n_qid, "bad-type-name", "Warning: lowercase in the virtual type `{name}`.") break end else + if mprop.is_broken then return assert mprop isa MVirtualTypeProp check_redef_property_visibility(modelbuilder, self.n_visibility, mprop) end diff --combined src/rapid_type_analysis.nit index 5da1494,88e2b7e..cea654b --- a/src/rapid_type_analysis.nit +++ b/src/rapid_type_analysis.nit @@@ -132,7 -132,7 +132,7 @@@ class RapidTypeAnalysi var types = typeset.to_a (new CachedAlphaComparator).sort(types) var res = new CsvDocument - res.format = new CsvFormat('"', ';', "\n") + res.separator = ';' res.header = ["Type", "Resolution", "Liveness", "Cast-liveness"] for t in types do var reso @@@ -245,6 -245,7 +245,6 @@@ v.add_monomorphic_send(vararg, self.modelbuilder.force_get_primitive_method(node, "with_native", vararg.mclass, self.mainmodule)) end - # TODO? new_msignature var sig = msignature var osig = mmeth.intro.msignature.as(not null) for i in [0..sig.arity[ do @@@ -254,19 -255,15 +254,21 @@@ add_cast(paramtype) end + if mmethoddef.is_abstract then continue + var npropdef = modelbuilder.mpropdef2node(mmethoddef) if npropdef isa AClassdef then if mmethoddef.mproperty.is_root_init then + # Final init call if not mmethoddef.is_intro then self.add_super_send(v.receiver, mmethoddef) end + else if mmethoddef.mclassdef.auto_init == mmethoddef then + # autoinit call + for i in mmethoddef.initializers do + if i isa MMethod then self.add_send(v.receiver, i) + end else npropdef.debug "cannot RTA {mmethoddef}" abort @@@ -319,7 -316,9 +321,9 @@@ if not check_depth(rt) then continue #print "{ot}/{t} -> {rt}" live_types.add(rt) - todo_types.add(rt) + # unshift means a deep-first visit. + # So that the `check_depth` limit is reached sooner. + todo_types.unshift(rt) end end #print "MType {live_types.length}: {live_types.join(", ")}" diff --combined src/semantize/typing.nit index 5f4c2dc,73e1bd0..375f80a --- a/src/semantize/typing.nit +++ b/src/semantize/typing.nit @@@ -318,12 -318,8 +318,12 @@@ private class TypeVisito var mproperty = self.try_get_mproperty_by_name2(node, unsafe_type, name) if name == "new" and mproperty == null then - name = "init" + name = "autoinit" mproperty = self.try_get_mproperty_by_name2(node, unsafe_type, name) + if mproperty == null then + name = "init" + mproperty = self.try_get_mproperty_by_name2(node, unsafe_type, name) + end end if mproperty == null then @@@ -382,7 -378,7 +382,7 @@@ end - var msignature = mpropdef.new_msignature or else mpropdef.msignature + var msignature = mpropdef.msignature if msignature == null then return null # skip error msignature = resolve_for(msignature, recvtype, recv_is_self).as(MSignature) @@@ -641,8 -637,7 +641,7 @@@ en class CallSite super MEntity - # The associated location of the callsite - var location: Location + redef var location: Location # The static type of the receiver (possibly unresolved) var recv: MType @@@ -1640,7 -1635,7 +1639,7 @@@ redef class ARangeExp # get the constructor var callsite if self isa ACrangeExpr then - callsite = v.get_method(self, mtype, "init", false) + callsite = v.get_method(self, mtype, "autoinit", false) else if self isa AOrangeExpr then callsite = v.get_method(self, mtype, "without_last", false) else @@@ -1671,11 -1666,15 +1670,15 @@@ redef class AIsaExp var variable = self.n_expr.its_variable if variable != null then - #var orig = self.n_expr.mtype + 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(v, variable, mtype) + + # Do not adapt if there is no information gain (i.e. adapt to a supertype) + if mtype == null or orig == null or not v.is_subtype(orig, mtype) then + self.after_flow_context.when_true.set_var(v, variable, mtype) + end end self.mtype = v.type_bool(self) @@@ -1971,7 -1970,7 +1974,7 @@@ redef class ABraReassignExp end redef class AInitExpr - redef fun property_name do return "init" + redef fun property_name do if n_args.n_exprs.is_empty then return "init" else return "autoinit" redef fun property_node do return n_kwinit redef fun compute_raw_arguments do return n_args.to_a end @@@ -2071,7 -2070,7 +2074,7 @@@ redef class ASuperExp return end - var msignature = superprop.new_msignature or else superprop.msignature.as(not null) + var msignature = superprop.msignature.as(not null) msignature = v.resolve_for(msignature, recvtype, true).as(MSignature) var callsite = new CallSite(hot_location, recvtype, v.mmodule, v.anchor, true, superprop.mproperty, superprop, msignature, false) diff --combined tests/sav/base_init_basic_alt3.res index d856b64,84d579c..f7e3b6d --- a/tests/sav/base_init_basic_alt3.res +++ b/tests/sav/base_init_basic_alt3.res @@@ -1,2 -1,2 +1,2 @@@ - alt/base_init_basic_alt3.nit:47,7: Error: cannot generate automatic init for class F. Conflict in the order in inherited initializers base_init_basic_alt3#D#autoinit(c=, b=) and base_init_basic_alt3#E#autoinit(c=, e=). Use `autoinit` to order initializers. eg `autoinit c=, e=, b=` - alt/base_init_basic_alt3.nit:54,7: Error: cannot generate automatic init for class G. Conflict in the order in inherited initializers base_init_basic_alt3#D#autoinit(c=, b=) and base_init_basic_alt3#E#autoinit(c=, e=). Use `autoinit` to order initializers. eg `autoinit c=, e=, b=, g=` -alt/base_init_basic_alt3.nit:47,7: Error: cannot generate automatic init for class F. Conflict in the order in inherited initializers base_init_basic_alt3$E$init(c=, e=) and base_init_basic_alt3$D$init(c=, b=). Use `autoinit` to order initializers. eg `autoinit c=, b=, e=` -alt/base_init_basic_alt3.nit:54,7: Error: cannot generate automatic init for class G. Conflict in the order in inherited initializers base_init_basic_alt3$E$init(c=, e=) and base_init_basic_alt3$D$init(c=, b=). Use `autoinit` to order initializers. eg `autoinit c=, b=, e=, g=` ++alt/base_init_basic_alt3.nit:47,7: Error: cannot generate automatic init for class F. Conflict in the order in inherited initializers base_init_basic_alt3$D$autoinit(c=, b=) and base_init_basic_alt3$E$autoinit(c=, e=). Use `autoinit` to order initializers. eg `autoinit c=, e=, b=` ++alt/base_init_basic_alt3.nit:54,7: Error: cannot generate automatic init for class G. Conflict in the order in inherited initializers base_init_basic_alt3$D$autoinit(c=, b=) and base_init_basic_alt3$E$autoinit(c=, e=). Use `autoinit` to order initializers. eg `autoinit c=, e=, b=, g=` diff --combined tests/sav/nitdoc_args4.res index c1ed475,9238b51..53f4e84 --- a/tests/sav/nitdoc_args4.res +++ b/tests/sav/nitdoc_args4.res @@@ -1,8 -1,35 +1,35 @@@ + Empty README for group `excluded` (readme-warning) + Errors: 0. Warnings: 1. + MGroupPage excluded + # excluded.section + ## excluded.intro + ## excluded.concerns + ## excluded.concern + ## excluded.concern + ## excluded-.concern + ### excluded-.definition + #### excluded-.intros_redefs + ##### list.group + ###### excluded-.intros + ###### excluded-.redefs + + MModulePage excluded + # excluded.section + ## excluded-.intro + ## excluded-.importation + ### excluded-.graph + ### list.group + #### excluded-.imports + #### excluded-.clients + OverviewPage Overview # home.article ## packages.section + ### excluded.definition ### test_prog.definition + ReadmePage excluded + ReadmePage test_prog # mdarticle-0 @@@ -67,17 -94,13 +94,17 @@@ MClassPage Starte #### test_prog-__Starter.children #### test_prog-__Starter.descendants ## test_prog-__Starter.constructors - ### test_prog__platform-__Object__init.definition + ### test_prog-__Starter__autoinit.definition ## test_prog-__Starter.concerns ## test_prog.concern ## test_prog.concern ## test_prog-.concern ### test_prog-__Starter__start.definition +MPropertyPage autoinit + # autoinit.section + ## test_prog-__Starter__autoinit.intro + MPropertyPage start # start.section ## test_prog-__Starter__start.intro @@@ -148,7 -171,7 +175,7 @@@ MClassPage Gam #### test_prog__game-__Game.children #### test_prog__game-__Game.descendants ## test_prog__game-__Game.constructors - ### test_prog__platform-__Object__init.definition + ### test_prog__game-__Game__autoinit.definition ## test_prog__game-__Game.concerns ## test_prog.concern ## test_prog.concern @@@ -160,10 -183,6 +187,10 @@@ ### test_prog__game-__Game__start_game.definition ### test_prog__game-__Game__stop_game.definition +MPropertyPage autoinit + # autoinit.section + ## test_prog__game-__Game__autoinit.intro + MPropertyPage computer_characters # computer_characters.section ## test_prog__game-__Game__computer_characters.intro @@@ -258,17 -277,6 +285,17 @@@ MClassPage Boo #### test_prog__platform-__Bool.ancestors #### test_prog__platform-__Bool.children #### test_prog__platform-__Bool.descendants + ## test_prog__platform-__Bool.constructors + ### test_prog__platform-__Bool__autoinit.definition + ## test_prog__platform-__Bool.concerns + ## test_prog.concern + ## test_prog.concern + ## test_prog__platform.concern + ## test_prog__platform-.concern + +MPropertyPage autoinit + # autoinit.section + ## test_prog__platform-__Bool__autoinit.intro MClassPage Float # Float.section @@@ -281,7 -289,7 +308,7 @@@ #### test_prog__platform-__Float.children #### test_prog__platform-__Float.descendants ## test_prog__platform-__Float.constructors - ### test_prog__platform-__Object__init.definition + ### test_prog__platform-__Float__autoinit.definition ## test_prog__platform-__Float.concerns ## test_prog.concern ## test_prog.concern @@@ -313,10 -321,6 +340,10 @@@ MPropertyPage > # >.section ## test_prog__platform-__Float___62d.intro +MPropertyPage autoinit + # autoinit.section + ## test_prog__platform-__Float__autoinit.intro + MClassPage Int # Int.section ## test_prog__platform-__Int.intro @@@ -328,7 -332,7 +355,7 @@@ #### test_prog__platform-__Int.children #### test_prog__platform-__Int.descendants ## test_prog__platform-__Int.constructors - ### test_prog__platform-__Object__init.definition + ### test_prog__platform-__Int__autoinit.definition ## test_prog__platform-__Int.concerns ## test_prog.concern ## test_prog.concern @@@ -362,10 -366,6 +389,10 @@@ MPropertyPage > # >.section ## test_prog__platform-__Int___62d.intro +MPropertyPage autoinit + # autoinit.section + ## test_prog__platform-__Int__autoinit.intro + MPropertyPage to_f # to_f.section ## test_prog__platform-__Int__to_f.intro @@@ -384,17 -384,6 +411,17 @@@ MClassPage Lis #### test_prog__platform-__List.ancestors #### test_prog__platform-__List.children #### test_prog__platform-__List.descendants + ## test_prog__platform-__List.constructors + ### test_prog__platform-__List__autoinit.definition + ## test_prog__platform-__List.concerns + ## test_prog.concern + ## test_prog.concern + ## test_prog__platform.concern + ## test_prog__platform-.concern + +MPropertyPage autoinit + # autoinit.section + ## test_prog__platform-__List__autoinit.intro MClassPage Object # Object.section @@@ -407,7 -396,6 +434,7 @@@ #### test_prog__platform-__Object.children #### test_prog__platform-__Object.descendants ## test_prog__platform-__Object.constructors + ### test_prog__platform-__Object__autoinit.definition ### test_prog__platform-__Object__init.definition ## test_prog__platform-__Object.concerns ## test_prog.concern @@@ -430,10 -418,6 +457,10 @@@ MPropertyPage = # ==.section ## test_prog__platform-__Object___61d_61d.intro +MPropertyPage autoinit + # autoinit.section + ## test_prog__platform-__Object__autoinit.intro + MPropertyPage init # init.section ## test_prog__platform-__Object__init.intro @@@ -451,6 -435,8 +478,6 @@@ ### test_prog__rpg__races__Human__init.definition ### test_prog__rpg__races__Dwarf__init.definition ### test_prog__rpg__races__Elf__init.definition - ## test_prog__rpg__character.concern - ### test_prog__rpg__character__Character__init.definition MClassPage String # String.section @@@ -462,17 -448,6 +489,17 @@@ #### test_prog__platform-__String.ancestors #### test_prog__platform-__String.children #### test_prog__platform-__String.descendants + ## test_prog__platform-__String.constructors + ### test_prog__platform-__String__autoinit.definition + ## test_prog__platform-__String.concerns + ## test_prog.concern + ## test_prog.concern + ## test_prog__platform.concern + ## test_prog__platform-.concern + +MPropertyPage autoinit + # autoinit.section + ## test_prog__platform-__String__autoinit.intro MGroupPage rpg # rpg.section @@@ -561,7 -536,6 +588,7 @@@ MClassPage Alcoholi #### test_prog__rpg__careers__Alcoholic.children #### test_prog__rpg__careers__Alcoholic.descendants ## test_prog__rpg__careers__Alcoholic.constructors + ### test_prog__rpg__careers__Alcoholic__autoinit.definition ### test_prog__rpg__careers__Alcoholic__init.definition #### test_prog__rpg__careers__Alcoholic__init.lin ## test_prog__rpg__careers__Alcoholic.concerns @@@ -570,10 -544,6 +597,10 @@@ ## test_prog__rpg.concern ## test_prog__rpg__careers.concern +MPropertyPage autoinit + # autoinit.section + ## test_prog__rpg__careers__Alcoholic__autoinit.intro + MClassPage Career # Career.section ## test_prog__rpg__careers__Career.intro @@@ -585,7 -555,6 +612,7 @@@ #### test_prog__rpg__careers__Career.children #### test_prog__rpg__careers__Career.descendants ## test_prog__rpg__careers__Career.constructors + ### test_prog__rpg__careers__Career__autoinit.definition ### test_prog__rpg__careers__Career__init.definition #### test_prog__rpg__careers__Career__init.lin ## test_prog__rpg__careers__Career.concerns @@@ -600,10 -569,6 +627,10 @@@ ### test_prog__rpg__careers__Career__strength_bonus.definition ### test_prog__rpg__careers__Career__strength_bonus_61d.definition +MPropertyPage autoinit + # autoinit.section + ## test_prog__rpg__careers__Career__autoinit.intro + MPropertyPage endurance_bonus # endurance_bonus.section ## test_prog__rpg__careers__Career__endurance_bonus.intro @@@ -639,7 -604,6 +666,7 @@@ MClassPage Magicia #### test_prog__rpg__careers__Magician.children #### test_prog__rpg__careers__Magician.descendants ## test_prog__rpg__careers__Magician.constructors + ### test_prog__rpg__careers__Magician__autoinit.definition ### test_prog__rpg__careers__Magician__init.definition #### test_prog__rpg__careers__Magician__init.lin ## test_prog__rpg__careers__Magician.concerns @@@ -648,10 -612,6 +675,10 @@@ ## test_prog__rpg.concern ## test_prog__rpg__careers.concern +MPropertyPage autoinit + # autoinit.section + ## test_prog__rpg__careers__Magician__autoinit.intro + MClassPage Warrior # Warrior.section ## test_prog__rpg__careers__Warrior.intro @@@ -663,7 -623,6 +690,7 @@@ #### test_prog__rpg__careers__Warrior.children #### test_prog__rpg__careers__Warrior.descendants ## test_prog__rpg__careers__Warrior.constructors + ### test_prog__rpg__careers__Warrior__autoinit.definition ### test_prog__rpg__careers__Warrior__init.definition #### test_prog__rpg__careers__Warrior__init.lin ## test_prog__rpg__careers__Warrior.concerns @@@ -672,10 -631,6 +699,10 @@@ ## test_prog__rpg.concern ## test_prog__rpg__careers.concern +MPropertyPage autoinit + # autoinit.section + ## test_prog__rpg__careers__Warrior__autoinit.intro + MModulePage character # character.section ## test_prog__rpg__character.intro @@@ -707,7 -662,8 +734,7 @@@ MClassPage Characte #### test_prog__rpg__character__Character.children #### test_prog__rpg__character__Character.descendants ## test_prog__rpg__character__Character.constructors - ### test_prog__rpg__character__Character__init.definition - #### test_prog__rpg__character__Character__init.lin + ### test_prog__rpg__character__Character__autoinit.definition ## test_prog__rpg__character__Character.concerns ## test_prog.concern ## test_prog.concern @@@ -742,10 -698,6 +769,10 @@@ MPropertyPage age # age=.section ## test_prog__rpg__character__Character__age_61d.intro +MPropertyPage autoinit + # autoinit.section + ## test_prog__rpg__character__Character__autoinit.intro + MPropertyPage career # career.section ## test_prog__rpg__character__Character__career.intro @@@ -859,7 -811,7 +886,7 @@@ MClassPage Combatabl #### test_prog__rpg__combat__Combatable.children #### test_prog__rpg__combat__Combatable.descendants ## test_prog__rpg__combat__Combatable.constructors - ### test_prog__platform-__Object__init.definition + ### test_prog__rpg__combat__Combatable__autoinit.definition ## test_prog__rpg__combat__Combatable.concerns ## test_prog.concern ## test_prog.concern @@@ -875,10 -827,6 +902,10 @@@ MPropertyPage attac # attack.section ## test_prog__rpg__combat__Combatable__attack.intro +MPropertyPage autoinit + # autoinit.section + ## test_prog__rpg__combat__Combatable__autoinit.intro + MPropertyPage defend # defend.section ## test_prog__rpg__combat__Combatable__defend.intro @@@ -912,7 -860,7 +939,7 @@@ MClassPage Weapo #### test_prog__rpg__combat__Weapon.children #### test_prog__rpg__combat__Weapon.descendants ## test_prog__rpg__combat__Weapon.constructors - ### test_prog__platform-__Object__init.definition + ### test_prog__rpg__combat__Weapon__autoinit.definition ## test_prog__rpg__combat__Weapon.concerns ## test_prog.concern ## test_prog.concern @@@ -920,10 -868,6 +947,10 @@@ ## test_prog__rpg__combat.concern ### test_prog__rpg__combat__Weapon__dps.definition +MPropertyPage autoinit + # autoinit.section + ## test_prog__rpg__combat__Weapon__autoinit.intro + MPropertyPage dps # dps.section ## test_prog__rpg__combat__Weapon__dps.intro @@@ -983,7 -927,6 +1010,7 @@@ MClassPage Dwar #### test_prog__rpg__races__Dwarf.children #### test_prog__rpg__races__Dwarf.descendants ## test_prog__rpg__races__Dwarf.constructors + ### test_prog__rpg__races__Dwarf__autoinit.definition ### test_prog__rpg__races__Dwarf__init.definition #### test_prog__rpg__races__Dwarf__init.lin ## test_prog__rpg__races__Dwarf.concerns @@@ -995,10 -938,6 +1022,10 @@@ ### test_prog__rpg__combat__Dwarf__dps.definition #### test_prog__rpg__combat__Dwarf__dps.lin +MPropertyPage autoinit + # autoinit.section + ## test_prog__rpg__races__Dwarf__autoinit.intro + MClassPage Elf # Elf.section ## test_prog__rpg__races__Elf.intro @@@ -1010,7 -949,6 +1037,7 @@@ #### test_prog__rpg__races__Elf.children #### test_prog__rpg__races__Elf.descendants ## test_prog__rpg__races__Elf.constructors + ### test_prog__rpg__races__Elf__autoinit.definition ### test_prog__rpg__races__Elf__init.definition #### test_prog__rpg__races__Elf__init.lin ## test_prog__rpg__races__Elf.concerns @@@ -1019,10 -957,6 +1046,10 @@@ ## test_prog__rpg.concern ## test_prog__rpg__races.concern +MPropertyPage autoinit + # autoinit.section + ## test_prog__rpg__races__Elf__autoinit.intro + MClassPage Human # Human.section ## test_prog__rpg__races__Human.intro @@@ -1034,7 -968,6 +1061,7 @@@ #### test_prog__rpg__races__Human.children #### test_prog__rpg__races__Human.descendants ## test_prog__rpg__races__Human.constructors + ### test_prog__rpg__races__Human__autoinit.definition ### test_prog__rpg__races__Human__init.definition #### test_prog__rpg__races__Human__init.lin ## test_prog__rpg__races__Human.concerns @@@ -1043,10 -976,6 +1070,10 @@@ ## test_prog__rpg.concern ## test_prog__rpg__races.concern +MPropertyPage autoinit + # autoinit.section + ## test_prog__rpg__races__Human__autoinit.intro + MClassPage Race # Race.section ## test_prog__rpg__races__Race.intro @@@ -1058,7 -987,6 +1085,7 @@@ #### test_prog__rpg__races__Race.children #### test_prog__rpg__races__Race.descendants ## test_prog__rpg__races__Race.constructors + ### test_prog__rpg__races__Race__autoinit.definition ### test_prog__rpg__races__Race__init.definition #### test_prog__rpg__races__Race__init.lin ## test_prog__rpg__races__Race.concerns @@@ -1073,10 -1001,6 +1100,10 @@@ ### test_prog__rpg__races__Race__base_strength.definition ### test_prog__rpg__races__Race__base_strength_61d.definition +MPropertyPage autoinit + # autoinit.section + ## test_prog__rpg__races__Race__autoinit.intro + MPropertyPage base_endurance # base_endurance.section ## test_prog__rpg__races__Race__base_endurance.intro @@@ -1110,24 -1034,24 +1137,24 @@@ MModulePage rp #### test_prog__rpg__rpg.imports #### test_prog__rpg__rpg.clients - Generated 115 pages -Generated 99 pages ++Generated 118 pages list: - MPropertyPage: 77 (66.95%) - MClassPage: 20 (17.39%) - MModulePage: 8 (6.95%) - MGroupPage: 4 (3.47%) - ReadmePage: 4 (3.47%) - SearchPage: 1 (0.86%) - OverviewPage: 1 (0.86%) - Found 219 mentities - MPropertyPage: 58 (58.58%) - MClassPage: 20 (20.20%) - MModulePage: 9 (9.09%) - ReadmePage: 5 (5.05%) - MGroupPage: 5 (5.05%) - SearchPage: 1 (1.01%) - OverviewPage: 1 (1.01%) -Found 185 mentities ++ MPropertyPage: 77 (65.25%) ++ MClassPage: 20 (16.94%) ++ MModulePage: 9 (7.62%) ++ ReadmePage: 5 (4.23%) ++ MGroupPage: 5 (4.23%) ++ SearchPage: 1 (0.84%) ++ OverviewPage: 1 (0.84%) ++Found 222 mentities list: - MMethodDef: 86 (39.26%) - MMethod: 76 (34.70%) - MClassDef: 22 (10.04%) - MClass: 20 (9.13%) - MModule: 8 (3.65%) - MGroup: 4 (1.82%) - MMethodDef: 68 (36.75%) - MMethod: 57 (30.81%) - MClassDef: 22 (11.89%) - MClass: 20 (10.81%) - MModule: 9 (4.86%) - MGroup: 5 (2.70%) - MPackage: 2 (1.08%) - MVirtualTypeDef: 1 (0.54%) - MVirtualTypeProp: 1 (0.54%) ++ MMethodDef: 86 (38.73%) ++ MMethod: 76 (34.23%) ++ MClassDef: 22 (9.90%) ++ MClass: 20 (9.00%) ++ MModule: 9 (4.05%) ++ MGroup: 5 (2.25%) ++ MPackage: 2 (0.90%) + MVirtualTypeDef: 1 (0.45%) + MVirtualTypeProp: 1 (0.45%) - MPackage: 1 (0.45%) quicksearch-list.js diff --combined tests/sav/nitlight_args1.res index 4a24924,cf89e02..00f8ce6 --- a/tests/sav/nitlight_args1.res +++ b/tests/sav/nitlight_args1.res @@@ -16,52 -16,52 +16,52 @@@ import end - interface Object + interface Object end - enum Bool + enum Bool end - enum Int - fun output is intern + enum Int + fun output is intern end - class A - init do 5.output - fun run do 6.output + class A + init do 5.output + fun run do 6.output end - class B - var val: Int - init(v: Int) + class B + var val: Int - init(v: Int) ++ init(v: Int) do - 7.output - self.val = v + 7.output + self.val = v end - fun run do val.output + fun run do val.output end - class C - var val1: Int - var val2: Int = 10 + class C + var val1: Int + var val2: Int = 10 end - fun foo do 2.output - fun bar(i: Int) do i.output - fun baz: Int do return 4 + fun foo do 2.output + fun bar(i: Int) do i.output + fun baz: Int do return 4 - 1.output - foo - bar(3) - baz.output + 1.output + foo + bar(3) + baz.output - var a = new A - a.run -var a = new A ++var a = new A + a.run - var b = new B(8) - b.run -var b = new B(8) ++var b = new B(8) + b.run - var c = new C(9) - c.val1.output - c.val2.output -var c = new C(9) ++var c = new C(9) + c.val1.output + c.val2.output diff --combined tests/sav/nitmetrics_args1.res index f6ad37b,6d734f6..7e642cc --- a/tests/sav/nitmetrics_args1.res +++ b/tests/sav/nitmetrics_args1.res @@@ -91,7 -91,7 +91,7 @@@ # MModules metrics ## package base_simple3 - `- group base_simple3 + `- group base_simple3> mnoa: number of ancestor modules avg: 0.0 max: base_simple3 (0) @@@ -344,30 -344,30 +344,30 @@@ Number of refined classes: 0 (0.00% Average number of class refinments by classes: 0.00 Average number of class refinments by refined classes: na -Number of properties: 18 - Number of MAttribute: 3 (16.66%) - Number of MMethod: 15 (83.33%) +Number of properties: 23 + Number of MAttribute: 3 (13.04%) + Number of MMethod: 20 (86.95%) -Number of property definitions: 20 -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 +Number of property definitions: 24 +Number of redefined properties: 1 (4.34%) +Average number of property redefinitions by property: 0.04 +Average number of property redefinitions by redefined property: 1.00 --- Explicit vs. Implicit Self --- Total number of self: 5 Total number of implicit self: 4 (80.00%) --- Construction of tables --- Number of runtime classes: 6 (excluding interfaces and abstract classes) Average number of composing class definition by runtime class: 2.00 -Total size of tables (classes and instances): 23 (not including stuff like info for subtyping or call-next-method) -Average size of table by runtime class: 3.83 -Values never redefined: 17 (73.91%) +Total size of tables (classes and instances): 33 (not including stuff like info for subtyping or call-next-method) +Average size of table by runtime class: 5.50 +Values never redefined: 27 (81.81%) generating package_hierarchy.dot generating module_hierarchy.dot # MClasses metrics ## package base_simple3 - `- group base_simple3 + `- group base_simple3> cnoa: number of ancestor classes avg: 0.0 max: Bool (1) @@@ -399,11 -399,11 +399,11 @@@ std: 0.926 sum: 6 cnbp: number of accessible properties (inherited + local) - avg: 3.0 - max: C (7) - min: Object (1) - std: 2.36 - sum: 24 + avg: 5.0 + max: C (9) + min: Object (2) + std: 2.268 + sum: 35 cnba: number of accessible attributes (inherited + local) avg: 0.0 max: C (2) @@@ -411,23 -411,23 +411,23 @@@ std: 0.845 sum: 3 cnbip: number of introduced properties - avg: 2.0 - max: C (6) - min: Bool (0) - std: 2.268 - sum: 18 + avg: 3.0 + max: C (7) + min: Bool (1) + std: 2.0 + sum: 23 cnbrp: number of redefined properties avg: 0.0 max: A (1) min: Object (0) - std: 0.535 - sum: 2 + std: 0.378 + sum: 1 cnbhp: number of inherited properties - avg: 0.0 - max: Bool (1) + avg: 1.0 + max: Bool (2) min: Object (0) - std: 0.926 - sum: 6 + std: 1.0 + sum: 12 ## global metrics cnoa: number of ancestor classes @@@ -461,11 -461,11 +461,11 @@@ std: 0.926 sum: 6 cnbp: number of accessible properties (inherited + local) - avg: 3.0 - max: C (7) - min: Object (1) - std: 2.36 - sum: 24 + avg: 5.0 + max: C (9) + min: Object (2) + std: 2.268 + sum: 35 cnba: number of accessible attributes (inherited + local) avg: 0.0 max: C (2) @@@ -473,28 -473,28 +473,28 @@@ std: 0.845 sum: 3 cnbip: number of introduced properties - avg: 2.0 - max: C (6) - min: Bool (0) - std: 2.268 - sum: 18 + avg: 3.0 + max: C (7) + min: Bool (1) + std: 2.0 + sum: 23 cnbrp: number of redefined properties avg: 0.0 max: A (1) min: Object (0) - std: 0.535 - sum: 2 + std: 0.378 + sum: 1 cnbhp: number of inherited properties - avg: 0.0 - max: Bool (1) + avg: 1.0 + max: Bool (2) min: Object (0) - std: 0.926 - sum: 6 + std: 1.0 + sum: 12 # Inheritance metrics ## package base_simple3 - `- group base_simple3 + `- group base_simple3> cnoac: number of class_kind ancestor avg: 0.0 max: Object (0) @@@ -695,12 -695,13 +695,12 @@@ Statistics of type usage A: 1 (11.11%) # Mendel metrics - large mclasses (threshold: 3.915) + large mclasses (threshold: 4.354) C: 5 - B: 4 - Sys: 4 - budding mclasses (threshold: 5.033) - blooming mclasses (threshold: 21.874) - C: 25.0 + budding mclasses (threshold: 3.207) + C: 3.5 + blooming mclasses (threshold: 14.316) + C: 17.5 --- Detection of the usage of covariance static type conformance --- -- Total -- - Kinds of the subtype - @@@ -751,7 -752,7 +751,7 @@@ # Nullable metrics ## package base_simple3 - `- group base_simple3 + `- group base_simple3> cnba: number of accessible attributes (inherited + local) avg: 0.0 max: C (2) @@@ -804,17 -805,17 +804,17 @@@ Number of buggy sends (cannot determin std: 0.0 sum: 17 mnlm: number of live methods in a mmodule - avg: 14.0 - max: base_simple3 (14) - min: base_simple3 (14) - std: 0.0 - sum: 14 - mnlmd: number of live method definitions in a mmodule avg: 16.0 max: base_simple3 (16) min: base_simple3 (16) std: 0.0 sum: 16 + mnlmd: number of live method definitions in a mmodule + avg: 17.0 + max: base_simple3 (17) + min: base_simple3 (17) + std: 0.0 + sum: 17 mnldd: number of dead method definitions in a mmodule avg: 0.0 max: base_simple3 (0) @@@ -868,17 -869,17 +868,17 @@@ MMethodDef locally designated (by numbe <=1: sub-population=13 (92.85%); cumulated value=13 (56.52%) <=16: sub-population=1 (7.14%); cumulated value=10 (43.47%) list: - base_simple3#Int#output: 10 (43.47%) - base_simple3#B#val: 1 (4.34%) - base_simple3#B#val=: 1 (4.34%) - base_simple3#Object#init: 1 (4.34%) - base_simple3#C#val2: 1 (4.34%) + base_simple3$Int$output: 10 (43.47%) + base_simple3$B$val: 1 (4.34%) + base_simple3$B$val=: 1 (4.34%) + base_simple3$Object$init: 1 (4.34%) + base_simple3$C$val2: 1 (4.34%) ... - base_simple3#A#autoinit: 1 (4.34%) - base_simple3#Sys#baz: 1 (4.34%) - base_simple3#Sys#bar: 1 (4.34%) - base_simple3#Sys#foo: 1 (4.34%) - base_simple3#C#autoinit: 1 (4.34%) - base_simple3$A$init: 1 (4.34%) ++ base_simple3$A$autoinit: 1 (4.34%) + base_simple3$Sys$baz: 1 (4.34%) + base_simple3$Sys$bar: 1 (4.34%) + base_simple3$Sys$foo: 1 (4.34%) - base_simple3$C$init: 1 (4.34%) ++ base_simple3$C$autoinit: 1 (4.34%) MMethodDef possibly invoked at runtime (by number of CallSites) population: 14 minimum value: 1 @@@ -889,17 -890,17 +889,17 @@@ <=1: sub-population=13 (92.85%); cumulated value=13 (56.52%) <=16: sub-population=1 (7.14%); cumulated value=10 (43.47%) list: - base_simple3#Int#output: 10 (43.47%) - base_simple3#B#val: 1 (4.34%) - base_simple3#B#val=: 1 (4.34%) - base_simple3#Object#init: 1 (4.34%) - base_simple3#C#val2: 1 (4.34%) + base_simple3$Int$output: 10 (43.47%) + base_simple3$B$val: 1 (4.34%) + base_simple3$B$val=: 1 (4.34%) + base_simple3$Object$init: 1 (4.34%) + base_simple3$C$val2: 1 (4.34%) ... - base_simple3#A#autoinit: 1 (4.34%) - base_simple3#Sys#baz: 1 (4.34%) - base_simple3#Sys#bar: 1 (4.34%) - base_simple3#Sys#foo: 1 (4.34%) - base_simple3#C#autoinit: 1 (4.34%) - base_simple3$A$init: 1 (4.34%) ++ base_simple3$A$autoinit: 1 (4.34%) + base_simple3$Sys$baz: 1 (4.34%) + base_simple3$Sys$bar: 1 (4.34%) + base_simple3$Sys$foo: 1 (4.34%) - base_simple3$C$init: 1 (4.34%) ++ base_simple3$C$autoinit: 1 (4.34%) class_hierarchy.dot classdef_hierarchy.dot inheritance/ diff --combined tests/sav/nituml_args3.res index 338a3d9,a43ae0d..4e62b3e --- a/tests/sav/nituml_args3.res +++ b/tests/sav/nituml_args3.res @@@ -12,88 -12,88 +12,88 @@@ digraph G fontsize = 8 ] Object [ - label = "{interface\nObject||+ object_id(): Int\l+ is_same_type(other: Object): Bool\l+ is_same_instance(other: nullable Object): Bool\l+ ==(other: nullable Object): Bool\l+ !=(other: nullable Object): Bool\l+ output()\l+ output_class_name()\l+ hash(): Int\l+ sys(): Sys\l+ init()\l}" + label = "{interface\nObject||+ object_id(): Int\l+ is_same_type(other: Object): Bool\l+ is_same_instance(other: nullable Object): Bool\l+ ==(other: nullable Object): Bool\l+ !=(other: nullable Object): Bool\l+ output()\l+ output_class_name()\l+ hash(): Int\l+ sys(): Sys\l+ init()\l+ autoinit()\l}" ] Sys [ - label = "{Sys||+ main()\l+ run()\l+ errno(): Int\l+ exit(exit_value: Int)\l}" + label = "{Sys||+ main()\l+ run()\l+ errno(): Int\l+ exit(exit_value: Int)\l+ autoinit()\l}" ] Object -> Sys [dir=back arrowtail=open style=dashed]; Comparable [ - label = "{interface\nComparable||+ \<(other: OTHER): Bool\l+ \<=(other: OTHER): Bool\l+ \>=(other: OTHER): Bool\l+ \>(other: OTHER): Bool\l+ \<=\>(other: OTHER): Int\l+ is_between(c: OTHER, d: OTHER): Bool\l+ max(other: OTHER): OTHER\l+ min(c: OTHER): OTHER\l}" + label = "{interface\nComparable||+ \<(other: OTHER): Bool\l+ \<=(other: OTHER): Bool\l+ \>=(other: OTHER): Bool\l+ \>(other: OTHER): Bool\l+ \<=\>(other: OTHER): Int\l+ is_between(c: OTHER, d: OTHER): Bool\l+ max(other: OTHER): OTHER\l+ min(c: OTHER): OTHER\l+ autoinit()\l}" ] Object -> Comparable [dir=back arrowtail=open style=dashed]; Discrete [ - label = "{interface\nDiscrete||+ successor(i: Int): OTHER\l+ predecessor(i: Int): OTHER\l+ distance(d: OTHER): Int\l}" + label = "{interface\nDiscrete||+ successor(i: Int): OTHER\l+ predecessor(i: Int): OTHER\l+ distance(d: OTHER): Int\l+ autoinit()\l}" ] Comparable -> Discrete [dir=back arrowtail=open style=dashed]; Cloneable [ - label = "{interface\nCloneable||+ clone(): SELF\l}" + label = "{interface\nCloneable||+ clone(): SELF\l+ autoinit()\l}" ] Object -> Cloneable [dir=back arrowtail=open style=dashed]; Numeric [ - label = "{interface\nNumeric||+ +(i: OTHER): OTHER\l+ -(i: OTHER): OTHER\l+ unary -(): OTHER\l+ *(i: OTHER): OTHER\l+ /(i: OTHER): OTHER\l+ to_i(): Int\l+ to_f(): Float\l+ to_b(): Byte\l+ is_zero(): Bool\l+ zero(): OTHER\l+ value_of(val: Numeric): OTHER\l}" + label = "{interface\nNumeric||+ +(i: OTHER): OTHER\l+ -(i: OTHER): OTHER\l+ unary -(): OTHER\l+ *(i: OTHER): OTHER\l+ /(i: OTHER): OTHER\l+ to_i(): Int\l+ to_f(): Float\l+ to_b(): Byte\l+ is_zero(): Bool\l+ zero(): OTHER\l+ value_of(val: Numeric): OTHER\l+ autoinit()\l}" ] Comparable -> Numeric [dir=back arrowtail=open style=dashed]; Bool [ - label = "{Bool||+ to_i(): Int\l}" + label = "{Bool||+ to_i(): Int\l+ autoinit()\l}" ] Object -> Bool [dir=back arrowtail=open style=dashed]; Float [ - label = "{Float||+ is_approx(other: Float, precision: Float): Bool\l}" + label = "{Float||+ is_approx(other: Float, precision: Float): Bool\l+ autoinit()\l}" ] Numeric -> Float [dir=back arrowtail=open style=dashed]; Byte [ - label = "{Byte||+ %(i: Byte): Byte\l+ \<\<(i: Int): Byte\l+ \>\>(i: Int): Byte\l+ ascii(): Char\l+ autoinit()\l}" - label = "{Byte||+ %(i: Byte): Byte\l+ \<\<(i: Int): Byte\l+ \>\>(i: Int): Byte\l+ ascii(): Char\l+ is_whitespace(): Bool\l}" ++ label = "{Byte||+ %(i: Byte): Byte\l+ \<\<(i: Int): Byte\l+ \>\>(i: Int): Byte\l+ ascii(): Char\l+ is_whitespace(): Bool\l+ autoinit()\l}" ] Discrete -> Byte [dir=back arrowtail=open style=dashed]; Numeric -> Byte [dir=back arrowtail=open style=dashed]; Int [ - label = "{Int||+ %(i: Int): Int\l+ \<\<(i: Int): Int\l+ \>\>(i: Int): Int\l+ code_point(): Char\l+ digit_count(b: Int): Int\l+ digit_count_base_10(): Int\l+ to_c(): Char\l+ abs(): Int\l}" + label = "{Int||+ %(i: Int): Int\l+ \<\<(i: Int): Int\l+ \>\>(i: Int): Int\l+ code_point(): Char\l+ digit_count(b: Int): Int\l+ digit_count_base_10(): Int\l+ to_c(): Char\l+ abs(): Int\l+ autoinit()\l}" ] Discrete -> Int [dir=back arrowtail=open style=dashed]; Numeric -> Int [dir=back arrowtail=open style=dashed]; Char [ - label = "{Char||+ to_i(): Int\l+ ascii(): Byte\l+ code_point(): Int\l+ is_ascii(): Bool\l+ to_lower(): Char\l+ to_upper(): Char\l+ is_digit(): Bool\l+ is_lower(): Bool\l+ is_upper(): Bool\l+ is_letter(): Bool\l+ is_whitespace(): Bool\l}" + label = "{Char||+ to_i(): Int\l+ ascii(): Byte\l+ code_point(): Int\l+ is_ascii(): Bool\l+ to_lower(): Char\l+ to_upper(): Char\l+ is_digit(): Bool\l+ is_lower(): Bool\l+ is_upper(): Bool\l+ is_letter(): Bool\l+ is_whitespace(): Bool\l+ autoinit()\l}" ] Discrete -> Char [dir=back arrowtail=open style=dashed]; Pointer [ - label = "{Pointer||+ address_is_null(): Bool\l+ free()\l}" + label = "{Pointer||+ address_is_null(): Bool\l+ free()\l+ autoinit()\l}" ] Object -> Pointer [dir=back arrowtail=open style=dashed]; Task [ - label = "{interface\nTask||+ main()\l}" + label = "{interface\nTask||+ main()\l+ autoinit()\l}" ] Object -> Task [dir=back arrowtail=open style=dashed]; A [ - label = "{A|- _vpubA: nullable A\l- _vproA: nullable A\l- _vpriA: nullable A\l- _vpubA2: A\l- _vproA2: A\l- _vpriA2: A\l- _vpriB: nullable B\l- _vpriB2: B\l|+ pubA(a: A)\l# proA(a: A)\l- priA(a: A)\l+ pubA2(): A\l# proA2(): A\l- priA2(): A\l+ vpubA(): nullable A\l+ vpubA=(vpubA: nullable A)\l# vproA(): nullable A\l# vproA=(vproA: nullable A)\l- vpriA(): nullable A\l- vpriA=(vpriA: nullable A)\l+ vpubA2(): A\l+ vpubA2=(vpubA2: A)\l# vproA2(): A\l# vproA2=(vproA2: A)\l- vpriA2(): A\l- vpriA2=(vpriA2: A)\l- priB(a: B)\l- priB2(): B\l- vpriB(): nullable B\l- vpriB=(vpriB: nullable B)\l- vpriB2(): B\l- vpriB2=(vpriB2: B)\l}" + label = "{A|- _vpubA: nullable A\l- _vproA: nullable A\l- _vpriA: nullable A\l- _vpubA2: A\l- _vproA2: A\l- _vpriA2: A\l- _vpriB: nullable B\l- _vpriB2: B\l|+ pubA(a: A)\l# proA(a: A)\l- priA(a: A)\l+ pubA2(): A\l# proA2(): A\l- priA2(): A\l+ vpubA(): nullable A\l+ vpubA=(vpubA: nullable A)\l# vproA(): nullable A\l# vproA=(vproA: nullable A)\l- vpriA(): nullable A\l- vpriA=(vpriA: nullable A)\l+ vpubA2(): A\l+ vpubA2=(vpubA2: A)\l# vproA2(): A\l# vproA2=(vproA2: A)\l- vpriA2(): A\l- vpriA2=(vpriA2: A)\l- priB(a: B)\l- priB2(): B\l- vpriB(): nullable B\l- vpriB=(vpriB: nullable B)\l- vpriB2(): B\l- vpriB2=(vpriB2: B)\l+ autoinit()\l}" ] Object -> A [dir=back arrowtail=open style=dashed]; B [ - label = "{B|- _vpubA: nullable A\l- _vpriA: nullable A\l- _vpubA2: A\l- _vpriA2: A\l- _vpubB: nullable B\l- _vpriB: nullable B\l- _vpubB2: B\l- _vpriB2: B\l|- pubA(a: A)\l- priA(a: A)\l- vpubA(): nullable A\l- vpubA=(vpubA: nullable A)\l- vpriA(): nullable A\l- vpriA=(vpriA: nullable A)\l- vpubA2(): A\l- vpubA2=(vpubA2: A)\l- vpriA2(): A\l- vpriA2=(vpriA2: A)\l- pubB(a: B)\l- priB(a: B)\l- vpubB(): nullable B\l- vpubB=(vpubB: nullable B)\l- vpriB(): nullable B\l- vpriB=(vpriB: nullable B)\l- vpubB2(): B\l- vpubB2=(vpubB2: B)\l- vpriB2(): B\l- vpriB2=(vpriB2: B)\l}" + label = "{B|- _vpubA: nullable A\l- _vpriA: nullable A\l- _vpubA2: A\l- _vpriA2: A\l- _vpubB: nullable B\l- _vpriB: nullable B\l- _vpubB2: B\l- _vpriB2: B\l|- pubA(a: A)\l- priA(a: A)\l- vpubA(): nullable A\l- vpubA=(vpubA: nullable A)\l- vpriA(): nullable A\l- vpriA=(vpriA: nullable A)\l- vpubA2(): A\l- vpubA2=(vpubA2: A)\l- vpriA2(): A\l- vpriA2=(vpriA2: A)\l- pubB(a: B)\l- priB(a: B)\l- vpubB(): nullable B\l- vpubB=(vpubB: nullable B)\l- vpriB(): nullable B\l- vpriB=(vpriB: nullable B)\l- vpubB2(): B\l- vpubB2=(vpubB2: B)\l- vpriB2(): B\l- vpriB2=(vpriB2: B)\l+ autoinit()\l}" ] Object -> B [dir=back arrowtail=open style=dashed]; C [ - label = "{C|- _vpriA: nullable A\l- _vpriA2: A\l|- priA(a: A)\l- vpriA(): nullable A\l- vpriA=(vpriA: nullable A)\l- vpriA2(): A\l- vpriA2=(vpriA2: A)\l}" + label = "{C|- _vpriA: nullable A\l- _vpriA2: A\l|- priA(a: A)\l- vpriA(): nullable A\l- vpriA=(vpriA: nullable A)\l- vpriA2(): A\l- vpriA2=(vpriA2: A)\l+ autoinit()\l}" ] Object -> C [dir=back arrowtail=open style=dashed]; D [ - label = "{D|- _vpubA: nullable A\l- _vpriA: nullable A\l- _vpubA2: A\l- _vpriA2: A\l|- pubA(a: A)\l- priA(a: A)\l- vpubA(): nullable A\l- vpubA=(vpubA: nullable A)\l- vpriA(): nullable A\l- vpriA=(vpriA: nullable A)\l- vpubA2(): A\l- vpubA2=(vpubA2: A)\l- vpriA2(): A\l- vpriA2=(vpriA2: A)\l}" + label = "{D|- _vpubA: nullable A\l- _vpriA: nullable A\l- _vpubA2: A\l- _vpriA2: A\l|- pubA(a: A)\l- priA(a: A)\l- vpubA(): nullable A\l- vpubA=(vpubA: nullable A)\l- vpriA(): nullable A\l- vpriA=(vpriA: nullable A)\l- vpubA2(): A\l- vpubA2=(vpubA2: A)\l- vpriA2(): A\l- vpriA2=(vpriA2: A)\l+ autoinit()\l}" ] Object -> D [dir=back arrowtail=open style=dashed]; diff --combined tests/sav/nituml_args4.res index de63dda,4bd5666..c79556c --- a/tests/sav/nituml_args4.res +++ b/tests/sav/nituml_args4.res @@@ -12,78 -12,78 +12,78 @@@ digraph G fontsize = 8 ] Object [ - label = "{interface\nObject||+ object_id(): Int\l+ is_same_type(other: Object): Bool\l+ is_same_instance(other: nullable Object): Bool\l+ ==(other: nullable Object): Bool\l+ !=(other: nullable Object): Bool\l+ output()\l+ output_class_name()\l+ hash(): Int\l+ sys(): Sys\l+ init()\l}" + label = "{interface\nObject||+ object_id(): Int\l+ is_same_type(other: Object): Bool\l+ is_same_instance(other: nullable Object): Bool\l+ ==(other: nullable Object): Bool\l+ !=(other: nullable Object): Bool\l+ output()\l+ output_class_name()\l+ hash(): Int\l+ sys(): Sys\l+ init()\l+ autoinit()\l}" ] Sys [ - label = "{Sys||+ main()\l+ run()\l+ errno(): Int\l+ exit(exit_value: Int)\l}" + label = "{Sys||+ main()\l+ run()\l+ errno(): Int\l+ exit(exit_value: Int)\l+ autoinit()\l}" ] Object -> Sys [dir=back arrowtail=open style=dashed]; Comparable [ - label = "{interface\nComparable||+ \<(other: OTHER): Bool\l+ \<=(other: OTHER): Bool\l+ \>=(other: OTHER): Bool\l+ \>(other: OTHER): Bool\l+ \<=\>(other: OTHER): Int\l+ is_between(c: OTHER, d: OTHER): Bool\l+ max(other: OTHER): OTHER\l+ min(c: OTHER): OTHER\l}" + label = "{interface\nComparable||+ \<(other: OTHER): Bool\l+ \<=(other: OTHER): Bool\l+ \>=(other: OTHER): Bool\l+ \>(other: OTHER): Bool\l+ \<=\>(other: OTHER): Int\l+ is_between(c: OTHER, d: OTHER): Bool\l+ max(other: OTHER): OTHER\l+ min(c: OTHER): OTHER\l+ autoinit()\l}" ] Object -> Comparable [dir=back arrowtail=open style=dashed]; Discrete [ - label = "{interface\nDiscrete||+ successor(i: Int): OTHER\l+ predecessor(i: Int): OTHER\l+ distance(d: OTHER): Int\l}" + label = "{interface\nDiscrete||+ successor(i: Int): OTHER\l+ predecessor(i: Int): OTHER\l+ distance(d: OTHER): Int\l+ autoinit()\l}" ] Comparable -> Discrete [dir=back arrowtail=open style=dashed]; Cloneable [ - label = "{interface\nCloneable||+ clone(): SELF\l}" + label = "{interface\nCloneable||+ clone(): SELF\l+ autoinit()\l}" ] Object -> Cloneable [dir=back arrowtail=open style=dashed]; Numeric [ - label = "{interface\nNumeric||+ +(i: OTHER): OTHER\l+ -(i: OTHER): OTHER\l+ unary -(): OTHER\l+ *(i: OTHER): OTHER\l+ /(i: OTHER): OTHER\l+ to_i(): Int\l+ to_f(): Float\l+ to_b(): Byte\l+ is_zero(): Bool\l+ zero(): OTHER\l+ value_of(val: Numeric): OTHER\l}" + label = "{interface\nNumeric||+ +(i: OTHER): OTHER\l+ -(i: OTHER): OTHER\l+ unary -(): OTHER\l+ *(i: OTHER): OTHER\l+ /(i: OTHER): OTHER\l+ to_i(): Int\l+ to_f(): Float\l+ to_b(): Byte\l+ is_zero(): Bool\l+ zero(): OTHER\l+ value_of(val: Numeric): OTHER\l+ autoinit()\l}" ] Comparable -> Numeric [dir=back arrowtail=open style=dashed]; Bool [ - label = "{Bool||+ to_i(): Int\l}" + label = "{Bool||+ to_i(): Int\l+ autoinit()\l}" ] Object -> Bool [dir=back arrowtail=open style=dashed]; Float [ - label = "{Float||+ is_approx(other: Float, precision: Float): Bool\l}" + label = "{Float||+ is_approx(other: Float, precision: Float): Bool\l+ autoinit()\l}" ] Numeric -> Float [dir=back arrowtail=open style=dashed]; Byte [ - label = "{Byte||+ %(i: Byte): Byte\l+ \<\<(i: Int): Byte\l+ \>\>(i: Int): Byte\l+ ascii(): Char\l+ autoinit()\l}" - label = "{Byte||+ %(i: Byte): Byte\l+ \<\<(i: Int): Byte\l+ \>\>(i: Int): Byte\l+ ascii(): Char\l+ is_whitespace(): Bool\l}" ++ label = "{Byte||+ %(i: Byte): Byte\l+ \<\<(i: Int): Byte\l+ \>\>(i: Int): Byte\l+ ascii(): Char\l+ is_whitespace(): Bool\l+ autoinit()\l}" ] Discrete -> Byte [dir=back arrowtail=open style=dashed]; Numeric -> Byte [dir=back arrowtail=open style=dashed]; Int [ - label = "{Int||+ %(i: Int): Int\l+ \<\<(i: Int): Int\l+ \>\>(i: Int): Int\l+ code_point(): Char\l+ digit_count(b: Int): Int\l+ digit_count_base_10(): Int\l+ to_c(): Char\l+ abs(): Int\l}" + label = "{Int||+ %(i: Int): Int\l+ \<\<(i: Int): Int\l+ \>\>(i: Int): Int\l+ code_point(): Char\l+ digit_count(b: Int): Int\l+ digit_count_base_10(): Int\l+ to_c(): Char\l+ abs(): Int\l+ autoinit()\l}" ] Discrete -> Int [dir=back arrowtail=open style=dashed]; Numeric -> Int [dir=back arrowtail=open style=dashed]; Char [ - label = "{Char||+ to_i(): Int\l+ ascii(): Byte\l+ code_point(): Int\l+ is_ascii(): Bool\l+ to_lower(): Char\l+ to_upper(): Char\l+ is_digit(): Bool\l+ is_lower(): Bool\l+ is_upper(): Bool\l+ is_letter(): Bool\l+ is_whitespace(): Bool\l}" + label = "{Char||+ to_i(): Int\l+ ascii(): Byte\l+ code_point(): Int\l+ is_ascii(): Bool\l+ to_lower(): Char\l+ to_upper(): Char\l+ is_digit(): Bool\l+ is_lower(): Bool\l+ is_upper(): Bool\l+ is_letter(): Bool\l+ is_whitespace(): Bool\l+ autoinit()\l}" ] Discrete -> Char [dir=back arrowtail=open style=dashed]; Pointer [ - label = "{Pointer||+ address_is_null(): Bool\l+ free()\l}" + label = "{Pointer||+ address_is_null(): Bool\l+ free()\l+ autoinit()\l}" ] Object -> Pointer [dir=back arrowtail=open style=dashed]; Task [ - label = "{interface\nTask||+ main()\l}" + label = "{interface\nTask||+ main()\l+ autoinit()\l}" ] Object -> Task [dir=back arrowtail=open style=dashed]; A [ - label = "{A||+ pubA(a: A)\l# proA(a: A)\l+ pubA2(): A\l# proA2(): A\l+ vpubA(): nullable A\l+ vpubA=(vpubA: nullable A)\l# vproA(): nullable A\l# vproA=(vproA: nullable A)\l+ vpubA2(): A\l+ vpubA2=(vpubA2: A)\l# vproA2(): A\l# vproA2=(vproA2: A)\l}" + label = "{A||+ pubA(a: A)\l# proA(a: A)\l+ pubA2(): A\l# proA2(): A\l+ vpubA(): nullable A\l+ vpubA=(vpubA: nullable A)\l# vproA(): nullable A\l# vproA=(vproA: nullable A)\l+ vpubA2(): A\l+ vpubA2=(vpubA2: A)\l# vproA2(): A\l# vproA2=(vproA2: A)\l+ autoinit()\l}" ] Object -> A [dir=back arrowtail=open style=dashed]; C [ - label = "{C||}" + label = "{C||+ autoinit()\l}" ] Object -> C [dir=back arrowtail=open style=dashed]; diff --combined tests/sav/test_highlight_args1.res index 6919258,e6ac401..8faceb9 --- a/tests/sav/test_highlight_args1.res +++ b/tests/sav/test_highlight_args1.res @@@ -2,6 -2,7 +2,7 @@@