another step closer to a working oo system

This commit is contained in:
Torsten Ruger
2014-06-03 22:16:57 +03:00
parent ca19f5cb16
commit 72d4adc7af
10 changed files with 43 additions and 43 deletions

View File

@ -21,9 +21,11 @@ module Vm
@functions << function
end
def get_function name
name = name.to_sym
@functions.detect{ |f| f.name == name }
def get_function fname
fname = fname.to_sym
f = @functions.detect{ |f| f.name == fname }
names = @functions.collect{|f| f.name }
f
end
# way of creating new functions that have not been parsed.
@ -36,12 +38,15 @@ module Vm
end
unless fun
fun = Core::Kernel.send(name , @context)
raise "no such function #{name}, #{name.class}" if fun == nil
return nil if fun == nil
@functions << fun
end
fun
end
def inspect
"BootClass #{@name} , super #{@super_class} #{@functions.length} functions"
end
# Code interface follows. Note position is inheitted as is from Code
# length of the class is the length of it's functions

View File

@ -45,6 +45,7 @@ module Vm
# dummies, just for the other to compile
obj = get_or_create_class :Object
[:index_of , :_get_instance_variable].each do |f|
puts "adding #{f}"
obj.add_function Boot::Object.send(f , @context)
end
end

View File

@ -26,6 +26,7 @@ module Vm
attr_reader :string
# currently aligned to 4 (ie padded with 0) and off course 0 at the end
def initialize str
str = str.to_s if str.is_a? Symbol
length = str.length
# rounding up to the next 4 (always adding one for zero pad)
pad = ((length / 4 ) + 1 ) * 4 - length

View File

@ -26,8 +26,12 @@ module Vm
def get_function name
name = name.to_sym
@functions.detect{ |f| f.name == name }
f = @functions.detect{ |f| f.name == name }
puts "no function for #{name} in Meta #{@me_self.inspect}" unless f
f
end
def inspect
"#{@me_self}, #{@functions.length} functions"
end
end
end