replace arrays with Statements class
This commit is contained in:
parent
9a1e4a6f27
commit
80c3430536
@ -15,10 +15,15 @@ module Common
|
||||
def first
|
||||
@statements.first
|
||||
end
|
||||
def last
|
||||
@statements.last
|
||||
end
|
||||
def length
|
||||
@statements.length
|
||||
end
|
||||
|
||||
def [](i)
|
||||
@statements[i]
|
||||
end
|
||||
def collect(arr)
|
||||
@statements.each { |s| s.collect(arr) }
|
||||
super
|
||||
|
@ -9,6 +9,10 @@ module Mom
|
||||
@if_true = if_true
|
||||
@if_false = if_false
|
||||
end
|
||||
|
||||
def flatten
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -18,7 +18,7 @@ module Vool
|
||||
@body.statements.each do |meth|
|
||||
methods << meth.to_mom( nil )
|
||||
end
|
||||
methods
|
||||
Mom::Statements.new(methods)
|
||||
end
|
||||
|
||||
def collect(arr)
|
||||
|
@ -15,7 +15,7 @@ module Vool
|
||||
# - store the given return value, this is a SlotMove / SlotConstant
|
||||
# - activate return sequence (reinstantiate old message and jump to return address)
|
||||
def to_mom( method )
|
||||
[Mom::SlotConstant.new([:message , :return_value] , @return_value) ,
|
||||
Mom::Statements.new [Mom::SlotConstant.new([:message , :return_value] , @return_value) ,
|
||||
Mom::ReturnSequence.new]
|
||||
end
|
||||
|
||||
|
@ -34,7 +34,7 @@ module Vool
|
||||
# in a not so distant future, temporary variables will have to be created
|
||||
# and complex statements hoisted to assign to them. pps: same as in conditions
|
||||
def to_mom( method )
|
||||
message_setup + call_instruction
|
||||
Mom::Statements.new( message_setup + call_instruction )
|
||||
end
|
||||
|
||||
def message_setup
|
||||
|
@ -4,9 +4,7 @@ module Vool
|
||||
|
||||
# create machine instructions
|
||||
def to_mom( method )
|
||||
all = @statements.collect do |statement|
|
||||
statement.to_mom( method )
|
||||
end
|
||||
all = @statements.collect { |statement| statement.to_mom( method ) }
|
||||
Mom::Statements.new(all)
|
||||
end
|
||||
|
||||
|
@ -10,7 +10,7 @@ module Vool
|
||||
end
|
||||
|
||||
def test_stats
|
||||
assert_equal Array , @stats.class
|
||||
assert_equal Mom::Statements , @stats.class
|
||||
end
|
||||
def test_class_compiles
|
||||
assert_equal Mom::SlotConstant , @stats.first.class , @stats
|
||||
|
Loading…
Reference in New Issue
Block a user