more on classes, have to work on asm next
This commit is contained in:
@ -2,11 +2,12 @@ module Vm
|
||||
# class is mainly a list of functions with a name (for now)
|
||||
# layout of object is seperated into Layout
|
||||
class BootClass < Code
|
||||
def initialize name , context
|
||||
def initialize name , context , superclass = :Object
|
||||
@context = context
|
||||
# class functions
|
||||
@functions = []
|
||||
@name = name.to_sym
|
||||
@superclass = superclass
|
||||
end
|
||||
attr_reader :name , :functions
|
||||
|
||||
@ -24,6 +25,11 @@ module Vm
|
||||
# preferred way of creating new functions (also forward declarations, will flag unresolved later)
|
||||
def get_or_create_function name
|
||||
fun = get_function name
|
||||
unless fun or name == :Object
|
||||
supr = @context.object_space.get_or_create_class(@superclass)
|
||||
fun = supr.get_function name
|
||||
puts "#{supr.functions.collect(&:name)} for #{name} GOT #{fun.class}" if name == :index_of
|
||||
end
|
||||
unless fun
|
||||
fun = Core::Kernel.send(name , @context)
|
||||
raise "no such function #{name}, #{name.class}" if fun == nil
|
||||
|
@ -45,6 +45,7 @@ module Vm
|
||||
end
|
||||
|
||||
def get_or_create_class name
|
||||
raise "uups #{name}" unless name.is_a? Symbol
|
||||
c = @classes[name]
|
||||
unless c
|
||||
c = BootClass.new(name,@context)
|
||||
|
@ -118,6 +118,9 @@ module Vm
|
||||
def - other
|
||||
class_for(LogicInstruction).new(nil , self , other , opcode: :sub )#, update_status: 1 )
|
||||
end
|
||||
def at_index block , left , right
|
||||
RegisterMachine.instance.integer_at_index block , self , left , right
|
||||
end
|
||||
def plus block , first , right
|
||||
RegisterMachine.instance.integer_plus block , self , first , right
|
||||
end
|
||||
|
Reference in New Issue
Block a user