From cc13b04d34c5f0f62449659a34017d63106f43a2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Christophe=20Beaupr=C3=A9?= Date: Thu, 18 May 2017 00:33:20 -0400 Subject: [PATCH] nitvm: Factorize the loading of superclasses MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-Christophe Beaupré --- src/vm/virtual_machine.nit | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/vm/virtual_machine.nit b/src/vm/virtual_machine.nit index 7de400a..07ad951 100644 --- a/src/vm/virtual_machine.nit +++ b/src/vm/virtual_machine.nit @@ -199,8 +199,7 @@ class VirtualMachine super NaiveInterpreter do if mclass.loaded then return - # Recursively load superclasses - for parent in mclass.in_hierarchy(mainmodule).direct_greaters do load_class_indirect(parent) + load_supers(mclass) if mclass.abstract_loaded then mclass.allocate_vtable(self) @@ -209,6 +208,14 @@ class VirtualMachine super NaiveInterpreter end end + # Recursively load superclasses. + private fun load_supers(mclass: MClass) + do + for parent in mclass.in_hierarchy(mainmodule).direct_greaters do + load_class_indirect(parent) + end + end + # This method is called to handle an implicitly loaded class, # i.e. a superclass of an explicitly loaded class # A class loaded implicitly will not be fully allocated @@ -217,7 +224,7 @@ class VirtualMachine super NaiveInterpreter # It the class was already implicitly loaded if mclass.abstract_loaded then return - for parent in mclass.in_hierarchy(mainmodule).direct_greaters do load_class_indirect(parent) + load_supers(mclass) mclass.make_vt(self, false) end -- 1.7.9.5