From: Jean Privat Date: Tue, 28 Jan 2020 20:03:52 +0000 (-0500) Subject: Merge: Fixed quick_sort when array is length 0 or 1 X-Git-Url: http://nitlanguage.org?hp=6c134b31bc63891eb9210e50ffe27aa0126febaa Merge: Fixed quick_sort when array is length 0 or 1 Fixed a bug where quick_sort could access out of bound element when `to` argument smaller or equal to 0. # Before var xs = [1] default_comparator.quick_sort(xs) # assertion failed # After var xs = [1] default_comparator.quick_sort(xs) assert xs == [1] # true Signed-off-by: Louis-Vincent Boudreault Pull-Request: #2811 --- diff --git a/contrib/pep8analysis/src/parser/lexer.nit b/contrib/pep8analysis/src/parser/lexer.nit index c663dcd..f985cf7 100644 --- a/contrib/pep8analysis/src/parser/lexer.nit +++ b/contrib/pep8analysis/src/parser/lexer.nit @@ -255,7 +255,7 @@ redef class AError init init_error(message: String, loc: Location) do - init(loc) + self.location = loc self.message = message end end diff --git a/lib/bucketed_game/bucketed_game.nit b/lib/bucketed_game/bucketed_game.nit index 213d875..58569ace 100644 --- a/lib/bucketed_game/bucketed_game.nit +++ b/lib/bucketed_game/bucketed_game.nit @@ -171,9 +171,12 @@ class GameTurn[G: Game] var game: G # Create a new game turn for `game`. - init (game: G) is old_style_init do - super(game.tick) - self.game = game + init(game: G) + is + is_old_style_init + do + _tick = game.tick + _game = game end # Insert the Bucketable event `e` to be executed at next tick. diff --git a/src/compiler/abstract_compiler.nit b/src/compiler/abstract_compiler.nit index 57e738f..e4b8ce6 100644 --- a/src/compiler/abstract_compiler.nit +++ b/src/compiler/abstract_compiler.nit @@ -1353,29 +1353,6 @@ abstract class AbstractCompilerVisitor 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 @@ -1412,7 +1389,7 @@ abstract class AbstractCompilerVisitor # 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) @@ -3710,6 +3687,31 @@ redef class AClassdef v.supercall(mpropdef, arguments.first.mtype.as(MClassType), arguments) end return + else if mclassdef.default_init == mpropdef then + var recv = arguments.first + var initializers = mpropdef.initializers + var no_init = false + if not initializers.is_empty and not mpropdef.is_old_style_init 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 diff --git a/src/compiler/java_compiler.nit b/src/compiler/java_compiler.nit index 60aea2b..7b83104 100644 --- a/src/compiler/java_compiler.nit +++ b/src/compiler/java_compiler.nit @@ -497,7 +497,7 @@ class JavaCompilerVisitor # 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) diff --git a/src/doc/commands/tests/test_commands_http.nit b/src/doc/commands/tests/test_commands_http.nit index 57f5dd6..1f51238 100644 --- a/src/doc/commands/tests/test_commands_http.nit +++ b/src/doc/commands/tests/test_commands_http.nit @@ -205,7 +205,7 @@ class TestCommandsHttp var cmd = new CmdFeatures(test_model) var res = cmd.http_init(req) assert res isa CmdSuccess - assert cmd.results.as(not null).length == 3 + assert cmd.results.as(not null).length == 4 end # CmdLinearization @@ -215,7 +215,7 @@ class TestCommandsHttp var cmd = new CmdLinearization(test_model, test_main) var res = cmd.http_init(req) assert res isa CmdSuccess - assert cmd.results.as(not null).length == 10 + assert cmd.results.as(not null).length == 9 end fun test_cmd_http_lin_no_lin is test do diff --git a/src/doc/commands/tests/test_commands_model.nit b/src/doc/commands/tests/test_commands_model.nit index 4847987..0ee6952 100644 --- a/src/doc/commands/tests/test_commands_model.nit +++ b/src/doc/commands/tests/test_commands_model.nit @@ -181,7 +181,7 @@ class TestCommandsModel var cmd = new CmdFeatures(test_model, mentity_name = "test_prog::Career") var res = cmd.init_command assert res isa CmdSuccess - assert cmd.results.as(not null).length == 10 + assert cmd.results.as(not null).length == 11 end fun test_cmd_features_with_filter_attribute is test do @@ -189,7 +189,7 @@ class TestCommandsModel var cmd = new CmdFeatures(test_model, filter, mentity_name = "test_prog::Career") var res = cmd.init_command assert res isa CmdSuccess - assert cmd.results.as(not null).length == 7 + assert cmd.results.as(not null).length == 8 end fun test_cmd_features_with_filter_public is test do @@ -197,7 +197,7 @@ class TestCommandsModel var cmd = new CmdFeatures(test_model, filter, mentity_name = "test_prog::Career") var res = cmd.init_command assert res isa CmdSuccess - assert cmd.results.as(not null).length == 4 + assert cmd.results.as(not null).length == 5 end fun test_cmd_features_with_filter_match is test do @@ -214,7 +214,7 @@ class TestCommandsModel var cmd = new CmdFeatures(test_model, filter, mentity_name = "test_prog::TestGame") var res = cmd.init_command assert res isa CmdSuccess - assert cmd.results.as(not null).length == 3 + assert cmd.results.as(not null).length == 4 end fun test_cmd_features_no_features is test do @@ -229,7 +229,7 @@ class TestCommandsModel var cmd = new CmdLinearization(test_model, test_main, mentity_name = "init") var res = cmd.init_command assert res isa CmdSuccess - assert cmd.results.as(not null).length == 10 + assert cmd.results.as(not null).length == 9 end fun test_cmd_lin_no_lin is test do diff --git a/src/doc/commands/tests/test_commands_parser.nit b/src/doc/commands/tests/test_commands_parser.nit index 41cc36b..f5d6699 100644 --- a/src/doc/commands/tests/test_commands_parser.nit +++ b/src/doc/commands/tests/test_commands_parser.nit @@ -239,7 +239,7 @@ class TestCommandsParser var cmd = parser.parse("defs: test_prog::TestGame | inherited: TestGame") assert cmd isa CmdFeatures assert parser.error == null - assert cmd.results.as(not null).length == 3 + assert cmd.results.as(not null).length == 4 end # CmdLinearization diff --git a/src/doc/templates/html_model.nit b/src/doc/templates/html_model.nit index 1b86587..90cd190 100644 --- a/src/doc/templates/html_model.nit +++ b/src/doc/templates/html_model.nit @@ -251,10 +251,6 @@ end redef class MMethodDef redef fun html_signature(short) do - var new_msignature = self.new_msignature - if mproperty.is_root_init and new_msignature != null then - return new_msignature.html_signature(short) - end var msignature = self.msignature if msignature == null then return new Template return msignature.html_signature(short) diff --git a/src/doc/templates/term_model.nit b/src/doc/templates/term_model.nit index 55351fb..b33ce7f 100644 --- a/src/doc/templates/term_model.nit +++ b/src/doc/templates/term_model.nit @@ -199,9 +199,6 @@ end redef class MMethodDef redef fun cs_signature(no_color) do - if mproperty.is_root_init then - return new_msignature.as(not null).cs_signature(no_color) - end return msignature.as(not null).cs_signature(no_color) end end diff --git a/src/doc/templates/tests/test_html_commands.sav/test_cmd_call.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_call.res index 6663e41..ab2acab 100644 --- a/src/doc/templates/tests/test_html_commands.sav/test_cmd_call.res +++ b/src/doc/templates/tests/test_html_commands.sav/test_cmd_call.res @@ -1 +1 @@ - + diff --git a/src/doc/templates/tests/test_html_commands.sav/test_cmd_features.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_features.res index 8904ee1..2f71284 100644 --- a/src/doc/templates/tests/test_html_commands.sav/test_cmd_features.res +++ b/src/doc/templates/tests/test_html_commands.sav/test_cmd_features.res @@ -1 +1 @@ - + diff --git a/src/doc/templates/tests/test_html_commands.sav/test_cmd_lin.res b/src/doc/templates/tests/test_html_commands.sav/test_cmd_lin.res index 3ae2de3..c7f7cf4 100644 --- a/src/doc/templates/tests/test_html_commands.sav/test_cmd_lin.res +++ b/src/doc/templates/tests/test_html_commands.sav/test_cmd_lin.res @@ -1 +1 @@ - + diff --git a/src/doc/templates/tests/test_json_commands.sav/test_cmd_call.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_call.res index 0b60952..087789a 100644 --- a/src/doc/templates/tests/test_json_commands.sav/test_cmd_call.res +++ b/src/doc/templates/tests/test_json_commands.sav/test_cmd_call.res @@ -1,6 +1,6 @@ { "results": [{ - "name": "init", + "name": "defaultinit", "namespace": [{ "name": "test_prog", "synopsis": "Test program for model tools." @@ -8,18 +8,48 @@ "name": "Character", "synopsis": "Characters can be played by both the human or the machine." }, "$", { - "name": "Object", - "synopsis": "Root of everything." - }, "::", { - "name": "init" + "name": "defaultinit" }], "class_name": "MMethodDef", - "full_name": "test_prog$Character$Object::init", + "full_name": "test_prog$Character$defaultinit", "visibility": "public", - "modifiers": ["redef", "init"], + "modifiers": ["init"], + "is_intro": true, "msignature": { - "arity": 0, - "mparameters": [], + "arity": 4, + "mparameters": [{ + "is_vararg": false, + "name": "race", + "mtype": { + "name": "Race", + "synopsis": "Race determines basic characteristics and what the character will be able to do in life.", + "html_synopsis": "Race determines basic characteristics and what the character will be able to do in life." + } + }, { + "is_vararg": false, + "name": "name", + "mtype": { + "name": "String", + "synopsis": "Strings (there is no chars...).", + "html_synopsis": "Strings (there is no chars...)." + } + }, { + "is_vararg": false, + "name": "age", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "sex", + "mtype": { + "name": "Bool", + "synopsis": "Booleans, `true` or `false`.", + "html_synopsis": "Booleans, true or false." + } + }], "return_mtype": null } }, { diff --git a/src/doc/templates/tests/test_json_commands.sav/test_cmd_features.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_features.res index 88019d8..e07fe59 100644 --- a/src/doc/templates/tests/test_json_commands.sav/test_cmd_features.res +++ b/src/doc/templates/tests/test_json_commands.sav/test_cmd_features.res @@ -69,6 +69,51 @@ "html_synopsis": "Some services about Integers." } }, { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Career", + "synopsis": "A `Career` gives a characteristic bonus or malus to the character." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Career::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "strength_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "endurance_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "intelligence_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } + }, { "name": "endurance_bonus", "namespace": [{ "name": "test_prog", diff --git a/src/doc/templates/tests/test_json_commands.sav/test_cmd_lin.res b/src/doc/templates/tests/test_json_commands.sav/test_cmd_lin.res index c7ddd5a..957889a 100644 --- a/src/doc/templates/tests/test_json_commands.sav/test_cmd_lin.res +++ b/src/doc/templates/tests/test_json_commands.sav/test_cmd_lin.res @@ -187,29 +187,6 @@ "name": "test_prog", "synopsis": "Test program for model tools." }, "$", { - "name": "Character", - "synopsis": "Characters can be played by both the human or the machine." - }, "$", { - "name": "Object", - "synopsis": "Root of everything." - }, "::", { - "name": "init" - }], - "class_name": "MMethodDef", - "full_name": "test_prog$Character$Object::init", - "visibility": "public", - "modifiers": ["redef", "init"], - "msignature": { - "arity": 0, - "mparameters": [], - "return_mtype": null - } - }, { - "name": "init", - "namespace": [{ - "name": "test_prog", - "synopsis": "Test program for model tools." - }, "$", { "name": "Dwarf", "synopsis": "Dwarves make strong warriors." }, "$", { diff --git a/src/doc/templates/tests/test_json_model.sav/test_propdefs_to_full_json.res b/src/doc/templates/tests/test_json_model.sav/test_propdefs_to_full_json.res index 802b1ec..126aca2 100644 --- a/src/doc/templates/tests/test_json_model.sav/test_propdefs_to_full_json.res +++ b/src/doc/templates/tests/test_json_model.sav/test_propdefs_to_full_json.res @@ -312,23 +312,21 @@ } } { - "name": "init", + "name": "defaultinit", "namespace": [{ "name": "test_prog", "synopsis": "Test program for model tools." }, "$", { - "name": "Character", - "synopsis": "Characters can be played by both the human or the machine." - }, "$", { "name": "Object", "synopsis": "Root of everything." - }, "::", { - "name": "init" + }, "$", { + "name": "defaultinit" }], "class_name": "MMethodDef", - "full_name": "test_prog$Character$Object::init", + "full_name": "test_prog$Object$defaultinit", "visibility": "public", - "modifiers": ["redef", "init"], + "modifiers": ["init"], + "is_intro": true, "msignature": { "arity": 0, "mparameters": [], @@ -558,6 +556,28 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Int", + "synopsis": "Some services about Integers." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Int$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "+", "namespace": [{ "name": "test_prog", @@ -728,6 +748,94 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Float", + "synopsis": "Some services about Floats." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Float$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Bool", + "synopsis": "Booleans, `true` or `false`." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Bool$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "String", + "synopsis": "Strings (there is no chars...)." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$String$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "List", + "synopsis": "List of things." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$List$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "main", "namespace": [{ "name": "test_prog", @@ -774,6 +882,28 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Sys", + "synopsis": "Sys" + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Sys$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "_strength_bonus", "namespace": [{ "name": "test_prog", @@ -1008,6 +1138,190 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Career", + "synopsis": "A `Career` gives a characteristic bonus or malus to the character." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Career$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "strength_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "endurance_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "intelligence_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Warrior", + "synopsis": "Warriors are good for fighting." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Warrior$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "strength_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "endurance_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "intelligence_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Magician", + "synopsis": "Magicians know magic and how to use it." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Magician$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "strength_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "endurance_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "intelligence_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Alcoholic", + "synopsis": "Alcoholics are good to nothing escept taking punches." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Alcoholic$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "strength_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "endurance_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "intelligence_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } +} +{ "name": "_base_strength", "synopsis": "Used to represents how strong the race is.", "namespace": [{ @@ -1207,57 +1521,241 @@ } } { - "name": "base_intelligence", - "synopsis": "Is this race smart?", + "name": "base_intelligence", + "synopsis": "Is this race smart?", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Race", + "synopsis": "Race determines basic characteristics and what the character will be able to do in life." + }, "$", { + "name": "base_intelligence", + "synopsis": "Is this race smart?" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Race$base_intelligence", + "visibility": "public", + "html_synopsis": "Is this race smart?", + "modifiers": ["fun"], + "is_intro": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + } +} +{ + "name": "base_intelligence=", + "synopsis": "Is this race smart?", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Race", + "synopsis": "Race determines basic characteristics and what the character will be able to do in life." + }, "$", { + "name": "base_intelligence=", + "synopsis": "Is this race smart?" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Race$base_intelligence=", + "visibility": "protected", + "html_synopsis": "Is this race smart?", + "modifiers": ["protected", "fun"], + "is_intro": true, + "msignature": { + "arity": 1, + "mparameters": [{ + "is_vararg": false, + "name": "base_intelligence", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Race", + "synopsis": "Race determines basic characteristics and what the character will be able to do in life." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Race$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "base_strength", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "base_endurance", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "base_intelligence", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Human", + "synopsis": "Humans are able to do everithing." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Human$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "base_strength", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "base_endurance", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "base_intelligence", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } +} +{ + "name": "defaultinit", "namespace": [{ "name": "test_prog", "synopsis": "Test program for model tools." }, "$", { - "name": "Race", - "synopsis": "Race determines basic characteristics and what the character will be able to do in life." + "name": "Dwarf", + "synopsis": "Dwarves make strong warriors." }, "$", { - "name": "base_intelligence", - "synopsis": "Is this race smart?" + "name": "defaultinit" }], "class_name": "MMethodDef", - "full_name": "test_prog$Race$base_intelligence", + "full_name": "test_prog$Dwarf$defaultinit", "visibility": "public", - "html_synopsis": "Is this race smart?", - "modifiers": ["fun"], + "modifiers": ["init"], "is_intro": true, "msignature": { - "arity": 0, - "mparameters": [], - "return_mtype": { - "name": "Int", - "synopsis": "Some services about Integers.", - "html_synopsis": "Some services about Integers." - } + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "base_strength", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "base_endurance", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "base_intelligence", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null } } { - "name": "base_intelligence=", - "synopsis": "Is this race smart?", + "name": "defaultinit", "namespace": [{ "name": "test_prog", "synopsis": "Test program for model tools." }, "$", { - "name": "Race", - "synopsis": "Race determines basic characteristics and what the character will be able to do in life." + "name": "Elf", + "synopsis": "Elves make good magicians." }, "$", { - "name": "base_intelligence=", - "synopsis": "Is this race smart?" + "name": "defaultinit" }], "class_name": "MMethodDef", - "full_name": "test_prog$Race$base_intelligence=", - "visibility": "protected", - "html_synopsis": "Is this race smart?", - "modifiers": ["protected", "fun"], + "full_name": "test_prog$Elf$defaultinit", + "visibility": "public", + "modifiers": ["init"], "is_intro": true, "msignature": { - "arity": 1, + "arity": 3, "mparameters": [{ "is_vararg": false, + "name": "base_strength", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "base_endurance", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, "name": "base_intelligence", "mtype": { "name": "Int", @@ -1902,6 +2400,60 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Character", + "synopsis": "Characters can be played by both the human or the machine." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Character$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 4, + "mparameters": [{ + "is_vararg": false, + "name": "race", + "mtype": { + "name": "Race", + "synopsis": "Race determines basic characteristics and what the character will be able to do in life.", + "html_synopsis": "Race determines basic characteristics and what the character will be able to do in life." + } + }, { + "is_vararg": false, + "name": "name", + "mtype": { + "name": "String", + "synopsis": "Strings (there is no chars...).", + "html_synopsis": "Strings (there is no chars...)." + } + }, { + "is_vararg": false, + "name": "age", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "sex", + "mtype": { + "name": "Bool", + "synopsis": "Booleans, `true` or `false`.", + "html_synopsis": "Booleans, true or false." + } + }], + "return_mtype": null + } +} +{ "name": "dps", "synopsis": "Damage per second inflicted by this weapon.", "namespace": [{ @@ -1965,6 +2517,28 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Weapon", + "synopsis": "Something that can be used to attack someone and inflict damage." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Weapon$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "hit_points", "namespace": [{ "name": "test_prog", @@ -2181,6 +2755,28 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Combatable", + "synopsis": "Something that can be combatted, it can `attack` and `defend`." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Combatable$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "player_characters", "synopsis": "Characters played by human players.", "namespace": [{ @@ -2487,6 +3083,28 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Game", + "synopsis": "This is the interface you have to implement to use ure gaming platform." + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Game$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "_player_characters", "namespace": [{ "name": "test_prog", @@ -2591,6 +3209,28 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "MyGame", + "synopsis": "This is an example of how to implement the Game interface" + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$MyGame$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "start", "namespace": [{ "name": "test_prog", @@ -2612,6 +3252,27 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "Starter" + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$Starter$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "_player_characters", "namespace": [{ "name": "test_prog", @@ -2662,6 +3323,27 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "TestGame" + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$TestGame$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "test_game", "namespace": [{ "name": "test_prog", @@ -2682,3 +3364,24 @@ "return_mtype": null } } +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "$", { + "name": "GameTest" + }, "$", { + "name": "defaultinit" + }], + "class_name": "MMethodDef", + "full_name": "test_prog$GameTest$defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_intro": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} diff --git a/src/doc/templates/tests/test_json_model.sav/test_props_to_full_json.res b/src/doc/templates/tests/test_json_model.sav/test_props_to_full_json.res index 09644aa..4b49e79 100644 --- a/src/doc/templates/tests/test_json_model.sav/test_props_to_full_json.res +++ b/src/doc/templates/tests/test_json_model.sav/test_props_to_full_json.res @@ -117,6 +117,28 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Object", + "synopsis": "Root of everything." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Object::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "unary -", "namespace": [{ "name": "test_prog", @@ -332,6 +354,28 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Int", + "synopsis": "Some services about Integers." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Int::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "+", "namespace": [{ "name": "test_prog", @@ -497,6 +541,94 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Float", + "synopsis": "Some services about Floats." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Float::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Bool", + "synopsis": "Booleans, `true` or `false`." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Bool::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "String", + "synopsis": "Strings (there is no chars...)." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::String::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "List", + "synopsis": "List of things." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::List::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "main", "namespace": [{ "name": "test_prog", @@ -518,6 +650,28 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Sys", + "synopsis": "Sys" + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Sys::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "_strength_bonus", "namespace": [{ "name": "test_prog", @@ -752,6 +906,190 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Career", + "synopsis": "A `Career` gives a characteristic bonus or malus to the character." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Career::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "strength_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "endurance_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "intelligence_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Warrior", + "synopsis": "Warriors are good for fighting." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Warrior::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "strength_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "endurance_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "intelligence_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Magician", + "synopsis": "Magicians know magic and how to use it." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Magician::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "strength_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "endurance_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "intelligence_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Alcoholic", + "synopsis": "Alcoholics are good to nothing escept taking punches." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Alcoholic::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "strength_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "endurance_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "intelligence_bonus", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } +} +{ "name": "_base_strength", "synopsis": "Used to represents how strong the race is.", "namespace": [{ @@ -953,55 +1291,239 @@ } } { - "name": "base_intelligence", - "synopsis": "Is this race smart?", + "name": "base_intelligence", + "synopsis": "Is this race smart?", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Race", + "synopsis": "Race determines basic characteristics and what the character will be able to do in life." + }, "::", { + "name": "base_intelligence", + "synopsis": "Is this race smart?" + }], + "class_name": "MMethod", + "full_name": "test_prog::Race::base_intelligence", + "visibility": "public", + "html_synopsis": "Is this race smart?", + "modifiers": ["fun"], + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + } +} +{ + "name": "base_intelligence=", + "synopsis": "Is this race smart?", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Race", + "synopsis": "Race determines basic characteristics and what the character will be able to do in life." + }, "::", { + "name": "base_intelligence=", + "synopsis": "Is this race smart?" + }], + "class_name": "MMethod", + "full_name": "test_prog::Race::base_intelligence=", + "visibility": "protected", + "html_synopsis": "Is this race smart?", + "modifiers": ["protected", "fun"], + "msignature": { + "arity": 1, + "mparameters": [{ + "is_vararg": false, + "name": "base_intelligence", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Race", + "synopsis": "Race determines basic characteristics and what the character will be able to do in life." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Race::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "base_strength", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "base_endurance", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "base_intelligence", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } +} +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Human", + "synopsis": "Humans are able to do everithing." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Human::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "base_strength", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "base_endurance", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "base_intelligence", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null + } +} +{ + "name": "defaultinit", "namespace": [{ "name": "test_prog", "synopsis": "Test program for model tools." }, "::", { - "name": "Race", - "synopsis": "Race determines basic characteristics and what the character will be able to do in life." + "name": "Dwarf", + "synopsis": "Dwarves make strong warriors." }, "::", { - "name": "base_intelligence", - "synopsis": "Is this race smart?" + "name": "defaultinit" }], "class_name": "MMethod", - "full_name": "test_prog::Race::base_intelligence", + "full_name": "test_prog::Dwarf::defaultinit", "visibility": "public", - "html_synopsis": "Is this race smart?", - "modifiers": ["fun"], + "modifiers": ["init"], + "is_init": true, "msignature": { - "arity": 0, - "mparameters": [], - "return_mtype": { - "name": "Int", - "synopsis": "Some services about Integers.", - "html_synopsis": "Some services about Integers." - } + "arity": 3, + "mparameters": [{ + "is_vararg": false, + "name": "base_strength", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "base_endurance", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "base_intelligence", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }], + "return_mtype": null } } { - "name": "base_intelligence=", - "synopsis": "Is this race smart?", + "name": "defaultinit", "namespace": [{ "name": "test_prog", "synopsis": "Test program for model tools." }, "::", { - "name": "Race", - "synopsis": "Race determines basic characteristics and what the character will be able to do in life." + "name": "Elf", + "synopsis": "Elves make good magicians." }, "::", { - "name": "base_intelligence=", - "synopsis": "Is this race smart?" + "name": "defaultinit" }], "class_name": "MMethod", - "full_name": "test_prog::Race::base_intelligence=", - "visibility": "protected", - "html_synopsis": "Is this race smart?", - "modifiers": ["protected", "fun"], + "full_name": "test_prog::Elf::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, "msignature": { - "arity": 1, + "arity": 3, "mparameters": [{ "is_vararg": false, + "name": "base_strength", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "base_endurance", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, "name": "base_intelligence", "mtype": { "name": "Int", @@ -1641,6 +2163,60 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Character", + "synopsis": "Characters can be played by both the human or the machine." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Character::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 4, + "mparameters": [{ + "is_vararg": false, + "name": "race", + "mtype": { + "name": "Race", + "synopsis": "Race determines basic characteristics and what the character will be able to do in life.", + "html_synopsis": "Race determines basic characteristics and what the character will be able to do in life." + } + }, { + "is_vararg": false, + "name": "name", + "mtype": { + "name": "String", + "synopsis": "Strings (there is no chars...).", + "html_synopsis": "Strings (there is no chars...)." + } + }, { + "is_vararg": false, + "name": "age", + "mtype": { + "name": "Int", + "synopsis": "Some services about Integers.", + "html_synopsis": "Some services about Integers." + } + }, { + "is_vararg": false, + "name": "sex", + "mtype": { + "name": "Bool", + "synopsis": "Booleans, `true` or `false`.", + "html_synopsis": "Booleans, true or false." + } + }], + "return_mtype": null + } +} +{ "name": "dps", "synopsis": "Damage per second inflicted by this weapon.", "namespace": [{ @@ -1669,6 +2245,28 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Weapon", + "synopsis": "Something that can be used to attack someone and inflict damage." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Weapon::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "hit_points", "namespace": [{ "name": "test_prog", @@ -1846,6 +2444,28 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Combatable", + "synopsis": "Something that can be combatted, it can `attack` and `defend`." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Combatable::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "player_characters", "synopsis": "Characters played by human players.", "namespace": [{ @@ -1974,6 +2594,28 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Game", + "synopsis": "This is the interface you have to implement to use ure gaming platform." + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Game::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "_player_characters", "namespace": [{ "name": "test_prog", @@ -2078,6 +2720,28 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "MyGame", + "synopsis": "This is an example of how to implement the Game interface" + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::MyGame::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "start", "namespace": [{ "name": "test_prog", @@ -2098,6 +2762,27 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "Starter" + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::Starter::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "_player_characters", "namespace": [{ "name": "test_prog", @@ -2148,6 +2833,27 @@ } } { + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "TestGame" + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::TestGame::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} +{ "name": "test_game", "namespace": [{ "name": "test_prog", @@ -2167,3 +2873,24 @@ "return_mtype": null } } +{ + "name": "defaultinit", + "namespace": [{ + "name": "test_prog", + "synopsis": "Test program for model tools." + }, "::", { + "name": "GameTest" + }, "::", { + "name": "defaultinit" + }], + "class_name": "MMethod", + "full_name": "test_prog::GameTest::defaultinit", + "visibility": "public", + "modifiers": ["init"], + "is_init": true, + "msignature": { + "arity": 0, + "mparameters": [], + "return_mtype": null + } +} diff --git a/src/doc/templates/tests/test_md_commands.sav/test_cmd_call.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_call.res index 3ed3eb0..91c5ae8 100644 --- a/src/doc/templates/tests/test_md_commands.sav/test_cmd_call.res +++ b/src/doc/templates/tests/test_md_commands.sav/test_cmd_call.res @@ -1,2 +1,2 @@ -* `character$Character$init` +* `character$Character$defaultinit` * `character$Character$total_strengh` - The actual strength of the character. diff --git a/src/doc/templates/tests/test_md_commands.sav/test_cmd_features.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_features.res index cfabfc6..9d0a142 100644 --- a/src/doc/templates/tests/test_md_commands.sav/test_cmd_features.res +++ b/src/doc/templates/tests/test_md_commands.sav/test_cmd_features.res @@ -1,6 +1,7 @@ * `_endurance_bonus` * `_intelligence_bonus` * `_strength_bonus` +* `defaultinit` * `endurance_bonus` * `endurance_bonus=` * `careers$Career$init` diff --git a/src/doc/templates/tests/test_md_commands.sav/test_cmd_lin.res b/src/doc/templates/tests/test_md_commands.sav/test_cmd_lin.res index 4f36fb0..c7b37e8 100644 --- a/src/doc/templates/tests/test_md_commands.sav/test_cmd_lin.res +++ b/src/doc/templates/tests/test_md_commands.sav/test_cmd_lin.res @@ -6,5 +6,4 @@ * `careers$Warrior$init` * `careers$Magician$init` * `careers$Alcoholic$init` -* `character$Character$init` * `races$Dwarf$init` diff --git a/src/doc/term/tests/test_term.sav/test_call.res b/src/doc/term/tests/test_term.sav/test_call.res index ac3c732..0947bc2 100644 --- a/src/doc/term/tests/test_term.sav/test_call.res +++ b/src/doc/term/tests/test_term.sav/test_call.res @@ -1,7 +1,7 @@ Methods calling `test_prog::Career::endurance_bonus`: - * test_prog$Character$Object::init - redef init init(race: Race, name: String, age: Int, sex: Bool) + + test_prog$Character$defaultinit + init defaultinit(race: Race, name: String, age: Int, sex: Bool) test_location + test_prog$Character$total_endurance diff --git a/src/doc/term/tests/test_term.sav/test_lin.res b/src/doc/term/tests/test_term.sav/test_lin.res index 23e94dc..532b2e3 100644 --- a/src/doc/term/tests/test_term.sav/test_lin.res +++ b/src/doc/term/tests/test_term.sav/test_lin.res @@ -5,6 +5,6 @@ Linearization for `test_prog::Object::init`: test_location * test_prog$Race$Object::init - redef init init(base_strength: Int, base_endurance: Int, base_intelligence: Int) + redef init init test_location diff --git a/src/doc/term/tests/test_term.sav/test_term_catalog_stats.res b/src/doc/term/tests/test_term.sav/test_term_catalog_stats.res index c8a157d..47521e8 100644 --- a/src/doc/term/tests/test_term.sav/test_term_catalog_stats.res +++ b/src/doc/term/tests/test_term.sav/test_term_catalog_stats.res @@ -1,7 +1,7 @@ Catalog statistics: * 2 packages * 11 modules - * 79 methods + * 101 methods * 26 classes * 509 lines of code * 6 contributors diff --git a/src/interpreter/naive_interpreter.nit b/src/interpreter/naive_interpreter.nit index 7557da7..527f16e 100644 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@ -490,7 +490,7 @@ class NaiveInterpreter # 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) @@ -615,28 +615,6 @@ class NaiveInterpreter 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 @@ -1657,6 +1635,31 @@ redef class AClassdef v.call(superpd, arguments) end return null + else if mclassdef.default_init == mpropdef then + var recv = arguments.first + var initializers = mpropdef.initializers + var no_init = false + if not initializers.is_empty and not mpropdef.is_old_style_init 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 diff --git a/src/metrics/ast_metrics.nit b/src/metrics/ast_metrics.nit index d34899e..e5f1e10 100644 --- a/src/metrics/ast_metrics.nit +++ b/src/metrics/ast_metrics.nit @@ -49,7 +49,6 @@ private class AstMetricsVisitor super Visitor var phase: AstMetricsPhase - init(phase: AstMetricsPhase) do self.phase = phase redef fun visit(n) do diff --git a/src/metrics/static_types_metrics.nit b/src/metrics/static_types_metrics.nit index 45c429b..4dd38d0 100644 --- a/src/metrics/static_types_metrics.nit +++ b/src/metrics/static_types_metrics.nit @@ -41,14 +41,6 @@ private class ATypeCounterVisitor var typecount: Counter[MType] - # Get a new visitor on a classef to add type count in `typecount`. - init(modelbuilder: ModelBuilder, nclassdef: AClassdef, typecount: Counter[MType]) - do - self.modelbuilder = modelbuilder - self.nclassdef = nclassdef - self.typecount = typecount - end - redef fun visit(n) do if n isa AAnnotation then return diff --git a/src/model/model.nit b/src/model/model.nit index e3fa3fd..e22ae84 100644 --- a/src/model/model.nit +++ b/src/model/model.nit @@ -778,9 +778,44 @@ class MClassDef # All property introductions and redefinitions in `self` (not inheritance). var mpropdefs = new Array[MPropDef] + # The special default_init constructor + var default_init: nullable MMethodDef = null is writable + # All property introductions and redefinitions (not inheritance) in `self` by its associated property. var mpropdefs_by_property = new HashMap[MProperty, MPropDef] + # Return the direct parent mtype of `self` + # Exemple + # ~~~nitish + # module 1 + # + # class A + # class B + # super A + # + # module 2 + # + # redef class A + # class C + # super B + # + # mclassdef_C.get_direct_supermtype == [B] + # ~~~~ + fun get_direct_supermtype: Collection[MClassType] + do + # Get the potentiel direct parents + var parents = in_hierarchy.direct_greaters + # Stock the potentiel direct parents + var res = supertypes + for parent in parents do + # remove all super parents of the potentiel direct parents + res.remove_all(parent.supertypes) + # if the length of the potentiel direct parent equal 1 break + if res.length == 1 then break + end + return res + end + redef fun mdoc_or_fallback do return mdoc or else mclass.mdoc_or_fallback end @@ -2622,19 +2657,21 @@ class MMethodDef # The signature attached to the property definition var msignature: nullable MSignature = null is writable - # The signature attached to the `new` call on a root-init - # This is a concatenation of the signatures of the initializers - # - # REQUIRE `mproperty.is_root_init == (new_msignature != null)` - var new_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 + + # Does the method is a old_style_init? + # + var is_old_style_init = false is writable + # Is the method definition abstract? var is_abstract: Bool = false is writable diff --git a/src/modelize/modelize_property.nit b/src/modelize/modelize_property.nit index 35e210e..beb9068 100644 --- a/src/modelize/modelize_property.nit +++ b/src/modelize/modelize_property.nit @@ -66,10 +66,9 @@ redef class ModelBuilder 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 @@ -150,7 +149,11 @@ redef class ModelBuilder var mclassdef = nclassdef.mclassdef.as(not null) # Are we a refinement - if not mclassdef.is_intro then return + if not mclassdef.is_intro then + # Set the default_init of the mclassdef with the intro default_init + mclassdef.default_init = mclassdef.mclass.intro.default_init + return + end # Look for the init in Object, or create it if mclassdef.mclass.name == "Object" and the_root_init_mmethod == null then @@ -161,11 +164,9 @@ redef class ModelBuilder var mparameters = new Array[MParameter] var msignature = new MSignature(mparameters, null) mpropdef.msignature = msignature - mpropdef.new_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? @@ -176,13 +177,15 @@ redef class ModelBuilder if mpropdef.mproperty.is_root_init then assert defined_init == null defined_init = mpropdef - else if mpropdef.mproperty.name == "init" then - # An explicit old-style init named "init", so return + else if mpropdef.name == "defaultinit" then return end end - if not nclassdef isa AStdClassdef then return + if mclassdef.default_init != null then return + + # If the class is not AStdClassdef or it's an enum just return. No defaultinit is need. + if not nclassdef isa AStdClassdef or nclassdef.n_classkind isa AEnumClasskind then return # Collect undefined attributes var mparameters = new Array[MParameter] @@ -194,7 +197,6 @@ redef class ModelBuilder if mpropdef == null then return # Skip broken method var sig = mpropdef.msignature if sig == null then continue # Skip broken method - mparameters.add_all sig.mparameters initializers.add(mpropdef.mproperty) mpropdef.mproperty.is_autoinit = true @@ -238,10 +240,13 @@ redef class ModelBuilder 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.get_direct_supermtype do + var y = x.mclass.intro.default_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 @@ -295,13 +300,29 @@ redef class ModelBuilder abort end end - else + else if spropdefs.not_empty then + # Search for inherited manual defaultinit + var manual = null + for s in spropdefs do + if mpropdef2npropdef.has_key(s) then + self.toolcontext.info("{mclassdef} inherits a manual defaultinit {s}", 3) + 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 defaultinit {manual} and automatic defaultinit {spd}.", 3) + end + end + # conflict with manual autoinit? + if longest != manual and manual != null then + self.error(nclassdef, "Error: conflict between manual defaultinit {manual} and automatic defaultinit {longest}.") end # part 2. compare # Check for conflict in the order of initializers @@ -334,41 +355,26 @@ redef class ModelBuilder 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, "defaultinit", 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.default_init = mpropdef + self.toolcontext.info("{mclassdef} gets a free auto constructor `{mpropdef}{msignature}`. {spropdefs}", 3) + 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`. @@ -504,11 +510,9 @@ end 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 + # 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 @@ -785,10 +789,16 @@ redef class AMethPropdef var name: String var amethodid = self.n_methid var name_node: ANode + var is_old_style_init = false if amethodid == null then if n_kwinit != null then name = "init" name_node = n_kwinit + var old_style_annot = get_single_annotation("old_style_init", modelbuilder) + if old_style_annot != null or self.n_signature.n_params.not_empty then + name = "defaultinit" + if old_style_annot != null then is_old_style_init = true + end else if n_kwnew != null then name = "new" name_node = n_kwnew @@ -822,7 +832,7 @@ redef class AMethPropdef 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 @@ -867,6 +877,15 @@ redef class AMethPropdef mclassdef.mprop2npropdef[mprop] = self var mpropdef = new MMethodDef(mclassdef, mprop, self.location) + if mpropdef.name == "defaultinit" and mclassdef.is_intro then + assert mclassdef.default_init == null + mpropdef.is_old_style_init = is_old_style_init + mclassdef.default_init = mpropdef + # Set the initializers with the mproperty. + # This point is need when a super class define this own default_init and inherited class use the default_init generated automaticlely. + mpropdef.initializers.add mprop + mpropdef.is_calling_init = true + end set_doc(mpropdef, modelbuilder) @@ -888,16 +907,6 @@ redef class AMethPropdef var mmodule = mclassdef.mmodule var nsig = self.n_signature - if mproperty.is_root_init and not mclassdef.is_intro then - 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 - end - var accept_special_last_parameter = self.n_methid == null or self.n_methid.accept_special_last_parameter var return_is_mandatory = self.n_methid != null and self.n_methid.return_is_mandatory diff --git a/src/neo.nit b/src/neo.nit index 3af570a..15b1de6 100644 --- a/src/neo.nit +++ b/src/neo.nit @@ -724,7 +724,7 @@ class NeoModel var rank = 0 for mparameter in mtype.mparameters do names.add mparameter.name - var pnode = mparameter_node(mparameter) + var pnode = to_node(mparameter) pnode["rank"] = rank node.out_edges.add(new NeoEdge(node, "PARAMETER", pnode)) rank += 1 diff --git a/src/nitni/nitni_callbacks.nit b/src/nitni/nitni_callbacks.nit index 6d05196..c9725d0 100644 --- a/src/nitni/nitni_callbacks.nit +++ b/src/nitni/nitni_callbacks.nit @@ -219,7 +219,7 @@ class MExplicitCall var cname if mproperty.is_init then - if mproperty.name == "init" or mproperty.name == "new" then + if mproperty.name == "init" or mproperty.name == "new" or mproperty.name == "defaultinit" then cname = "new_{recv_mtype.mangled_cname}" else cname = "new_{recv_mtype.mangled_cname}_{mproperty.short_cname}" @@ -350,7 +350,7 @@ redef class AInitPropExternCall mmodule, mtype, meth_name ) if meth == null then - meth_name = "init" + meth_name = "defaultinit" meth = toolcontext.modelbuilder.try_get_mproperty_by_name2( self, mmodule, mtype, meth_name ) end diff --git a/src/nitni/nitni_utilities.nit b/src/nitni/nitni_utilities.nit index 910877b..b1b5917 100644 --- a/src/nitni/nitni_utilities.nit +++ b/src/nitni/nitni_utilities.nit @@ -28,7 +28,7 @@ redef class MMethod do var cname if self.is_init then - if self.name == "init" or self.name == "new" then + if self.name == "init" or self.name == "new" or self.name == "defaultinit" then cname = "new_{recv_mtype.mangled_cname}" else cname = "new_{recv_mtype.mangled_cname}_{self.short_cname}" diff --git a/src/rapid_type_analysis.nit b/src/rapid_type_analysis.nit index 970d8df..404ebce 100644 --- a/src/rapid_type_analysis.nit +++ b/src/rapid_type_analysis.nit @@ -245,7 +245,6 @@ class RapidTypeAnalysis 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 @@ -261,9 +260,15 @@ class RapidTypeAnalysis 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.default_init == mmethoddef then + # default_init 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 diff --git a/src/semantize/auto_super_init.nit b/src/semantize/auto_super_init.nit index 55263bd..0be7107 100644 --- a/src/semantize/auto_super_init.nit +++ b/src/semantize/auto_super_init.nit @@ -104,14 +104,9 @@ redef class AMethPropdef var auto_super_inits = new Array[CallSite] # The look for new-style super constructors (called from a old style constructor) - var the_root_init_mmethod = modelbuilder.the_root_init_mmethod - if the_root_init_mmethod != null and auto_super_inits.is_empty then - var candidatedefs = the_root_init_mmethod.lookup_definitions(mmodule, anchor) - if candidatedefs.is_empty then - # skip broken - is_broken = true - return - end + var candidatedefs = get_super_candidatedefs(modelbuilder) + + if not candidatedefs.is_empty and auto_super_inits.is_empty then var candidatedef = candidatedefs.first if candidatedefs.length > 1 then @@ -121,18 +116,34 @@ redef class AMethPropdef return end - var msignature = candidatedef.new_msignature or else candidatedef.msignature + var msignature = candidatedef.msignature msignature = msignature.resolve_for(recvtype, anchor, mmodule, true) - if msignature.arity > 0 then + if msignature.arity > mpropdef.msignature.arity then modelbuilder.error(self, "Error: cannot do an implicit constructor call to `{candidatedef}{msignature}`. Expected at least `{msignature.arity}` arguments.") is_broken = true return end - var callsite = new CallSite(hot_location, recvtype, mmodule, anchor, true, the_root_init_mmethod, candidatedef, msignature, false) + if candidatedef.mproperty != mpropdef.mproperty then + var i = 0 + for candidat_mparameter in msignature.mparameters do + var actual_mparameter = mpropdef.msignature.mparameters[i] + if not candidat_mparameter.mtype.is_subtype(mmodule, anchor, actual_mparameter.mtype) then + modelbuilder.error(self, "Type Error: expected argument #{i} of type `{candidat_mparameter.mtype}`, got implicit argument `{candidat_mparameter.name}` of type `{actual_mparameter.mtype}`. Signature is {msignature}") + return + end + i += 1 + end + end + + var callsite = new CallSite(hot_location, recvtype, mmodule, anchor, true, candidatedef.mproperty, candidatedef, msignature, false) auto_super_inits.add(callsite) - modelbuilder.toolcontext.info("Auto-super init for {mpropdef} to {the_root_init_mmethod.full_name}", 4) + modelbuilder.toolcontext.info("Auto-super init for {mpropdef} to {candidatedef.full_name}", 4) + else if candidatedefs.is_empty then + # skip broken + is_broken = true + return end if auto_super_inits.is_empty then modelbuilder.error(self, "Error: no constructors to call implicitly in `{mpropdef}`. Call one explicitly.") @@ -142,6 +153,34 @@ redef class AMethPropdef self.auto_super_inits = auto_super_inits end + # This method returns the list of possible candidates for the current definition. + # + # Warning this method supports super call from old_style_init to default_inits without signature verification!!! + private fun get_super_candidatedefs(modelbuilder: ModelBuilder): Array[MMethodDef] + do + var candidatedefs = new Array[MMethodDef] + + var mclassdef = self.parent.as(AClassdef).mclassdef + if mclassdef == null or mclassdef.is_broken then return candidatedefs # skip error + var mpropdef = self.mpropdef + if mpropdef == null or mpropdef.is_broken then return candidatedefs # skip error + var mmodule = mpropdef.mclassdef.mmodule + var anchor = mclassdef.bound_mtype + var mproperty = mpropdef.mproperty + + # The look for new-style super constructors (called from a old style constructor) + var the_root_init_mmethod = modelbuilder.the_root_init_mmethod + + if mpropdef.is_old_style_init then + var superprop: nullable MMethodDef = null + for mclass in mclassdef.mclass.in_hierarchy(mmodule).direct_greaters do + candidatedefs.add(mclass.intro.default_init.as(not null)) + end + else + candidatedefs = the_root_init_mmethod.lookup_definitions(mmodule, anchor) + end + return candidatedefs + end end redef class ANode diff --git a/src/semantize/typing.nit b/src/semantize/typing.nit index b9acd5e..5d6b5da 100644 --- a/src/semantize/typing.nit +++ b/src/semantize/typing.nit @@ -315,13 +315,22 @@ private class TypeVisitor var mproperty = self.try_get_mproperty_by_name2(node, unsafe_type, name) if name == "new" and mproperty == null then - name = "init" + name = "defaultinit" 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 if recv_is_self then - self.modelbuilder.error(node, "Error: method or variable `{name}` unknown in `{recvtype}`.") + # FIXME This test was added to display a more explicit error when a potential duplication of root object class. + if name == "init" then + self.modelbuilder.error(node, "Possible duplication of the root class `Object`") + else + self.modelbuilder.error(node, "Error: method or variable `{name}` unknown in `{recvtype}`.") + end else if recvtype.need_anchor then self.modelbuilder.error(node, "Error: method `{name}` does not exists in `{recvtype}: {unsafe_type}`.") else @@ -395,7 +404,7 @@ private class TypeVisitor # The `build_callsite_by_propdef` builds the callsite directly with the `mprodef` passed in argument. fun build_callsite_by_propdef(node: ANode, recvtype: MType, mpropdef: MMethodDef, recv_is_self: Bool): nullable CallSite do - 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) @@ -1774,7 +1783,7 @@ redef class ARangeExpr # get the constructor var callsite if self isa ACrangeExpr then - callsite = v.build_callsite_by_name(self, mtype, "init", false) + callsite = v.build_callsite_by_name(self, mtype, "defaultinit", false) else if self isa AOrangeExpr then callsite = v.build_callsite_by_name(self, mtype, "without_last", false) else @@ -2156,7 +2165,7 @@ redef class ABraReassignExpr 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 "defaultinit" redef fun property_node do return n_kwinit redef fun compute_raw_arguments do return n_args.to_a end @@ -2325,7 +2334,7 @@ redef class ASuperExpr 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 --git a/src/vm/vm_optimizations.nit b/src/vm/vm_optimizations.nit index 514d3d1..3fe9672 100644 --- a/src/vm/vm_optimizations.nit +++ b/src/vm/vm_optimizations.nit @@ -24,28 +24,7 @@ redef class VirtualMachine # Add optimization of the method dispatch redef fun callsite(callsite: nullable CallSite, arguments: Array[Instance]): nullable Instance do - var initializers = callsite.mpropdef.initializers - if initializers.is_empty then return send_optimize(callsite.as(not null), arguments) - - 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_optimize(callsite.as(not null), [recv]) + return send_optimize(callsite.as(not null), arguments) end # Try to have the most efficient implementation of the method dispatch diff --git a/tests/base_attr_nullable.nit b/tests/base_attr_nullable.nit index ae29324..112f86b 100644 --- a/tests/base_attr_nullable.nit +++ b/tests/base_attr_nullable.nit @@ -26,7 +26,6 @@ end class Integer var val: Int - init(val: Int) do _val = val fun output do _val.output end diff --git a/tests/base_init_super_call2.nit b/tests/base_init_super_call2.nit index be64735..0f2988b 100644 --- a/tests/base_init_super_call2.nit +++ b/tests/base_init_super_call2.nit @@ -40,7 +40,10 @@ end class C1 super A - init(j: Int) do + init(j: Int) + is + old_style_init + do super j.output end @@ -48,7 +51,10 @@ end class D1 super A - init(j: Int) do + init(j: Int) + is + old_style_init + do super j.output end @@ -56,7 +62,10 @@ end class E1 super A - init(j: Bool) do + init(j: Bool) + is + old_style_init + do super(8)#alt4#super j.output end @@ -64,7 +73,10 @@ end class C2 super A - init(j: Int) do + init(j: Int) + is + old_style_init + do super(j) j.output end @@ -72,7 +84,10 @@ end class D2 super A - init(j: Int) do + init(j: Int) + is + old_style_init + do super(j) j.output end @@ -80,7 +95,10 @@ end class E2 super A - init(j: Bool) do + init(j: Bool) + is + old_style_init + do super(11)#alt5#super(j) j.output end @@ -88,7 +106,10 @@ end class C3 super A - init(j: Int) do + init(j: Int) + is + old_style_init + do super(j)#alt6# j.output end @@ -96,7 +117,10 @@ end class D3 super A - init(j: Int) do + init(j: Int) + is + old_style_init + do super(j)#alt6# j.output end @@ -104,7 +128,10 @@ end class E3 super A - init(j: Bool) do + init(j: Bool) + is + old_style_init + do super(14)#alt6# j.output end @@ -112,7 +139,10 @@ end class F1 super A - init(j: Int, k: Bool) do + init(j: Int, k: Bool) + is + old_style_init + do super j.output end @@ -120,7 +150,10 @@ end class F2 super A - init(j: Int, k: Bool) do + init(j: Int, k: Bool) + is + old_style_init + do super(j)#alt6# j.output end diff --git a/tests/base_simple3.nit b/tests/base_simple3.nit index 8bb2bc8..6515ef7 100644 --- a/tests/base_simple3.nit +++ b/tests/base_simple3.nit @@ -33,11 +33,7 @@ end class B var val: Int - init(v: Int) - do - 7.output - self.val = v - end + init do 7.output fun run do val.output end diff --git a/tests/error_defs_init.nit b/tests/error_defs_init.nit index adff5f2..710fe07 100644 --- a/tests/error_defs_init.nit +++ b/tests/error_defs_init.nit @@ -16,18 +16,18 @@ import kernel class A #1alt1#init do abort - #1alt2#init(a: Int) do abort + #1alt2#init(a: Int) is old_style_init do abort #1alt3#new do abort #1alt4#new(c: Int) do abort - #1alt5#init foo(a: Int) do abort + #1alt5#init foo(a: Int) is old_style_init do abort #1alt6#new foo(c: Int) do abort #1alt7#fun foo do end #alt1#init do abort - #alt2#init(b: Float) do abort + #alt2#init(b: Float)is old_style_init do abort #alt3#new do abort #alt4#new(d: Float) do abort - #alt5#init foo(a: Float) do abort + #alt5#init foo(a: Float)is old_style_init do abort #alt6#new foo(c: Float) do abort #alt7#fun foo do end end diff --git a/tests/sav/base_arg_default_autoinit_alt1.res b/tests/sav/base_arg_default_autoinit_alt1.res index d6c4929..df31aac 100644 --- a/tests/sav/base_arg_default_autoinit_alt1.res +++ b/tests/sav/base_arg_default_autoinit_alt1.res @@ -1,9 +1,9 @@ -alt/base_arg_default_autoinit_alt1.nit:59,5--7: Error: expected at least 1 argument(s) for `init(mandatory: Int, optional: nullable Int)`; got 0. See introduction at `core::Object::init`. -alt/base_arg_default_autoinit_alt1.nit:68,5--7: Error: expected 2 argument(s) for `init(mandatory: Int, optional: nullable Int)`; got 3. See introduction at `core::Object::init`. -alt/base_arg_default_autoinit_alt1.nit:71,5--7: Error: expected 4 argument(s) for `init(mandatory: Int, optional, optional_b: nullable Int, mandatory_b: Int)`; got 1. See introduction at `core::Object::init`. -alt/base_arg_default_autoinit_alt1.nit:74,5--7: Error: expected 4 argument(s) for `init(mandatory: Int, optional, optional_b: nullable Int, mandatory_b: Int)`; got 2. See introduction at `core::Object::init`. -alt/base_arg_default_autoinit_alt1.nit:77,5--7: Error: expected 4 argument(s) for `init(mandatory: Int, optional, optional_b: nullable Int, mandatory_b: Int)`; got 3. See introduction at `core::Object::init`. -alt/base_arg_default_autoinit_alt1.nit:83,5--7: Error: expected 4 argument(s) for `init(mandatory: Int, optional, optional_b: nullable Int, mandatory_b: Int)`; got 5. See introduction at `core::Object::init`. -alt/base_arg_default_autoinit_alt1.nit:86,5--7: Error: expected 3 argument(s) for `init(optional_b: nullable Int, mandatory_b, mandatory: Int)`; got 1. See introduction at `core::Object::init`. -alt/base_arg_default_autoinit_alt1.nit:89,5--7: Error: expected 3 argument(s) for `init(optional_b: nullable Int, mandatory_b, mandatory: Int)`; got 2. See introduction at `core::Object::init`. -alt/base_arg_default_autoinit_alt1.nit:95,5--7: Error: expected 3 argument(s) for `init(optional_b: nullable Int, mandatory_b, mandatory: Int)`; got 4. See introduction at `core::Object::init`. +alt/base_arg_default_autoinit_alt1.nit:59,5--7: Error: expected at least 1 argument(s) for `defaultinit(mandatory: Int, optional: nullable Int)`; got 0. See introduction at `base_arg_default_autoinit_alt1::A::defaultinit`. +alt/base_arg_default_autoinit_alt1.nit:68,5--7: Error: expected 2 argument(s) for `defaultinit(mandatory: Int, optional: nullable Int)`; got 3. See introduction at `base_arg_default_autoinit_alt1::A::defaultinit`. +alt/base_arg_default_autoinit_alt1.nit:71,5--7: Error: expected 4 argument(s) for `defaultinit(mandatory: Int, optional, optional_b: nullable Int, mandatory_b: Int)`; got 1. See introduction at `base_arg_default_autoinit_alt1::B::defaultinit`. +alt/base_arg_default_autoinit_alt1.nit:74,5--7: Error: expected 4 argument(s) for `defaultinit(mandatory: Int, optional, optional_b: nullable Int, mandatory_b: Int)`; got 2. See introduction at `base_arg_default_autoinit_alt1::B::defaultinit`. +alt/base_arg_default_autoinit_alt1.nit:77,5--7: Error: expected 4 argument(s) for `defaultinit(mandatory: Int, optional, optional_b: nullable Int, mandatory_b: Int)`; got 3. See introduction at `base_arg_default_autoinit_alt1::B::defaultinit`. +alt/base_arg_default_autoinit_alt1.nit:83,5--7: Error: expected 4 argument(s) for `defaultinit(mandatory: Int, optional, optional_b: nullable Int, mandatory_b: Int)`; got 5. See introduction at `base_arg_default_autoinit_alt1::B::defaultinit`. +alt/base_arg_default_autoinit_alt1.nit:86,5--7: Error: expected 3 argument(s) for `defaultinit(optional_b: nullable Int, mandatory_b, mandatory: Int)`; got 1. See introduction at `base_arg_default_autoinit_alt1::C::defaultinit`. +alt/base_arg_default_autoinit_alt1.nit:89,5--7: Error: expected 3 argument(s) for `defaultinit(optional_b: nullable Int, mandatory_b, mandatory: Int)`; got 2. See introduction at `base_arg_default_autoinit_alt1::C::defaultinit`. +alt/base_arg_default_autoinit_alt1.nit:95,5--7: Error: expected 3 argument(s) for `defaultinit(optional_b: nullable Int, mandatory_b, mandatory: Int)`; got 4. See introduction at `base_arg_default_autoinit_alt1::C::defaultinit`. diff --git a/tests/sav/base_attr_annot_1alt1.res b/tests/sav/base_attr_annot_1alt1.res index 9caee3f..55e832d 100644 --- a/tests/sav/base_attr_annot_1alt1.res +++ b/tests/sav/base_attr_annot_1alt1.res @@ -1 +1 @@ -alt/base_attr_annot_1alt1.nit:33,9--11: Error: expected 0 argument(s) for `init`; got 1. See introduction at `core::Object::init`. +alt/base_attr_annot_1alt1.nit:33,9--11: Error: expected 0 argument(s) for `defaultinit`; got 1. See introduction at `base_attr_annot_1alt1::B::defaultinit`. diff --git a/tests/sav/base_attr_annot_alt1.res b/tests/sav/base_attr_annot_alt1.res index ea3b78f..7b33360 100644 --- a/tests/sav/base_attr_annot_alt1.res +++ b/tests/sav/base_attr_annot_alt1.res @@ -1 +1 @@ -alt/base_attr_annot_alt1.nit:33,9--11: Error: expected 1 argument(s) for `init(a: Object)`; got 0. See introduction at `core::Object::init`. +alt/base_attr_annot_alt1.nit:33,9--11: Error: expected 1 argument(s) for `defaultinit(a: Object)`; got 0. See introduction at `base_attr_annot_alt1::B::defaultinit`. diff --git a/tests/sav/base_attr_nullable_alt1.res b/tests/sav/base_attr_nullable_alt1.res index c7cab54..60c2eaf 100644 --- a/tests/sav/base_attr_nullable_alt1.res +++ b/tests/sav/base_attr_nullable_alt1.res @@ -1 +1 @@ -Runtime error: Uninitialized attribute _a1 (alt/base_attr_nullable_alt1.nit:38) +Runtime error: Uninitialized attribute _a1 (alt/base_attr_nullable_alt1.nit:37) diff --git a/tests/sav/base_attr_nullable_alt2.res b/tests/sav/base_attr_nullable_alt2.res index d238261..46a38b1 100644 --- a/tests/sav/base_attr_nullable_alt2.res +++ b/tests/sav/base_attr_nullable_alt2.res @@ -1,2 +1,2 @@ -Runtime error: Uninitialized attribute _a2 (alt/base_attr_nullable_alt2.nit:39) +Runtime error: Uninitialized attribute _a2 (alt/base_attr_nullable_alt2.nit:38) 1 diff --git a/tests/sav/base_attr_nullable_alt3.res b/tests/sav/base_attr_nullable_alt3.res index b6f38c8..a725723 100644 --- a/tests/sav/base_attr_nullable_alt3.res +++ b/tests/sav/base_attr_nullable_alt3.res @@ -1 +1 @@ -Runtime error: Uninitialized attribute _a1 (alt/base_attr_nullable_alt3.nit:64) +Runtime error: Uninitialized attribute _a1 (alt/base_attr_nullable_alt3.nit:63) diff --git a/tests/sav/base_attr_nullable_alt4.res b/tests/sav/base_attr_nullable_alt4.res index 1a98ce8..7ab0b21 100644 --- a/tests/sav/base_attr_nullable_alt4.res +++ b/tests/sav/base_attr_nullable_alt4.res @@ -1,2 +1,2 @@ -Runtime error: Uninitialized attribute _a2 (alt/base_attr_nullable_alt4.nit:45) +Runtime error: Uninitialized attribute _a2 (alt/base_attr_nullable_alt4.nit:44) 10 diff --git a/tests/sav/base_attr_nullable_alt5.res b/tests/sav/base_attr_nullable_alt5.res index 891e424..eadaa67 100644 --- a/tests/sav/base_attr_nullable_alt5.res +++ b/tests/sav/base_attr_nullable_alt5.res @@ -1,3 +1,3 @@ -Runtime error: Uninitialized attribute _a3 (alt/base_attr_nullable_alt5.nit:66) +Runtime error: Uninitialized attribute _a3 (alt/base_attr_nullable_alt5.nit:65) 10 20 diff --git a/tests/sav/base_init_basic_alt3.res b/tests/sav/base_init_basic_alt3.res index 84d579c..971fe14 100644 --- a/tests/sav/base_init_basic_alt3.res +++ b/tests/sav/base_init_basic_alt3.res @@ -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$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$E$defaultinit(c=, e=) and base_init_basic_alt3$D$defaultinit(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$defaultinit(c=, e=) and base_init_basic_alt3$D$defaultinit(c=, b=). Use `autoinit` to order initializers. eg `autoinit c=, b=, e=, g=` diff --git a/tests/sav/base_init_basic_alt5.res b/tests/sav/base_init_basic_alt5.res index 82ddfc6..565d4e7 100644 --- a/tests/sav/base_init_basic_alt5.res +++ b/tests/sav/base_init_basic_alt5.res @@ -1 +1 @@ -alt/base_init_basic_alt5.nit:79,9--11: Error: expected 2 argument(s) for `init(c, b: Int)`; got 1. See introduction at `core::Object::init`. +alt/base_init_basic_alt5.nit:79,9--11: Error: expected 2 argument(s) for `defaultinit(c, b: Int)`; got 1. See introduction at `base_init_basic_alt5::D::defaultinit`. diff --git a/tests/sav/base_init_combine_alt1.res b/tests/sav/base_init_combine_alt1.res index b079cab..d9b9b04 100644 --- a/tests/sav/base_init_combine_alt1.res +++ b/tests/sav/base_init_combine_alt1.res @@ -1 +1 @@ -alt/base_init_combine_alt1.nit:59,9--11: Error: expected 2 argument(s) for `init(i, z: Int)`; got 1. See introduction at `core::Object::init`. +alt/base_init_combine_alt1.nit:59,9--11: Error: expected 2 argument(s) for `defaultinit(i, z: Int)`; got 1. See introduction at `base_init_combine_alt1::F::defaultinit`. diff --git a/tests/sav/base_init_noinit_alt4.res b/tests/sav/base_init_noinit_alt4.res index 7282bf5..5d7df60 100644 --- a/tests/sav/base_init_noinit_alt4.res +++ b/tests/sav/base_init_noinit_alt4.res @@ -1 +1 @@ -alt/base_init_noinit_alt4.nit:30,3--5: Error: expected 0 argument(s) for `init`; got 1. See introduction at `core::Object::init`. +alt/base_init_noinit_alt4.nit:30,3--5: Error: expected 0 argument(s) for `defaultinit`; got 1. See introduction at `base_init_noinit_alt4::A::defaultinit`. diff --git a/tests/sav/base_init_super_call2_alt3.res b/tests/sav/base_init_super_call2_alt3.res index d75b874..9245c89 100644 --- a/tests/sav/base_init_super_call2_alt3.res +++ b/tests/sav/base_init_super_call2_alt3.res @@ -1 +1 @@ -alt/base_init_super_call2_alt3.nit:38,2--5: Error: cannot do an implicit constructor call to `base_init_super_call2_alt3$A$init(i: Int)`. Expected at least `1` arguments. +alt/base_init_super_call2_alt3.nit:38,2--5: Error: cannot do an implicit constructor call to `base_init_super_call2_alt3$A$defaultinit(i: Int)`. Expected at least `1` arguments. diff --git a/tests/sav/base_init_super_call2_alt4.res b/tests/sav/base_init_super_call2_alt4.res index 823de40..eeb33c5 100644 --- a/tests/sav/base_init_super_call2_alt4.res +++ b/tests/sav/base_init_super_call2_alt4.res @@ -1 +1 @@ -alt/base_init_super_call2_alt4.nit:60,3--7: Type Error: expected argument #0 of type `Int`, got implicit argument `j` of type `Bool`. Signature is (i: Int) +alt/base_init_super_call2_alt4.nit:69,3--7: Type Error: expected argument #0 of type `Int`, got implicit argument `j` of type `Bool`. Signature is (i: Int) diff --git a/tests/sav/base_init_super_call2_alt5.res b/tests/sav/base_init_super_call2_alt5.res index b6e45c9..7fd2621 100644 --- a/tests/sav/base_init_super_call2_alt5.res +++ b/tests/sav/base_init_super_call2_alt5.res @@ -1 +1 @@ -alt/base_init_super_call2_alt5.nit:84,9: Type Error: expected `Int`, got `Bool`. +alt/base_init_super_call2_alt5.nit:102,9: Type Error: expected `Int`, got `Bool`. diff --git a/tests/sav/base_init_super_call2_alt6.res b/tests/sav/base_init_super_call2_alt6.res index a920abb..0d1abc9 100644 --- a/tests/sav/base_init_super_call2_alt6.res +++ b/tests/sav/base_init_super_call2_alt6.res @@ -1,4 +1 @@ -alt/base_init_super_call2_alt6.nit:91,2--5: Error: cannot do an implicit constructor call to `base_init_super_call2_alt6$A$init(i: Int)`. Expected at least `1` arguments. -alt/base_init_super_call2_alt6.nit:99,2--5: Error: cannot do an implicit constructor call to `base_init_super_call2_alt6$A$init(i: Int)`. Expected at least `1` arguments. -alt/base_init_super_call2_alt6.nit:107,2--5: Error: cannot do an implicit constructor call to `base_init_super_call2_alt6$A$init(i: Int)`. Expected at least `1` arguments. -alt/base_init_super_call2_alt6.nit:123,2--5: Error: cannot do an implicit constructor call to `base_init_super_call2_alt6$A$init(i: Int)`. Expected at least `1` arguments. +alt/base_init_super_call2_alt6.nit:131,2--5: Type Error: expected argument #0 of type `Int`, got implicit argument `i` of type `Bool`. Signature is (i: Int) diff --git a/tests/sav/base_init_super_call_alt3.res b/tests/sav/base_init_super_call_alt3.res index 138108b..4adff4b 100644 --- a/tests/sav/base_init_super_call_alt3.res +++ b/tests/sav/base_init_super_call_alt3.res @@ -1,23 +1 @@ -1 -2 -3 -4 -6 -6 -7 -7 -8 -true -9 -9 -10 -10 -11 -true -12 -13 -14 -true -15 -15 -16 +alt/base_init_super_call_alt3.nit:38,2--5: Error: cannot do an implicit constructor call to `base_init_super_call_alt3$A$defaultinit(i: Int)`. Expected at least `1` arguments. diff --git a/tests/sav/base_new_alt8.res b/tests/sav/base_new_alt8.res index 880abb6..a0517ba 100644 --- a/tests/sav/base_new_alt8.res +++ b/tests/sav/base_new_alt8.res @@ -1 +1,2 @@ +alt/base_new_alt8.nit:91,2--4: Error: ambiguous property name `defaultinit` for `Int`; conflict between core::Numeric::defaultinit and core::Discrete::defaultinit. alt/base_new_alt8.nit:91,2--8: Type Error: cannot instantiate enum `Int`. diff --git a/tests/sav/base_vararg_mult_alt1.res b/tests/sav/base_vararg_mult_alt1.res index 8189994..b9c7f9d 100644 --- a/tests/sav/base_vararg_mult_alt1.res +++ b/tests/sav/base_vararg_mult_alt1.res @@ -1,3 +1,3 @@ -alt/base_vararg_mult_alt1.nit:40,5--7: Error: expected at least 1 argument(s) for `init(ints: Int...)`; got 0. See introduction at `core::Object::init`. -alt/base_vararg_mult_alt1.nit:47,5--7: Error: expected 2 argument(s) for `init(ints: Int..., objs: Object...)`; got 3. See introduction at `core::Object::init`. +alt/base_vararg_mult_alt1.nit:40,5--7: Error: expected at least 1 argument(s) for `defaultinit(ints: Int...)`; got 0. See introduction at `base_vararg_mult_alt1::A::defaultinit`. +alt/base_vararg_mult_alt1.nit:47,5--7: Error: expected 2 argument(s) for `defaultinit(ints: Int..., objs: Object...)`; got 3. See introduction at `base_vararg_mult_alt1::B::defaultinit`. alt/base_vararg_mult_alt1.nit:48,11--18: Type Error: expected `Int`, got `Array[Int]`. Is an ellipsis `...` missing on the argument? diff --git a/tests/sav/error_class_glob.res b/tests/sav/error_class_glob.res index 0a541aa..5c09788 100644 --- a/tests/sav/error_class_glob.res +++ b/tests/sav/error_class_glob.res @@ -1,13 +1,2 @@ -../lib/core/kernel.nit:32,1--225,3: Error: `kernel$Object` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? -../lib/core/kernel.nit:227,1--300,3: Error: `kernel$Sys` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? -../lib/core/kernel.nit:313,1--371,3: Error: `kernel$Comparable` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? -../lib/core/kernel.nit:373,1--410,3: Error: `kernel$Discrete` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? -../lib/core/kernel.nit:412,1--429,3: Error: `kernel$Cloneable` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? -../lib/core/kernel.nit:431,1--486,3: Error: `kernel$Numeric` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? -../lib/core/kernel.nit:492,1--515,3: Error: `kernel$Bool` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? -../lib/core/kernel.nit:517,1--599,3: Error: `kernel$Float` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? -../lib/core/kernel.nit:601,1--700,3: Error: `kernel$Byte` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? -../lib/core/kernel.nit:702,1--886,3: Error: `kernel$Int` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? -../lib/core/kernel.nit:888,1--1067,3: Error: `kernel$Char` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? -../lib/core/kernel.nit:1069,1--1086,3: Error: `kernel$Pointer` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? -../lib/core/kernel.nit:1088,1--1097,3: Error: `kernel$Task` does not specialize `module_0$Object`. Possible duplication of the root class `Object`? +../lib/core/collection/hash_collection.nit:275,3--6: Possible duplication of the root class `Object` +../lib/core/collection/hash_collection.nit:473,3--6: Possible duplication of the root class `Object` diff --git a/tests/sav/error_defs_init_1alt1_alt2.res b/tests/sav/error_defs_init_1alt1_alt2.res index 85a7e8e..e69de29 100644 --- a/tests/sav/error_defs_init_1alt1_alt2.res +++ b/tests/sav/error_defs_init_1alt1_alt2.res @@ -1 +0,0 @@ -alt/error_defs_init_1alt1_alt2.nit:27,2--5: Error: a property `init` is already defined in class `A` at line 18. diff --git a/tests/sav/error_defs_init_1alt2_alt1.res b/tests/sav/error_defs_init_1alt2_alt1.res index d0f5aa7..e69de29 100644 --- a/tests/sav/error_defs_init_1alt2_alt1.res +++ b/tests/sav/error_defs_init_1alt2_alt1.res @@ -1 +0,0 @@ -alt/error_defs_init_1alt2_alt1.nit:26,2--5: Error: a property `init` is already defined in class `A` at line 18. diff --git a/tests/sav/error_defs_init_1alt2_alt2.res b/tests/sav/error_defs_init_1alt2_alt2.res index c9e3a71..b0df7ca 100644 --- a/tests/sav/error_defs_init_1alt2_alt2.res +++ b/tests/sav/error_defs_init_1alt2_alt2.res @@ -1 +1 @@ -alt/error_defs_init_1alt2_alt2.nit:27,2--5: Error: a property `init` is already defined in class `A` at line 18. +alt/error_defs_init_1alt2_alt2.nit:27,2--5: Error: a property `defaultinit` is already defined in class `A` at line 18. diff --git a/tests/sav/error_init_auto.res b/tests/sav/error_init_auto.res index a466472..b4fea22 100644 --- a/tests/sav/error_init_auto.res +++ b/tests/sav/error_init_auto.res @@ -1,4 +1,4 @@ -error_init_auto.nit:34,5--7: Error: expected 1 argument(s) for `init(x: Int)`; got 0. See introduction at `core::Object::init`. -error_init_auto.nit:36,5--7: Error: expected 1 argument(s) for `init(x: Int)`; got 2. See introduction at `core::Object::init`. -error_init_auto.nit:37,5--7: Error: expected 1 argument(s) for `init(x: Int)`; got 3. See introduction at `core::Object::init`. +error_init_auto.nit:34,5--7: Error: expected 1 argument(s) for `defaultinit(x: Int)`; got 0. See introduction at `error_init_auto::A::defaultinit`. +error_init_auto.nit:36,5--7: Error: expected 1 argument(s) for `defaultinit(x: Int)`; got 2. See introduction at `error_init_auto::A::defaultinit`. +error_init_auto.nit:37,5--7: Error: expected 1 argument(s) for `defaultinit(x: Int)`; got 3. See introduction at `error_init_auto::A::defaultinit`. error_init_auto.nit:38,11--13: Error: method `foo` does not exists in `A`. diff --git a/tests/sav/error_init_auto_alt1.res b/tests/sav/error_init_auto_alt1.res index 3356259..390923a 100644 --- a/tests/sav/error_init_auto_alt1.res +++ b/tests/sav/error_init_auto_alt1.res @@ -1,4 +1,4 @@ -alt/error_init_auto_alt1.nit:35,5--7: Error: expected 0 argument(s) for `init`; got 1. See introduction at `core::Object::init`. -alt/error_init_auto_alt1.nit:36,5--7: Error: expected 0 argument(s) for `init`; got 2. See introduction at `core::Object::init`. -alt/error_init_auto_alt1.nit:37,5--7: Error: expected 0 argument(s) for `init`; got 3. See introduction at `core::Object::init`. +alt/error_init_auto_alt1.nit:35,5--7: Error: expected 0 argument(s) for `defaultinit`; got 1. See introduction at `error_init_auto_alt1::A::defaultinit`. +alt/error_init_auto_alt1.nit:36,5--7: Error: expected 0 argument(s) for `defaultinit`; got 2. See introduction at `error_init_auto_alt1::A::defaultinit`. +alt/error_init_auto_alt1.nit:37,5--7: Error: expected 0 argument(s) for `defaultinit`; got 3. See introduction at `error_init_auto_alt1::A::defaultinit`. alt/error_init_auto_alt1.nit:38,11--13: Error: method `foo` does not exists in `A`. diff --git a/tests/sav/error_init_auto_alt2.res b/tests/sav/error_init_auto_alt2.res index 16c9ed4..d43fffd 100644 --- a/tests/sav/error_init_auto_alt2.res +++ b/tests/sav/error_init_auto_alt2.res @@ -1,4 +1,4 @@ -alt/error_init_auto_alt2.nit:34,5--7: Error: expected 2 argument(s) for `init(x, y: Int)`; got 0. See introduction at `core::Object::init`. -alt/error_init_auto_alt2.nit:35,5--7: Error: expected 2 argument(s) for `init(x, y: Int)`; got 1. See introduction at `core::Object::init`. -alt/error_init_auto_alt2.nit:37,5--7: Error: expected 2 argument(s) for `init(x, y: Int)`; got 3. See introduction at `core::Object::init`. +alt/error_init_auto_alt2.nit:34,5--7: Error: expected 2 argument(s) for `defaultinit(x, y: Int)`; got 0. See introduction at `error_init_auto_alt2::A::defaultinit`. +alt/error_init_auto_alt2.nit:35,5--7: Error: expected 2 argument(s) for `defaultinit(x, y: Int)`; got 1. See introduction at `error_init_auto_alt2::A::defaultinit`. +alt/error_init_auto_alt2.nit:37,5--7: Error: expected 2 argument(s) for `defaultinit(x, y: Int)`; got 3. See introduction at `error_init_auto_alt2::A::defaultinit`. alt/error_init_auto_alt2.nit:38,11--13: Error: method `foo` does not exists in `A`. diff --git a/tests/sav/error_init_auto_alt3.res b/tests/sav/error_init_auto_alt3.res index 61e44f6..8a30015 100644 --- a/tests/sav/error_init_auto_alt3.res +++ b/tests/sav/error_init_auto_alt3.res @@ -1,4 +1,4 @@ -alt/error_init_auto_alt3.nit:34,5--7: Error: expected 1 argument(s) for `init(xx: Int)`; got 0. See introduction at `error_init_auto_alt3::A::init`. -alt/error_init_auto_alt3.nit:36,5--7: Error: expected 1 argument(s) for `init(xx: Int)`; got 2. See introduction at `error_init_auto_alt3::A::init`. -alt/error_init_auto_alt3.nit:37,5--7: Error: expected 1 argument(s) for `init(xx: Int)`; got 3. See introduction at `error_init_auto_alt3::A::init`. +alt/error_init_auto_alt3.nit:34,5--7: Error: expected 1 argument(s) for `defaultinit(xx: Int)`; got 0. See introduction at `error_init_auto_alt3::A::defaultinit`. +alt/error_init_auto_alt3.nit:36,5--7: Error: expected 1 argument(s) for `defaultinit(xx: Int)`; got 2. See introduction at `error_init_auto_alt3::A::defaultinit`. +alt/error_init_auto_alt3.nit:37,5--7: Error: expected 1 argument(s) for `defaultinit(xx: Int)`; got 3. See introduction at `error_init_auto_alt3::A::defaultinit`. alt/error_init_auto_alt3.nit:38,11--13: Error: method `foo` does not exists in `A`. diff --git a/tests/sav/error_init_auto_alt4.res b/tests/sav/error_init_auto_alt4.res index 1e2a53a..8d39276 100644 --- a/tests/sav/error_init_auto_alt4.res +++ b/tests/sav/error_init_auto_alt4.res @@ -1,3 +1,3 @@ -alt/error_init_auto_alt4.nit:34,5--7: Error: expected 1 argument(s) for `init(x: Int)`; got 0. See introduction at `core::Object::init`. -alt/error_init_auto_alt4.nit:36,5--7: Error: expected 1 argument(s) for `init(x: Int)`; got 2. See introduction at `core::Object::init`. -alt/error_init_auto_alt4.nit:37,5--7: Error: expected 1 argument(s) for `init(x: Int)`; got 3. See introduction at `core::Object::init`. +alt/error_init_auto_alt4.nit:34,5--7: Error: expected 1 argument(s) for `defaultinit(x: Int)`; got 0. See introduction at `error_init_auto_alt4::A::defaultinit`. +alt/error_init_auto_alt4.nit:36,5--7: Error: expected 1 argument(s) for `defaultinit(x: Int)`; got 2. See introduction at `error_init_auto_alt4::A::defaultinit`. +alt/error_init_auto_alt4.nit:37,5--7: Error: expected 1 argument(s) for `defaultinit(x: Int)`; got 3. See introduction at `error_init_auto_alt4::A::defaultinit`. diff --git a/tests/sav/nitcatalog_args1.res b/tests/sav/nitcatalog_args1.res index 040f43c..6cca568 100644 --- a/tests/sav/nitcatalog_args1.res +++ b/tests/sav/nitcatalog_args1.res @@ -84,7 +84,7 @@

