Merge: Intern new
authorJean Privat <jean@pryen.org>
Tue, 14 Apr 2015 09:33:32 +0000 (16:33 +0700)
committerJean Privat <jean@pryen.org>
Tue, 14 Apr 2015 09:33:32 +0000 (16:33 +0700)
A small short PR that enables a `new`-factory to instantiate itself.

previously there was no way to do that. The following code will stack-overflow:

~~~nit
class A
   new do
      var res = new A
      res.do_thigns
      return res
   end
end
var a = new A # infinite recursion of `new A`
~~~

Note: this is a very bad example as what is done in the previous `new` should be done in an `init` instead since it is related to the initialization of the object. A `new` factory should be exclusively used for some factory-concern like returning a more specialized object or returning an already existing object.

With this PR, the primitive constructor is available and is called `intern`, as the annotation that indicates things that cannot be programmed in Nit but are provided by the execution engine.

So in the previous example, just use this primitive constructor instead of doing a recursive call:

~~~
      var res = new A.intern
~~~

This intern constructor just do the allocation and the initialization of attributes with default values.
`init` is not called.

Maybe it should not do the initialization of attributes neither but if I skip them, there is no way for the programmer to ask for them manually. whereas `init` in not automatically called but can be called manually.

note: this PR is a small step toward the conclusion of the constructor saga, more will come soon (I hope)

Pull-Request: #1252
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

60 files changed:
clib/gc_chooser.c
contrib/nitester/src/nitester.nit
contrib/pep8analysis/src/backbone.nit
lib/android/intent/intent_api10.nit
lib/android/log.nit
lib/app/app_base.nit
lib/egl.nit
lib/geometry/quadtree.nit
lib/glesv2/glesv2.nit
lib/md5.nit
lib/pthreads/README.md
lib/pthreads/examples/threaded_example.nit
lib/signals.nit
lib/standard/file.nit
lib/standard/file_nit.h
lib/standard/kernel.nit
lib/standard/kernel_nit.h
lib/standard/string.nit
misc/README.md
misc/vim/plugin/nit.vim
src/compiler/abstract_compiler.nit
src/compiler/global_compiler.nit
src/frontend/parallelization_phase.nit
src/interpreter/naive_interpreter.nit
src/mixin.nit
src/modelize/modelize_class.nit
src/modelize/modelize_property.nit
src/platform/ios.nit
src/platform/xcode_templates.nit
src/semantize/typing.nit
tests/error_toplevel.nit
tests/sav/error_class_glob.res
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-e/fixme/base_gen_reassign_alt4.res
tests/sav/nitg-e/fixme/base_gen_reassign_alt5.res
tests/sav/nitg-e/fixme/base_gen_reassign_alt6.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/sav/threaded_example.res
tests/test_ffi_c_callbacks.nit
tests/test_ffi_c_more_callbacks.nit
tests/test_ffi_objc_types_and_callbacks.nit

index f40a23e..497cc7e 100644 (file)
@@ -61,6 +61,7 @@ void nit_gcollect(void) {
 #ifdef WITH_LIBGC
        case gc_opt_boehm: GC_gcollect(); break;
 #endif
+       default: break; /* nothing can be done */
        }
 }
 
index 11df5b2..fb51b4d 100644 (file)
@@ -131,7 +131,6 @@ abstract class Processor
                                else
                                        full_path.file_delete
                                end
-                               stat.free
                        end
                        mpi.finalize
                        exit 0
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 97c0783..089b6ee 100644 (file)
@@ -29,7 +29,7 @@ import pipeline
 abstract class QuadTree[E: Boxed[Numeric]]
        super BoxedCollection[E]
 
-       protected var center: nullable Point[Numeric]
+       protected var center: nullable Point[Numeric] = null
        var data: Array[E] = new Array[E]
 
        #  ________________
@@ -39,20 +39,14 @@ abstract class QuadTree[E: Boxed[Numeric]]
        #  |   0   |   3   |
        #  |_______|_______|
 
-       protected var child0: nullable QuadTree[E]
-       protected var child1: nullable QuadTree[E]
-       protected var child2: nullable QuadTree[E]
-       protected var child3: nullable QuadTree[E]
+       protected var child0: nullable QuadTree[E] = null
+       protected var child1: nullable QuadTree[E] = null
+       protected var child2: nullable QuadTree[E] = null
+       protected var child3: nullable QuadTree[E] = null
 
        # represent the threshold before subdividing the node
-       protected var item_limit = 4
-       protected var parent_node: nullable QuadTree[E]
-
-       # create the quadtree and set the item limit for each node
-       init(limit: Int)
-       do
-               self.item_limit = limit
-       end
+       protected var item_limit: Int
+       protected var parent_node: nullable QuadTree[E] = null
 
        # create a node, giving him self as a parent. Used to create children nodes
        init with_parent(limit: Int, parent: QuadTree[E])
@@ -62,10 +56,10 @@ abstract class QuadTree[E: Boxed[Numeric]]
        end
 
        redef fun items_overlapping(region :Boxed[Numeric]): SimpleCollection[E] do
-        var res = new Array[E]
-        items_overlapping_in(region,res)
-        return res
-     end  
+               var res = new Array[E]
+               items_overlapping_in(region,res)
+               return res
+       end
 
        # add the item to the tree, create children if the limit is reached
        redef fun add(item: E) do if self.is_leaf then self.data.add(item) else add_to_children(item)
