From a28b41a5f58e3164405988b1f52e8a15395fb7d2 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Thu, 21 May 2015 21:49:47 +0300 Subject: [PATCH] renamed adapter seemed more appropriate as it makes the parfait work in the vm (i.e. adapts parfait) --- lib/parfait.rb | 2 +- lib/parfait/README.md | 2 +- ...{compile_parfait.rb => parfait_adapter.rb} | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) rename lib/virtual/{compile_parfait.rb => parfait_adapter.rb} (83%) diff --git a/lib/parfait.rb b/lib/parfait.rb index 4ab70e9e..eca027ae 100644 --- a/lib/parfait.rb +++ b/lib/parfait.rb @@ -12,4 +12,4 @@ require "parfait/frame" require "parfait/space" #if we are in the ruby run-time / generating an executable -require "virtual/compile_parfait" +require "virtual/parfait_adapter" diff --git a/lib/parfait/README.md b/lib/parfait/README.md index da44729a..4aa98620 100644 --- a/lib/parfait/README.md +++ b/lib/parfait/README.md @@ -7,7 +7,7 @@ The run-time needs to contain quite a lot of functionality for a dynamic system. And a large part of that functionality must actually be used at compile time too. We reuse the Parfait code at compile-time, to create the data for the compiled vm. -To do this the vm (re) defines the object memory (in compile_parfait). +To do this the vm (re) defines the object memory (in parfait_adapter). To do the actual compiling we parse and compile the parfait code and inline it to appropriate places (ie send, get_instance_variable etc). We have to inline to avoid recursion. diff --git a/lib/virtual/compile_parfait.rb b/lib/virtual/parfait_adapter.rb similarity index 83% rename from lib/virtual/compile_parfait.rb rename to lib/virtual/parfait_adapter.rb index 3a7a650d..6ea96d26 100644 --- a/lib/virtual/compile_parfait.rb +++ b/lib/virtual/parfait_adapter.rb @@ -6,11 +6,30 @@ module FakeMem def initialize + if( self.class.name == "Parfait::Space") + puts "YES , I am SPACE" + end @memory = [0,nil] + if Parfait::Space.object_space and Parfait::Space.object_space.objects + Parfait::Space.object_space.add_object self + puts "got it #{self.class.name}" + else + puts "it escaped #{self.class.name}" + end + end + def init_layout + class_name = self.class.name + puts "CLASS #{class_name}" + puts "Check for #{class_name}" + cl = Parfait::Space.space.get_class(class_name) + puts "found #{cl}" if cl end end module Parfait + Space.class_eval do + attr_accessor :vm_objects + end # Objects memory functions. Object memory is 1 based # but we implement it with ruby array (0 based) and use 0 as type-word # These are the same functions that Builtin implements at run-time