start to use parfait classes

bit of a bumpy road
This commit is contained in:
Torsten Ruger 2015-05-12 14:58:29 +03:00
parent 73a6a5db39
commit 2e8b514e9c
4 changed files with 34 additions and 7 deletions

View File

@ -7,3 +7,34 @@ require "parfait/array"
require "parfait/string" require "parfait/string"
require "parfait/message" require "parfait/message"
require "parfait/frame" require "parfait/frame"
# Below we define functions (in different classes) that are not part of the run-time
# They are used for the boot process, ie when this codes executes in the vm that builds salama
# To stay sane, we use the same classes that we use later, but "adapt" them to work in ruby
# This affects mainly memory layout
module FakeMem
def initialize
@memory = []
end
end
class Parfait::Object
include FakeMem
def self.new_object &args
puts "I am #{self}"
object = self.new(*args)
object
end
def object_length
@memory.length
end
end
class Parfait::Class
end
class Parfait::Array
def length
object_length
end
end

View File

@ -3,8 +3,8 @@
module Parfait module Parfait
class Hash < Object class Hash < Object
def initialize def initialize
@keys = Array.new() @keys = Array.new_object()
@values = Array.new() @values = Array.new_object()
end end
def values() def values()
@values @values

View File

@ -1,9 +1,5 @@
require 'parslet' require 'parslet'
module Parfait
eval(File.open("./lib/parfait/hash.rb").read)
end
require "stream_reader" require "stream_reader"
require "elf/object_writer" require "elf/object_writer"
require 'salama-reader' require 'salama-reader'

View File

@ -14,7 +14,7 @@ module Virtual
def initialize def initialize
super() super()
@classes = Parfait::Hash.new @classes = Parfait::Hash.new_object
#global objects (data) #global objects (data)
@objects = [] @objects = []
@symbols = [] @symbols = []