@@ -92,7 +86,7 @@ abstract class QuadTree[E: Boxed[Numeric]]
                        else if self.center.y > item.top then
                                self.data.add(item)
                        else if self.center.y < item.bottom then
-                                       self.data.add(item)
+                               self.data.add(item)
                        else
                                self.data.add(item)
                        end
@@ -215,23 +209,16 @@ end
 # the center of the parent node
 class SQuadTree[E: Boxed[Numeric]]
        super QuadTree[E]
-       
+
        # the width of the current node of the QuadTree
        var width: Numeric
        # the height of the current node of the QuadTree
        var height: Numeric
 
-       init(l: Int, c: Point[Numeric], w: Numeric, h: Numeric)
-       do
-               self.item_limit = l
-               self.center = c
-               self.width = w
-               self.height = h
-       end
-
        init with_parent(l: Int, c: Point[Numeric], w: Numeric, h: Numeric, p: QuadTree[E])
        do
-               init(l, c, w, h)
+               init(l, w, h)
+               center = c
                self.parent_node = p
        end
 
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 e612dbe..4a117b4 100644 (file)
@@ -11,6 +11,9 @@ This group also provides two optional modules with thread-safe collections:
 
 Theses services are implemented using the POSIX threads.
 
+You can also use the `is threaded` annotation on methods, which makes them run on their own thread.
+Methods with return value or self calls are not supported.
+
 ## Known limitations:
 
 * Most services from the Nit library are not thread-safe. You must manage
index 175c753..9a0af4b 100644 (file)
@@ -19,12 +19,20 @@ module threaded_example
 
 import pthreads
 
-# the "is threaded" annotation makes this fun run on an other thread
+# the `is threaded` annotation makes this method run on an other thread
 fun foo is threaded do
        sys.nanosleep(1,0)
        print "threaded"
 end
 
+# Parameterized `threaded` method, same as foo, but with parameters
+fun bar(i : Int, s : String) is threaded do
+       sys.nanosleep(2, 0)
+       print i
+       print s
+end
+
 foo
+bar(10, "parameterized and threaded")
 print "main"
-sys.nanosleep(2,0)
+sys.nanosleep(5,0)
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 81341ad..bb87a6f 100644 (file)
@@ -42,7 +42,17 @@ abstract class FileStream
        private var file: nullable NativeFile = null
 
        # The status of a file. see POSIX stat(2).
-       fun file_stat: NativeFileStat do return _file.file_stat
+       #
+       #     var f = new FileReader.open("/etc/issue")
+       #     assert f.file_stat.is_file
+       #
+       # Return null in case of error
+       fun file_stat: nullable FileStat
+       do
+               var stat = _file.file_stat
+               if stat.address_is_null then return null
+               return new FileStat(stat)
+       end
 
        # File descriptor of this file
        fun fd: Int do return _file.fileno
@@ -87,6 +97,11 @@ class FileReader
 
        # Open the same file again.
        # The original path is reused, therefore the reopened file can be a different file.
+       #
+       #     var f = new FileReader.open("/etc/issue")
+       #     var l = f.read_line
+       #     f.reopen
+       #     assert l == f.read_line
        fun reopen
        do
                if not eof and not _file.address_is_null then close
@@ -124,6 +139,16 @@ class FileReader
        redef var end_reached: Bool = false
 
        # Open the file at `path` for reading.
+       #
+       #     var f = new FileReader.open("/etc/issue")
+       #     assert not f.end_reached
+       #     f.close
+       #
+       # In case of error, `last_error` is set
+       #
+       #     f = new FileReader.open("/fail/does not/exist")
+       #     assert f.end_reached
+       #     assert f.last_error != null
        init open(path: String)
        do
                self.path = path
@@ -136,6 +161,8 @@ class FileReader
        end
 
        # Creates a new File stream from a file descriptor
+       #
+       # This is a low-level method.
        init from_fd(fd: Int) do
                self.path = ""
                prepare_buffer(1)
@@ -225,18 +252,20 @@ redef class Int
 end
 
 # Constant for read-only file streams
-private fun read_only: NativeString do return "r".to_cstring
+private fun read_only: NativeString do return once "r".to_cstring
 
 # Constant for write-only file streams
 #
 # If a stream is opened on a file with this method,
 # it will wipe the previous file if any.
 # Else, it will create the file.
-private fun wipe_write: NativeString do return "w".to_cstring
+private fun wipe_write: NativeString do return once "w".to_cstring
 
 ###############################################################################
 
 # Standard input stream.
+#
+# The class of the default value of `sys.stdin`.
 class Stdin
        super FileReader
 
@@ -250,6 +279,8 @@ class Stdin
 end
 
 # Standard output stream.
+#
+# The class of the default value of `sys.stdout`.
 class Stdout
        super FileWriter
        init do
@@ -261,6 +292,8 @@ class Stdout
 end
 
 # Standard error stream.
+#
+# The class of the default value of `sys.stderr`.
 class Stderr
        super FileWriter
        init do
@@ -307,6 +340,10 @@ class Path
        #
        # Returns `null` if there is no file at `self`.
        #
+       #     assert "/etc/".to_path.stat.is_dir
+       #     assert "/etc/issue".to_path.stat.is_file
+       #     assert "/fail/does not/exist".to_path.stat == null
+       #
        # ~~~
        # var p = "/tmp/".to_path
        # var stat = p.stat
