separate frames and messages
also not using context which was not defined anyway
This commit is contained in:
parent
e2e692e25d
commit
e881a5f2ee
@ -19,19 +19,19 @@ module Virtual
|
|||||||
#global objects (data)
|
#global objects (data)
|
||||||
@objects = []
|
@objects = []
|
||||||
@symbols = []
|
@symbols = []
|
||||||
frames = 100.times.collect{ ::Frame.new }
|
@frames = 100.times.collect{ ::Frame.new }
|
||||||
@messages = 100.times.collect{ ::Message.new } + frames
|
@messages = 100.times.collect{ ::Message.new }
|
||||||
@next_message = @messages.first
|
@next_message = @messages.first
|
||||||
@next_frame = frames.first
|
@next_frame = @frames.first
|
||||||
@passes = [ "Virtual::SendImplementation" ]
|
@passes = [ "Virtual::SendImplementation" ]
|
||||||
end
|
end
|
||||||
attr_reader :init , :main , :classes , :objects , :symbols,:messages, :next_message , :next_frame
|
attr_reader :init , :main , :classes , :objects , :symbols,:messages, :next_message , :next_frame
|
||||||
|
|
||||||
def run_passes
|
def run_passes
|
||||||
@passes.each do |pass_class|
|
@passes.each do |pass_class|
|
||||||
all = [@init] + main.blocks
|
blocks = [@init] + main.blocks
|
||||||
@classes.values.each do |c|
|
@classes.values.each do |c|
|
||||||
c.instance_methods.each {|f| all += f.blocks }
|
c.instance_methods.each {|f| blocks += f.blocks }
|
||||||
end
|
end
|
||||||
#puts "running #{pass_class}"
|
#puts "running #{pass_class}"
|
||||||
all.each do |block|
|
all.each do |block|
|
||||||
@ -51,7 +51,7 @@ module Virtual
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Passes are initiated empty and added to by anyone who wants (basically)
|
# Passes may be added to by anyone who wants
|
||||||
# This is intentionally quite flexible, though one sometimes has to watch the order of them
|
# This is intentionally quite flexible, though one sometimes has to watch the order of them
|
||||||
# most ordering is achieved by ordering the requires and using add_pass
|
# most ordering is achieved by ordering the requires and using add_pass
|
||||||
# but more precise control is possible with the _after and _before versions
|
# but more precise control is possible with the _after and _before versions
|
||||||
@ -78,16 +78,16 @@ module Virtual
|
|||||||
# dummies, just for the other to compile
|
# dummies, just for the other to compile
|
||||||
obj = get_or_create_class :Object
|
obj = get_or_create_class :Object
|
||||||
[:index_of , :_get_instance_variable , :_set_instance_variable].each do |f|
|
[:index_of , :_get_instance_variable , :_set_instance_variable].each do |f|
|
||||||
obj.add_instance_method Builtin::Object.send(f , @context)
|
obj.add_instance_method Builtin::Object.send(f , nil)
|
||||||
end
|
end
|
||||||
obj = get_or_create_class :Kernel
|
obj = get_or_create_class :Kernel
|
||||||
# create main first, __init__ calls it
|
# create main first, __init__ calls it
|
||||||
@main = Builtin::Kernel.send(:main , @context)
|
@main = Builtin::Kernel.send(:main , @context)
|
||||||
obj.add_instance_method @main
|
obj.add_instance_method @main
|
||||||
underscore_init = Builtin::Kernel.send(:__init__ , @context) #store , so we don't have to resolve it below
|
underscore_init = Builtin::Kernel.send(:__init__ ,nil) #store , so we don't have to resolve it below
|
||||||
obj.add_instance_method underscore_init
|
obj.add_instance_method underscore_init
|
||||||
[:putstring,:exit,:__send].each do |f|
|
[:putstring,:exit,:__send].each do |f|
|
||||||
obj.add_instance_method Builtin::Kernel.send(f , @context)
|
obj.add_instance_method Builtin::Kernel.send(f , nil)
|
||||||
end
|
end
|
||||||
# and the @init block in turn _jumps_ to __init__
|
# and the @init block in turn _jumps_ to __init__
|
||||||
# the point of which is that by the time main executes, all is "normal"
|
# the point of which is that by the time main executes, all is "normal"
|
||||||
@ -95,15 +95,15 @@ module Virtual
|
|||||||
@init.add_code(Register::RegisterMain.new(underscore_init))
|
@init.add_code(Register::RegisterMain.new(underscore_init))
|
||||||
obj = get_or_create_class :Integer
|
obj = get_or_create_class :Integer
|
||||||
[:putint,:fibo].each do |f|
|
[:putint,:fibo].each do |f|
|
||||||
obj.add_instance_method Builtin::Integer.send(f , @context)
|
obj.add_instance_method Builtin::Integer.send(f , nil)
|
||||||
end
|
end
|
||||||
obj = get_or_create_class :String
|
obj = get_or_create_class :String
|
||||||
[:get , :set , :puts].each do |f|
|
[:get , :set , :puts].each do |f|
|
||||||
obj.add_instance_method Builtin::String.send(f , @context)
|
obj.add_instance_method Builtin::String.send(f , nil)
|
||||||
end
|
end
|
||||||
obj = get_or_create_class :Array
|
obj = get_or_create_class :Array
|
||||||
[:get , :set , :push].each do |f|
|
[:get , :set , :push].each do |f|
|
||||||
obj.add_instance_method Builtin::Array.send(f , @context)
|
obj.add_instance_method Builtin::Array.send(f , nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user