From: Jean Privat Date: Fri, 10 Apr 2015 15:19:40 +0000 (+0700) Subject: Merge: Sys is top X-Git-Tag: v0.7.4~31 X-Git-Url: http://nitlanguage.org?hp=3bb4feedc794b56d23e5692a120df5864db93be5 Merge: Sys is top And when I say *top* I mean *great*. But I also mean *top* in fact. The idea is to move the top-level methods (those defined outside classes) from Object to Sys. While this is a cosmetic move, it has a lot of benefits: * top-level methods get a real meaningful receiver: the current system. It is meaningful both on the declaration side and the call side. * no more need to distinguish the concept of top-level methods with their rules and semantic, so this simplify the language with one less thing (almost, see bellow) * self is now usable in top-level methods, not that useful now because it is `sys`, a singleton, but this allow some kind of inheritance if you add super-classes to Sys. * no more name conflicts between a standard class method and a top-level method * no more useless slots in table of classes for crazy methods defined in Object and never redefined * close #461 and close #1081 by making them irrelevant * Let us see a bright future where the singleton Sys become a multiton and allow specific isolation of computation. Specific Sys will then be active objects (threads, computation node, actors, whatever) isolated with their own specific cloud of objects and efficient lock-less concurrency, dedicated memory model (realtime?), and why not transparent distribution There is still two drawbacks * what is the status of `sys` that represent the current `Sys`? I hard-coded it to stay a method in Object. One way to solve the probem is to make it a keyword (like `self`) * when doing `foo(x)`, first this tries `self.foo(x)` then `sys.foo(x)` thus this is some additional rule of the language. Pull-Request: #1249 Reviewed-by: Alexis Laferrière Reviewed-by: Alexandre Terrasa Reviewed-by: Lucas Bajolet --- diff --git a/contrib/pep8analysis/src/backbone.nit b/contrib/pep8analysis/src/backbone.nit index d731e41..251f920 100644 --- a/contrib/pep8analysis/src/backbone.nit +++ b/contrib/pep8analysis/src/backbone.nit @@ -98,4 +98,4 @@ redef class Location end end -protected fun manager: AnalysisManager do return once new AnalysisManager +fun manager: AnalysisManager do return once new AnalysisManager diff --git a/lib/android/intent/intent_api10.nit b/lib/android/intent/intent_api10.nit index 8d84981..d2aa796 100644 --- a/lib/android/intent/intent_api10.nit +++ b/lib/android/intent/intent_api10.nit @@ -1334,11 +1334,11 @@ redef extern class NativeActivity end # Allows user to get values with enum-like syntax : `intent_action.main` -protected fun intent_action: Action do return once new Action +fun intent_action: Action do return once new Action # Allows user to get values with enum-like syntax : `intent_category.home` -protected fun intent_category: Category do return once new Category +fun intent_category: Category do return once new Category # Allows user to get values with enum-like syntax : `intent_flag.activity_brought_to_front` -protected fun intent_flag: Flag do return once new Flag +fun intent_flag: Flag do return once new Flag private class StringCopyArray var collection = new Array[String] diff --git a/lib/android/log.nit b/lib/android/log.nit index c165331..6b0faea 100644 --- a/lib/android/log.nit +++ b/lib/android/log.nit @@ -24,30 +24,30 @@ in "C" `{ `} # Default Android log priority -protected fun priority_default: Int do return 1 +fun priority_default: Int do return 1 # Verbose Android log priority -protected fun priority_verbose: Int do return 2 +fun priority_verbose: Int do return 2 # Debug Android log priority -protected fun priority_debug: Int do return 3 +fun priority_debug: Int do return 3 # Info Android log priority -protected fun priority_info: Int do return 4 +fun priority_info: Int do return 4 # Warn Android log priority -protected fun priority_warn: Int do return 5 +fun priority_warn: Int do return 5 # Error Android log priority -protected fun priority_error: Int do return 6 +fun priority_error: Int do return 6 # Fatal Android log priority -protected fun priority_fatal: Int do return 7 +fun priority_fatal: Int do return 7 # Silent Android log priority -protected fun priority_silent: Int do return 8 +fun priority_silent: Int do return 8 # Write `text` to Android log at priority `level` with tag `tag` -protected fun log_write(level: Int, tag, text: NativeString) `{ +fun log_write(level: Int, tag, text: NativeString) `{ __android_log_write(level, tag, text); `} diff --git a/lib/app/app_base.nit b/lib/app/app_base.nit index f892033..2a335c4 100644 --- a/lib/app/app_base.nit +++ b/lib/app/app_base.nit @@ -52,6 +52,6 @@ class App fun window_closing do end end -protected fun app: App do return once new App +fun app: App do return once new App app.setup app.run diff --git a/lib/egl.nit b/lib/egl.nit index b664c8a..d062cfc 100644 --- a/lib/egl.nit +++ b/lib/egl.nit @@ -452,6 +452,6 @@ redef class Object end end -protected fun egl_bind_opengl_api: Bool `{ return eglBindAPI(EGL_OPENGL_API); `} -protected fun egl_bind_opengl_es_api: Bool `{ return eglBindAPI(EGL_OPENGL_ES_API); `} -protected fun egl_bind_openvg_api: Bool `{ return eglBindAPI(EGL_OPENVG_API); `} +fun egl_bind_opengl_api: Bool `{ return eglBindAPI(EGL_OPENGL_API); `} +fun egl_bind_opengl_es_api: Bool `{ return eglBindAPI(EGL_OPENGL_ES_API); `} +fun egl_bind_openvg_api: Bool `{ return eglBindAPI(EGL_OPENVG_API); `} diff --git a/lib/glesv2/glesv2.nit b/lib/glesv2/glesv2.nit index de2babc..5b05f8b 100644 --- a/lib/glesv2/glesv2.nit +++ b/lib/glesv2/glesv2.nit @@ -366,7 +366,7 @@ extern class GLError end end -protected fun assert_no_gl_error +fun assert_no_gl_error do var error = gl.error if not error.is_ok then diff --git a/lib/md5.nit b/lib/md5.nit index f0b028e..85828aa 100644 --- a/lib/md5.nit +++ b/lib/md5.nit @@ -492,7 +492,7 @@ in "C Header" `{ redef class String # returns the md5 digest of the receiver string # algorithm implemented by L. Peter Deutsch - fun md5: String import String.to_cstring, NativeString.to_s, String.print `{ + fun md5: String import String.to_cstring, NativeString.to_s `{ md5_state_t state; md5_byte_t digest[16]; /* result */ char *hex_output = malloc(33*sizeof(char)); diff --git a/lib/signals.nit b/lib/signals.nit index f9709da..58482a8 100644 --- a/lib/signals.nit +++ b/lib/signals.nit @@ -244,82 +244,82 @@ redef class Process end # Hang up detected on controlling terminal or death of controlling process -protected fun sighup: Int do return 1 +fun sighup: Int do return 1 # Issued if the user sends an interrupt signal -protected fun sigint: Int do return 2 +fun sigint: Int do return 2 # Issued if the user sends a quit signal -protected fun sigquit: Int do return 3 +fun sigquit: Int do return 3 # Issued if the user attempts to execute an illegal, malformed, unknown, or privileged instruction -protected fun sigill: Int do return 4 +fun sigill: Int do return 4 # Issued when an exception occurs: a condition that a debugger has requested to be informed of -protected fun sigtrap: Int do return 5 +fun sigtrap: Int do return 5 # This signal is sent to a process to tell it to abort, i. e. to terminate -protected fun sigabrt: Int do return 6 +fun sigabrt: Int do return 6 # This signal is sent to a process when it causes a bus error -protected fun sigbus: Int do return 7 +fun sigbus: Int do return 7 # Issued if an illegal mathematical operation is attempted -protected fun sigfpe: Int do return 8 +fun sigfpe: Int do return 8 # If a process gets this signal it must quit immediately and will not perform any clean-up operations -protected fun sigkill: Int do return 9 +fun sigkill: Int do return 9 # Sent to a process to indicate user-defined conditions -protected fun sigusr1: Int do return 10 +fun sigusr1: Int do return 10 # Sent to a process when it makes an invalid virtual memory reference, or segmentation fault -protected fun sigsegv: Int do return 11 +fun sigsegv: Int do return 11 # Sent to a process to indicate user-defined conditions -protected fun sigusr2: Int do return 12 +fun sigusr2: Int do return 12 # Sent to a process when it attempts to write to a pipe without a process connected to the other end -protected fun sigpipe: Int do return 13 +fun sigpipe: Int do return 13 # Alarm Clock signal -protected fun sigalarm: Int do return 14 +fun sigalarm: Int do return 14 # Software termination signal -protected fun sigterm: Int do return 15 +fun sigterm: Int do return 15 # Sent to a process when a child process terminates or is interrupted -protected fun sigchild: Int do return 17 +fun sigchild: Int do return 17 # Tell the operating system to continue (restart) a process previously paused by the SIGSTOP or SIGTSTP signal -protected fun sigcont: Int do return 18 +fun sigcont: Int do return 18 # Tell the operating system to stop a process -protected fun sigstop: Int do return 19 +fun sigstop: Int do return 19 # Sent to a process by its terminal to request it to stop temporarily -protected fun sigtstp: Int do return 20 +fun sigtstp: Int do return 20 # Sent to a process when a socket has urgent or out-of-band data available to read -protected fun sigurg: Int do return 23 +fun sigurg: Int do return 23 # Sent to a process when it has used the CPU for a duration that exceeds a user-settable value -protected fun sigxcpu: Int do return 24 +fun sigxcpu: Int do return 24 # Sent to a process when it grows a file larger than the maximum allowed size -protected fun sigxfsz: Int do return 25 +fun sigxfsz: Int do return 25 # Virtual timer expired -protected fun sigvtalrm: Int do return 26 +fun sigvtalrm: Int do return 26 # Profiling timer expired -protected fun sigprof: Int do return 27 +fun sigprof: Int do return 27 # Sent to a process when its controlling terminal changes its window size -protected fun sigwinch: Int do return 28 +fun sigwinch: Int do return 28 # Sent to a process when the system experiences a power failure -protected fun sigpwr: Int do return 30 +fun sigpwr: Int do return 30 # Sent to a process when it passes a bad argument to a system call -protected fun sigsys: Int do return 31 +fun sigsys: Int do return 31 diff --git a/src/compiler/abstract_compiler.nit b/src/compiler/abstract_compiler.nit index 3956744..059961f 100644 --- a/src/compiler/abstract_compiler.nit +++ b/src/compiler/abstract_compiler.nit @@ -2521,6 +2521,13 @@ redef class ASelfExpr redef fun expr(v) do return v.frame.arguments.first end +redef class AImplicitSelfExpr + redef fun expr(v) do + if not is_sys then return super + return v.new_expr("glob_sys", mtype.as(not null)) + end +end + redef class AEscapeExpr redef fun stmt(v) do v.add("goto BREAK_{v.escapemark_name(self.escapemark)};") end diff --git a/src/compiler/global_compiler.nit b/src/compiler/global_compiler.nit index 1aff84e..ede1beb 100644 --- a/src/compiler/global_compiler.nit +++ b/src/compiler/global_compiler.nit @@ -528,11 +528,6 @@ class GlobalCompilerVisitor private fun get_recvtype(m: MMethodDef, recvtype: MClassType, args: Array[RuntimeVariable]): MClassType do check_valid_reciever(recvtype) - #debug("call {m} on {recvtype} on {args.first}:{args.first.mtype}") - if m.mproperty.is_toplevel then - # Do not customize top-level methods - recvtype = m.mclassdef.bound_mtype - end return recvtype end diff --git a/src/interpreter/naive_interpreter.nit b/src/interpreter/naive_interpreter.nit index c847b5f..4cab2e5 100644 --- a/src/interpreter/naive_interpreter.nit +++ b/src/interpreter/naive_interpreter.nit @@ -1323,6 +1323,14 @@ redef class ASelfExpr end end +redef class AImplicitSelfExpr + redef fun expr(v) + do + if not is_sys then return super + return v.mainobj + end +end + redef class AEscapeExpr redef fun stmt(v) do diff --git a/src/mixin.nit b/src/mixin.nit index 94d0c32..1ee4109 100644 --- a/src/mixin.nit +++ b/src/mixin.nit @@ -52,7 +52,8 @@ redef class ToolContext mainmodule.is_fictive = true end - var recv = mainmodule.object_type + var recv = mainmodule.sys_type + assert recv != null var mclassdef = new MClassDef(mainmodule, recv, location) mclassdef.add_in_hierarchy diff --git a/src/modelize/modelize_class.nit b/src/modelize/modelize_class.nit index 5618c11..ae4e4c2 100644 --- a/src/modelize/modelize_class.nit +++ b/src/modelize/modelize_class.nit @@ -75,20 +75,21 @@ redef class ModelBuilder names.add(ptname) end - else if nclassdef isa ATopClassdef then + else if nclassdef isa ATopClassdef and nclassdef.n_propdefs.first.as(AMethPropdef).n_methid.collect_text == "sys" then + # Special case to keep `sys` in object. + # Needed to keep working bootstrap and a working java FFI together. + # TODO: remove once safe to remove name = "Object" nkind = null mkind = interface_kind nvisibility = null mvisibility = public_visibility - else if nclassdef isa AMainClassdef then + else name = "Sys" nkind = null mkind = concrete_kind nvisibility = null mvisibility = public_visibility - else - abort end var mclass = try_get_mclass_by_name(nclassdef, mmodule, name) @@ -311,7 +312,13 @@ redef class ModelBuilder if errcount != toolcontext.error_count then return # Create all classes + # process AStdClassdef before so that non-AStdClassdef classes can be attached to existing ones, if any + for nclassdef in nmodule.n_classdefs do + if not nclassdef isa AStdClassdef then continue + self.build_a_mclass(nmodule, nclassdef) + end for nclassdef in nmodule.n_classdefs do + if nclassdef isa AStdClassdef then continue self.build_a_mclass(nmodule, nclassdef) end @@ -319,6 +326,11 @@ redef class ModelBuilder # Create all classdefs for nclassdef in nmodule.n_classdefs do + if not nclassdef isa AStdClassdef then continue + self.build_a_mclassdef(nmodule, nclassdef) + end + for nclassdef in nmodule.n_classdefs do + if nclassdef isa AStdClassdef then continue self.build_a_mclassdef(nmodule, nclassdef) end diff --git a/src/modelize/modelize_property.nit b/src/modelize/modelize_property.nit index c224b29..d4a5654 100644 --- a/src/modelize/modelize_property.nit +++ b/src/modelize/modelize_property.nit @@ -622,15 +622,6 @@ redef class APropdef modelbuilder.error(self, "Error: A property {mprop} is already defined in class {mclassdef.mclass} at line {mclassdef.mprop2npropdef[mprop].location.line_start}.") return false end - if mprop isa MMethod and mprop.is_toplevel != (parent isa ATopClassdef) then - if mprop.is_toplevel then - modelbuilder.error(self, "Error: {mprop} is a top level method.") - else - modelbuilder.error(self, "Error: {mprop} is not a top level method.") - end - return false - - end if mprop isa MMethod and mprop.is_root_init then return true if kwredef == null then if need_redef then @@ -824,7 +815,7 @@ redef class AMethPropdef mprop.is_init = is_init mprop.is_new = n_kwnew != null if mprop.is_new then mclassdef.mclass.has_new_factory = true - if parent isa ATopClassdef then mprop.is_toplevel = true + if name == "sys" then mprop.is_toplevel = true # special case for sys allowed in `new` factories self.check_redef_keyword(modelbuilder, mclassdef, n_kwredef, false, mprop) else if not self.check_redef_keyword(modelbuilder, mclassdef, n_kwredef, not self isa AMainMethPropdef, mprop) then return diff --git a/src/semantize/typing.nit b/src/semantize/typing.nit index cf8bbda..e51269f 100644 --- a/src/semantize/typing.nit +++ b/src/semantize/typing.nit @@ -52,6 +52,7 @@ private class TypeVisitor # Is `self` use restricted? # * no explicit `self` # * method called on the implicit self must be top-level + # Currently only used for `new` factory since there is no valid receiver inside var is_toplevel_context = false init @@ -71,7 +72,7 @@ private class TypeVisitor selfvariable.declared_type = mclass.mclass_type var mprop = mpropdef.mproperty - if mprop isa MMethod and (mprop.is_toplevel or mprop.is_new) then + if mprop isa MMethod and mprop.is_new then is_toplevel_context = true end end @@ -1460,6 +1461,15 @@ redef class ASelfExpr end end +redef class AImplicitSelfExpr + # Is the implicit receiver `sys`? + # + # By default, the implicit receiver is `self`. + # But when there is not method for `self`, `sys` is used as a fall-back. + # Is this case this flag is set to `true`. + var is_sys = false +end + ## MESSAGE SENDING AND PROPERTY redef class ASendExpr @@ -1468,13 +1478,38 @@ redef class ASendExpr redef fun accept_typing(v) do - var recvtype = v.visit_expr(self.n_expr) + var nrecv = self.n_expr + var recvtype = v.visit_expr(nrecv) var name = self.property_name if recvtype == null then return # Forward error - var callsite = v.get_method(self, recvtype, name, self.n_expr isa ASelfExpr) - if callsite == null then return + var callsite = null + var unsafe_type = v.anchor_to(recvtype) + var mproperty = v.try_get_mproperty_by_name2(self, unsafe_type, name) + if mproperty == null and nrecv isa AImplicitSelfExpr then + # Special fall-back search in `sys` when noting found in the implicit receiver. + var sysclass = v.try_get_mclass(self, "Sys") + if sysclass != null then + var systype = sysclass.mclass_type + mproperty = v.try_get_mproperty_by_name2(self, systype, name) + if mproperty != null then + callsite = v.get_method(self, systype, name, false) + if callsite == null then return # Forward error + # Update information, we are looking at `sys` now, not `self` + nrecv.is_sys = true + nrecv.its_variable = null + nrecv.mtype = systype + recvtype = systype + end + end + end + if callsite == null then + # If still nothing, just exit + callsite = v.get_method(self, recvtype, name, nrecv isa ASelfExpr) + if callsite == null then return + end + self.callsite = callsite var msignature = callsite.msignature diff --git a/tests/error_toplevel.nit b/tests/error_toplevel.nit index c33bcb0..797261c 100644 --- a/tests/error_toplevel.nit +++ b/tests/error_toplevel.nit @@ -45,5 +45,9 @@ do o.output end +redef class Sys + redef fun output do 'S'.output +end + 0.foo1 foo2 diff --git a/tests/sav/error_defs2_alt1.res b/tests/sav/error_defs2_alt1.res index c79fb13..00c3748 100644 --- a/tests/sav/error_defs2_alt1.res +++ b/tests/sav/error_defs2_alt1.res @@ -1 +1,3 @@ -alt/error_defs2_alt1.nit:20,11--13: Error: bar is not a top level method. +4 +40 +124 diff --git a/tests/sav/error_defs2_alt2.res b/tests/sav/error_defs2_alt2.res index 8b01fd5..496828c 100644 --- a/tests/sav/error_defs2_alt2.res +++ b/tests/sav/error_defs2_alt2.res @@ -1 +1 @@ -alt/error_defs2_alt2.nit:21,11--13: Error: No property Object::foo is inherited. Remove the redef keyword to define a new property. +alt/error_defs2_alt2.nit:21,11--13: Error: No property Sys::foo is inherited. Remove the redef keyword to define a new property. diff --git a/tests/sav/error_defs_alt4.res b/tests/sav/error_defs_alt4.res index 80e2677..70d33d8 100644 --- a/tests/sav/error_defs_alt4.res +++ b/tests/sav/error_defs_alt4.res @@ -1 +1,2 @@ -alt/error_defs_alt4.nit:29,5--7: Error: baz is a top level method. +alt/error_defs_alt4.nit:27,36--38: Error: Incorrect number of parameters. Got 0, expected 1. Signature is (c: Char) +alt/error_defs_alt4.nit:27,36--38: Type error: expected expression. diff --git a/tests/sav/error_defs_alt5.res b/tests/sav/error_defs_alt5.res index fec299a..39b0cbd 100644 --- a/tests/sav/error_defs_alt5.res +++ b/tests/sav/error_defs_alt5.res @@ -1 +1 @@ -alt/error_defs_alt5.nit:30,11--13: Error: baz is a top level method. +alt/error_defs_alt5.nit:30,11--13: Error: No property A::baz is inherited. Remove the redef keyword to define a new property. diff --git a/tests/sav/error_defs_alt9.res b/tests/sav/error_defs_alt9.res index 8c547a1..eed537b 100644 --- a/tests/sav/error_defs_alt9.res +++ b/tests/sav/error_defs_alt9.res @@ -1 +1 @@ -alt/error_defs_alt9.nit:46,5--7: Error: A property baz is already defined in class Object at line 45. +alt/error_defs_alt9.nit:46,5--7: Error: A property baz is already defined in class Sys at line 45. diff --git a/tests/sav/error_expr_not_ok_alt4.res b/tests/sav/error_expr_not_ok_alt4.res index d22055c..62c634d 100644 --- a/tests/sav/error_expr_not_ok_alt4.res +++ b/tests/sav/error_expr_not_ok_alt4.res @@ -10,8 +10,7 @@ alt/error_expr_not_ok_alt4.nit:43,1--8: Error: Method 'fail' doesn't exists in I alt/error_expr_not_ok_alt4.nit:45,7--10: Type error: expected A, got Object alt/error_expr_not_ok_alt4.nit:46,1--9: Error: Method 'fail' doesn't exists in Object. alt/error_expr_not_ok_alt4.nit:49,7--10: Type error: expected A, got Object -alt/error_expr_not_ok_alt4.nit:50,1--10: Error: cannot call 'trash', a top-level method, with a receiver. -alt/error_expr_not_ok_alt4.nit:50,1--10: Error: Incorrect number of parameters. Got 0, expected 1. Signature is (x: A) +alt/error_expr_not_ok_alt4.nit:50,1--10: Error: Method 'trash' doesn't exists in Object. alt/error_expr_not_ok_alt4.nit:60,4--7: Type error: expected Bool, got Int alt/error_expr_not_ok_alt4.nit:60,20: Type error: expected A, got Int alt/error_expr_not_ok_alt4.nit:62,10--13: Type error: expected Bool, got Int diff --git a/tests/sav/error_toplevel_alt1.res b/tests/sav/error_toplevel_alt1.res index b18282f..5f067c0 100644 --- a/tests/sav/error_toplevel_alt1.res +++ b/tests/sav/error_toplevel_alt1.res @@ -1 +1 @@ -alt/error_toplevel_alt1.nit:25,3--10: Error: cannot call 'bar', a top-level method, with a receiver. +alt/error_toplevel_alt1.nit:25,3--10: Error: Method 'bar' doesn't exists in Int. diff --git a/tests/sav/error_toplevel_alt2.res b/tests/sav/error_toplevel_alt2.res index 8b3cf76..e7a0d8b 100644 --- a/tests/sav/error_toplevel_alt2.res +++ b/tests/sav/error_toplevel_alt2.res @@ -1 +1,7 @@ -alt/error_toplevel_alt2.nit:35,2--5: Error: self cannot be used in top-level method. +1 +0 +5 +0 +10 +20 +50 diff --git a/tests/sav/error_toplevel_alt3.res b/tests/sav/error_toplevel_alt3.res index acfd7bf..d61c3b2 100644 --- a/tests/sav/error_toplevel_alt3.res +++ b/tests/sav/error_toplevel_alt3.res @@ -1 +1,6 @@ -alt/error_toplevel_alt3.nit:36,6--9: Error: self cannot be used in top-level method. +1 +0 +5 +0 +10 +S50 diff --git a/tests/sav/error_toplevel_alt4.res b/tests/sav/error_toplevel_alt4.res index c1a37ee..af5d48f 100644 --- a/tests/sav/error_toplevel_alt4.res +++ b/tests/sav/error_toplevel_alt4.res @@ -1 +1 @@ -alt/error_toplevel_alt4.nit:37,2--10: Error: cannot call 'bar', a top-level method, with a receiver. +alt/error_toplevel_alt4.nit:37,2--10: Error: Method 'bar' doesn't exists in Int. diff --git a/tests/sav/error_toplevel_alt5.res b/tests/sav/error_toplevel_alt5.res index dff56d2..4528c41 100644 --- a/tests/sav/error_toplevel_alt5.res +++ b/tests/sav/error_toplevel_alt5.res @@ -1 +1,7 @@ -alt/error_toplevel_alt5.nit:40,2--4: Error: 'baz' is not a top-level method, thus need a receiver. +1 +0 +5 +0 +10 +50 +S \ No newline at end of file diff --git a/tests/sav/nitg-g/fixme/test_deriving_alt1.res b/tests/sav/nitg-g/fixme/test_deriving_alt1.res deleted file mode 100644 index 7457500..0000000 --- a/tests/sav/nitg-g/fixme/test_deriving_alt1.res +++ /dev/null @@ -1,15 +0,0 @@ - s: > -i=5 s=Hello - - -true -true -true - - s: a: s: >> -i=100 s=World a= - - -true -true -true diff --git a/tests/sav/nitlight_args1.res b/tests/sav/nitlight_args1.res index 8b7dbb3..570c986 100644 --- a/tests/sav/nitlight_args1.res +++ b/tests/sav/nitlight_args1.res @@ -46,9 +46,9 @@ 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 diff --git a/tests/sav/nitmetrics_args1.res b/tests/sav/nitmetrics_args1.res index 139f52b..9bd4a19 100644 --- a/tests/sav/nitmetrics_args1.res +++ b/tests/sav/nitmetrics_args1.res @@ -162,11 +162,11 @@ std: 0.926 sum: 6 cnbp: number of accessible properties (inherited + local) - avg: 6.0 - max: C (10) - min: Object (4) - std: 2.268 - sum: 42 + avg: 3.0 + max: C (7) + min: Object (1) + std: 2.36 + sum: 24 cnba: number of accessible attributes (inherited + local) avg: 0.0 max: C (2) @@ -186,11 +186,11 @@ std: 0.535 sum: 2 cnbhp: number of inherited properties - avg: 3.0 - max: Bool (4) + avg: 0.0 + max: Bool (1) min: Object (0) - std: 1.464 - sum: 24 + std: 0.926 + sum: 6 ## global metrics cnoa: number of ancestor classes @@ -224,11 +224,11 @@ std: 0.926 sum: 6 cnbp: number of accessible properties (inherited + local) - avg: 6.0 - max: C (10) - min: Object (4) - std: 2.268 - sum: 42 + avg: 3.0 + max: C (7) + min: Object (1) + std: 2.36 + sum: 24 cnba: number of accessible attributes (inherited + local) avg: 0.0 max: C (2) @@ -248,11 +248,41 @@ std: 0.535 sum: 2 cnbhp: number of inherited properties - avg: 3.0 - max: Bool (4) + avg: 0.0 + max: Bool (1) min: Object (0) - std: 1.464 - sum: 24 + std: 0.926 + sum: 6 +--- Metrics of refinement usage --- +Number of modules: 1 + +Number of classes: 7 + Number of interface kind: 1 (14.28%) + Number of enum kind: 2 (28.57%) + Number of class kind: 4 (57.14%) + +Number of class definitions: 7 +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 property definitions: 20 +Number of redefined properties: 1 (5.55%) +Average number of property redefinitions by property: 0.11 +Average number of property redefinitions by redefined property: 2.00 +--- Explicit vs. Implicit Self --- +Total number of self: 5 +Total number of implicit self: 4 (80.00%) +--- Construction of tables --- +Number of runtime classes: 6 (excluding interfaces and abstract classes) +Average number of composing class definition by runtime class: 2.00 +Total size of tables (classes and instances): 23 (not including stuff like info for subtyping or call-next-method) +Average size of table by runtime class: 3.83 +Values never redefined: 17 (73.91%) --- Poset metrics --- ## Module importation hierarchy Number of nodes: 1 @@ -458,36 +488,6 @@ Distribution of direct smallers bivariants: 0 (na%) invariants: 0 (na%) total: 0 ---- Metrics of refinement usage --- -Number of modules: 1 - -Number of classes: 7 - Number of interface kind: 1 (14.28%) - Number of enum kind: 2 (28.57%) - Number of class kind: 4 (57.14%) - -Number of class definitions: 7 -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 property definitions: 20 -Number of redefined properties: 1 (5.55%) -Average number of property redefinitions by property: 0.11 -Average number of property redefinitions by redefined property: 2.00 ---- Explicit vs. Implicit Self --- -Total number of self: 5 -Total number of implicit self: 4 (80.00%) ---- Construction of tables --- -Number of runtime classes: 6 (excluding interfaces and abstract classes) -Average number of composing class definition by runtime class: 2.00 -Total size of tables (classes and instances): 38 (not including stuff like info for subtyping or call-next-method) -Average size of table by runtime class: 6.33 -Values never redefined: 32 (84.21%) generating project_hierarchy.dot generating module_hierarchy.dot @@ -695,18 +695,14 @@ Statistics of type usage: A: 1 (11.11%) # Mendel metrics - large mclasses (threshold: 2.291) - B: 3 - C: 3 - budding mclasses (threshold: 0.693) - B: 0.75 - C: 0.75 - blooming mclasses (threshold: 1.935) - B: 2.25 - C: 2.25 - blooming mclasses (threshold: 1.935) - B: 2.25 - C: 2.25 + large mclasses (threshold: 3.354) + Sys: 4 + budding mclasses (threshold: 3.51) + Sys: 4.0 + blooming mclasses (threshold: 12.0) + Sys: 16.0 + blooming mclasses (threshold: 12.0) + Sys: 16.0 --- Detection of the usage of covariance static type conformance --- -- Total -- - Kinds of the subtype - @@ -880,9 +876,9 @@ MMethodDef locally designated (by number of CallSites) base_simple3#C#val1: 1 (4.54%) ... base_simple3#A#init: 1 (4.54%) - base_simple3#Object#baz: 1 (4.54%) - base_simple3#Object#bar: 1 (4.54%) - base_simple3#Object#foo: 1 (4.54%) + base_simple3#Sys#baz: 1 (4.54%) + base_simple3#Sys#bar: 1 (4.54%) + base_simple3#Sys#foo: 1 (4.54%) base_simple3#C#init: 1 (4.54%) MMethodDef possibly invoked at runtime (by number of CallSites) population: 13 @@ -901,9 +897,9 @@ MMethodDef possibly invoked at runtime (by number of CallSites) base_simple3#C#val1: 1 (4.54%) ... base_simple3#A#init: 1 (4.54%) - base_simple3#Object#baz: 1 (4.54%) - base_simple3#Object#bar: 1 (4.54%) - base_simple3#Object#foo: 1 (4.54%) + base_simple3#Sys#baz: 1 (4.54%) + base_simple3#Sys#bar: 1 (4.54%) + base_simple3#Sys#foo: 1 (4.54%) base_simple3#C#init: 1 (4.54%) class_hierarchy.dot classdef_hierarchy.dot diff --git a/tests/sav/nituml_args3.res b/tests/sav/nituml_args3.res index 94b3764..a8a1cd3 100644 --- a/tests/sav/nituml_args3.res +++ b/tests/sav/nituml_args3.res @@ -12,11 +12,11 @@ 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+ exit(exit_value: Int)\l+ sys(): Sys\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}" ] Sys [ - label = "{Sys||+ main()\l+ run()\l+ errno(): Int\l}" + label = "{Sys||+ main()\l+ run()\l+ errno(): Int\l+ exit(exit_value: Int)\l}" ] Object -> Sys [dir=back arrowtail=open style=dashed]; diff --git a/tests/sav/nituml_args4.res b/tests/sav/nituml_args4.res index 1664fce..437fbe4 100644 --- a/tests/sav/nituml_args4.res +++ b/tests/sav/nituml_args4.res @@ -12,11 +12,11 @@ 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+ exit(exit_value: Int)\l+ sys(): Sys\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}" ] Sys [ - label = "{Sys||+ main()\l+ run()\l+ errno(): Int\l}" + label = "{Sys||+ main()\l+ run()\l+ errno(): Int\l+ exit(exit_value: Int)\l}" ] Object -> Sys [dir=back arrowtail=open style=dashed]; diff --git a/tests/sav/nitunit_args4.res b/tests/sav/nitunit_args4.res index 91eb55f..8c655a2 100644 --- a/tests/sav/nitunit_args4.res +++ b/tests/sav/nitunit_args4.res @@ -5,17 +5,17 @@ Entities: 4; Documented ones: 3; With nitunits: 3; Failures: 0 TestSuites: No test cases found Class suites: 0; Test Cases: 0; Failures: 0 -if true then +if true then assert true end -if true then +if true then assert true end -var a = 1 +var a = 1 assert a == 1 assert a == 1 \ No newline at end of file diff --git a/tests/sav/nitunit_args5.res b/tests/sav/nitunit_args5.res index 356eaf4..3da2105 100644 --- a/tests/sav/nitunit_args5.res +++ b/tests/sav/nitunit_args5.res @@ -5,7 +5,7 @@ Entities: 6; Documented ones: 5; With nitunits: 3; Failures: 0 TestSuites: No test cases found Class suites: 0; Test Cases: 0; Failures: 0 -assert true # tested -assert true # tested -assert true # tested +assert true # tested +assert true # tested +assert true # tested \ No newline at end of file diff --git a/tests/sav/nitx_args2.res b/tests/sav/nitx_args2.res index 4138d94..bdb2b9f 100644 --- a/tests/sav/nitx_args2.res +++ b/tests/sav/nitx_args2.res @@ -1,5 +1,5 @@ = result for 'foo' fun foo - base_simple3::Object::foo (lines 49-49) + base_simple3::Sys::foo (lines 49-49) diff --git a/tests/sav/nitx_args3.res b/tests/sav/nitx_args3.res index e3174b3..83a361e 100644 --- a/tests/sav/nitx_args3.res +++ b/tests/sav/nitx_args3.res @@ -24,5 +24,5 @@ base_simple3::Object (lines 19-20) class Sys - base_simple3::Sys (lines 53-66) + base_simple3::Sys (lines 49-49) diff --git a/tests/sav/test_docdown_args2.res b/tests/sav/test_docdown_args2.res index 51196e3..2da0aeb 100644 --- a/tests/sav/test_docdown_args2.res +++ b/tests/sav/test_docdown_args2.res @@ -55,11 +55,11 @@ h5 {font-weight:bold;} .popover { max-width: 800px !important; } -

