Merge: Sys is top
authorJean Privat <jean@pryen.org>
Fri, 10 Apr 2015 15:19:40 +0000 (22:19 +0700)
committerJean Privat <jean@pryen.org>
Fri, 10 Apr 2015 15:19:40 +0000 (22:19 +0700)
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 <alexis.laf@xymus.net>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

40 files changed:
contrib/pep8analysis/src/backbone.nit
lib/android/intent/intent_api10.nit
lib/android/log.nit
lib/app/app_base.nit
lib/egl.nit
lib/glesv2/glesv2.nit
lib/md5.nit
lib/signals.nit
src/compiler/abstract_compiler.nit
src/compiler/global_compiler.nit
src/interpreter/naive_interpreter.nit
src/mixin.nit
src/modelize/modelize_class.nit
src/modelize/modelize_property.nit
src/semantize/typing.nit
tests/error_toplevel.nit
tests/sav/error_defs2_alt1.res
tests/sav/error_defs2_alt2.res
tests/sav/error_defs_alt4.res
tests/sav/error_defs_alt5.res
tests/sav/error_defs_alt9.res
tests/sav/error_expr_not_ok_alt4.res
tests/sav/error_toplevel_alt1.res
tests/sav/error_toplevel_alt2.res
tests/sav/error_toplevel_alt3.res
tests/sav/error_toplevel_alt4.res
tests/sav/error_toplevel_alt5.res
tests/sav/nitg-g/fixme/test_deriving_alt1.res [deleted file]
tests/sav/nitlight_args1.res
tests/sav/nitmetrics_args1.res
tests/sav/nituml_args3.res
tests/sav/nituml_args4.res
tests/sav/nitunit_args4.res
tests/sav/nitunit_args5.res
tests/sav/nitx_args2.res
tests/sav/nitx_args3.res
tests/sav/test_docdown_args2.res
tests/test_ffi_c_callbacks.nit
tests/test_ffi_c_more_callbacks.nit
tests/test_ffi_objc_types_and_callbacks.nit

