modelbuilder: simplify the call of `add_in_hierarchy`

We have all the needed model information, moreover, it is more
robust than using the AST

Signed-off-by: Jean Privat <jean@pryen.org>
modelbuilder: mclass2nclassdef registers the first occurrence of a class

The first one is the good one.

Signed-off-by: Jean Privat <jean@pryen.org>
modelbuilder: `build_a_mclassdef` reuse existing mclassdefs

In a module, a second AClassdef of a given class, that is valid for
implicit Object and implicit Sys, is now attached a single MClassDef.

Signed-off-by: Jean Privat <jean@pryen.org>
modelbuilder: modeling of top-level methods use `parent`

Because nclassdef is the first one, not the local one

This gives more information
modelbuilder: add `AClassdef::all_defs` to retrieve all sibling definitions

Signed-off-by: Jean Privat <jean@pryen.org>
modelbuilder: `build_properties` process `all_defs` at once

Signed-off-by: Jean Privat <jean@pryen.org>
modelbuilder: `check_redef_keyword` and `build_property` rely on mclassdef

Signed-off-by: Jean Privat <jean@pryen.org>
tests: check that double definitions in distinct AClassdef are detected

Signed-off-by: Jean Privat <jean@pryen.org>
tests: update model-related tools because there is less mclassdef

Since multiple nclassdef can share a single mclassdef

Signed-off-by: Jean Privat <jean@pryen.org>
First files for the Nit virtual machine

A virtual table is now constructed for each MClass
The virtual table is constructed according to the specifications.

The perfect hashtable is at negative offsets.
It contains pointer to blocks of (id, methods) which
are at positive offsets of the virtual table.

Signed-off-by: Julien Pagès <julien.projet@gmail.com>
Modification of the numbering in perfect_hashing.

The numbering now start at 1 instead of 0.

Signed-off-by: Julien Pagès <julien.projet@gmail.com>
Merge: No duplicated mclassdefs

This series avoid the creation of multiple mclassdefs for a same class in a same module.

It appended for implicit classes: Object for top-level methods and Sys for top-level main.

The series was more complex than expected because it breaks the symmetry between AClassdef and MClassDef. However, thanks to the separation of the AST and the model, it was sill feasible.

Pull-Request: #503
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
tests: add tests for nitvm

Signed-off-by: Jean Privat <jean@pryen.org>
Merge: Subtyping test with perfect hashing in the Nit vm

This pull request contains the first files for the Nit virtual machine.

In this PR, the vm constructs runtime structures for each MClass of the model. These structures represent virtual tables for classes. When constructed, the virtual tables only reserve memory for method pointer but the method call is made with the naive_interpreter mechanisms.

The virtual machine can now performs subtyping test with the perfect hashing approach.

In the perfect_hashing module, numbering of items now start at 1 instead of 0.

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