nit.git
9 years agomodel-clients: use `is_root_init` instead of `.name == "init"`
Jean Privat [Fri, 17 Oct 2014 09:57:22 +0000 (05:57 -0400)]
model-clients: use `is_root_init` instead of `.name == "init"`

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

9 years agoMerge: Some gammar improvements
Jean Privat [Wed, 22 Oct 2014 22:45:27 +0000 (18:45 -0400)]
Merge: Some gammar improvements

A bunch of unrelated grammar work: bugfixes, a feature and stuff for future work.

The only implemented feature is the use of extended method identifiers in annotation (setters and operators)

~~~nit
class A
   var foo: String is writable(real_foo=)
   fun foo=(f: String) do
      print "Hello!"
      real_foo = f
   end
end
~~~

Some additional syntax for future works are now accepted but are ignored (or will crash at compile-time).

* user defined factories in class (eg. define `new` in interface)

~~~
interface Buffer
   new do return new FlatBuffer
end
var x = new Buffer
~~~

* code-block in attributes. when the default/lazy value is more complex than a single expression

~~~
class A
   var foo: Int do
      print "Hello!"
      return 5
   end
end
~~~

* generalized tuples. eg. for multiple returns, but more word is needed #839

~~~
fun foo(a,b: Int)
do
   return (a/b, a%b)
end
~~~

In fact, generalized tuples accepts anything that annotations accepts... (eventually they will be rejected just after parsing)

~~~
var x = (1, Array[Int], for x in a do print x, toto=, -)
# in order: a literal expression, a type, a statement, a method identifier (setter),
# an other method identifier (the minus operator)
~~~

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

9 years agotests: update tests because the parser gets better to parse arbitrary things.
Jean Privat [Wed, 22 Oct 2014 14:24:46 +0000 (10:24 -0400)]
tests: update tests because the parser gets better to parse arbitrary things.

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

9 years agoparser: regenerate
Jean Privat [Tue, 21 Oct 2014 23:52:03 +0000 (19:52 -0400)]
parser: regenerate

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

9 years agogrammar: allows blocks in attribute definitions
Jean Privat [Tue, 21 Oct 2014 23:45:22 +0000 (19:45 -0400)]
grammar: allows blocks in attribute definitions

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

9 years agogrammar: accepts new-factory with code
Jean Privat [Fri, 17 Oct 2014 09:55:28 +0000 (05:55 -0400)]
grammar: accepts new-factory with code

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

9 years agoannotation: `as_id` works with operators and setters
Jean Privat [Fri, 17 Oct 2014 02:44:18 +0000 (22:44 -0400)]
annotation: `as_id` works with operators and setters

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

9 years agoparser: generalise Prod::collect_text
Jean Privat [Fri, 17 Oct 2014 02:43:25 +0000 (22:43 -0400)]
parser: generalise Prod::collect_text

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

9 years agoast: accept methodid in at_args
Jean Privat [Fri, 17 Oct 2014 02:33:37 +0000 (22:33 -0400)]
ast: accept methodid in at_args

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

9 years agogrammar: add qmethid for qualified methid id
Jean Privat [Fri, 17 Oct 2014 02:24:40 +0000 (22:24 -0400)]
grammar: add qmethid for qualified methid id

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

9 years agoMerge: neo: Add `MAttributeDef.static_type` in the graph.
Jean Privat [Tue, 21 Oct 2014 23:42:20 +0000 (19:42 -0400)]
Merge: neo: Add `MAttributeDef.static_type` in the graph.

Pull-Request: #838
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

9 years agoneo: Add `MAttributeDef.static_type` in the graph.
Jean-Christophe Beaupré [Mon, 20 Oct 2014 17:40:59 +0000 (13:40 -0400)]
neo: Add `MAttributeDef.static_type` in the graph.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

9 years agoMerge: Fix the old bug where (-0.1).to_s == "0.-1"
Jean Privat [Mon, 20 Oct 2014 13:48:17 +0000 (09:48 -0400)]
Merge: Fix the old bug where (-0.1).to_s == "0.-1"

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

9 years agoMerge: neo: correct the documentation of neo.nit according to PR #781.
Jean Privat [Mon, 20 Oct 2014 13:48:12 +0000 (09:48 -0400)]
Merge: neo: correct the documentation of neo.nit according to PR #781.

PR #781 changed the model, but not the documentation of neo.nit.

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

