nit.git
9 years agogitignore: ingore all bin/ and doc/ in examples/
Jean Privat [Wed, 27 Aug 2014 00:48:01 +0000 (20:48 -0400)]
gitignore: ingore all bin/ and doc/ in examples/

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoc_src: Fix uname in Makefile
Jean Privat [Tue, 26 Aug 2014 15:28:02 +0000 (11:28 -0400)]
c_src: Fix uname in Makefile

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: New constructors
Jean Privat [Tue, 26 Aug 2014 00:55:47 +0000 (20:55 -0400)]
Merge: New constructors

A very long development for a very important but experimental feature: the new-style constructors.

Most of the cleaning and other stuff was committed under interdependent PR.
So what remain here is the hardcore fundamental stuff.

I didn't find a simple way to have nice commits. So I went for some kind of incremental features.

## First commit

It is the worse since it introduces the new-style constructors in the model, semantic analysis and engines.

With the new-style constructors, the point is to understand that the syntax `var a = new A(some_b)` is in fact the following sequence

~~~
var a = ALLOC_INSTANCE(A)
a.b=(some_b)
a.init()
~~~

Where the `a.b=` part is a standard method call for the accessor `b=`.
Therefore, each constructor has a sequence of methods to call, they are called `initializers`.
Since redefinitions of constructor can provide different initializers, the initializers are attached to the MMethodDef class.

Because of this, a MMethodDef for a new-style constructor has two signatures, the real empty msigntature seen by the programmer that implements the constructor, and the one seen by the programmer that uses it to instantiate objects trough `new`, so called `new_msignature`.

~~~
class A
  var b: B
  # here, an implicit init, with, by rule of inheritance, the empty signature
end
var a = new A(some_b) # here the `new` takes a single B
~~~

Note that the `new_msignature` has to be conform with the `inititializers` since the arguments of the `new` are used for the invocations of the inititializers.

Modules `modelize_property` (and `auto_super_init` in a lesser extend) is modified to use new-style constructors for the default/automatic/free/implicit constructors.
Explicit constructors (named or not) use the old-style-constructors.
The code in these two modules is quite complex because it has to deal with the various implicit combinations of the old-style and new-style constructors.

For the engines (and rta), modifications are made to handle correctly the implementations of:

1. the invocation of the new-style constructors. by invoking each initializer, and
2. the implicit body of the new-style default/automatic/free/implicit constructors; they do just a call to super since the initializations of the attributes is done outside the init: in the sequence code of the new.

While user-defined constructor is not present in this commit, all the implicit init are converted.
The boostrap still works, and most tests pass.

## Second commit

Just introduce (and use) the annotation `old_style_init` that is used to mark explicit constructors to use the old semantic (and implementation).
The annotation can be put on a single `init`, or on the whole module.

## Third commit

'simple' `init` are those defined without name nor parameters (and that are public).
They are converted to the new-style constructors.
This is just magic because things, like the boostrap and most tests, still work as expected.

Now, programmers can use the default init and get the initializers automatically called.
Basically, instead of writing

~~~
class A
  var b: B
  init(b: B)
  do
    self.b = b
    rest_of_init
  end
end
var a = new A(some_b)
~~~

just write

~~~
class A
  var b: B
  init
  do
    rest_of_init
  end
end
var a = new A(some_b) # Same client, but less code in the A class
~~~

And simple subclasses get easier

~~~
class SubA
  super A
  var c: C
  init
  do
    some_other_stuff
  end
end
var sa = new SubA(some_b, some_c)
# Done in order:
# 1. set b
# 2. set c
# 3. rest_of_init
# 4. some_other_stuff
~~~

## Fourth commit

Update existing tests.

## Last commit

add a new test that illustrates combination and the linearization of the simple init

## What is next?

### User-definer initializers

Conflict on initializers are detected, but currently there is no simple way for the used to define its own sequence of initializers.

* what syntax to use? something like `init is initializers(a,b,c) do ...`?
* what rules? are any sequence allowed?

### Not-simple constructors

The status of the constructors that remains is still unclear.