@@ -333,8 +370,6 @@ class Path
        end
 
        # Delete a file from the file system, return `true` on success
-       #
-       # Require: `exists`
        fun delete: Bool do return path.to_cstring.file_delete
 
        # Copy content of file at `path` to `dest`
@@ -460,7 +495,7 @@ class Path
                end
 
                # Delete the directory itself
-               if ok then path.to_cstring.rmdir
+               if ok then ok = path.to_cstring.rmdir and ok
 
                return ok
        end
@@ -502,6 +537,11 @@ class FileStat
                return stat.atime
        end
 
+       # Returns the last access time
+       #
+       # alias for `last_access_time`
+       fun atime: Int do return last_access_time
+
        # Returns the last modification time in seconds since Epoch
        fun last_modification_time: Int
        do
@@ -509,6 +549,12 @@ class FileStat
                return stat.mtime
        end
 
+       # Returns the last modification time
+       #
+       # alias for `last_modification_time`
+       fun mtime: Int do return last_modification_time
+
+
        # Size of the file at `path`
        fun size: Int
        do
@@ -516,13 +562,16 @@ class FileStat
                return stat.size
        end
 
-       # Is this a regular file and not a device file, pipe, socket, etc.?
+       # Is self a regular file and not a device file, pipe, socket, etc.?
        fun is_file: Bool
        do
                assert not finalized
                return stat.is_reg
        end
 
+       # Alias for `is_file`
+       fun is_reg: Bool do return is_file
+
        # Is this a directory?
        fun is_dir: Bool
        do
@@ -546,6 +595,11 @@ class FileStat
                return stat.ctime
        end
 
+       # Returns the last status change time
+       #
+       # alias for `last_status_change_time`
+       fun ctime: Int do return last_status_change_time
+
        # Returns the permission bits of file
        fun mode: Int
        do
@@ -592,10 +646,20 @@ redef class String
        fun file_exists: Bool do return to_cstring.file_exists
 
        # The status of a file. see POSIX stat(2).
-       fun file_stat: NativeFileStat do return to_cstring.file_stat
+       fun file_stat: nullable FileStat
+       do
+               var stat = to_cstring.file_stat
+               if stat.address_is_null then return null
+               return new FileStat(stat)
+       end
 
        # The status of a file or of a symlink. see POSIX lstat(2).
-       fun file_lstat: NativeFileStat do return to_cstring.file_lstat
+       fun file_lstat: nullable FileStat
+       do
+               var stat = to_cstring.file_lstat
+               if stat.address_is_null then return null
+               return new FileStat(stat)
+       end
 
        # Remove a file, return true if success
        fun file_delete: Bool do return to_cstring.file_delete
@@ -678,11 +742,12 @@ redef class String
        end
 
        # Simplify a file path by remove useless ".", removing "//", and resolving ".."
-       # ".." are not resolved if they start the path
-       # starting "/" is not removed
-       # trainling "/" is removed
        #
-       # Note that the method only wonrk on the string:
+       # * ".." are not resolved if they start the path
+       # * starting "/" is not removed
+       # * trailing "/" is removed
+       #
+       # Note that the method only work on the string:
        #
        #  * no I/O access is performed
        #  * the validity of the path is not checked
@@ -718,7 +783,6 @@ redef class String
        # Using a standard "{self}/{path}" does not work in the following cases:
        #
        # * `self` is empty.
-       # * `path` ends with `'/'`.
        # * `path` starts with `'/'`.
        #
        # This method ensures that the join is valid.
@@ -839,28 +903,47 @@ redef class String
        end
 
        # Create a directory (and all intermediate directories if needed)
-       fun mkdir
+       #
+       # Return an error object in case of error.
+       #
+       #    assert "/etc/".mkdir != null
+       fun mkdir: nullable Error
        do
                var dirs = self.split_with("/")
                var path = new FlatBuffer
-               if dirs.is_empty then return
+               if dirs.is_empty then return null
                if dirs[0].is_empty then
                        # it was a starting /
                        path.add('/')
                end
+               var error: nullable Error = null
                for d in dirs do
                        if d.is_empty then continue
                        path.append(d)
                        path.add('/')
-                       path.to_s.to_cstring.file_mkdir
+                       var res = path.to_s.to_cstring.file_mkdir
+                       if not res and error == null then
+                               error = new IOError("Cannot create directory `{path}`: {sys.errno.strerror}")
+                       end
                end
+               return error
        end
 
        # Delete a directory and all of its content, return `true` on success
        #
        # Does not go through symbolic links and may get stuck in a cycle if there
        # is a cycle in the filesystem.
-       fun rmdir: Bool do return to_path.rmdir
+       #
+       # Return an error object in case of error.
+       #
+       #    assert "/fail/does not/exist".rmdir != null
+       fun rmdir: nullable Error
+       do
+               var res = to_path.rmdir
+               if res then return null
+               var error = new IOError("Cannot change remove `{self}`: {sys.errno.strerror}")
+               return error
+       end
 
        # Change the current working directory
        #
@@ -869,8 +952,18 @@ redef class String
        #     "..".chdir
        #     assert getcwd == "/"
        #
