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>
end
end
-protected fun manager: AnalysisManager do return once new AnalysisManager
+fun manager: AnalysisManager do return once new AnalysisManager
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]
`}
# 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);
`}
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
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); `}
end
end
-protected fun assert_no_gl_error
+fun assert_no_gl_error
do
var error = gl.error
if not error.is_ok then
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));
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
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
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
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
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
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)
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
# 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
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
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
# 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
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
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
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
o.output
end
+redef class Sys
+ redef fun output do 'S'.output
+end
+
0.foo1
foo2
-alt/error_defs2_alt1.nit:20,11--13: Error: bar is not a top level method.
+4
+40
+124
-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.
-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.
-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.
-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.
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
-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.
-alt/error_toplevel_alt2.nit:35,2--5: Error: self cannot be used in top-level method.
+1
+0
+5
+0
+10
+20
+50
-alt/error_toplevel_alt3.nit:36,6--9: Error: self cannot be used in top-level method.
+1
+0
+5
+0
+10
+S50
-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.
-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
+++ /dev/null
-<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
</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="<a href="base_simple3.html#base_simple3#Object#foo">base_simple3#Object#foo</a>" data-content="<div><b>fun</b> <span>foo<span></span></span><br/></div>" 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="<a href="base_simple3.html#base_simple3#Object#bar">base_simple3#Object#bar</a>" data-content="<div><b>fun</b> <span>bar<span>(i: <a href="base_simple3.html#base_simple3#Int">Int</a>)</span></span><br/></div>" 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="<a href="base_simple3.html#base_simple3#Object#baz">base_simple3#Object#baz</a>" data-content="<div><b>fun</b> <span>baz<span>: <a href="base_simple3.html#base_simple3#Int">Int</a></span></span><br/></div>" 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="<a href="base_simple3.html#base_simple3#Sys#foo">base_simple3#Sys#foo</a>" data-content="<div><b>fun</b> <span>foo<span></span></span><br/></div>" 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="<a href="base_simple3.html#base_simple3#Sys#bar">base_simple3#Sys#bar</a>" data-content="<div><b>fun</b> <span>bar<span>(i: <a href="base_simple3.html#base_simple3#Int">Int</a>)</span></span><br/></div>" 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="<a href="base_simple3.html#base_simple3#Sys#baz">base_simple3#Sys#baz</a>" data-content="<div><b>fun</b> <span>baz<span>: <a href="base_simple3.html#base_simple3#Int">Int</a></span></span><br/></div>" 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>
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
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
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 -
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
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
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];
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];
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
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
\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
\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
.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
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 `{
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));
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)