Quality

Tags

@@ -95,7 +95,7 @@ none

Contributors

diff --git a/tests/sav/nitdoc_args1.res b/tests/sav/nitdoc_args1.res index a7326d6..7fd3669 100644 --- a/tests/sav/nitdoc_args1.res +++ b/tests/sav/nitdoc_args1.res @@ -1,13 +1,13 @@ Parsing code... Generating documentation pages... Documentation produced in `out/nitdoc_args1.write` -Generated 22/22 pages +Generated 27/27 pages PageHome: 1 PageMPackage: 2 PageMGroup: 2 PageMModule: 2 PageMClass: 5 - PageMProperty: 10 + PageMProperty: 15 PagePerson: 0 PageTag: 0 class_module_95d0_58d_58dInt.html @@ -25,15 +25,20 @@ module_module_95d0_58d_58dmodule_95d0.html module_module_95d1_58d_58dmodule_95d1.html package_module_95d0.html package_module_95d1.html +property_module_95d0_58d_58dInt_58d_58ddefaultinit.html +property_module_95d0_58d_58dObject_58d_58ddefaultinit.html property_module_95d0_58d_58dObject_58d_58dinit.html property_module_95d0_58d_58dObject_58d_58doutput.html property_module_95d0_58d_58dObject_58d_58dprint.html +property_module_95d0_58d_58dSys_58d_58ddefaultinit.html property_module_95d0_58d_58dSys_58d_58dmain.html property_module_95d1_58d_58dA_58d_58da1.html property_module_95d1_58d_58dA_58d_58da12.html property_module_95d1_58d_58dA_58d_58da123.html property_module_95d1_58d_58dA_58d_58da13.html +property_module_95d1_58d_58dA_58d_58ddefaultinit.html property_module_95d1_58d_58dB_58d_58dall2.html property_module_95d1_58d_58dB_58d_58dall25.html +property_module_95d1_58d_58dB_58d_58ddefaultinit.html quicksearch-list.js vendors/ diff --git a/tests/sav/nitdoc_args2.res b/tests/sav/nitdoc_args2.res index 268190c..6d7fcc3 100644 --- a/tests/sav/nitdoc_args2.res +++ b/tests/sav/nitdoc_args2.res @@ -1,13 +1,13 @@ Parsing code... Generating documentation pages... Documentation produced in `out/nitdoc_args2.write` -Generated 28/28 pages +Generated 31/31 pages PageHome: 1 PageMPackage: 1 PageMGroup: 1 PageMModule: 1 PageMClass: 7 - PageMProperty: 17 + PageMProperty: 20 PagePerson: 0 PageTag: 0 class_base_attr_nullable_58d_58dBar.html @@ -26,19 +26,22 @@ module_base_attr_nullable_58d_58dbase_attr_nullable.html package_base_attr_nullable.html property_base_attr_nullable_58d_58dBar_58d_58da3.html property_base_attr_nullable_58d_58dBar_58d_58da3_61d.html +property_base_attr_nullable_58d_58dBar_58d_58ddefaultinit.html property_base_attr_nullable_58d_58dFoo_58d_58da1.html property_base_attr_nullable_58d_58dFoo_58d_58da1_61d.html property_base_attr_nullable_58d_58dFoo_58d_58da2.html property_base_attr_nullable_58d_58dFoo_58d_58da2_61d.html +property_base_attr_nullable_58d_58dFoo_58d_58ddefaultinit.html property_base_attr_nullable_58d_58dFoo_58d_58dnop.html property_base_attr_nullable_58d_58dFoo_58d_58drun.html property_base_attr_nullable_58d_58dFoo_58d_58drun_other.html property_base_attr_nullable_58d_58dInt_58d_58d_43d.html property_base_attr_nullable_58d_58dInt_58d_58doutput.html -property_base_attr_nullable_58d_58dInteger_58d_58dinit.html +property_base_attr_nullable_58d_58dInteger_58d_58ddefaultinit.html property_base_attr_nullable_58d_58dInteger_58d_58doutput.html property_base_attr_nullable_58d_58dInteger_58d_58dval.html property_base_attr_nullable_58d_58dInteger_58d_58dval_61d.html +property_base_attr_nullable_58d_58dObject_58d_58ddefaultinit.html property_base_attr_nullable_58d_58dObject_58d_58dinit.html property_base_attr_nullable_58d_58dSys_58d_58dmain.html quicksearch-list.js diff --git a/tests/sav/nitdoc_args3.res b/tests/sav/nitdoc_args3.res index 105d27c..c61e127 100644 --- a/tests/sav/nitdoc_args3.res +++ b/tests/sav/nitdoc_args3.res @@ -1,13 +1,13 @@ Parsing code... Generating documentation pages... Documentation produced in `out/nitdoc_args3.write` -Generated 28/28 pages +Generated 31/31 pages PageHome: 1 PageMPackage: 1 PageMGroup: 1 PageMModule: 1 PageMClass: 7 - PageMProperty: 17 + PageMProperty: 20 PagePerson: 0 PageTag: 0 class_base_attr_nullable_58d_58dBar.html @@ -26,19 +26,22 @@ module_base_attr_nullable_58d_58dbase_attr_nullable.html package_base_attr_nullable.html property_base_attr_nullable_58d_58dBar_58d_58da3.html property_base_attr_nullable_58d_58dBar_58d_58da3_61d.html +property_base_attr_nullable_58d_58dBar_58d_58ddefaultinit.html property_base_attr_nullable_58d_58dFoo_58d_58da1.html property_base_attr_nullable_58d_58dFoo_58d_58da1_61d.html property_base_attr_nullable_58d_58dFoo_58d_58da2.html property_base_attr_nullable_58d_58dFoo_58d_58da2_61d.html +property_base_attr_nullable_58d_58dFoo_58d_58ddefaultinit.html property_base_attr_nullable_58d_58dFoo_58d_58dnop.html property_base_attr_nullable_58d_58dFoo_58d_58drun.html property_base_attr_nullable_58d_58dFoo_58d_58drun_other.html property_base_attr_nullable_58d_58dInt_58d_58d_43d.html property_base_attr_nullable_58d_58dInt_58d_58doutput.html -property_base_attr_nullable_58d_58dInteger_58d_58dinit.html +property_base_attr_nullable_58d_58dInteger_58d_58ddefaultinit.html property_base_attr_nullable_58d_58dInteger_58d_58doutput.html property_base_attr_nullable_58d_58dInteger_58d_58dval.html property_base_attr_nullable_58d_58dInteger_58d_58dval_61d.html +property_base_attr_nullable_58d_58dObject_58d_58ddefaultinit.html property_base_attr_nullable_58d_58dObject_58d_58dinit.html property_base_attr_nullable_58d_58dSys_58d_58dmain.html quicksearch-list.js diff --git a/tests/sav/nitdoc_args4.res b/tests/sav/nitdoc_args4.res index 3be4a55..dfe20dd 100644 --- a/tests/sav/nitdoc_args4.res +++ b/tests/sav/nitdoc_args4.res @@ -1,11 +1,11 @@ Parsing code... Generating documentation pages... -Generated 111/111 pages +Generated 134/134 pages PageHome: 1 PageMPackage: 2 PageMGroup: 7 PageMModule: 10 PageMClass: 22 - PageMProperty: 61 + PageMProperty: 84 PagePerson: 6 PageTag: 2 diff --git a/tests/sav/nitlight_args1.res b/tests/sav/nitlight_args1.res index e7f3ab8..feb5de0 100644 --- a/tests/sav/nitlight_args1.res +++ b/tests/sav/nitlight_args1.res @@ -33,35 +33,31 @@ class B var val: Int - init(v: Int) - do - 7.output - self.val = v - end - fun run do val.output -end - -class C - var val1: Int - var val2: Int = 10 -end + init do 7.output + fun run do val.output +end + +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 - -var a = new A -a.run - -var b = new B(8) -b.run - -var c = new C(9) -c.val1.output -c.val2.output +1.output +foo +bar(3) +baz.output + +var a = new A +a.run + +var b = new B(8) +b.run + +var c = new C(9) +c.val1.output +c.val2.output \ No newline at end of file diff --git a/tests/sav/nitlight_args2.res b/tests/sav/nitlight_args2.res index 204c980..a4316b9 100644 --- a/tests/sav/nitlight_args2.res +++ b/tests/sav/nitlight_args2.res @@ -73,37 +73,33 @@ class B var val: Int - init(v: Int) - do - 7.output - self.val = v - end - fun run do val.output -end - -class C - var val1: Int - var val2: Int = 10 -end + init do 7.output + fun run do val.output +end + +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 - -var a = new A -a.run - -var b = new B(8) -b.run - -var c = new C(9) -c.val1.output -c.val2.output +1.output +foo +bar(3) +baz.output + +var a = new A +a.run + +var b = new B(8) +b.run + +var c = new C(9) +c.val1.output +c.val2.output \ No newline at end of file diff --git a/tests/sav/nitlight_args3.res b/tests/sav/nitlight_args3.res index f1c2d87..af3ce32 100644 --- a/tests/sav/nitlight_args3.res +++ b/tests/sav/nitlight_args3.res @@ -1,10 +1,10 @@ - 7.output - self.val = v - end - fun run do val.output -end - -class C - var val1: Int - var val2: Int = 10 - \ No newline at end of file +end + +class C + var val1: Int + var val2: Int = 10 +end + +fun foo do 2.output +fun bar(i: Int) do i.output + \ No newline at end of file diff --git a/tests/sav/nitlight_args4.res b/tests/sav/nitlight_args4.res index 8bb2bc8..6515ef7 100644 --- a/tests/sav/nitlight_args4.res +++ b/tests/sav/nitlight_args4.res @@ -33,11 +33,7 @@ end class B var val: Int - init(v: Int) - do - 7.output - self.val = v - end + init do 7.output fun run do val.output end diff --git a/tests/sav/nitlight_args5.res b/tests/sav/nitlight_args5.res index 90f6ed3..7b59e9a 100644 --- a/tests/sav/nitlight_args5.res +++ b/tests/sav/nitlight_args5.res @@ -73,37 +73,33 @@ class B var val: Int - init(v: Int) - do - 7.output - self.val = v - end - fun run do val.output -end - -class C - var val1: Int - var val2: Int = 10 -end + init do 7.output + fun run do val.output +end + +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 - -var a = new A -a.run - -var b = new B(8) -b.run - -var c = new C(9) -c.val1.output -c.val2.output +1.output +foo +bar(3) +baz.output + +var a = new A +a.run + +var b = new B(8) +b.run + +var c = new C(9) +c.val1.output +c.val2.output \ No newline at end of file diff --git a/tests/sav/nitmetrics_args1.res b/tests/sav/nitmetrics_args1.res index 139d036..29e31bd 100644 --- a/tests/sav/nitmetrics_args1.res +++ b/tests/sav/nitmetrics_args1.res @@ -1,74 +1,73 @@ *** METRICS *** --- AST Metrics --- ## All nodes of the AST - population: 52 + population: 49 minimum value: 1 - maximum value: 40 - total value: 304 - average value: 5.84 + maximum value: 37 + total value: 286 + average value: 5.83 distribution: - <=1: sub-population=16 (30.76%); cumulated value=16 (5.26%) - <=2: sub-population=5 (9.61%); cumulated value=10 (3.28%) - <=4: sub-population=9 (17.30%); cumulated value=28 (9.21%) - <=8: sub-population=12 (23.07%); cumulated value=76 (25.00%) - <=16: sub-population=5 (9.61%); cumulated value=59 (19.40%) - <=32: sub-population=4 (7.69%); cumulated value=75 (24.67%) - <=64: sub-population=1 (1.92%); cumulated value=40 (13.15%) + <=1: sub-population=15 (30.61%); cumulated value=15 (5.24%) + <=2: sub-population=3 (6.12%); cumulated value=6 (2.09%) + <=4: sub-population=12 (24.48%); cumulated value=40 (13.98%) + <=8: sub-population=10 (20.40%); cumulated value=67 (23.42%) + <=16: sub-population=4 (8.16%); cumulated value=48 (16.78%) + <=32: sub-population=4 (8.16%); cumulated value=73 (25.52%) + <=64: sub-population=1 (2.04%); cumulated value=37 (12.93%) list: - TId: 40 (13.15%) - APublicVisibility: 19 (6.25%) - AListExprs: 19 (6.25%) - AQid: 19 (6.25%) - ACallExpr: 18 (5.92%) - TClassid: 15 (4.93%) - AQclassid: 15 (4.93%) - TInteger: 10 (3.28%) - AIntegerExpr: 10 (3.28%) - AType: 9 (2.96%) + TId: 37 (12.93%) + APublicVisibility: 19 (6.64%) + ACallExpr: 18 (6.29%) + AQid: 18 (6.29%) + AListExprs: 18 (6.29%) + AQclassid: 14 (4.89%) + TClassid: 14 (4.89%) + TInteger: 10 (3.49%) + AIntegerExpr: 10 (3.49%) + ASignature: 8 (2.79%) ... - AAnnotation: 1 (0.32%) - AAnnotations: 1 (0.32%) - AReturnExpr: 1 (0.32%) - TKwreturn: 1 (0.32%) - AInterfaceClasskind: 1 (0.32%) - TKwinterface: 1 (0.32%) - ANoImport: 1 (0.32%) - AMainMethPropdef: 1 (0.32%) - AMainClassdef: 1 (0.32%) - TKwimport: 1 (0.32%) + TKwreturn: 1 (0.34%) + AAnnotation: 1 (0.34%) + AParam: 1 (0.34%) + AMainMethPropdef: 1 (0.34%) + AInterfaceClasskind: 1 (0.34%) + TKwinterface: 1 (0.34%) + ANoImport: 1 (0.34%) + ABlockExpr: 1 (0.34%) + AMainClassdef: 1 (0.34%) + TKwimport: 1 (0.34%) ## All identifiers of the AST - population: 20 + population: 19 minimum value: 1 maximum value: 11 - total value: 55 - average value: 2.75 + total value: 51 + average value: 2.68 distribution: - <=1: sub-population=3 (15.00%); cumulated value=3 (5.45%) - <=2: sub-population=12 (60.00%); cumulated value=24 (43.63%) - <=4: sub-population=3 (15.00%); cumulated value=10 (18.18%) - <=8: sub-population=1 (5.00%); cumulated value=7 (12.72%) - <=16: sub-population=1 (5.00%); cumulated value=11 (20.00%) + <=1: sub-population=3 (15.78%); cumulated value=3 (5.88%) + <=2: sub-population=12 (63.15%); cumulated value=24 (47.05%) + <=4: sub-population=2 (10.52%); cumulated value=7 (13.72%) + <=8: sub-population=1 (5.26%); cumulated value=6 (11.76%) + <=16: sub-population=1 (5.26%); cumulated value=11 (21.56%) list: - output: 11 (20.00%) - Int: 7 (12.72%) - run: 4 (7.27%) - c: 3 (5.45%) - val: 3 (5.45%) - i: 2 (3.63%) - bar: 2 (3.63%) - foo: 2 (3.63%) - val2: 2 (3.63%) - val1: 2 (3.63%) - C: 2 (3.63%) - v: 2 (3.63%) - baz: 2 (3.63%) - a: 2 (3.63%) - A: 2 (3.63%) - B: 2 (3.63%) - b: 2 (3.63%) - intern: 1 (1.81%) - Object: 1 (1.81%) - Bool: 1 (1.81%) + output: 11 (21.56%) + Int: 6 (11.76%) + run: 4 (7.84%) + c: 3 (5.88%) + baz: 2 (3.92%) + i: 2 (3.92%) + bar: 2 (3.92%) + val2: 2 (3.92%) + val1: 2 (3.92%) + C: 2 (3.92%) + val: 2 (3.92%) + B: 2 (3.92%) + a: 2 (3.92%) + A: 2 (3.92%) + foo: 2 (3.92%) + b: 2 (3.92%) + intern: 1 (1.96%) + Object: 1 (1.96%) + Bool: 1 (1.96%) --- Detection of variance constraints on formal parameter types --- -- Generic classes -- list: @@ -221,41 +220,41 @@ 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: 21 + Number of MAttribute: 3 (14.28%) + Number of MMethod: 18 (85.71%) -Number of property definitions: 20 -Number of redefined properties: 1 (5.55%) -Average number of property redefinitions by property: 0.11 +Number of property definitions: 23 +Number of redefined properties: 1 (4.76%) +Average number of property redefinitions by property: 0.09 Average number of property redefinitions by redefined property: 2.00 --- Explicit vs. Implicit Self --- -Total number of self: 5 -Total number of implicit self: 4 (80.00%) +Total number of self: 4 +Total number of implicit self: 4 (100.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): 31 (not including stuff like info for subtyping or call-next-method) +Average size of table by runtime class: 5.16 +Values never redefined: 25 (80.64%) generating package_hierarchy.dot generating module_hierarchy.dot --- Metrics of the explitic static types --- -Total number of explicit static types: 9 +Total number of explicit static types: 8 Statistics of type usage: population: 4 minimum value: 1 - maximum value: 6 - total value: 9 - average value: 2.25 + maximum value: 5 + total value: 8 + average value: 2.00 distribution: - <=1: sub-population=3 (75.00%); cumulated value=3 (33.33%) - <=8: sub-population=1 (25.00%); cumulated value=6 (66.66%) + <=1: sub-population=3 (75.00%); cumulated value=3 (37.50%) + <=8: sub-population=1 (25.00%); cumulated value=5 (62.50%) list: - Int: 6 (66.66%) - C: 1 (11.11%) - B: 1 (11.11%) - A: 1 (11.11%) + Int: 5 (62.50%) + C: 1 (12.50%) + B: 1 (12.50%) + A: 1 (12.50%) # MClasses metrics @@ -292,11 +291,11 @@ Statistics of type usage: 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: 4.0 + max: C (9) + min: Object (2) + std: 2.591 + sum: 33 cnba: number of accessible attributes (inherited + local) avg: 0.0 max: C (2) @@ -304,17 +303,17 @@ Statistics of type usage: std: 0.845 sum: 3 cnbi: number of accessible constructors (inherited + local) - avg: 1.0 - max: B (2) - min: Object (1) - std: 0.378 - sum: 8 + avg: 2.0 + max: A (3) + min: Object (2) + std: 0.655 + sum: 17 cnbm: number of accessible methods (inherited + local) - avg: 3.0 - max: B (5) - min: Object (1) - std: 1.773 - sum: 21 + avg: 4.0 + max: C (7) + min: Object (2) + std: 1.927 + sum: 30 cnbv: number of accessible virtual types (inherited + local) avg: 0.0 max: Object (0) @@ -322,11 +321,11 @@ Statistics of type usage: std: 0.0 sum: 0 cnbip: number of introduced properties - avg: 2.0 - max: C (6) + avg: 3.0 + max: C (7) min: Bool (0) std: 2.268 - sum: 18 + sum: 21 cnbrp: number of redefined properties avg: 0.0 max: A (1) @@ -334,11 +333,11 @@ Statistics of type usage: std: 0.535 sum: 2 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 @@ -372,11 +371,11 @@ Statistics of type usage: 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: 4.0 + max: C (9) + min: Object (2) + std: 2.591 + sum: 33 cnba: number of accessible attributes (inherited + local) avg: 0.0 max: C (2) @@ -384,17 +383,17 @@ Statistics of type usage: std: 0.845 sum: 3 cnbi: number of accessible constructors (inherited + local) - avg: 1.0 - max: B (2) - min: Object (1) - std: 0.378 - sum: 8 + avg: 2.0 + max: A (3) + min: Object (2) + std: 0.655 + sum: 17 cnbm: number of accessible methods (inherited + local) - avg: 3.0 - max: B (5) - min: Object (1) - std: 1.773 - sum: 21 + avg: 4.0 + max: C (7) + min: Object (2) + std: 1.927 + sum: 30 cnbv: number of accessible virtual types (inherited + local) avg: 0.0 max: Object (0) @@ -402,11 +401,11 @@ Statistics of type usage: std: 0.0 sum: 0 cnbip: number of introduced properties - avg: 2.0 - max: C (6) + avg: 3.0 + max: C (7) min: Bool (0) std: 2.268 - sum: 18 + sum: 21 cnbrp: number of redefined properties avg: 0.0 max: A (1) @@ -414,11 +413,11 @@ Statistics of type usage: std: 0.535 sum: 2 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 # MModules metrics @@ -738,27 +737,27 @@ Warning: no source file for `base_simple3` sum: 0.143 # Mendel metrics - large mclasses (threshold: 3.915) + large mclasses (threshold: 4.915) + B: 5 C: 5 - B: 4 - Sys: 4 - budding mclasses (threshold: 5.033) - blooming mclasses (threshold: 21.874) - C: 25.0 + budding mclasses (threshold: 3.231) + C: 3.5 + blooming mclasses (threshold: 15.285) + C: 17.5 --- Detection of the usage of covariance static type conformance --- -- Total -- - Kinds of the subtype - list: - primitive type: 6 (100.00%) - total: 6 + primitive type: 5 (100.00%) + total: 5 - Variance - list: - monomorph: 6 (100.00%) - total: 6 + monomorph: 5 (100.00%) + total: 5 - Classes of the subtype - list: - Int: 6 (100.00%) - total: 6 + Int: 5 (100.00%) + total: 5 -- On covariance only -- - Specific covariance case explanations - list: @@ -815,7 +814,7 @@ Warning: no source file for `base_simple3` cnbna: number of accessible nullable attributes (inherited + local) -- nothing sum: 0 --- Sends on Nullable Receiver --- -Total number of sends: 19 +Total number of sends: 18 Number of sends on a unsafe nullable receiver: 0 (0.00%) Number of sends on a safe nullable receiver: 0 (0.00%) Number of buggy sends (cannot determine the type of the receiver): 0 (0.00%) @@ -848,17 +847,17 @@ Number of buggy sends (cannot determine the type of the receiver): 0 (0.00%) 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: 18.0 + max: base_simple3 (18) + min: base_simple3 (18) + std: 0.0 + sum: 18 mnldd: number of dead method definitions in a mmodule avg: 0.0 max: base_simple3 (0) @@ -901,49 +900,49 @@ Number of buggy sends (cannot determine the type of the receiver): 0 (0.00%) sum: 0 ## Callsites -* 23 live callsites +* 21 live callsites MMethodDef locally designated (by number of CallSites) - population: 14 + population: 12 minimum value: 1 maximum value: 10 - total value: 23 - average value: 1.64 + total value: 21 + average value: 1.75 distribution: - <=1: sub-population=13 (92.85%); cumulated value=13 (56.52%) - <=16: sub-population=1 (7.14%); cumulated value=10 (43.47%) + <=1: sub-population=11 (91.66%); cumulated value=11 (52.38%) + <=16: sub-population=1 (8.33%); cumulated value=10 (47.61%) 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 (47.61%) + base_simple3$B$val: 1 (4.76%) + base_simple3$C$val2: 1 (4.76%) + base_simple3$C$val1: 1 (4.76%) + base_simple3$B$run: 1 (4.76%) ... - base_simple3$A$init: 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$A$defaultinit: 1 (4.76%) + base_simple3$Sys$baz: 1 (4.76%) + base_simple3$Sys$bar: 1 (4.76%) + base_simple3$Sys$foo: 1 (4.76%) + base_simple3$C$defaultinit: 1 (4.76%) MMethodDef possibly invoked at runtime (by number of CallSites) - population: 14 + population: 12 minimum value: 1 maximum value: 10 - total value: 23 - average value: 1.64 + total value: 21 + average value: 1.75 distribution: - <=1: sub-population=13 (92.85%); cumulated value=13 (56.52%) - <=16: sub-population=1 (7.14%); cumulated value=10 (43.47%) + <=1: sub-population=11 (91.66%); cumulated value=11 (52.38%) + <=16: sub-population=1 (8.33%); cumulated value=10 (47.61%) 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 (47.61%) + base_simple3$B$val: 1 (4.76%) + base_simple3$C$val2: 1 (4.76%) + base_simple3$C$val1: 1 (4.76%) + base_simple3$B$run: 1 (4.76%) ... - base_simple3$A$init: 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$A$defaultinit: 1 (4.76%) + base_simple3$Sys$baz: 1 (4.76%) + base_simple3$Sys$bar: 1 (4.76%) + base_simple3$Sys$foo: 1 (4.76%) + base_simple3$C$defaultinit: 1 (4.76%) class_hierarchy.dot classdef_hierarchy.dot inheritance/ diff --git a/tests/sav/nitsmells_args1.res b/tests/sav/nitsmells_args1.res index 6bf7b3d..251dd03 100644 --- a/tests/sav/nitsmells_args1.res +++ b/tests/sav/nitsmells_args1.res @@ -7,7 +7,7 @@ Long method: Average 1 lines -total_strengh has 2 lines -total_endurance has 2 lines -total_intelligence has 2 lines -Large class: 6 attributes and 18 methods (4.673A 6.923M Average) +Large class: 6 attributes and 18 methods (4.673A 6.858M Average) -------------------- Full name: test_prog$GameTest Location: test_prog/tests/test_game.nit:25,1--33,3 Feature envy: diff --git a/tests/sav/nitsmells_args3.res b/tests/sav/nitsmells_args3.res index 0ef08f3..972ccf1 100644 --- a/tests/sav/nitsmells_args3.res +++ b/tests/sav/nitsmells_args3.res @@ -2,4 +2,4 @@ --- Code Smells Metrics --- -------------------- Full name: TestNitsmells$LargeClass Location: TestNitsmells/LargeClass/largeclass.nit:20,1--55,3 -Large class: 18 attributes and 48 methods (17.515A 30.464M Average) +Large class: 18 attributes and 49 methods (17.515A 24.215M Average) diff --git a/tests/sav/nituml_args1.res b/tests/sav/nituml_args1.res index ecae7b8..8c7ce7d 100644 --- a/tests/sav/nituml_args1.res +++ b/tests/sav/nituml_args1.res @@ -13,10 +13,10 @@ digraph G { subgraph clusterbase_prot_sig2 { label = "base_prot_sig2" base_prot_sig2C [ - 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+ init()\l}"color="#58B26A" + 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+ init()\l+ defaultinit()\l}"color="#58B26A" ] base_prot_sig2D [ - 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+ init()\l}"color="#58B26A" + 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+ init()\l+ defaultinit()\l}"color="#58B26A" ] } } diff --git a/tests/sav/nituml_args2.res b/tests/sav/nituml_args2.res index 5a9488d..8fbab9b 100644 --- a/tests/sav/nituml_args2.res +++ b/tests/sav/nituml_args2.res @@ -13,7 +13,7 @@ digraph G { subgraph clusterbase_prot_sig2 { label = "base_prot_sig2" base_prot_sig2C [ - label = "{C||+ init()\l}"color="#58B26A" + label = "{C||+ init()\l+ defaultinit()\l}"color="#58B26A" ] } } diff --git a/tests/sav/nituml_args3.res b/tests/sav/nituml_args3.res index a5a027f..e30a297 100644 --- a/tests/sav/nituml_args3.res +++ b/tests/sav/nituml_args3.res @@ -12,31 +12,31 @@ 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+ defaultinit()\l}" ] Sys [ - label = "{Sys||+ main()\l+ run()\l+ errno(): Int\l+ exit(exit_value: Int)\l+ is_windows(): Bool\l}" + label = "{Sys||+ main()\l+ run()\l+ errno(): Int\l+ exit(exit_value: Int)\l+ is_windows(): Bool\l+ defaultinit()\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+ defaultinit()\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+ defaultinit()\l}" ] Comparable -> Discrete [dir=back arrowtail=open style=dashed]; Cloneable [ - label = "{interface\nCloneable||+ clone(): SELF\l}" + label = "{interface\nCloneable||+ clone(): SELF\l+ defaultinit()\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+ defaultinit()\l}" ] Comparable -> Numeric [dir=back arrowtail=open style=dashed]; @@ -68,32 +68,32 @@ Char [ Discrete -> Char [dir=back arrowtail=open style=dashed]; Pointer [ - label = "{Pointer||+ nul(): Pointer\l+ address_is_null(): Bool\l+ free()\l- native_equals(o: Pointer): Bool\l}" + label = "{Pointer||+ nul(): Pointer\l+ address_is_null(): Bool\l+ free()\l- native_equals(o: Pointer): Bool\l+ defaultinit()\l}" ] Object -> Pointer [dir=back arrowtail=open style=dashed]; Task [ - label = "{interface\nTask||+ main()\l}" + label = "{interface\nTask||+ main()\l+ defaultinit()\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+ defaultinit()\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+ defaultinit()\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+ defaultinit()\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+ defaultinit()\l}" ] Object -> D [dir=back arrowtail=open style=dashed]; diff --git a/tests/sav/nituml_args4.res b/tests/sav/nituml_args4.res index f03123a..3248f5a 100644 --- a/tests/sav/nituml_args4.res +++ b/tests/sav/nituml_args4.res @@ -12,31 +12,31 @@ 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+ defaultinit()\l}" ] Sys [ - label = "{Sys||+ main()\l+ run()\l+ errno(): Int\l+ exit(exit_value: Int)\l+ is_windows(): Bool\l}" + label = "{Sys||+ main()\l+ run()\l+ errno(): Int\l+ exit(exit_value: Int)\l+ is_windows(): Bool\l+ defaultinit()\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+ defaultinit()\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+ defaultinit()\l}" ] Comparable -> Discrete [dir=back arrowtail=open style=dashed]; Cloneable [ - label = "{interface\nCloneable||+ clone(): SELF\l}" + label = "{interface\nCloneable||+ clone(): SELF\l+ defaultinit()\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+ defaultinit()\l}" ] Comparable -> Numeric [dir=back arrowtail=open style=dashed]; @@ -68,22 +68,22 @@ Char [ Discrete -> Char [dir=back arrowtail=open style=dashed]; Pointer [ - label = "{Pointer||+ nul(): Pointer\l+ address_is_null(): Bool\l+ free()\l}" + label = "{Pointer||+ nul(): Pointer\l+ address_is_null(): Bool\l+ free()\l+ defaultinit()\l}" ] Object -> Pointer [dir=back arrowtail=open style=dashed]; Task [ - label = "{interface\nTask||+ main()\l}" + label = "{interface\nTask||+ main()\l+ defaultinit()\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+ defaultinit()\l}" ] Object -> A [dir=back arrowtail=open style=dashed]; C [ - label = "{C||}" + label = "{C||+ defaultinit()\l}" ] Object -> C [dir=back arrowtail=open style=dashed]; diff --git a/tests/sav/nitx_args2.res b/tests/sav/nitx_args2.res index 48c2f5f..36bf720 100644 --- a/tests/sav/nitx_args2.res +++ b/tests/sav/nitx_args2.res @@ -5,5 +5,5 @@ Documentation for `base_simple3::Sys::foo`: + base_simple3::Sys::foo fun foo - base_simple3.nit:49,1--19 + base_simple3.nit:45,1--19 diff --git a/tests/sav/nitx_args3.res b/tests/sav/nitx_args3.res index e191640..8c12ac9 100644 --- a/tests/sav/nitx_args3.res +++ b/tests/sav/nitx_args3.res @@ -7,7 +7,7 @@ Features for `base_simple3::base_simple3`: + base_simple3$B class B - base_simple3.nit:34,1--42,3 + base_simple3.nit:34,1--38,3 + base_simple3$Bool enum Bool @@ -15,7 +15,7 @@ Features for `base_simple3::base_simple3`: + base_simple3$C class C - base_simple3.nit:44,1--47,3 + base_simple3.nit:40,1--43,3 + base_simple3$Int enum Int @@ -27,5 +27,5 @@ Features for `base_simple3::base_simple3`: + base_simple3$Sys class Sys - base_simple3.nit:49,1--19 + base_simple3.nit:45,1--19 diff --git a/tests/sav/test_highlight_args1.res b/tests/sav/test_highlight_args1.res index c9cc4e2..43b741f 100644 --- a/tests/sav/test_highlight_args1.res +++ b/tests/sav/test_highlight_args1.res @@ -53,48 +53,44 @@
	var val: Int