-       # TODO: errno
-       fun chdir do to_cstring.file_chdir
+       # Return an error object in case of error.
+       #
+       #     assert "/etc".chdir == null
+       #     assert "/fail/does no/exist".chdir != null
+       #     assert getcwd == "/etc" # unchanger
+       fun chdir: nullable Error
+       do
+               var res = to_cstring.file_chdir
+               if res then return null
+               var error = new IOError("Cannot change directory to `{self}`: {sys.errno.strerror}")
+               return error
+       end
 
        # Return right-most extension (without the dot)
        #
@@ -900,7 +993,17 @@ redef class String
                end
        end
 
-       # returns files contained within the directory represented by self
+       # Returns entries contained within the directory represented by self.
+       #
+       #     var files = "/etc".files
+       #     assert files.has("issue")
+       #
+       # Returns an empty array in case of error
+       #
+       #     files = "/etc/issue".files
+       #     assert files.is_empty
+       #
+       # TODO find a better way to handle errors and to give them back to the user.
        fun files: Array[String] is extern import Array[String], Array[String].add, NativeString.to_s, String.to_cstring `{
                char *dir_path;
                DIR *dir;
@@ -908,8 +1011,11 @@ redef class String
                dir_path = String_to_cstring( recv );
                if ((dir = opendir(dir_path)) == NULL)
                {
-                       perror( dir_path );
-                       exit( 1 );
+                       //perror( dir_path );
+                       //exit( 1 );
+                       Array_of_String results;
+                       results = new_Array_of_String();
+                       return results;
                }
                else
                {
@@ -945,14 +1051,14 @@ redef class NativeString
                return stat_element;
        `}
        private fun file_mkdir: Bool is extern "string_NativeString_NativeString_file_mkdir_0"
-       private fun rmdir: Bool `{ return rmdir(recv); `}
+       private fun rmdir: Bool `{ return !rmdir(recv); `}
        private fun file_delete: Bool is extern "string_NativeString_NativeString_file_delete_0"
-       private fun file_chdir is extern "string_NativeString_NativeString_file_chdir_0"
+       private fun file_chdir: Bool is extern "string_NativeString_NativeString_file_chdir_0"
        private fun file_realpath: NativeString is extern "file_NativeString_realpath"
 end
 
 # This class is system dependent ... must reify the vfs
-extern class NativeFileStat `{ struct stat * `}
+private extern class NativeFileStat `{ struct stat * `}
        # Returns the permission bits of file
        fun mode: Int is extern "file_FileStat_FileStat_mode_0"
        # Returns the last access time
@@ -1096,30 +1202,30 @@ redef class Sys
 end
 
 # Print `objects` on the standard output (`stdout`).
-protected fun printn(objects: Object...)
+fun printn(objects: Object...)
 do
        sys.stdout.write(objects.to_s)
 end
 
 # Print an `object` on the standard output (`stdout`) and add a newline.
-protected fun print(object: Object)
+fun print(object: Object)
 do
        sys.stdout.write(object.to_s)
        sys.stdout.write("\n")
 end
 
 # Read a character from the standard input (`stdin`).
-protected fun getc: Char
+fun getc: Char
 do
        return sys.stdin.read_char.ascii
 end
 
 # Read a line from the standard input (`stdin`).
-protected fun gets: String
+fun gets: String
 do
        return sys.stdin.read_line
 end
 
 # Return the working (current) directory
-protected fun getcwd: String do return file_getcwd.to_s
+fun getcwd: String do return file_getcwd.to_s
 private fun file_getcwd: NativeString is extern "string_NativeString_NativeString_file_getcwd_0"
index d8d9b4b..d86b2df 100644 (file)
@@ -46,9 +46,9 @@ int file_NativeFile_NativeFile_set_buffering_type_0(FILE* f, int buf_sz, int mod
 #define file_Sys_Sys_buffer_mode_line_0(self) _IOLBF
 #define file_Sys_Sys_buffer_mode_none_0(self) _IONBF
 
-#define string_NativeString_NativeString_file_mkdir_0(p) (mkdir(p, 0777))
+#define string_NativeString_NativeString_file_mkdir_0(p) (!mkdir(p, 0777))
 #define string_NativeString_NativeString_file_getcwd_0(p) (getcwd(NULL, 0))
-#define string_NativeString_NativeString_file_chdir_0(p) (chdir(p)?-1:0) /* hack to avoid warn_unused_result */
+#define string_NativeString_NativeString_file_chdir_0(p) (!chdir(p))
 #define file_NativeString_realpath(p) (realpath(p, NULL))
 
 #define file_stdin_poll_in(self) file_stdin_poll_in_()
index 01e72e3..dfff892 100644 (file)
@@ -17,10 +17,6 @@ module kernel
 
 import end # Mark this module is a top level one. (must be only one)
 
-`{
-#include <errno.h>
-`}
-
 ###############################################################################
 # System Classes                                                              #
 ###############################################################################
@@ -111,9 +107,7 @@ class Sys
        fun run do main
 
        # Number of the last error
-       fun errno: Int is extern `{
-               return errno;
-       `}
+       fun errno: Int is extern "sys_errno"
 end
 
 # Quit the program with a specific return code
index 3a09c9c..ba97c06 100644 (file)
@@ -12,7 +12,9 @@
  */
 
 #include <stdlib.h>
+#include <errno.h>
 
 #define address_is_null(x) ((x)==NULL)
+#define sys_errno(x) (errno)
 
 #endif
index 409b4ed..8db6a4e 100644 (file)
@@ -1952,9 +1952,7 @@ end
 redef class Int
 
        # Wrapper of strerror C function