9 years agoMerge: Small compiler things
Jean Privat [Mon, 20 Oct 2014 13:47:55 +0000 (09:47 -0400)]
Merge: Small compiler things

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

9 years agoMerge: file: Fix `join_path` to handle paths ending with a slash.
Jean Privat [Mon, 20 Oct 2014 13:47:50 +0000 (09:47 -0400)]
Merge: file: Fix `join_path` to handle paths ending with a slash.

That way, we no longer need to manually remove the trailing slash before calling `join_path`.

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

9 years agotests: update savs for tests using the previously broken to_precision
Alexis Laferrière [Fri, 17 Oct 2014 15:36:06 +0000 (11:36 -0400)]
tests: update savs for tests using the previously broken to_precision

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

9 years agolib/standard: fix `Float::to_precision`
Alexis Laferrière [Sun, 12 Oct 2014 05:16:00 +0000 (01:16 -0400)]
lib/standard: fix `Float::to_precision`

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

9 years agoneo: correct the documentation of neo.nit according to PR #781.
Jean-Christophe Beaupré [Fri, 17 Oct 2014 14:41:12 +0000 (10:41 -0400)]
neo: correct the documentation of neo.nit according to PR #781.

PR #781 changed the model, but not the documentation of neo.nit.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

9 years agoabstract_compiler: prefers implementing expr than stmt in assignments
Jean Privat [Fri, 17 Oct 2014 02:57:07 +0000 (22:57 -0400)]
abstract_compiler: prefers implementing expr than stmt in assignments

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

9 years agoabstract_compiler: default stmt implmentation do not need to execute variables as...
Jean Privat [Fri, 17 Oct 2014 02:56:17 +0000 (22:56 -0400)]
abstract_compiler: default stmt implmentation do not need to execute variables as statments

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

9 years agoparser: add tuples
Jean Privat [Thu, 16 Oct 2014 04:18:04 +0000 (00:18 -0400)]
parser: add tuples

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

9 years agoast: remove classes AAtArg and make them simple AExpr
Jean Privat [Thu, 16 Oct 2014 01:18:46 +0000 (21:18 -0400)]
ast: remove classes AAtArg and make them simple AExpr

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

9 years agoMerge: Robust debug
Jean Privat [Fri, 17 Oct 2014 00:21:34 +0000 (20:21 -0400)]
Merge: Robust debug

First pass on the debugger, simple cleanup/fixes that might be helpful for the end-user.

Addresses some of the issues mentioned in #742.

Pull-Request: #822
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Brainfuck
Jean Privat [Fri, 17 Oct 2014 00:21:14 +0000 (20:21 -0400)]
Merge: Brainfuck

As the name implies, this is a very simple Brainfuck interpreter written in Nit.

Yes, it is (mostly) useless, but it might serve as an example of a simple Nit program.

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

9 years agoMerge: src: remove two TODO that are done/unneeded
Jean Privat [Fri, 17 Oct 2014 00:21:10 +0000 (20:21 -0400)]
Merge: src: remove two TODO that are done/unneeded

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

9 years agoMerge: Better varargs
Jean Privat [Fri, 17 Oct 2014 00:20:53 +0000 (20:20 -0400)]
Merge: Better varargs

since their introduction in Nit, varargs had a quick and dirty implementation.
They where implemented with a complex path in the low-level parts of engine instead being implemented at  the AST level as it should be: varargs is more a syntactic sugar than something else.

Thus this PR changes the implementation of varargs in the engines.
This rationalize the `varargize` methods and simplify the code for low-level part (and also solve some bugs)

Additionally, the reverse-vararg, already accepted by the parser but unused until now, is implemented.
The principle it to pass an array where a vararg is expected.
Because of static ambiguities, the array passed as-is must be annotated with an ellipsis (`...`).

~~~nit
fun foo (xs: Object...) do print x.join("-")
foo(1,2,3) # prints "1-2-3"
var a = [1,2,3]
foo(a...) # prints "1-2-3"
foo(a) # pass `[a]`, a new array with a single element `a`, to foo, thus prints "123"
foo(1...) # Static Type Error: expected Array[Object], got Int.
~~~