base_simple3$B$val=

	var val: Int
-

base_simple3$B$init

-
	init(v: Int)
-	do
-		7.output
-		self.val = v
-	end
+

base_simple3$B$Object::init

+
	init do 7.output

base_simple3$B$run

-
	fun run do val.output
+
	fun run do val.output

base_simple3$C$_val1

-
	var val1: Int
+
	var val1: Int

base_simple3$C$val1

-
	var val1: Int
+
	var val1: Int

base_simple3$C$val1=

-
	var val1: Int
+
	var val1: Int

base_simple3$C$_val2

-
	var val2: Int = 10
+
	var val2: Int = 10

base_simple3$C$val2

-
	var val2: Int = 10
+
	var val2: Int = 10

base_simple3$C$val2=

-
	var val2: Int = 10
+
	var val2: Int = 10

base_simple3$Sys$foo

-
fun foo do 2.output
+
fun foo do 2.output

base_simple3$Sys$bar

-
fun bar(i: Int) do i.output
+
fun bar(i: Int) do i.output

base_simple3$Sys$baz

-
fun baz: Int do return 4
+
fun baz: Int do return 4

base_simple3$Sys$main

-
1.output
-foo
-bar(3)
-baz.output
-
-var a = new A
-a.run
-
-var b = new B(8)
-b.run
-
-var c = new C(9)
-c.val1.output
-c.val2.output
-