-       private fun strerror_ext: NativeString is extern `{
-               return strerror(recv);
-       `}
+       private fun strerror_ext: NativeString is extern "strerror"
 
        # Returns a string describing error number
        fun strerror: String do return strerror_ext.to_s
index 1661f43..9b4bf06 100644 (file)
@@ -98,13 +98,15 @@ the environment variable `NIT_VIM_DIR`.
 
 ## Documentation in preview window
 
-You can display the documentation for the entity under the cursor with `:call Nitdoc()`.
-It will use the same metadata files as the omnifunc and the preview window.
+The command `:Nitdoc` searches the documentation for the word under the cursor.
+The results are displayed in the preview window in order of relevance.
+You can search for any word by passing it as an argument, as in `:Nitdoc modulo`.
+The Nitdoc command uses the same metadata files as the omnifunc.
 You may want to map the function to a shortcut by adding the following code to `~/.vimrc`.
 
 ~~~
 " Map displaying Nitdoc to Ctrl-D
-map <C-d> :call Nitdoc()<enter>
+map <C-d> :Nitdoc<enter>
 ~~~
 
 ## Search declarations and usages of the word under the cursor
index f19224a..86d5e45 100644 (file)
@@ -84,7 +84,7 @@ endfunction
 " Get path to the best metadata file named `name`
 "
 " Returns an empty string if not found.
-fun NitMetadataFile(name)
+fun s:NitMetadataFile(name)
        " Where are the generated metadata files?
        if empty($NIT_VIM_DIR)
                let metadata_dir = $HOME . '/.vim/nit'
@@ -122,7 +122,7 @@ fun NitOmnifuncAddFromFile(base, matches, path)
        let synopsis_matches = []
        let doc_matches = []
 
-       let path = NitMetadataFile(a:path)
+       let path = s:NitMetadataFile(a:path)
        if empty(path)
                return
        endif
@@ -134,19 +134,19 @@ fun NitOmnifuncAddFromFile(base, matches, path)
                " Add?
                if name == a:base
                        " Exact match
-                       call NitOmnifuncAddAMatch(a:matches, words, name)
+                       call s:NitOmnifuncAddAMatch(a:matches, words, name)
                elseif name =~? '^'.a:base
                        " Common-prefix match
-                       call NitOmnifuncAddAMatch(prefix_matches, words, name)
+                       call s:NitOmnifuncAddAMatch(prefix_matches, words, name)
                elseif name =~? a:base
                        " Substring match
-                       call NitOmnifuncAddAMatch(substring_matches, words, name)
+                       call s:NitOmnifuncAddAMatch(substring_matches, words, name)
                elseif get(words, 2, '') =~? a:base
                        " Match in the synopsis
-                       call NitOmnifuncAddAMatch(synopsis_matches, words, name)
+                       call s:NitOmnifuncAddAMatch(synopsis_matches, words, name)
                elseif get(words, 3, '') =~? a:base
                        " Match in the longer doc
-                       call NitOmnifuncAddAMatch(synopsis_matches, words, name)
+                       call s:NitOmnifuncAddAMatch(doc_matches, words, name)
                endif
        endfor
 
@@ -158,7 +158,7 @@ fun NitOmnifuncAddFromFile(base, matches, path)
 endfun
 
 " Internal function to search parse the information from a metadata line
-fun NitOmnifuncAddAMatch(matches, words, name)
+fun s:NitOmnifuncAddAMatch(matches, words, name)
        let pretty = get(a:words, 1, '')
        let synopsis = get(a:words, 2, '')
        let desc = get(a:words, 3, '')
@@ -266,16 +266,24 @@ fun NitOmnifunc(findstart, base)
 endfun
 
 " Show doc for the entity under the cursor in the preview window
-fun Nitdoc()
-       " Word under cursor
-       let word = expand("<cword>")
+fun Nitdoc(...)
+       if a:0 == 0 || empty(a:1)
+               " Word under cursor
+               let word = expand("<cword>")
+       else
+               let word = join(a:000, ' ')
+       endif
 
        " All possible docs (there may be more than one entity with the same name)
        let docs = []
+       let prefix_matches = []
+       let substring_matches = []
+       let synopsis_matches = []
+       let doc_matches = []
 
        " Search in all metadata files
        for file in ['modules', 'classes', 'properties']
-               let path = NitMetadataFile(file.'.txt')
+               let path = s:NitMetadataFile(file.'.txt')
                if empty(path)
                        continue
                endif
@@ -283,17 +291,34 @@ fun Nitdoc()
                for line in readfile(path)
                        let words = split(line, '#====#', 1)
                        let name = get(words, 0, '')
-                       if name =~ '^' . word . '\>'
-                               " It fits our word, get long doc
-                               let desc = get(words,3,'')
-                               let desc = join(split(desc, '#nnnn#', 1), "\n")
-                               call add(docs, desc)
+                       if name =~ '^'.word.'\>'
+                               " Exact match
+                               call s:NitdocAdd(docs, words)
+                       elseif name =~? '^'.word
+                               " Common-prefix match
+                               call s:NitdocAdd(prefix_matches, words)
+                       elseif name =~? word
+                               " Substring match
+                               call s:NitdocAdd(substring_matches, words)
+                       elseif get(words, 2, '') =~? word
+                               " Match in the synopsis
+                               call s:NitdocAdd(synopsis_matches, words)
+                       elseif get(words, 3, '') =~? word
+                               " Match in the longer doc
+                               call s:NitdocAdd(doc_matches, words)
                        endif
                endfor
        endfor
 