* named constructors are the simpler case since the proposed specification want to have them working like standard method but usable with a new. In fact, they will behave as a simple version of the old-style-constructors, with less shenanigans.
* init with parameters, still accepted for compatibility but they should be migrated. If not migratable, more investigation and thinking will be required
* private init. Since the root `init` of Object is public, subclasses cannot change its visibility. So how to indicate that a class cannot be instantiated publicly? Again, more investigation and thinking.

Pull-Request: #679
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agotests: add base_init_basic.nit
Jean Privat [Wed, 20 Aug 2014 01:43:12 +0000 (21:43 -0400)]
tests: add base_init_basic.nit

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: update to pass tests
Jean Privat [Wed, 20 Aug 2014 00:52:23 +0000 (20:52 -0400)]
tests: update to pass tests

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agomodelize_property: simple inits are new-style
Jean Privat [Wed, 20 Aug 2014 00:37:50 +0000 (20:37 -0400)]
modelize_property: simple inits are new-style

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: tests: do not check whitespace errors in *.res files
Jean Privat [Mon, 25 Aug 2014 17:01:13 +0000 (13:01 -0400)]
Merge: tests: do not check whitespace errors in *.res files

Pull-Request: #682
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agotests: do not check whitespace errors in *.res files
Jean Privat [Sat, 23 Aug 2014 19:59:09 +0000 (15:59 -0400)]
tests: do not check whitespace errors in *.res files

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Intro `user/group_exists` and apply a few small fixes
Jean Privat [Sat, 23 Aug 2014 19:49:58 +0000 (15:49 -0400)]
Merge: Intro `user/group_exists` and apply a few small fixes

Pull-Request: #678
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agolib/curl: use more precise return types
Alexis Laferrière [Fri, 18 Jul 2014 16:01:08 +0000 (12:01 -0400)]
lib/curl: use more precise return types

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agosrc: new annotation old_style_init
Jean Privat [Wed, 20 Aug 2014 00:36:41 +0000 (20:36 -0400)]
src: new annotation old_style_init

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agosrc: introduce new constructors
Jean Privat [Tue, 19 Aug 2014 23:53:37 +0000 (19:53 -0400)]
src: introduce new constructors

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/privileges: prevent seg faults with asserts and require in doc
Alexis Laferrière [Fri, 1 Aug 2014 23:19:44 +0000 (19:19 -0400)]
lib/privileges: prevent seg faults with asserts and require in doc

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agolib: intro `user_exists` and `group_exists`
Alexis Laferrière [Fri, 1 Aug 2014 23:19:08 +0000 (19:19 -0400)]
lib: intro `user_exists` and `group_exists`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agosendmail: fix missing empty line between header and body
Alexis Laferrière [Wed, 6 Aug 2014 17:45:22 +0000 (13:45 -0400)]
sendmail: fix missing empty line between header and body

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agoMerge: Auto super init call next method
Jean Privat [Tue, 19 Aug 2014 00:33:07 +0000 (20:33 -0400)]
Merge: Auto super init call next method

If one redefines a constructor in a subclass (a real redefinition, not just a look-alike init with the same name) the auto-super-init phase automatically inserted a call to a compatible constructor in the super-class, so a call to itself, so a fatal infinite recursive call :/

It is an old bug, but nobody did real redefinitions of constructors, except that it will be the norm with the new constructors. So just let solve the bug now, before people start to complain.

Pull-Request: #676
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agoMerge: introduce Sequence::prepend
Jean Privat [Mon, 18 Aug 2014 13:11:17 +0000 (09:11 -0400)]
Merge: introduce Sequence::prepend

How could people live without having a working prepend?

