starting to_risc descent
just fleshing it for now
This commit is contained in:
@ -16,6 +16,9 @@ module Mom
|
||||
def initialize(name)
|
||||
@name = name
|
||||
end
|
||||
def to_risc(compiler)
|
||||
Risc::Label.new(self,name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -16,6 +16,11 @@ module Mom
|
||||
def initialize(method)
|
||||
@method = method
|
||||
end
|
||||
|
||||
def to_risc(compiler)
|
||||
Risc::Label.new(self,method.name)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
@ -12,5 +12,9 @@ module Mom
|
||||
def initialize(left, right)
|
||||
@left , @right = left , right
|
||||
end
|
||||
|
||||
def to_risc(compiler)
|
||||
Risc::Label.new(self,"nosense")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -33,6 +33,11 @@ module Mom
|
||||
raise "left not SlotDefinition, #{left}" unless left.is_a? SlotDefinition
|
||||
# raise "right not Mom, #{right.to_rxf}" unless right.class.name.include?("Mom")
|
||||
end
|
||||
|
||||
def to_risc(compiler)
|
||||
Risc::Label.new(self,"nosense")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# A SlotConstant moves a constant into a known Slot.
|
||||
@ -52,6 +57,9 @@ module Mom
|
||||
|
||||
#SlotMove is a SlotLoad where the right side is a slot, just like the left.
|
||||
class SlotMove < SlotLoad
|
||||
def to_risc(compiler)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
class SlotDefinition
|
||||
|
@ -1,5 +1,6 @@
|
||||
module Mom
|
||||
class Statement
|
||||
include Common::List
|
||||
# flattening will change the structure from a tree to a linked list (and use
|
||||
# nekst to do so)
|
||||
def flatten(options = {})
|
||||
@ -18,6 +19,12 @@ module Mom
|
||||
flat
|
||||
end
|
||||
|
||||
def initialize(arr)
|
||||
super(arr)
|
||||
arr.each {|s|
|
||||
raise "Not a Statement #{s}" unless s.is_a?( Statement) or s.is_a?(Instruction)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -18,5 +18,10 @@ module Mom
|
||||
def initialize(condition)
|
||||
@condition = condition
|
||||
end
|
||||
|
||||
def to_risc(compiler)
|
||||
Risc::Label.new(self,"nosense")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -11,13 +11,13 @@ module Mom
|
||||
end
|
||||
|
||||
def flatten(options = {})
|
||||
cond_label = Label.new( "cond_label_#{object_id}")
|
||||
head = cond_label
|
||||
head.append hoisted.flatten
|
||||
merge_label = Label.new( "merge_label_#{object_id}")
|
||||
head.append condition.flatten( true_label: cond_label , false_label: merge_label)
|
||||
head.append merge_label
|
||||
head
|
||||
cond_label = Label.new( "cond_label_#{object_id}")
|
||||
@nekst = cond_label
|
||||
@nekst.append(hoisted.flatten) if hoisted
|
||||
@nekst.append condition.flatten( true_label: cond_label , false_label: merge_label)
|
||||
@nekst.append merge_label
|
||||
@nekst
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user