+       " Unite all results in prefered order
+       call extend(docs, sort(prefix_matches))
+       call extend(docs, sort(substring_matches))
+       call extend(docs, sort(synopsis_matches))
+       call extend(docs, sort(doc_matches))
+
        " Found no doc, give up
        if empty(docs) || !(join(docs, '') =~ '\w')
+               echo 'Nitdoc found nothing for "' . word . '"'
                return
        endif
 
@@ -310,6 +335,8 @@ fun Nitdoc()
                        silent put = ''
                endif
        endfor
+       execute 0
+       delete " the first empty line
 
        " Set options
        setlocal buftype=nofile
@@ -322,6 +349,13 @@ fun Nitdoc()
        redraw!
 endfun
 
+" Internal function to search parse the information from a metadata line
+fun s:NitdocAdd(matches, words)
+       let desc = get(a:words, 3, '')
+       let desc = join(split(desc, '#nnnn#', 1), "\n")
+       call add(a:matches, desc)
+endfun
+
 " Call `git grep` on the word under the cursor
 "
 " Shows declarations first, then all matches, in the preview window.
@@ -351,4 +385,7 @@ endfun
 " Activate the omnifunc on Nit files
 autocmd FileType nit set omnifunc=NitOmnifunc
 
+" Define the user command Nitdoc for ease of use
+command -nargs=* Nitdoc call Nitdoc("<args>")
+
 let s:script_dir = fnamemodify(resolve(expand('<sfile>:p')), ':h')
index 0baf216..3116924 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 7da80ff..8cd7965 100644 (file)
@@ -39,10 +39,9 @@ private class ParallelizationPhase
                        toolcontext.error(nmethdef.location, "Syntax error: only a method can be threaded.")
                        return
                end
-               if nmethdef.n_signature.n_params.length != 0 then
-                       toolcontext.error(nmethdef.location, "Syntax error: parametrized method not supported yet.")
-                       return
-               end
+
+               #TODO: check for self calls
+
                if nmethdef.n_signature.n_type != null then
                        toolcontext.error(nmethdef.location, "Syntax error: method with a return value not supported yet.")
                        return
@@ -66,11 +65,24 @@ private class ParallelizationPhase
                        classname += nmethdef.n_methid.as(AIdMethid).n_id.text
                end
 
-               # Create a string corresponding to the threaded class
-               var s ="""
+
+               var params = new Array[String]
+               # case if the method has parameters
+               if nmethdef.n_signature.n_params.not_empty then
+                       for param in nmethdef.n_signature.n_params do
+                               params.add("""
+var {{{param.n_id.text}}} : {{{param.n_type.n_id.text}}}
+
+""")
+                       end
+               end
+
+               # String corresponding to the generated class
+               var s="""
 class {{{classname}}}
        super Thread
 
+       {{{params.join("\n")}}}
        redef fun main do
        end
 end
@@ -95,11 +107,24 @@ end
                assert nullreturn isa AExpr
                mainfun.n_block.as(ABlockExpr).n_expr.add(nullreturn)
 
+
                # Create new body for the annotated fun
-               var s_newbody ="""
+               var s_newbody : String
+               if nmethdef.n_signature.n_params.not_empty then
+                       var init_params = new Array[String]
+                       for param in nmethdef.n_signature.n_params do
+                               init_params.add(param.n_id.text)
+                       end
+                       s_newbody ="""
+var thread = new {{{classname}}}({{{init_params.join(",")}}})
+thread.start
+"""
+               else
+                       s_newbody = """
 var thread = new {{{classname}}}
 thread.start
 """
+               end
 
                var newbody = toolcontext.parse_something(s_newbody)
                nmethdef.n_block = newbody.as(ABlockExpr)
index 2950bae..3168c76 100644 (file)
@@ -1001,11 +1001,11 @@ redef class AMethPropdef
                        else if pname == "file_exists" then
                                return v.bool_instance(recvval.to_s.file_exists)
                        else if pname == "file_mkdir" then
-                               recvval.to_s.mkdir
-                               return null
+                               var res = recvval.to_s.mkdir
+                               return v.bool_instance(res == null)
                        else if pname == "file_chdir" then
-                               recvval.to_s.chdir
-                               return null
+                               var res = recvval.to_s.chdir
+                               return v.bool_instance(res == null)
                        else if pname == "file_realpath" then
                                return v.native_string_instance(recvval.to_s.realpath)
                        else if pname == "get_environ" then
@@ -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 f81b5d2..27c05c6 100644 (file)
@@ -36,6 +36,12 @@ private class IOSPlatform
        redef fun toolchain(toolcontext, compiler) do return new IOSToolchain(toolcontext, compiler)
 end
 
+private class IosProject
+       super AppProject
+
+       redef fun namespace do return super.to_camel_case
+end
+
 private class IOSToolchain
        super MakefileToolchain
 
@@ -43,7 +49,7 @@ private class IOSToolchain
        var ios_project_root: String is noinit
 
        # `app.nit` project for the current compilation target
-       var app_project = new AppProject(compiler.modelbuilder, compiler.mainmodule) is lazy
+       var app_project = new IosProject(compiler.modelbuilder, compiler.mainmodule) is lazy
 
        redef fun default_outname do return "{super}.app"
 
index e4ebbdf..aa6cc5b 100644 (file)
@@ -221,25 +221,6 @@ class PbxprojectTemplate
                        path = Base.lproj/LaunchScreen.xib;
                        sourceTree = "<group>";
                        };
-               AF9F83E91A5F0D21004B62C0 /* {{{name}}}Tests.xctest */ = {
-                       isa = PBXFileReference;
-                       explicitFileType = wrapper.cfbundle;
-                       includeInIndex = 0;
-                       path = {{{name}}}Tests.xctest;
-                       sourceTree = BUILT_PRODUCTS_DIR;
-                       };
-               AF9F83EE1A5F0D21004B62C0 /* Info.plist */ = {
-                       isa = PBXFileReference;
-                       lastKnownFileType = text.plist.xml;
-                       path = Info.plist;
-                       sourceTree = "<group>";
-                       };
-               AF9F83EF1A5F0D21004B62C0 /* {{{name}}}Tests.m */ = {
-                       isa = PBXFileReference;
-                       lastKnownFileType = sourcecode.c.objc;
-                       path = {{{name}}}Tests.m;
-                       sourceTree = "<group>";
-                       };
 
        /* Changing generated files */
 """
