compiler: do not create empty .h file

Signed-off-by: Jean Privat <jean@pryen.org>
compiler: add option --max-c-lines

Signed-off-by: Jean Privat <jean@pryen.org>
compile: use shortest path from the compiledir to the outname

Signed-off-by: Jean Privat <jean@pryen.org>
compile: remove clib from the -I dir because the usufull files are already copied

Signed-off-by: Jean Privat <jean@pryen.org>
compile: add option --group-c-files

Signed-off-by: Jean Privat <jean@pryen.org>
compile: also generates a makefile named Makefile

Signed-off-by: Jean Privat <jean@pryen.org>
compiler: introduce `AAttrPropdef::evaluate_expr` to factorize the compilation of default values

Signed-off-by: Jean Privat <jean@pryen.org>
tools: accept statement block in attributes

Signed-off-by: Jean Privat <jean@pryen.org>
modelize: introduce `AAttrPropdef::has_value`

Signed-off-by: Jean Privat <jean@pryen.org>
tests: add base_attr_init_val_block.nit

Signed-off-by: Jean Privat <jean@pryen.org>
semantize: move noinit attribute to `AAttrPropdef::build_property`

Signed-off-by: Jean Privat <jean@pryen.org>
modelize: handle `autoinit` on attributes

Signed-off-by: Jean Privat <jean@pryen.org>
tests: add base_init_autoinit2.nit

Signed-off-by: Jean Privat <jean@pryen.org>
mkcsrc: rewrite a simplified version

Signed-off-by: Jean Privat <jean@pryen.org>
.gitattributes: nodiff all c_src

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

Allow `autoinit` on attributes.

This means that the initialization of the attribute is done during the initializer phase.
This will help when the initial value of an attribute depend on the value of another attribute set a the initializer phase.

So that

~~~
class A
   var x: String
   var y: String = x + " world!"
end
var a = new A("hello") # BOOM! uninitialized x while initializing y
print a.y
~~~

Can become:

~~~
class A
   var x: String
   var y: String = x + " world!" is autoinit
end
var a = new A("hello")
print a.y # => hello world!
~~~

The inconvenient is that the initialisation markers of attributes become more complex.
Now we have:

* no default value and no special annotation: the setter is collected as an initializer
* no default value and `noinit`: not automatically initialized
* default value and no special annotation: the value is set between the allocation and all initializers
* default value and annotation `lazy`: the value is set at the first access
* *new* default value and annotation `autoinit`: the value is set with all other initializers (other `autoinit`)

For an implementation explanation, the mechanism is a quick hack: `autoinit` means `lazy` + the getter is collector as an initializer. Therefore, when initializers are invoked, the getter will be invoked and the value lazily evaluated.

So the example is equivalent to

~~~
class A
   var x: String
   var y: String = x + " world!" is lazy
end
var a = ALLOCATE(A)
a.x = "hello" # collected setter for x
a.y # lazy getter for y
a.init
print a.y # => hello world!
~~~

Pull-Request: #857
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Merge: Attribute block

As promised in #832, here the attribute initialized with a block instead of a simple expression.

The syntax is quite strange but nobody complained in #832.
The final value is returned with a `return` and the `do` block follows optional annotation to look like the definition of methods.

`lazy` and all other annotations on attributes should works as expected.

~~~
class A
   var foo: String do return "Hello"
   var bar: String is lazy do
      return foo + ", world!"
   end
end
var a = new A
print a.bar # => hello, world!
~~~

Pull-Request: #858
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Merge: Distribuable compiledir

Unfortunately, Nit is not yet available everywhere.
Therefore, in order to be able to distribute or deploy Nit programs, one easy way is to distribute the generated C code.

This is what we already do with `c_src` that contains modified C code from the compilation of nith.

This PR generalize the approach and allow the compiler to produce some neat and distributable .compile_dir.
Look at the new `mkcsrc` to see how things are simpler now.

Example, you want to disribute `hello_world`:

~~~sh
$ nitg examples/hello_world.nit --semi-global --no-cc --dir hello --compile-dir hello
$ ls -l hello
abstract_collection.sep.0.h
abstract_collection.sep.1.c
array.sep.0.h
array.sep.1.c
c_functions_hash.c
c_functions_hash.h
file_nit.c
file_nit.h
file.sep.0.h
file.sep.1.c
gc_chooser.c
gc_chooser.h
hello_world.classes.0.h
hello_world.classes.1.c
hello_world.main.0.h
hello_world.main.1.c
hello_world.mk
hello_world.sep.0.h
hello_world.sep.1.c
hello_world.types.0.h
hello_world.types.1.c
kernel.sep.0.h
kernel.sep.1.c
Makefile
math_nit.h
math.sep.0.h
math.sep.1.c
nit.common.h
stream.sep.0.h
stream.sep.1.c
string_nit.c
string_nit.h
string.sep.0.h
string.sep.1.c
$ cd hello
$ make
ccache cc -g -O2 -Wno-unused-value -Wno-switch  -c -o hello_world.classes.1.o hello_world.classes.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch  -c -o hello_world.main.1.o hello_world.main.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch  -c -o hello_world.sep.1.o hello_world.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch  -c -o string.sep.1.o string.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch  -c -o math.sep.1.o math.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch  -c -o kernel.sep.1.o kernel.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch  -c -o abstract_collection.sep.1.o abstract_collection.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch  -c -o array.sep.1.o array.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch  -c -o file.sep.1.o file.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch  -c -o stream.sep.1.o stream.sep.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch  -c -o hello_world.types.1.o hello_world.types.1.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch  -c -o string_nit.extern.o string_nit.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch  -c -o file_nit.extern.o file_nit.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch  -c -o c_functions_hash.extern.o c_functions_hash.c
ccache cc -g -O2 -Wno-unused-value -Wno-switch -DWITH_LIBGC -c -o gc_chooser.extern.o gc_chooser.c
ccache cc  -o hello_world hello_world.classes.1.o hello_world.main.1.o hello_world.sep.1.o string.sep.1.o math.sep.1.o kernel.sep.1.o abstract_collection.sep.1.o array.sep.1.o file.sep.1.o stream.sep.1.o hello_world.types.1.o string_nit.extern.o file_nit.extern.o c_functions_hash.extern.o gc_chooser.extern.o -lm -lgc  -lunwind
$ ./hello_world
hello world
~~~

Pull-Request: #860
lib/android: hacks to fix new_global_ref awaiting a fix for #845

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

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