index d731e41..251f920 100644 (file)
@@ -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
index 8d84981..d2aa796 100644 (file)
@@ -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]
index c165331..6b0faea 100644 (file)
@@ -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);
 `}
index f892033..2a335c4 100644 (file)
@@ -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
index b664c8a..d062cfc 100644 (file)
@@ -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); `}
index de2babc..5b05f8b 100644 (file)
@@ -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
index f0b028e..85828aa 100644 (file)
@@ -492,7 +492,7 @@ in "C Header" `{
 redef class String
        # returns the md5 digest of the receiver string
        # algorithm implemented by L. Peter Deutsch <ghost@aladdin.com>
-       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));
index f9709da..58482a8 100644 (file)
@@ -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
index 3956744..059961f 100644 (file)
@@ -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
index 1aff84e..ede1beb 100644 (file)
@@ -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
 
index c847b5f..4cab2e5 100644 (file)
@@ -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
index 94d0c32..1ee4109 100644 (file)
@@ -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
 
index 5618c11..ae4e4c2 100644 (file)
@@ -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
 
index c224b29..d4a5654 100644 (file)
@@ -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
index cf8bbda..e51269f 100644 (file)
@@ -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
 
index c33bcb0..797261c 100644 (file)
@@ -45,5 +45,9 @@ do
        o.output
 end
 
+redef class Sys
+       redef fun output do 'S'.output
+end
+
 0.foo1
 foo2
index c79fb13..00c3748 100644 (file)
@@ -1 +1,3 @@
-alt/error_defs2_alt1.nit:20,11--13: Error: bar is not a top level method.
+4
+40
+124
index 8b01fd5..496828c 100644 (file)
@@ -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.
index 80e2677..70d33d8 100644 (file)
@@ -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.
index fec299a..39b0cbd 100644 (file)
@@ -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.
index 8c547a1..eed537b 100644 (file)
@@ -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.
index d22055c..62c634d 100644 (file)
@@ -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
index b18282f..5f067c0 100644 (file)
@@ -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.
index 8b3cf76..e7a0d8b 100644 (file)
@@ -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
index acfd7bf..d61c3b2 100644 (file)
@@ -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
index c1a37ee..af5d48f 100644 (file)
@@ -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.
index dff56d2..4528c41 100644 (file)
@@ -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 (file)
index 7457500..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-<A i: <Int> s: <FlatString>>
-i=5 s=Hello
-<A>
-
-true
-true
-true
-
-<B i: <Int> s: <FlatString> a: <A i: <Int> s: <FlatString>>>
-i=100 s=World a=<A>
-<B>
-
-true
-true
-true
index 8b7dbb3..570c986 100644 (file)
@@ -46,9 +46,9 @@
 </span></span><span class="nc_pdef foldable" id="base_simple3#C#_val2"><a id="base_simple3#C#val2"></a><a id="base_simple3#C#val2="></a><span class="line" id="L46">   <span class="nc_k">var</span> <span class="nc_def nc_i">val2</span><span>:</span> <span class="nc_t">Int</span> <span>=</span> <span class="nc_l">10</span>
 </span></span><span class="line" id="L47"><span class="nc_k">end</span>
 </span></span><span class="line" id="L48">
-</span><span class="nc_pdef foldable" id="base_simple3#Object#foo"><span class="line" id="L49"><span class="nc_k">fun</span> <span class="nc_def popupable" title="base_simple3#Object#foo" data-title="&lt;a href=&#34;base_simple3.html#base_simple3#Object#foo&#34;&gt;base_simple3#Object#foo&lt;&#47;a&gt;" data-content="&lt;div&gt;&lt;b&gt;fun&lt;&#47;b&gt; &lt;span&gt;foo&lt;span&gt;&lt;&#47;span&gt;&lt;&#47;span&gt;&lt;br&#47;&gt;&lt;&#47;div&gt;" data-toggle="popover"><span class="nc_i">foo</span></span> <span class="nc_k">do</span> <span class="nc_l">2</span><span>.</span><span class="nc_i">output</span>
-</span></span><span class="nc_pdef foldable" id="base_simple3#Object#bar"><span class="line" id="L50"><span class="nc_k">fun</span> <span class="nc_def popupable" title="base_simple3#Object#bar" data-title="&lt;a href=&#34;base_simple3.html#base_simple3#Object#bar&#34;&gt;base_simple3#Object#bar&lt;&#47;a&gt;" data-content="&lt;div&gt;&lt;b&gt;fun&lt;&#47;b&gt; &lt;span&gt;bar&lt;span&gt;(i: &lt;a href=&#34;base_simple3.html#base_simple3#Int&#34;&gt;Int&lt;&#47;a&gt;)&lt;&#47;span&gt;&lt;&#47;span&gt;&lt;br&#47;&gt;&lt;&#47;div&gt;" data-toggle="popover"><span class="nc_i">bar</span></span><span>(</span><span class="nc_v nc_i">i</span><span>:</span> <span class="nc_t">Int</span><span>)</span> <span class="nc_k">do</span> <span class="nc_v nc_i">i</span><span>.</span><span class="nc_i">output</span>
-</span></span><span class="nc_pdef foldable" id="base_simple3#Object#baz"><span class="line" id="L51"><span class="nc_k">fun</span> <span class="nc_def popupable" title="base_simple3#Object#baz" data-title="&lt;a href=&#34;base_simple3.html#base_simple3#Object#baz&#34;&gt;base_simple3#Object#baz&lt;&#47;a&gt;" data-content="&lt;div&gt;&lt;b&gt;fun&lt;&#47;b&gt; &lt;span&gt;baz&lt;span&gt;: &lt;a href=&#34;base_simple3.html#base_simple3#Int&#34;&gt;Int&lt;&#47;a&gt;&lt;&#47;span&gt;&lt;&#47;span&gt;&lt;br&#47;&gt;&lt;&#47;div&gt;" data-toggle="popover"><span class="nc_i">baz</span></span><span>:</span> <span class="nc_t">Int</span> <span class="nc_k">do</span> <span class="nc_k">return</span> <span class="nc_l">4</span>
+</span><span class="nc_pdef foldable" id="base_simple3#Sys#foo"><span class="line" id="L49"><span class="nc_k">fun</span> <span class="nc_def popupable" title="base_simple3#Sys#foo" data-title="&lt;a href=&#34;base_simple3.html#base_simple3#Sys#foo&#34;&gt;base_simple3#Sys#foo&lt;&#47;a&gt;" data-content="&lt;div&gt;&lt;b&gt;fun&lt;&#47;b&gt; &lt;span&gt;foo&lt;span&gt;&lt;&#47;span&gt;&lt;&#47;span&gt;&lt;br&#47;&gt;&lt;&#47;div&gt;" data-toggle="popover"><span class="nc_i">foo</span></span> <span class="nc_k">do</span> <span class="nc_l">2</span><span>.</span><span class="nc_i">output</span>
+</span></span><span class="nc_pdef foldable" id="base_simple3#Sys#bar"><span class="line" id="L50"><span class="nc_k">fun</span> <span class="nc_def popupable" title="base_simple3#Sys#bar" data-title="&lt;a href=&#34;base_simple3.html#base_simple3#Sys#bar&#34;&gt;base_simple3#Sys#bar&lt;&#47;a&gt;" data-content="&lt;div&gt;&lt;b&gt;fun&lt;&#47;b&gt; &lt;span&gt;bar&lt;span&gt;(i: &lt;a href=&#34;base_simple3.html#base_simple3#Int&#34;&gt;Int&lt;&#47;a&gt;)&lt;&#47;span&gt;&lt;&#47;span&gt;&lt;br&#47;&gt;&lt;&#47;div&gt;" data-toggle="popover"><span class="nc_i">bar</span></span><span>(</span><span class="nc_v nc_i">i</span><span>:</span> <span class="nc_t">Int</span><span>)</span> <span class="nc_k">do</span> <span class="nc_v nc_i">i</span><span>.</span><span class="nc_i">output</span>
+</span></span><span class="nc_pdef foldable" id="base_simple3#Sys#baz"><span class="line" id="L51"><span class="nc_k">fun</span> <span class="nc_def popupable" title="base_simple3#Sys#baz" data-title="&lt;a href=&#34;base_simple3.html#base_simple3#Sys#baz&#34;&gt;base_simple3#Sys#baz&lt;&#47;a&gt;" data-content="&lt;div&gt;&lt;b&gt;fun&lt;&#47;b&gt; &lt;span&gt;baz&lt;span&gt;: &lt;a href=&#34;base_simple3.html#base_simple3#Int&#34;&gt;Int&lt;&#47;a&gt;&lt;&#47;span&gt;&lt;&#47;span&gt;&lt;br&#47;&gt;&lt;&#47;div&gt;" data-toggle="popover"><span class="nc_i">baz</span></span><span>:</span> <span class="nc_t">Int</span> <span class="nc_k">do</span> <span class="nc_k">return</span> <span class="nc_l">4</span>
 </span></span><span class="line" id="L52">
 </span><span class="nc_pdef foldable" id="base_simple3#Sys#main"><span class="line" id="L53"><span class="nc_l">1</span><span>.</span><span class="nc_i">output</span>
 </span><span class="line" id="L54"><span class="nc_i">foo</span>
index 139f52b..9bd4a19 100644 (file)
          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)
          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
          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)
          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
index 94b3764..a8a1cd3 100644 (file)
@@ -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];
 
index 1664fce..437fbe4 100644 (file)
@@ -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];
 
index 91eb55f..8c655a2 100644 (file)
@@ -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
-<testsuites><testsuite package="test_nitunit2"><testcase classname="nitunit.test_nitunit2.standard::Object" name="test_nitunit2::Object::foo1"><system-err></system-err><system-out>if true then
+<testsuites><testsuite package="test_nitunit2"><testcase classname="nitunit.test_nitunit2.standard::Sys" name="test_nitunit2::Sys::foo1"><system-err></system-err><system-out>if true then
 
    assert true
 
 end
-</system-out></testcase><testcase classname="nitunit.test_nitunit2.standard::Object" name="test_nitunit2::Object::bar2"><system-err></system-err><system-out>if true then
+</system-out></testcase><testcase classname="nitunit.test_nitunit2.standard::Sys" name="test_nitunit2::Sys::bar2"><system-err></system-err><system-out>if true then
 
     assert true
 
 end
-</system-out></testcase><testcase classname="nitunit.test_nitunit2.standard::Object" name="test_nitunit2::Object::foo3"><system-err></system-err><system-out>var a = 1
+</system-out></testcase><testcase classname="nitunit.test_nitunit2.standard::Sys" name="test_nitunit2::Sys::foo3"><system-err></system-err><system-out>var a = 1
 assert a == 1
 assert a == 1
 </system-out></testcase></testsuite><testsuite></testsuite></testsuites>
\ No newline at end of file
index 356eaf4..3da2105 100644 (file)
@@ -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
-<testsuites><testsuite package="test_doc2"><testcase classname="nitunit.test_doc2.standard::Object" name="test_doc2::Object::foo1"><system-err></system-err><system-out>assert true # tested
-</system-out></testcase><testcase classname="nitunit.test_doc2.standard::Object" name="test_doc2::Object::foo2"><system-err></system-err><system-out>assert true # tested
-</system-out></testcase><testcase classname="nitunit.test_doc2.standard::Object" name="test_doc2::Object::foo3"><system-err></system-err><system-out>assert true # tested
+<testsuites><testsuite package="test_doc2"><testcase classname="nitunit.test_doc2.standard::Sys" name="test_doc2::Sys::foo1"><system-err></system-err><system-out>assert true # tested
+</system-out></testcase><testcase classname="nitunit.test_doc2.standard::Sys" name="test_doc2::Sys::foo2"><system-err></system-err><system-out>assert true # tested
+</system-out></testcase><testcase classname="nitunit.test_doc2.standard::Sys" name="test_doc2::Sys::foo3"><system-err></system-err><system-out>assert true # tested
 </system-out></testcase></testsuite><testsuite></testsuite></testsuites>
\ No newline at end of file
index 4138d94..bdb2b9f 100644 (file)
@@ -1,5 +1,5 @@
 \e[1m= result for 'foo'\e[0m
 
   fun \e[1m\e[32mfoo\e[0m\e[0m
-  \e[30m\e[1mbase_simple3::Object::foo\e[0m\e[0m\e[30m (lines 49-49)\e[0m
+  \e[30m\e[1mbase_simple3::Sys::foo\e[0m\e[0m\e[30m (lines 49-49)\e[0m
 
index e3174b3..83a361e 100644 (file)
@@ -24,5 +24,5 @@
       \e[30m\e[1mbase_simple3::Object\e[0m\e[0m\e[30m (lines 19-20)\e[0m
       
       class \e[32m\e[1mSys\e[0m\e[0m
-      \e[30m\e[1mbase_simple3::Sys\e[0m\e[0m\e[30m (lines 53-66)\e[0m
+      \e[30m\e[1mbase_simple3::Sys\e[0m\e[0m\e[30m (lines 49-49)\e[0m
 
index 51196e3..2da0aeb 100644 (file)
@@ -55,11 +55,11 @@ h5 {font-weight:bold;}
 .popover { max-width: 800px !important; }
 
 </style>
-</head><body><h3 id='test_doc2'>module test_doc2</h1><h5 id='test_doc2#Object#foo1'>prop test_doc2#Object#foo1</h3><div class="nitdoc"><p class="synopsys">Test code</p><pre class="nitcode"><span class="nitcode"><span class="line" id="L1"><span class="nc_k">assert</span> <span class="nc_k">true</span> <span># tested
-</span></span><span class="line" id="L2"><span></span></span></span></pre></div><h5 id='test_doc2#Object#foo2'>prop test_doc2#Object#foo2</h3><div class="nitdoc"><p class="synopsys">Test code</p><pre class="nitcode"><span class="nitcode"><span class="line" id="L1"><span class="nc_k">assert</span> <span class="nc_k">true</span> <span># tested
-</span></span><span class="line" id="L2"><span></span></span></span></pre></div><h5 id='test_doc2#Object#foo3'>prop test_doc2#Object#foo3</h3><div class="nitdoc"><p class="synopsys">Test code</p><pre class="nitcode"><span class="nitcode"><span class="line" id="L1"><span class="nc_k">assert</span> <span class="nc_k">true</span> <span># tested
-</span></span><span class="line" id="L2"><span></span></span></span></pre></div><h5 id='test_doc2#Object#foo4'>prop test_doc2#Object#foo4</h3><div class="nitdoc"><p class="synopsys">Test code</p><pre class="rawcode">assert false # not tested (and not highlighted)
-</pre></div><h5 id='test_doc2#Object#foo5'>prop test_doc2#Object#foo5</h3><div class="nitdoc"><p class="synopsys">Test code</p><pre class="nitcode"><span class="nitcode"><span class="line" id="L1"><span class="nc_k">assert</span> <span class="nc_k">false</span> <span># not tested (but highlighted)
+</head><body><h3 id='test_doc2'>module test_doc2</h1><h5 id='test_doc2#Sys#foo1'>prop test_doc2#Sys#foo1</h3><div class="nitdoc"><p class="synopsys">Test code</p><pre class="nitcode"><span class="nitcode"><span class="line" id="L1"><span class="nc_k">assert</span> <span class="nc_k">true</span> <span># tested
+</span></span><span class="line" id="L2"><span></span></span></span></pre></div><h5 id='test_doc2#Sys#foo2'>prop test_doc2#Sys#foo2</h3><div class="nitdoc"><p class="synopsys">Test code</p><pre class="nitcode"><span class="nitcode"><span class="line" id="L1"><span class="nc_k">assert</span> <span class="nc_k">true</span> <span># tested
+</span></span><span class="line" id="L2"><span></span></span></span></pre></div><h5 id='test_doc2#Sys#foo3'>prop test_doc2#Sys#foo3</h3><div class="nitdoc"><p class="synopsys">Test code</p><pre class="nitcode"><span class="nitcode"><span class="line" id="L1"><span class="nc_k">assert</span> <span class="nc_k">true</span> <span># tested
+</span></span><span class="line" id="L2"><span></span></span></span></pre></div><h5 id='test_doc2#Sys#foo4'>prop test_doc2#Sys#foo4</h3><div class="nitdoc"><p class="synopsys">Test code</p><pre class="rawcode">assert false # not tested (and not highlighted)
+</pre></div><h5 id='test_doc2#Sys#foo5'>prop test_doc2#Sys#foo5</h3><div class="nitdoc"><p class="synopsys">Test code</p><pre class="nitcode"><span class="nitcode"><span class="line" id="L1"><span class="nc_k">assert</span> <span class="nc_k">false</span> <span># not tested (but highlighted)
 </span></span><span class="line" id="L2"><span></span></span></span></pre></div><script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
 <script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
 <script>$(".popupable").popover({html:true, placement:'top'})/*initialize bootstrap popover*/</script></body></html>
\ No newline at end of file
index fee35a5..5445bbf 100644 (file)
@@ -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 `{
index 6be81fe..5fb5b35 100644 (file)
@@ -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));
index 9b0cd1c..4512519 100644 (file)
@@ -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)