@@ -257,13 +238,6 @@ class PbxprojectTemplate
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
-               AF9F83E61A5F0D21004B62C0 /* Frameworks */ = {
-                       isa = PBXFrameworksBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
 /* End PBXFrameworksBuildPhase section */
 
 /* Begin PBXGroup section */
@@ -271,7 +245,6 @@ class PbxprojectTemplate
                        isa = PBXGroup;
                        children = (
                                AF9F83CE1A5F0D21004B62C0 /* {{{name}}} */,
-                               AF9F83EC1A5F0D21004B62C0 /* {{{name}}}Tests */,
                                AF9F83CD1A5F0D21004B62C0 /* Products */,
                        );
                        sourceTree = "<group>";
@@ -280,7 +253,6 @@ class PbxprojectTemplate
                        isa = PBXGroup;
                        children = (
                                AF9F83CC1A5F0D21004B62C0 /* {{{name}}}.app */,
-                               AF9F83E91A5F0D21004B62C0 /* {{{name}}}Tests.xctest */,
                        );
                        name = Products;
                        sourceTree = "<group>";
@@ -308,23 +280,6 @@ class PbxprojectTemplate
                        name = "Supporting Files";
                        sourceTree = "<group>";
                };
-               AF9F83EC1A5F0D21004B62C0 /* {{{name}}}Tests */ = {
-                       isa = PBXGroup;
-                       children = (
-                               AF9F83EF1A5F0D21004B62C0 /* {{{name}}}Tests.m */,
-                               AF9F83ED1A5F0D21004B62C0 /* Supporting Files */,
-                       );
-                       path = {{{name}}}Tests;
-                       sourceTree = "<group>";
-               };
-               AF9F83ED1A5F0D21004B62C0 /* Supporting Files */ = {
-                       isa = PBXGroup;
-                       children = (
-                               AF9F83EE1A5F0D21004B62C0 /* Info.plist */,
-                       );
-                       name = "Supporting Files";
-                       sourceTree = "<group>";
-               };
 /* End PBXGroup section */
 
 /* Begin PBXNativeTarget section */
@@ -345,24 +300,6 @@ class PbxprojectTemplate
                        productReference = AF9F83CC1A5F0D21004B62C0 /* {{{name}}}.app */;
                        productType = "com.apple.product-type.application";
                };
-               AF9F83E81A5F0D21004B62C0 /* {{{name}}}Tests */ = {
-                       isa = PBXNativeTarget;
-                       buildConfigurationList = AF9F83F61A5F0D21004B62C0 /* Build configuration list for PBXNativeTarget "{{{name}}}Tests" */;
-                       buildPhases = (
-                               AF9F83E51A5F0D21004B62C0 /* Sources */,
-                               AF9F83E61A5F0D21004B62C0 /* Frameworks */,
-                               AF9F83E71A5F0D21004B62C0 /* Resources */,
-                       );
-                       buildRules = (
-                       );
-                       dependencies = (
-                               AF9F83EB1A5F0D21004B62C0 /* PBXTargetDependency */,
-                       );
-                       name = {{{name}}}Tests;
-                       productName = {{{name}}}Tests;
-                       productReference = AF9F83E91A5F0D21004B62C0 /* {{{name}}}Tests.xctest */;
-                       productType = "com.apple.product-type.bundle.unit-test";
-               };
 /* End PBXNativeTarget section */
 
 /* Begin PBXProject section */
@@ -374,10 +311,6 @@ class PbxprojectTemplate
                                        AF9F83CB1A5F0D21004B62C0 = {
                                                CreatedOnToolsVersion = 6.1.1;
                                        };
-                                       AF9F83E81A5F0D21004B62C0 = {
-                                               CreatedOnToolsVersion = 6.1.1;
-                                               TestTargetID = AF9F83CB1A5F0D21004B62C0;
-                                       };
                                };
                        };
                        buildConfigurationList = AF9F83C71A5F0D21004B62C0 /* Build configuration list for PBXProject "{{{name}}}" */;
@@ -394,7 +327,6 @@ class PbxprojectTemplate
                        projectRoot = "";
                        targets = (
                                AF9F83CB1A5F0D21004B62C0 /* {{{name}}} */,
-                               AF9F83E81A5F0D21004B62C0 /* {{{name}}}Tests */,
                        );
                };
 /* End PBXProject section */
