From: Julien Pagès Date: Fri, 12 Sep 2014 14:31:59 +0000 (+0200) Subject: nitvm: Introduces a type which represents initial values inside attributes X-Git-Tag: v0.6.9~35^2~2 X-Git-Url: http://nitlanguage.org nitvm: Introduces a type which represents initial values inside attributes Signed-off-by: Julien Pagès --- diff --git a/src/vm.nit b/src/vm.nit index b5e5bb8..fd27117 100644 --- a/src/vm.nit +++ b/src/vm.nit @@ -44,6 +44,16 @@ class VirtualMachine super NaiveInterpreter # Handles memory and garbage collection var memory_manager: MemoryManager = new MemoryManager + # The unique instance of the `MInit` value + var initialization_value: Instance + + init(modelbuilder: ModelBuilder, mainmodule: MModule, arguments: Array[String]) + do + super + var init_type = new MInitType(mainmodule.model) + initialization_value = new MutableInstance(init_type) + end + # Subtyping test for the virtual machine redef fun is_subtype(sub, sup: MType): Bool do @@ -458,6 +468,29 @@ redef class MutableInstance var internal_attributes: Pointer end +# Is the type of the initial value inside attributes +class MInitType + super MType + + redef var model: Model + protected init(model: Model) + do + self.model = model + end + + redef fun to_s do return "InitType" + redef fun as_nullable do return self + redef fun need_anchor do return false + redef fun resolve_for(mtype, anchor, mmodule, cleanup_virtual) do return self + redef fun can_resolve_for(mtype, anchor, mmodule) do return true + + redef fun collect_mclassdefs(mmodule) do return new HashSet[MClassDef] + + redef fun collect_mclasses(mmodule) do return new HashSet[MClass] + + redef fun collect_mtypes(mmodule) do return new HashSet[MClassType] +end + # A VTable contains the virtual method table for the dispatch # and informations to perform subtyping tests class VTable