AST node: AModule at base_simple3.nit:17,1--66,13

+
1.output
+foo
+bar(3)
+baz.output
+
+var a = new A
+a.run
+
+var b = new B(8)
+b.run
+
+var c = new C(9)
+c.val1.output
+c.val2.output
+

AST node: AModule at base_simple3.nit:17,1--62,13

import end
 
 interface Object
@@ -114,37 +110,33 @@
 
 class B
 	var val: Int
-	init(v: Int)
-	do
-		7.output
-		self.val = v
-	end
-	fun run do val.output
-end
-
-class C
-	var val1: Int
-	var val2: Int = 10
-end
+	init do 7.output
+	fun run do val.output
+end
+
+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
-
-var a = new A
-a.run
-
-var b = new B(8)
-b.run
-
-var c = new C(9)
-c.val1.output
-c.val2.output
+1.output +foo +bar(3) +baz.output + +var a = new A +a.run + +var b = new B(8) +b.run + +var c = new C(9) +c.val1.output +c.val2.output

AST node: ANoImport at base_simple3.nit:17,1--10

import end

AST node: APublicVisibility at base_simple3.nit:17,1

@@ -184,4 +176,35 @@
 is

AST node: AAnnotation at base_simple3.nit:26,16--21

 intern
-

AST node: AIdAtid at bas***TRUNCATED*** +