@@ -414,13 +346,6 @@ class PbxprojectTemplate
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
-               AF9F83E71A5F0D21004B62C0 /* Resources */ = {
-                       isa = PBXResourcesBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
 /* End PBXResourcesBuildPhase section */
 
 /* Begin PBXSourcesBuildPhase section */
@@ -437,24 +362,8 @@ class PbxprojectTemplate
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
-               AF9F83E51A5F0D21004B62C0 /* Sources */ = {
-                       isa = PBXSourcesBuildPhase;
-                       buildActionMask = 2147483647;
-                       files = (
-                               AF9F83F01A5F0D21004B62C0 /* {{{name}}}Tests.m in Sources */,
-                       );
-                       runOnlyForDeploymentPostprocessing = 0;
-               };
 /* End PBXSourcesBuildPhase section */
 
-/* Begin PBXTargetDependency section */
-               AF9F83EB1A5F0D21004B62C0 /* PBXTargetDependency */ = {
-                       isa = PBXTargetDependency;
-                       target = AF9F83CB1A5F0D21004B62C0 /* {{{name}}} */;
-                       targetProxy = AF9F83EA1A5F0D21004B62C0 /* PBXContainerItemProxy */;
-               };
-/* End PBXTargetDependency section */
-
 /* Begin PBXVariantGroup section */
                AF9F83DD1A5F0D21004B62C0 /* Main.storyboard */ = {
                        isa = PBXVariantGroup;
@@ -553,40 +462,6 @@ class PbxprojectTemplate
                        };
                        name = Release;
                };
-               AF9F83F71A5F0D21004B62C0 /* Debug */ = {
-                       isa = XCBuildConfiguration;
-                       buildSettings = {
-                               BUNDLE_LOADER = "$(TEST_HOST)";
-                               FRAMEWORK_SEARCH_PATHS = (
-                                       "$(SDKROOT)/Developer/Library/Frameworks",
-                                       "$(inherited)",
-                               );
-                               GCC_PREPROCESSOR_DEFINITIONS = (
-                                       "DEBUG=1",
-                                       "$(inherited)",
-                               );
-                               INFOPLIST_FILE = {{{name}}}Tests/Info.plist;
-                               LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
-                               PRODUCT_NAME = "$(TARGET_NAME)";
-                               TEST_HOST = "$(BUILT_PRODUCTS_DIR)/{{{name}}}.app/{{{name}}}";
-                       };
-                       name = Debug;
-               };
-               AF9F83F81A5F0D21004B62C0 /* Release */ = {
-                       isa = XCBuildConfiguration;
-                       buildSettings = {
-                               BUNDLE_LOADER = "$(TEST_HOST)";
-                               FRAMEWORK_SEARCH_PATHS = (
-                                       "$(SDKROOT)/Developer/Library/Frameworks",
-                                       "$(inherited)",
-                               );
-                               INFOPLIST_FILE = {{{name}}}Tests/Info.plist;
-                               LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
-                               PRODUCT_NAME = "$(TARGET_NAME)";
-                               TEST_HOST = "$(BUILT_PRODUCTS_DIR)/{{{name}}}.app/{{{name}}}";
-                       };
-                       name = Release;
-               };
 /* End XCBuildConfiguration section */
 
 /* Begin XCConfigurationList section */
@@ -607,14 +482,6 @@ class PbxprojectTemplate
                        );
                        defaultConfigurationIsVisible = 0;
                };
-               AF9F83F61A5F0D21004B62C0 /* Build configuration list for PBXNativeTarget "{{{name}}}Tests" */ = {
-                       isa = XCConfigurationList;
-                       buildConfigurations = (
-                               AF9F83F71A5F0D21004B62C0 /* Debug */,
-                               AF9F83F81A5F0D21004B62C0 /* Release */,
-                       );
-                       defaultConfigurationIsVisible = 0;
-               };
 /* End XCConfigurationList section */
        };
        rootObject = AF9F83C41A5F0D21004B62C0 /* Project object */;
index 93ed60d..2bbc78b 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 2a02c5e..7dda3fb 100644 (file)
@@ -1 +1 @@
-../lib/standard/kernel.nit:101,1--117,3: Error: kernel#Sys does not specialize module_0#Object. Possible duplication of the root class `Object`?
+../lib/standard/kernel.nit:97,1--111,3: Error: kernel#Sys does not specialize module_0#Object. Possible duplication of the root class `Object`?
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
index 2ddb582..f1d9e06 100644 (file)
@@ -1,4 +1,4 @@
-Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/standard/kernel.nit:432)
+Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/standard/kernel.nit:426)
 11
 21
 31
index 2ddb582..f1d9e06 100644 (file)
@@ -1,4 +1,4 @@
-Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/standard/kernel.nit:432)
+Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/standard/kernel.nit:426)
 11
 21
 31
index 2ddb582..f1d9e06 100644 (file)
@@ -1,4 +1,4 @@
-Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/standard/kernel.nit:432)
+Runtime error: Cast failed. Expected `OTHER`, got `Float` (../lib/standard/kernel.nit:426)
 11
 21
 31
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 050d79d..e90aa48 100644 (file)
@@ -1,2 +1,4 @@
 main
 threaded
+10
+parameterized and threaded
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)