small clean
This commit is contained in:
parent
f92e5cf475
commit
bf5576f805
@ -5,7 +5,6 @@ require "virtual/instruction"
|
|||||||
require "virtual/compiled_method"
|
require "virtual/compiled_method"
|
||||||
require "virtual/slots/slot"
|
require "virtual/slots/slot"
|
||||||
require "virtual/type"
|
require "virtual/type"
|
||||||
require "virtual/object"
|
|
||||||
require "virtual/constants"
|
require "virtual/constants"
|
||||||
# the passes _are_ order dependant
|
# the passes _are_ order dependant
|
||||||
require "virtual/passes/send_implementation"
|
require "virtual/passes/send_implementation"
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
require_relative "object"
|
|
||||||
|
|
||||||
module Virtual
|
module Virtual
|
||||||
|
|
||||||
# Think flowcharts: blocks are the boxes. The smallest unit of linear code
|
# Think flowcharts: blocks are the boxes. The smallest unit of linear code
|
||||||
|
|
||||||
# Blocks must end in control instructions (jump/call/return).
|
# Blocks must end in control instructions (jump/call/return).
|
||||||
# And the only valid argument for a jump is a Block
|
# And the only valid argument for a jump is a Block
|
||||||
|
|
||||||
# Blocks form a graph, which is managed by the method
|
# Blocks form a graph, which is managed by the method
|
||||||
|
|
||||||
class Block < Virtual::Object
|
class Block < Virtual::Object
|
||||||
|
|
||||||
def initialize(name , method )
|
def initialize(name , method )
|
||||||
@ -21,7 +19,7 @@ module Virtual
|
|||||||
|
|
||||||
attr_reader :name , :codes , :method
|
attr_reader :name , :codes , :method
|
||||||
attr_accessor :branch
|
attr_accessor :branch
|
||||||
|
|
||||||
def reachable ret = []
|
def reachable ret = []
|
||||||
add_next ret
|
add_next ret
|
||||||
add_branch ret
|
add_branch ret
|
||||||
@ -69,14 +67,14 @@ module Virtual
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
# helper for determining reachable blocks
|
# helper for determining reachable blocks
|
||||||
def add_next ret
|
def add_next ret
|
||||||
return if @next.nil?
|
return if @next.nil?
|
||||||
return if ret.include? @next
|
return if ret.include? @next
|
||||||
ret << @next
|
ret << @next
|
||||||
@next.reachable ret
|
@next.reachable ret
|
||||||
end
|
end
|
||||||
# helper for determining reachable blocks
|
# helper for determining reachable blocks
|
||||||
def add_branch ret
|
def add_branch ret
|
||||||
return if @branch.nil?
|
return if @branch.nil?
|
||||||
return if ret.include? @branch
|
return if ret.include? @branch
|
||||||
@ -84,4 +82,4 @@ module Virtual
|
|||||||
@branch.reachable ret
|
@branch.reachable ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -38,19 +38,6 @@ module Virtual
|
|||||||
end
|
end
|
||||||
attr_reader :me, :next_normal, :next_exception, :arguments , :frame
|
attr_reader :me, :next_normal, :next_exception, :arguments , :frame
|
||||||
|
|
||||||
# dummy for the eventual
|
|
||||||
def new_frame
|
|
||||||
raise self.inspect
|
|
||||||
end
|
|
||||||
#
|
#
|
||||||
def compile_get method , name
|
|
||||||
raise "CALLED"
|
|
||||||
if method.has_arg(name)
|
|
||||||
method.add_code MessageGet.new(name)
|
|
||||||
else
|
|
||||||
method.add_code FrameGet.new(name)
|
|
||||||
end
|
|
||||||
method.get_var(name)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user