Still, I think that error messages should be improved (cf. #98) but this seems to need some additional work in the error infrastructure.

A remaining question is what is the best acceptable type passed.
In the proposed implementation, the reverse-vararg must be a compatible Array (so a Sequence or a List are not accepted) and is given as is to the real method, that is allowed to modify it.
Should we change the type on a vararg to be a Sequence, a SequenceRead, of even a simple Collection ?

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

9 years agotests: add base_vararg3.nit
Jean Privat [Wed, 15 Oct 2014 18:53:16 +0000 (14:53 -0400)]
tests: add base_vararg3.nit

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

9 years agotyping+engines: handle reverse-vararg: passing an array as-is.
Jean Privat [Wed, 15 Oct 2014 14:46:39 +0000 (10:46 -0400)]
typing+engines: handle reverse-vararg: passing an array as-is.

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

9 years agofile: Fix `join_path` to handle paths ending with a slash.
Jean-Christophe Beaupré [Thu, 16 Oct 2014 18:16:52 +0000 (14:16 -0400)]
file: Fix `join_path` to handle paths ending with a slash.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

9 years agobrainfuck: Added a simple Brainfuck interpreter
Lucas Bajolet [Wed, 15 Oct 2014 18:15:59 +0000 (14:15 -0400)]
brainfuck: Added a simple Brainfuck interpreter

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

9 years agogrammar: minus and once do not need nopar variants
Jean Privat [Thu, 16 Oct 2014 00:29:19 +0000 (20:29 -0400)]
grammar: minus and once do not need nopar variants

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

9 years agosrc: remove two TODO that are done/unneeded
Jean Privat [Thu, 16 Oct 2014 00:22:02 +0000 (20:22 -0400)]
src: remove two TODO that are done/unneeded

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

9 years agoMerge: Manpages
Jean Privat [Wed, 15 Oct 2014 20:16:01 +0000 (16:16 -0400)]
Merge: Manpages

~~~sh
$ man nitg
~~~

A dream come true.

More seriously, toolcontext is extended to be able to generate manpages (in a similar way than completion).
Then a bunch of manpages is generated.

The content of the manpages should be improved but this is better than nothing.

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

9 years agoMerge: transform loops
Jean Privat [Wed, 15 Oct 2014 20:15:47 +0000 (16:15 -0400)]
Merge: transform loops

In order to activate more optimizations and simplify code generators and analysis, the `while` and `for` loops must be transformed into simpler forms (in fact in complex forms but with simpler elements)

However, to do such a transformation, the escaping mechanism (break/continue/goto) must be rewrote.
Previously, for each loop control structure (loop for, while), a single EscapeMark was generated and breaks and continues are associated to the same mark, even if they branch in distinct points (so each escapemark had 2 branching mechanisms)
Now, with the first commits, two escapemarks are generated for each loop control structure, and breaks and continues are associated to a different one. The advantage is that each mark only have a single branching mechanism and that once associated to their mark, there is no need to distinguish break and continue (both become simple gotos).

The transformations of loops can be then implemented.

The `while`

~~~
while cond do block
~~~

is transformed into

~~~
loop if cond then block else break
~~~

and `for`

~~~
for i in col do block
~~~

is transformed into

~~~
var it = col.iterator
loop
   if it.is_ok then
      var i = it.item
      do block
      # ^ `continue` in the block it attached to the `do`
      # this is why the transformation of escape-marks where needed in fact.
      # and break is associated to the main loop
      it.next
   else
      break
   end
end
it.finish
~~~

Note that these transformations are basically what is currently implemented in rta, niti and nitg. Except that, now with a single transformation point, those three workers does not need to do their own transformation and basically can just rely on the one done on the AST level.

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

9 years agoMerge: console: use snake case.
Jean Privat [Wed, 15 Oct 2014 20:13:33 +0000 (16:13 -0400)]
Merge: console: use snake case.

Correct a little mistake.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

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

9 years agoshare: generate stubs for manpages
Jean Privat [Wed, 15 Oct 2014 19:04:52 +0000 (15:04 -0400)]
share: generate stubs for manpages

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

9 years agotests: update sav/test_toolcontext_args*.res
Jean Privat [Wed, 15 Oct 2014 01:59:06 +0000 (21:59 -0400)]
tests: update sav/test_toolcontext_args*.res

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

9 years agotoolcontext: add --stub-man
Jean Privat [Mon, 6 Oct 2014 12:48:32 +0000 (08:48 -0400)]
toolcontext: add --stub-man

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

9 years agotransform: move up shortcut-range from abstract_compiler to transform
Jean Privat [Sat, 11 Oct 2014 15:15:28 +0000 (11:15 -0400)]
transform: move up shortcut-range from abstract_compiler to transform

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

9 years agotransform: shortcut range
Jean Privat [Sat, 11 Oct 2014 15:11:48 +0000 (11:11 -0400)]
transform: shortcut range

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

9 years agotransform: transforms `while` and `for`
Jean Privat [Sat, 11 Oct 2014 04:28:37 +0000 (00:28 -0400)]
transform: transforms `while` and `for`

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

9 years agoastbuilder: can make loops and breaks
Jean Privat [Sat, 11 Oct 2014 04:27:47 +0000 (00:27 -0400)]
astbuilder: can make loops and breaks

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

9 years agoscope: create two escapemaks in loops
Jean Privat [Sat, 11 Oct 2014 02:33:38 +0000 (22:33 -0400)]
scope: create two escapemaks in loops

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

9 years agoglobal_compiler: remove useless methods since varargisation is done at the AST level
Jean Privat [Wed, 15 Oct 2014 14:39:18 +0000 (10:39 -0400)]
global_compiler: remove useless methods since varargisation is done at the AST level

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

9 years agocompiler: do the varargization in the ANodes
Jean Privat [Wed, 15 Oct 2014 14:38:11 +0000 (10:38 -0400)]
compiler: do the varargization in the ANodes

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

9 years agointerpreter: remove useless methods `*call_without_varargs`
Jean Privat [Wed, 15 Oct 2014 14:30:34 +0000 (10:30 -0400)]
interpreter: remove useless methods `*call_without_varargs`

since varargs is now done at the AST level.

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

9 years agointerpreter: do the varargization in the ANodes
Jean Privat [Wed, 15 Oct 2014 14:29:20 +0000 (10:29 -0400)]
interpreter: do the varargization in the ANodes

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

9 years agoconsole: use snake case.
Jean-Christophe Beaupré [Wed, 15 Oct 2014 14:18:40 +0000 (10:18 -0400)]
console: use snake case.

Correct a little mistake.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

9 years agodebugger: Simplified names and integrate bad_command/help functions
Lucas Bajolet [Tue, 14 Oct 2014 19:04:07 +0000 (15:04 -0400)]
debugger: Simplified names and integrate bad_command/help functions

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

Conflicts:
src/interpreter/debugger.nit

9 years agodebugger: Added help/bad_command functions
Lucas Bajolet [Thu, 9 Oct 2014 18:59:37 +0000 (14:59 -0400)]
debugger: Added help/bad_command functions

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

9 years agodebugger: Removed module Breakpoint, moved Breakpoint class to debugger module
Lucas Bajolet [Thu, 9 Oct 2014 18:14:05 +0000 (14:14 -0400)]
debugger: Removed module Breakpoint, moved Breakpoint class to debugger module

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

9 years agolib/standard: improve documentation of `Float::to_s`
Alexis Laferrière [Sun, 12 Oct 2014 05:15:22 +0000 (01:15 -0400)]
lib/standard: improve documentation of `Float::to_s`

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

9 years agoMerge: src: remove some warnings and do some cleaning
Jean Privat [Mon, 13 Oct 2014 17:40:08 +0000 (13:40 -0400)]
Merge: src: remove some warnings and do some cleaning

Extracted from the first version of #817

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

9 years agoMerge: new warning: useless null test
Jean Privat [Mon, 13 Oct 2014 17:40:05 +0000 (13:40 -0400)]
Merge: new warning: useless null test

So, detect things like

~~~nit
var a = "Hello"
if a != null then print a
#   ^ useless null test!
~~~

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

9 years agotests: update some tests related to useless-null-test
Jean Privat [Sat, 11 Oct 2014 13:35:57 +0000 (09:35 -0400)]
tests: update some tests related to useless-null-test

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

9 years agolib: remove useless comparison on null that broke tests
Jean Privat [Sat, 11 Oct 2014 17:22:24 +0000 (13:22 -0400)]
lib: remove useless comparison on null that broke tests

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

9 years agosrc: remove useless comparisons on null
Jean Privat [Sat, 11 Oct 2014 00:39:38 +0000 (20:39 -0400)]
src: remove useless comparisons on null

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

9 years agotyping: new warning useless-null-test that detect == and != between non-nullables...
Jean Privat [Sat, 11 Oct 2014 16:31:00 +0000 (12:31 -0400)]
typing: new warning useless-null-test that detect == and != between non-nullables and null

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

9 years agotyping: refactor type adaptations in AEqExpr and ANeExpr
Jean Privat [Sat, 11 Oct 2014 00:41:16 +0000 (20:41 -0400)]
typing: refactor type adaptations in AEqExpr and ANeExpr

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

9 years agosrc: remove some warnings and do some cleaning
Jean Privat [Sat, 11 Oct 2014 01:24:36 +0000 (21:24 -0400)]
src: remove some warnings and do some cleaning

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

9 years agoMerge: new option --define
Jean Privat [Sat, 11 Oct 2014 12:24:15 +0000 (08:24 -0400)]
Merge: new option --define

It is standard in compiled programs to be able to setup some program configuration at compile-time.

Eg. C compilers accept a command-line option `-D` to define macros that will be used inside programs.
It is useful for configuring some string (like `-D PREFIX=/opt/nit/`, or `-D PORT=8081`) or activate some parts (conditional compilation, eg `-D WITH_SSL`).

This PR brings an equivalent capability to Nit engines through the new `-D` (`--define`) option.

The design behind the -D it to enable specific refinement of top-level functions at link-time.
Thus, basically

~~~sh
$ cat my_foo.nit
import foo
redef fun prefix do return "/opt/nit/"
$ nitg my_foo.nit
~~~

can be simplified into

~~~sh
$ nitg foo.nit -D prefix=/opt/nit/
~~~

Like `-m`, the `-D` creates a fictive module that refines the main module of the program.

`-D` also use the return type of the refined method to know how to interpret the text of the value.
Currently only Int, String and Bool is supported.

~~~nit
module foo
fun str: String do return "test"
fun num: Int do return 1
fun flag: Bool do return false
print str
print num
print flag
~~~

~~~sh
$ nitg foo.nit
$ ./foo
test
1
false
$ nitg foo.nit -D str=hello -D num=42 -D flag
$ ./foo
hello
42
true
~~~

The code of the PR is quite straightforward and show again that the new model is quite robust.

As usual, the first commits are some cleanup. The fun stuff is in the latter commits.

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

9 years agotests: update error_needed_method for niti
Jean Privat [Sat, 11 Oct 2014 12:23:33 +0000 (08:23 -0400)]
tests: update error_needed_method for niti

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

9 years agoast: add new node AEscapeExpr to generalizes ABreakExpr and AContinueExpr
Jean Privat [Sat, 11 Oct 2014 02:32:26 +0000 (22:32 -0400)]
ast: add new node AEscapeExpr to generalizes ABreakExpr and AContinueExpr

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

9 years agoMerge: console: Offer a more reliable API.
Jean Privat [Sat, 11 Oct 2014 00:03:32 +0000 (20:03 -0400)]
Merge: console: Offer a more reliable API.

The old API is error-prone when combining two character attributes.

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

9 years agotests: test --define in engines
Jean Privat [Fri, 10 Oct 2014 22:54:42 +0000 (18:54 -0400)]
tests: test --define in engines

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

9 years agomixin: introduce -D option to redefine functions from the command-line
Jean Privat [Fri, 10 Oct 2014 02:09:12 +0000 (22:09 -0400)]
mixin: introduce -D option to redefine functions from the command-line

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

9 years agosrc: new module mixin to factorize the -m option
Jean Privat [Fri, 10 Oct 2014 02:07:03 +0000 (22:07 -0400)]
src: new module mixin to factorize the -m option

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

9 years agocompiler: do not use the outnames of fictive modules
Jean Privat [Fri, 10 Oct 2014 02:05:26 +0000 (22:05 -0400)]
compiler: do not use the outnames of fictive modules

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

9 years agoconsole: Offer a more reliable API.
Jean-Christophe Beaupré [Wed, 8 Oct 2014 18:39:52 +0000 (14:39 -0400)]
console: Offer a more reliable API.

The old API is error-prone when combining two character attributes.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

9 years agoMerge: tests: detect and use portable time and date command
Jean Privat [Fri, 10 Oct 2014 13:08:31 +0000 (09:08 -0400)]
Merge: tests: detect and use portable time and date command

Advanced behavior of `time` and `date` is not protable. Thus try
to detect known working configurations and use them.

time and date are not fundamental for tests, so having
an unsupported implementation is not a big deal.

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

9 years agoMerge: introduce `Iterator::finish`
Jean Privat [Fri, 10 Oct 2014 13:08:30 +0000 (09:08 -0400)]
Merge: introduce `Iterator::finish`

While initially playing with for_abuse, an idea was to have the lib informed of an "end of iteration".

When the end of iteration was a result of `is_ok` false, it is easy for the lib to be informed.
But, if for some reason the client chose to abort the loop (with a `break` statement), the lib cannot be informed and some early release of resources cannot occurs.

This PR introduce a new optional service in iterators, namely `finish` that is automatically called at the end of `for` structures.

Currently, there is no user of such a function, but it is a POC that can be used for a nit-version of a `with` structure to implements for_abuse-like controls.

~~~nit
# Simple implementation of the `head` command
var head_limit = 10
for line in read_lines("some file") do
  # `read_lines` opens and reads each line
  head_limit -= 1
  if head_limit < 0 then break
  print line
end
# Here the file is automatically closed thanks to finish
~~~

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

9 years agoMerge: Fix test of for abuse
Jean Privat [Fri, 10 Oct 2014 13:08:28 +0000 (09:08 -0400)]
Merge: Fix test of for abuse

Some cleaning of the for_abuse test.

A future PR will improve things.

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

9 years agotoolcontext: introduce ToolContext::make_main_module
Jean Privat [Fri, 10 Oct 2014 02:04:50 +0000 (22:04 -0400)]
toolcontext: introduce ToolContext::make_main_module

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

9 years agocompiler: add Visitor::bool_instance
Jean Privat [Fri, 10 Oct 2014 01:49:22 +0000 (21:49 -0400)]
compiler: add Visitor::bool_instance

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

9 years agomodelbuilder: node is optionnal in Modelbuilder::force_get_primitive_method
Jean Privat [Fri, 10 Oct 2014 01:46:32 +0000 (21:46 -0400)]
modelbuilder: node is optionnal in Modelbuilder::force_get_primitive_method

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

9 years agoengines: do not crash on AST-less mclassdef
Jean Privat [Fri, 10 Oct 2014 00:21:01 +0000 (20:21 -0400)]
engines: do not crash on AST-less mclassdef

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

9 years agointerpreter: add Interpreter::string_instance
Jean Privat [Fri, 10 Oct 2014 00:19:37 +0000 (20:19 -0400)]
interpreter: add Interpreter::string_instance

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

9 years agotests: detect and use portable time and date command
Jean Privat [Thu, 9 Oct 2014 17:39:52 +0000 (13:39 -0400)]
tests: detect and use portable time and date command

Advanced behavior of `time` and `date` is not protable. Thus try
to detect known working configurations and use them.

time and date are not fundamental for tests, so having
an unsupported implementation is not a big deal.

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

9 years agoMerge: Tester over MPI
Jean Privat [Thu, 9 Oct 2014 03:32:01 +0000 (23:32 -0400)]
Merge: Tester over MPI

On turing, running `mpirun -np 120 ../nitester --engine nitg-s,nitg-g,nitg-sg,nitg-e,niti ../src/nit*.nit ../examples/*.nit *.nit` from the `tests` directory takes 2m 46s on 120 processors to evaluate 9003 programs/engine combinations. On a single processor, the same work takes over 2 hours.

# Results (for the execution specified above)

* 9003 total test programs
* 5728 oks & 0ks
* 1245 fails (a lot of libraries and SDKs are missing)
* 175 no savs
* 191 fixmes
* 1494 sosos
* 125 skips
* 45 unknowns (unsupported results: skip soso, changed, etc.)

# Features and todo

- [x] Uses OpenMPI
- [x] Supports all engines through tests.sh
- [x] Collects and classify results
- [x] Works on the Turing cluster
- [x] Optimized to avoid overloading NFS
- [ ] Correctly detect the all the results (no more unknowns)
- [ ] Use with Jenkins (see what we can do with the generated XML files)
- [ ] Gather and keep failed results temporary files
- [ ] Be more customizable to run on different clusters
- [ ] Integrate some features from tests.sh

Pull-Request: #807
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agoast: kill AProxyExpr
Jean Privat [Thu, 9 Oct 2014 02:44:10 +0000 (22:44 -0400)]
ast: kill AProxyExpr

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

9 years agogrammar: remove useless production expr_final
Jean Privat [Thu, 9 Oct 2014 01:17:43 +0000 (21:17 -0400)]
grammar: remove useless production expr_final

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

9 years agogrammar: remove no before comma in idlist
Jean Privat [Thu, 9 Oct 2014 01:07:48 +0000 (21:07 -0400)]
grammar: remove no before comma in idlist

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

9 years agotests: add base_for_finish
Jean Privat [Thu, 9 Oct 2014 00:35:19 +0000 (20:35 -0400)]
tests: add base_for_finish

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

9 years agolib/standard: introduce *Iterator::finish
Jean Privat [Thu, 9 Oct 2014 00:29:21 +0000 (20:29 -0400)]
lib/standard: introduce *Iterator::finish

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

9 years agocompiler: implements method_finish (partially)
Jean Privat [Thu, 9 Oct 2014 00:21:07 +0000 (20:21 -0400)]
compiler: implements method_finish (partially)

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

9 years agointerpreter: implements method_finish
Jean Privat [Thu, 9 Oct 2014 00:18:06 +0000 (20:18 -0400)]
interpreter: implements method_finish

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

9 years agotyping: add AForExpr::method_finish
Jean Privat [Thu, 9 Oct 2014 00:17:25 +0000 (20:17 -0400)]
typing: add AForExpr::method_finish

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

9 years agotyping: add method try_get_method
Jean Privat [Thu, 9 Oct 2014 00:16:45 +0000 (20:16 -0400)]
typing: add method try_get_method

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

9 years agoMerge: Opportunity
Jean Privat [Wed, 8 Oct 2014 22:00:25 +0000 (18:00 -0400)]
Merge: Opportunity

Intoducing Opportunity, a Meetup planifier (or planner, if we listen to @xymus, will correct that along with your remarks).

So, here's the long awaited Opportunity that will be the cornerstone of every ~~nutritious breakfast~~ Latece weekly seminar.

Maybe more once finished, let's conquer the world with Nit's amazing abilities for easy web development.

Also, a function was missing from SQLite, I needed it so, here it is as well.

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

9 years agotests: improve and fix test_for_abuse.nit
Jean Privat [Wed, 8 Oct 2014 20:18:43 +0000 (16:18 -0400)]
tests: improve and fix test_for_abuse.nit

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

9 years agolib/file: fix IFStream::close
Jean Privat [Wed, 8 Oct 2014 20:18:14 +0000 (16:18 -0400)]
lib/file: fix IFStream::close

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

9 years agocontrib: intro nitester, a tester of Nit engines using MPI
Alexis Laferrière [Fri, 4 Jul 2014 16:01:31 +0000 (12:01 -0400)]
contrib: intro nitester, a tester of Nit engines using MPI

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

9 years agoMerge: Can refine inits
Jean Privat [Wed, 8 Oct 2014 17:30:56 +0000 (13:30 -0400)]
Merge: Can refine inits

Bugfix where a redefined init constructor in a refined class loses its initializers.

This is a fast fix. A cleaner and more generalized approach may be developed latter.

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

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

9 years agotests: add base_init_auto_refine
Jean Privat [Tue, 7 Oct 2014 18:00:48 +0000 (14:00 -0400)]
tests: add base_init_auto_refine

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

9 years agomodelize_property: inherit the initializers in the refinements of init
Jean Privat [Tue, 7 Oct 2014 18:00:11 +0000 (14:00 -0400)]
modelize_property: inherit the initializers in the refinements of init

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

9 years agojenkins: Added opportunity to Jenkins paths
Lucas Bajolet [Wed, 8 Oct 2014 14:54:41 +0000 (10:54 -0400)]
jenkins: Added opportunity to Jenkins paths

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

9 years agoopportunity: Added Makefile and README
Lucas Bajolet [Tue, 7 Oct 2014 14:19:04 +0000 (10:19 -0400)]
opportunity: Added Makefile and README

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

9 years agocontrib/opportunity: Added tests for opportunity
Lucas Bajolet [Tue, 30 Sep 2014 20:24:19 +0000 (16:24 -0400)]
contrib/opportunity: Added tests for opportunity

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

9 years agocontrib: Intro Opportunity, a meetup planner in Nit
Lucas Bajolet [Mon, 29 Sep 2014 21:19:49 +0000 (17:19 -0400)]
contrib: Intro Opportunity, a meetup planner in Nit

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