Pull-Request: #675
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agotests: add base_init_super_call3.nit and it does not stack-overflow
Jean Privat [Sat, 16 Aug 2014 01:09:21 +0000 (21:09 -0400)]
tests: add base_init_super_call3.nit and it does not stack-overflow

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoauto_super_init: handle the case of constructors redefinition (instead of infinitivel...
Jean Privat [Sat, 16 Aug 2014 01:07:03 +0000 (21:07 -0400)]
auto_super_init: handle the case of constructors redefinition (instead of infinitively recurse)

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: update sav/test_new_native_alt1.res because of changes in array.nit
Jean Privat [Sat, 16 Aug 2014 00:41:20 +0000 (20:41 -0400)]
tests: update sav/test_new_native_alt1.res because of changes in array.nit

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Prepare for new constructors
Jean Privat [Fri, 15 Aug 2014 21:21:39 +0000 (17:21 -0400)]
Merge: Prepare for new constructors

With new constructors, attributes without default value are considered even if a constructor is present.

So, while ugly, the following code is currently working.
~~~
class A
   var attr: Attr
   init do attr = new Attr(foo)
end
var a = new A
~~~

With the new constructors, the attribute `attr` will be part of the signature of the new,

~~~
var a = new A # Error, expected one argument `attr: Attr`
~~~

So this series do some cosmetic changes to accommodate the future new constructors.
Most of these change make senes own their own since they:

* reduce the number of lines by removing useless init
* clarify the behavior of some attributes by adding a default value or a `noinit` annotation

More precisely, easy cases of the previous code is usually migrated into

~~~
class A
   var attr = new Attr(foo)
end
var a = new A
~~~

And complex cases into

~~~
class A
   var attr: Attr is noinit
   init do attr = new Attr(foo)
end
var a = new A
~~~

The few remaining very complex cases (ex parser) will be migrated latter, and a temporally new annotation `old_style_init` may be created for them.

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

9 years agoMerge: Annotation `nosuper` to avoid automatic super call in constructors
Jean Privat [Fri, 15 Aug 2014 21:21:36 +0000 (17:21 -0400)]
Merge: Annotation `nosuper` to avoid automatic super call in constructors

A super-init-call is automatically added in constructors that do not invoke one (a la java)
But sometimes one may want to avoid calling a super-init.

Before, this could be done with a dead super

~~~
init do
  if false the super # a super is present, so no additional implicit super-init
  rest
end
~~~

Now, one can just write

~~~
init is nosuper do
   rest
end
~~~

that is more KISS I think.

Pull-Request: #673
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agoMerge: Fixes for supercalls
Jean Privat [Fri, 15 Aug 2014 21:21:34 +0000 (17:21 -0400)]
Merge: Fixes for supercalls

A bug was found while working on the new constructors.

Pull-Request: #672
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agolib: add Seq:prepend as an alias of `insert_all(0)`
Jean Privat [Fri, 15 Aug 2014 19:56:27 +0000 (15:56 -0400)]
lib: add Seq:prepend as an alias of `insert_all(0)`

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib: add Seq:insert_all as a generalized `insert`
Jean Privat [Fri, 15 Aug 2014 19:55:50 +0000 (15:55 -0400)]
lib: add Seq:insert_all as a generalized `insert`

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib: make Seq::append an alias of add_all (instead of relying on an inefficient defau...
Jean Privat [Fri, 15 Aug 2014 19:54:52 +0000 (15:54 -0400)]
lib: make Seq::append an alias of add_all (instead of relying on an inefficient default implementation)

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: update sav for modified files
Jean Privat [Fri, 15 Aug 2014 10:54:00 +0000 (06:54 -0400)]
tests: update sav for modified files

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: prepare for new constructors
Jean Privat [Fri, 15 Aug 2014 10:46:28 +0000 (06:46 -0400)]
tests: prepare for new constructors

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agosrc: prepare for new constructors
Jean Privat [Fri, 15 Aug 2014 10:25:35 +0000 (06:25 -0400)]
src: prepare for new constructors

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agocontrib: prepare for new constructors
Jean Privat [Fri, 15 Aug 2014 10:22:53 +0000 (06:22 -0400)]
contrib: prepare for new constructors

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib: prepare for new constructors
Jean Privat [Fri, 15 Aug 2014 10:21:22 +0000 (06:21 -0400)]
lib: prepare for new constructors

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: add base_init_nosuper.nit
Jean Privat [Fri, 15 Aug 2014 02:34:41 +0000 (22:34 -0400)]
tests: add base_init_nosuper.nit

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoauto_super_init: add annotation `nosuper`
Jean Privat [Fri, 15 Aug 2014 02:32:04 +0000 (22:32 -0400)]
auto_super_init: add annotation `nosuper`

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: nitgg: use is_toplevel instead of heuristics to not customize top-level methods
Jean Privat [Fri, 15 Aug 2014 02:12:58 +0000 (22:12 -0400)]
Merge: nitgg: use is_toplevel instead of heuristics to not customize top-level methods

Pull-Request: #671
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: phase: remove a useless verbose line
Jean Privat [Fri, 15 Aug 2014 02:12:56 +0000 (22:12 -0400)]
Merge: phase: remove a useless verbose line

Was called nb_classdefs*nb_phases times, so approximatively 50.000 for nitg.
Without it, the gain is 6% in compiling nitg

Pull-Request: #670
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agorta: `add_super_send` uses live_classes instead of live_types
Jean Privat [Thu, 14 Aug 2014 17:38:49 +0000 (13:38 -0400)]
rta: `add_super_send` uses live_classes instead of live_types

Otherwise, some not-yet-resolved open types can be forgot.

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agosrc: add some asserts on `super` related things
Jean Privat [Thu, 14 Aug 2014 17:37:00 +0000 (13:37 -0400)]
src: add some asserts on `super` related things

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agophase: remove a useless verbose executed
Jean Privat [Thu, 14 Aug 2014 01:50:38 +0000 (21:50 -0400)]
phase: remove a useless verbose executed

Was called nb_classdefs*nb_phases times, so approximatively 50.000 for nitg.
Without it, the gain is 6% in compiling nitg

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agonitgg: use is_toplevel instead of heuristics to not customize top-level methods
Jean Privat [Thu, 14 Aug 2014 00:25:12 +0000 (20:25 -0400)]
nitgg: use is_toplevel instead of heuristics to not customize top-level methods

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: lib: introduce module hash_debug
Jean Privat [Wed, 13 Aug 2014 20:31:00 +0000 (16:31 -0400)]
Merge: lib: introduce module hash_debug

Nit-exclusivity thanks to class refinements, intrude imports and the control of the main function.

Inject behavior analysis to hash-collections (HashMap, HashSet, etc.)
Accesses to hash collections are instrumented, and statistics are automatically displayed at the end of the program.

This module helps to detect, and track bad behavior on hash-collections, especially collisions.

Simple usage:

1. compile your program with `-m hash_debug`
2. execute your program.

Advanced usage:

import `hash_debug` and use the functions `Sys::show_hash_stats` and `Sys::clear_hash_stats` at strategic points.

You can also use some dynamic call-graph tools (like valgrind) and look at callers of `HashCollection::gt_collide` and `HashCollection::st_collide`.

Pull-Request: #664
Reviewed-by: Frédéric Vachon <fredvac@gmail.com>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: Deserialize generics with nitserial
Jean Privat [Wed, 13 Aug 2014 20:30:15 +0000 (16:30 -0400)]
Merge: Deserialize generics with nitserial

nitserial compiles a Nit module after analyzing a Nit program. This module can then be compiled with the program (possibly using `-m`) to support deserializing any alive generic type. Many generated module can be used to support different libraries with hidden serialization logic, or to support exchanges between a client and a server.

Will be used by the RESTful interface of Benitlux.

Pull-Request: #650
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>

9 years agoMerge: cleanup --no-check-*
Jean Privat [Wed, 13 Aug 2014 20:30:12 +0000 (16:30 -0400)]
Merge: cleanup --no-check-*

Some people like to live dangerously, they unplug their usb stick without unmounting, they write long comments in a textbox in a browser, they eat pasta with a white t-shirt.
Now, they can also `--no-check-all` to disable all runtime-tests and sweat pure adrenaline.

Some numbers, because people like numbers: `--no-check-all` gives a small 6% boost for compiling nitg.
(for reference, --semi-global is a 20% boost).

Pull-Request: #665
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: Optimize usage of the chars of a string
Jean Privat [Wed, 13 Aug 2014 20:29:53 +0000 (16:29 -0400)]
Merge: Optimize usage of the chars of a string

* The first commit, on `html_escape`, improves nitdoc execution on RnR by about 10s, or 6%.
* The second commit _theorically_ improves access to the chars of strings. It _worsen_ the execution of nitdoc on RnR by about 9s.

The overall gain on this specific use case is of 1s. Obviously this PR is not to be merged as is!

Pull-Request: #663
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agotests: nitg-e doesn't know the full type of generics, expect the error
Alexis Laferrière [Thu, 7 Aug 2014 16:18:44 +0000 (12:18 -0400)]
tests: nitg-e doesn't know the full type of generics, expect the error

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agotests: test a module generated by `nitserial`
Alexis Laferrière [Wed, 6 Aug 2014 17:19:54 +0000 (13:19 -0400)]
tests: test a module generated by `nitserial`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agotests: test nitserial itself
Alexis Laferrière [Wed, 6 Aug 2014 15:20:57 +0000 (11:20 -0400)]
tests: test nitserial itself

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agotests: extend test_deserialization with generics
Alexis Laferrière [Wed, 18 Jun 2014 17:07:07 +0000 (13:07 -0400)]
tests: extend test_deserialization with generics

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agonitserial: intro a support tool to deserialize generic types
Alexis Laferrière [Sun, 20 Jul 2014 18:46:29 +0000 (14:46 -0400)]
nitserial: intro a support tool to deserialize generic types

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agolib/json_serialization: support Arrays
Alexis Laferrière [Wed, 18 Jun 2014 17:01:15 +0000 (13:01 -0400)]
lib/json_serialization: support Arrays

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agolib/string: use indexed access to chars instead of iterators
Alexis Laferrière [Tue, 12 Aug 2014 21:11:38 +0000 (17:11 -0400)]
lib/string: use indexed access to chars instead of iterators

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agocomp: add --no-check-all
Jean Privat [Wed, 13 Aug 2014 14:12:59 +0000 (10:12 -0400)]
comp: add --no-check-all

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agocomp: rename --no-check-other to --no-check-null, because it is what it does
Jean Privat [Wed, 13 Aug 2014 14:02:35 +0000 (10:02 -0400)]
comp: rename --no-check-other to --no-check-null, because it is what it does

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agonitgg: correclty disable attr check with --no-check-attr-isset
Jean Privat [Wed, 13 Aug 2014 13:59:08 +0000 (09:59 -0400)]
nitgg: correclty disable attr check with --no-check-attr-isset

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Ai search
Jean Privat [Wed, 13 Aug 2014 13:47:48 +0000 (09:47 -0400)]
Merge: Ai search

Second part of the ai library. now with astar (and other search algos)

Look a puzzle.nit for a simple example of usage.

Pull-Request: #660
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: Intent: An android API to launch activities and services
Jean Privat [Wed, 13 Aug 2014 13:47:27 +0000 (09:47 -0400)]
Merge: Intent: An android API to launch activities and services

New API for `lib/android` allowing to start/stop activities and services. Intent tests raised new subtle errors in `Bundle`API and `Audio` API that have been fixed in this PR.

Pull-Request: #644
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

9 years agoMerge: UTF-8 Strings without index
Jean Privat [Wed, 13 Aug 2014 13:47:16 +0000 (09:47 -0400)]
Merge: UTF-8 Strings without index

Another WIP version of UTF-8 Strings, without indexing this time.

This is more likely to become the final implementation, depending on the performance of it. I'll add benches for the versions of UTF-8 to examine their impact and decide a bit later.

This implementation being less rigid than the other, more of the API is supported, still, more work needs to be done.

Pull-Request: #655
Reviewed-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Memcpy -> memmove
Jean Privat [Wed, 13 Aug 2014 13:46:50 +0000 (09:46 -0400)]
Merge: Memcpy -> memmove

As discussed in #655, this PR replaces the uses of memcpy in standard by memmove, a safer alternative while not costing that much more.

Before : 0m15.584s
After : 0m15.748s

Pull-Request: #661
Reviewed-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Finalizing Nit objects on garbage collection
Jean Privat [Wed, 13 Aug 2014 13:46:43 +0000 (09:46 -0400)]
Merge: Finalizing Nit objects on garbage collection

Rules for finalizable objects:

* They must be a standard Nit class (not an extern, nor a universal).
* They must not have any cycles, or else they won't be finalized.
* In practice, they should be used on small Nit objects acting as a thin layer around a resource. In other words, it is to be used in the Nity layer.
* `finalize` may be invoked more than once, and the underlying resources may also be used by other instances. This must be considered when implementing `finalize`.
* The finalizer will be called on garbage collection. It can be forced with `sys.force_garbage_collection`.
* When attempting to aquire a limited resource (for example, a file description) if you hit the limit, it is a good practice to force the garbage collection and try again.

Pull-Request: #659
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Frédéric Vachon <fredvac@gmail.com>

9 years agolib: introduce module hash_debug
Jean Privat [Wed, 13 Aug 2014 03:17:00 +0000 (23:17 -0400)]
lib: introduce module hash_debug

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/android: Removed deprecated `super Serializable`
Frédéric Vachon [Tue, 5 Aug 2014 18:02:19 +0000 (14:02 -0400)]
lib/android: Removed deprecated `super Serializable`

Signed-off-by: Frédéric Vachon <fredvac@gmail.com>

9 years agolib/android: Fixes audio module tests
Frédéric Vachon [Tue, 5 Aug 2014 02:10:30 +0000 (22:10 -0400)]
lib/android: Fixes audio module tests

Signed-off-by: Frédéric Vachon <fredvac@gmail.com>

9 years agolib/android: Bundle API JNI error fix
Frédéric Vachon [Tue, 5 Aug 2014 01:10:02 +0000 (21:10 -0400)]
lib/android: Bundle API JNI error fix

Signed-off-by: Frédéric Vachon <fredvac@gmail.com>

9 years agolib/android: Added Intent API tests to mnit_simple
Frédéric Vachon [Mon, 4 Aug 2014 23:51:09 +0000 (19:51 -0400)]
lib/android: Added Intent API tests to mnit_simple

Signed-off-by: Frédéric Vachon <fredvac@gmail.com>

9 years agolib: use a simple iteration in `html_escape` and move to `string`
Alexis Laferrière [Tue, 12 Aug 2014 21:05:14 +0000 (17:05 -0400)]
lib: use a simple iteration in `html_escape` and move to `string`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agotests: test finalization effect
Alexis Laferrière [Fri, 8 Aug 2014 23:18:45 +0000 (19:18 -0400)]
tests: test finalization effect

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agonitg & lib: intro `Finalizable` to be called when an object is freed
Alexis Laferrière [Fri, 8 Aug 2014 23:18:20 +0000 (19:18 -0400)]
nitg & lib: intro `Finalizable` to be called when an object is freed

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agolib/ai: add the n-puzzle problem as an example of search
Jean Privat [Mon, 11 Aug 2014 19:09:35 +0000 (15:09 -0400)]
lib/ai: add the n-puzzle problem as an example of search

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/ai: add search.nit as the second module
Jean Privat [Mon, 11 Aug 2014 18:58:31 +0000 (14:58 -0400)]
lib/ai: add search.nit as the second module

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agonitg: Replace memcpy by memmove for safety.
Lucas Bajolet [Tue, 12 Aug 2014 18:56:07 +0000 (14:56 -0400)]
nitg: Replace memcpy by memmove for safety.

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agolib/string_exp/utf8_no_index: Updated README
Lucas Bajolet [Thu, 7 Aug 2014 17:58:49 +0000 (13:58 -0400)]
lib/string_exp/utf8_no_index: Updated README

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoutf8_noindex/tests: Added a test for utf8 without index variant
Lucas Bajolet [Thu, 7 Aug 2014 16:52:40 +0000 (12:52 -0400)]
utf8_noindex/tests: Added a test for utf8 without index variant

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agolib/string_exp/utf8_no_index: FlatBuffer is compatible with UTF-8
Lucas Bajolet [Thu, 7 Aug 2014 16:59:44 +0000 (12:59 -0400)]
lib/string_exp/utf8_no_index: FlatBuffer is compatible with UTF-8

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: AI backtrack
Jean Privat [Mon, 11 Aug 2014 18:06:26 +0000 (14:06 -0400)]
Merge: AI backtrack

The first part of the artificial intelligence library.

This provides a framework for a basic backtracking algorithm.

It is used in a standard 8 queens problem (quite elegant!), but also replace the specific solver in friendz (the new solver is a little faster in fact)

Pull-Request: #642
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agofriendz: add solver_cmd for solve from command line
Jean Privat [Tue, 5 Aug 2014 02:57:35 +0000 (22:57 -0400)]
friendz: add solver_cmd for solve from command line

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agofriendz: use ai::backtrack instead of the ad-hoc solver
Jean Privat [Tue, 5 Aug 2014 02:56:50 +0000 (22:56 -0400)]
friendz: use ai::backtrack instead of the ad-hoc solver

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/ai: add the eight-queen problem as an example
Jean Privat [Tue, 5 Aug 2014 02:34:49 +0000 (22:34 -0400)]
lib/ai: add the eight-queen problem as an example

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/ai: introduce the ai library with `backtrack` as the first module
Jean Privat [Tue, 5 Aug 2014 02:31:05 +0000 (22:31 -0400)]
lib/ai: introduce the ai library with `backtrack` as the first module

For information, the logic is extracted from the solver of friendz.

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/android: Intro of the Android Intent API
Frédéric Vachon [Mon, 4 Aug 2014 23:50:11 +0000 (19:50 -0400)]
lib/android: Intro of the Android Intent API

Signed-off-by: Frédéric Vachon <fredvac@gmail.com>

9 years agoMerge: Compare arrays
Jean Privat [Fri, 8 Aug 2014 22:41:27 +0000 (18:41 -0400)]
Merge: Compare arrays

Improve comparaisons in arrays

Pull-Request: #658
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: lib/trees: improve bintrees efficiency
Jean Privat [Fri, 8 Aug 2014 17:30:31 +0000 (13:30 -0400)]
Merge: lib/trees: improve bintrees efficiency

First, comment potential slow asserts in the hot-path.
These asserts are needed only to check that the implementation is
correct.

Second, use a single `<=>` instead of doing multiple comparisons.
So reduce the total number of comparisons.

On a real instance (IA-related problems), the gain is the following:

RBTreeMap, 8738 insertions, 24855 accesses
Before: 2.54s
After: 0.07s (so, in the noise)

Pull-Request: #653
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agoMerge: Improve Floats perfs
Jean Privat [Fri, 8 Aug 2014 17:30:28 +0000 (13:30 -0400)]
Merge: Improve Floats perfs

Improve perf for those who do not need excessive boxing of floats

Pull-Request: #656
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agoMerge: Reactivate shortcut range
Jean Privat [Fri, 8 Aug 2014 17:30:18 +0000 (13:30 -0400)]
Merge: Reactivate shortcut range

Since transform.nit and the Numeric class (that renamed Discrete::succ into something else) the optimization that shortcut range was innefective.

After reactivating them, Perf increase is approx 5%.

Pull-Request: #657
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agotests: update because line changes in errors.
Jean Privat [Fri, 8 Aug 2014 17:26:48 +0000 (13:26 -0400)]
tests: update because line changes in errors.

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/std: add ArrayCmp to easily compare arrays of comparable elements.
Jean Privat [Fri, 8 Aug 2014 17:23:50 +0000 (13:23 -0400)]
lib/std: add ArrayCmp to easily compare arrays of comparable elements.

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/std: add fast implementation for Array::==
Jean Privat [Fri, 8 Aug 2014 17:23:13 +0000 (13:23 -0400)]
lib/std: add fast implementation for Array::==

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotransform: do not transform rranges in for; this reactivates the short-range optimisation
Jean Privat [Fri, 8 Aug 2014 04:17:59 +0000 (00:17 -0400)]
transform: do not transform rranges in for; this reactivates the short-range optimisation

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: update sav related to lines in kernel
Jean Privat [Fri, 8 Aug 2014 03:11:06 +0000 (23:11 -0400)]
tests: update sav related to lines in kernel

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agocomp: shortcut-range work also on closed ranges
Jean Privat [Fri, 8 Aug 2014 04:15:46 +0000 (00:15 -0400)]
comp: shortcut-range work also on closed ranges

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agocomp: fix shortcut-range (succ was removed)
Jean Privat [Fri, 8 Aug 2014 04:15:08 +0000 (00:15 -0400)]
comp: fix shortcut-range (succ was removed)

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/std: Float has their own `==` and Comparable-related methods
Jean Privat [Fri, 8 Aug 2014 03:09:24 +0000 (23:09 -0400)]
lib/std: Float has their own `==` and Comparable-related methods

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/string_exp/utf8_no_index: Bytelen now defined in Text
Lucas Bajolet [Thu, 7 Aug 2014 16:58:12 +0000 (12:58 -0400)]
lib/string_exp/utf8_no_index: Bytelen now defined in Text

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agolib/string_exp/utf8_no_index: Adapted String methods to UTF-8 string
Lucas Bajolet [Wed, 6 Aug 2014 15:18:14 +0000 (11:18 -0400)]
lib/string_exp/utf8_no_index: Adapted String methods to UTF-8 string

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agolib/string_exp/utf8_no_index: Added char_at, does the same as [] but with UnicodeChar.
Lucas Bajolet [Mon, 4 Aug 2014 16:54:03 +0000 (12:54 -0400)]
lib/string_exp/utf8_no_index: Added char_at, does the same as [] but with UnicodeChar.

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agolib/string_exp/utf8_no_index: Added new constructor for UnicodeChar
Lucas Bajolet [Mon, 4 Aug 2014 16:53:26 +0000 (12:53 -0400)]
lib/string_exp/utf8_no_index: Added new constructor for UnicodeChar

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agolib/string_exp/utf8_no_index: Introducing utf8 variant without indexes
Lucas Bajolet [Mon, 4 Aug 2014 16:52:56 +0000 (12:52 -0400)]
lib/string_exp/utf8_no_index: Introducing utf8 variant without indexes

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: jwrapper: New features added
Jean Privat [Thu, 7 Aug 2014 11:07:08 +0000 (07:07 -0400)]
Merge: jwrapper: New features added

This may be considered as the first release of jwrapper. Here's a list of the new implemented features since the last PR:
* Grep into `lib/android` to retrieve already wrapped classes
* Auto-generate licence
* Basic user interface added
* Choice between :
  * Auto-wrap unknown types
  * Comment methods containing unknown types

Pull-Request: #641
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agolib/trees: improve bintrees efficiency
Jean Privat [Thu, 7 Aug 2014 02:04:46 +0000 (22:04 -0400)]
lib/trees: improve bintrees efficiency

First, comment potential slow asserts in the hot-path.
These asserts are needed only to check that the implementation is
correct.

Second, use a single `<=>` instead of doing multiple comparisons.
So reduce the total number of comparisons.

On a real instance (IA-related problems), the gain is the following:

RBTreeMap, 8738 insertions, 24855 accesses
Before: 2.54s
After: 0.07s (so, in the noise)

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Sys.run
Jean Privat [Thu, 7 Aug 2014 01:24:03 +0000 (21:24 -0400)]
Merge: Sys.run

Add `Sys::run` as the new entry point of programs.
So some modules (eg. platforms) can more easily inject code before or after the execution of programs.

Pull-Request: #652
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agocontrib/jwrapper: Added jwrapper.res to sav
Frédéric Vachon [Mon, 4 Aug 2014 01:42:01 +0000 (21:42 -0400)]
contrib/jwrapper: Added jwrapper.res to sav

Signed-off-by: Frédéric Vachon <fredvac@gmail.com>

9 years agoMerge: Improve hash perfs
Jean Privat [Thu, 7 Aug 2014 01:24:01 +0000 (21:24 -0400)]
Merge: Improve hash perfs

Some improvements.

## nitg nitg.nit
before: 0m9.688s
after: 0m9.172s

## ./nit naive_interpreter.nit
usage of HashCollection before:
average length: 128.41
average capacity: 294.06 (229.01%)
average number of collisions: 113571 (35.27%)
average length of collision: 3.74

usage of HashCollection after:
average length: 128.40
average capacity: 327.42 (255.00%)
average number of collisions: 62608 (19.44%)
average length of collision: 2.29

All this is needed for the ai library

Pull-Request: #651
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>