interpreter: add Interpreter::string_instance

Signed-off-by: Jean Privat <jean@pryen.org>
engines: do not crash on AST-less mclassdef

Signed-off-by: Jean Privat <jean@pryen.org>
modelbuilder: node is optionnal in Modelbuilder::force_get_primitive_method

Signed-off-by: Jean Privat <jean@pryen.org>
compiler: add Visitor::bool_instance

Signed-off-by: Jean Privat <jean@pryen.org>
toolcontext: introduce ToolContext::make_main_module

Signed-off-by: Jean Privat <jean@pryen.org>
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>
compiler: do not use the outnames of fictive modules

Signed-off-by: Jean Privat <jean@pryen.org>
src: new module mixin to factorize the -m option

Signed-off-by: Jean Privat <jean@pryen.org>
mixin: introduce -D option to redefine functions from the command-line

Signed-off-by: Jean Privat <jean@pryen.org>
tests: test --define in engines

Signed-off-by: Jean Privat <jean@pryen.org>
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>
ast: add new node AEscapeExpr to generalizes ABreakExpr and AContinueExpr

Signed-off-by: Jean Privat <jean@pryen.org>
tests: update error_needed_method for niti

Signed-off-by: Jean Privat <jean@pryen.org>
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>
src: remove some warnings and do some cleaning

Signed-off-by: Jean Privat <jean@pryen.org>
typing: refactor type adaptations in AEqExpr and ANeExpr

Signed-off-by: Jean Privat <jean@pryen.org>
typing: new warning useless-null-test that detect == and != between non-nullables and null

Signed-off-by: Jean Privat <jean@pryen.org>
src: remove useless comparisons on null

Signed-off-by: Jean Privat <jean@pryen.org>
lib: remove useless comparison on null that broke tests

Signed-off-by: Jean Privat <jean@pryen.org>
tests: update some tests related to useless-null-test

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