AST node: AIdAtid at base_simple3.nit:26,16--21

+
 intern
+

AST node: AConcreteClasskind at base_simple3.nit:29,1--5

+
class
+

AST node: TKwclass at base_simple3.nit:29,1--5

+
class
+

AST node: TKwinit at base_simple3.nit:30,2--5

+
	init
+

AST node: TKwdo at base_simple3.nit:30,7--8

+
 do
+

AST node: ACallExpr at base_simple3.nit:30,10--17

+
 5.output
+

AST node: AIntegerExpr at base_simple3.nit:30,10

+
 5
+

AST node: TInteger at base_simple3.nit:30,10

+
 5
+

AST node: AQid at base_simple3.nit:30,12--17

+
output
+

AST node: AListExprs at base_simple3.nit:30,17

+
+

AST node: AAttrPropdef at base_simple3.nit:35,2--13

+
	var val: Int
+

AST node: TKwvar at base_simple3.nit:35,2--4

+
	var
+

AST node: AType at base_simple3.nit:35,11--13

+
 Int
+

AST node: AImplicitSelfExpr at base_simple3.nit:37,13

+
+

AST node: TAssign at base_simple3.nit:42,16

+
 =
+

AST node: ATopClassdef at base_simple3.nit:45,1--19

+
fun foo do 2.