module test_doc2

prop test_doc2#Object#foo1

Test code

assert true # tested
-
prop test_doc2#Object#foo2

Test code

assert true # tested
-
prop test_doc2#Object#foo3

Test code

assert true # tested
-
prop test_doc2#Object#foo4

Test code

assert false # not tested (and not highlighted)
-
prop test_doc2#Object#foo5

Test code

assert false # not tested (but highlighted)
+

module test_doc2

prop test_doc2#Sys#foo1

Test code

assert true # tested
+
prop test_doc2#Sys#foo2

Test code

assert true # tested
+
prop test_doc2#Sys#foo3

Test code

assert true # tested
+
prop test_doc2#Sys#foo4

Test code

assert false # not tested (and not highlighted)
+
prop test_doc2#Sys#foo5

Test code

assert false # not tested (but highlighted)
 
\ No newline at end of file diff --git a/tests/test_ffi_c_callbacks.nit b/tests/test_ffi_c_callbacks.nit index fee35a5..5445bbf 100644 --- a/tests/test_ffi_c_callbacks.nit +++ b/tests/test_ffi_c_callbacks.nit @@ -21,7 +21,7 @@ end fun foo do print "foo" fun call_a_fun import foo `{ - Object_foo(recv); + Sys_foo(recv); `} fun call_a_constructor import A, A.bar `{ diff --git a/tests/test_ffi_c_more_callbacks.nit b/tests/test_ffi_c_more_callbacks.nit index 6be81fe..5fb5b35 100644 --- a/tests/test_ffi_c_more_callbacks.nit +++ b/tests/test_ffi_c_more_callbacks.nit @@ -33,7 +33,7 @@ fun in2(i: Float) do print "Back in Nit: in2" fun out(i: Int, f: Float): Int import in1, in2, A, A.alt, A.to_i `{ printf("From C, beginning out: %ld\n", i); - Object_in1(recv, i); + Sys_in1(recv, i); A a = new_A(); A b = new_A_alt(10); printf("From C, a=%ld\n", A_to_i(a)); diff --git a/tests/test_ffi_objc_types_and_callbacks.nit b/tests/test_ffi_objc_types_and_callbacks.nit index 9b0cd1c..4512519 100644 --- a/tests/test_ffi_objc_types_and_callbacks.nit +++ b/tests/test_ffi_objc_types_and_callbacks.nit @@ -24,7 +24,7 @@ import bar, String.to_cstring, Int.+ in "ObjC" `{ printf("From Objective-C: %ld %f %s\n", ii, f, cstr); - Object_bar(recv, ii, f, s); + Sys_bar(recv, ii, f, s); `} fun bar(i: Int, f: Float, s: String)