own statements class for mom
so we don’t have to deal with arrays (as a special case) and use method sending as is good oo
This commit is contained in:
@ -17,20 +17,11 @@ module Mom
|
||||
end
|
||||
end
|
||||
|
||||
class Statement
|
||||
# flattening will change the structure from a tree to a linked list (and use
|
||||
# next_instruction to do so)
|
||||
def flatten
|
||||
raise "not implemented"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
require_relative "simple_call"
|
||||
require_relative "if_statement"
|
||||
require_relative "while_statement"
|
||||
require_relative "truth_check"
|
||||
require_relative "jump"
|
||||
require_relative "slot_load"
|
||||
require_relative "return_sequence"
|
||||
require_relative "statement"
|
||||
|
21
lib/mom/statement.rb
Normal file
21
lib/mom/statement.rb
Normal file
@ -0,0 +1,21 @@
|
||||
module Mom
|
||||
class Statement
|
||||
# flattening will change the structure from a tree to a linked list (and use
|
||||
# next_instruction to do so)
|
||||
def flatten
|
||||
raise "not implemented for #{self}"
|
||||
end
|
||||
end
|
||||
|
||||
class Statements < Statement
|
||||
include Common::Statements
|
||||
|
||||
def flatten
|
||||
@statements.each{ |s| s.flatten }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
require_relative "if_statement"
|
||||
require_relative "while_statement"
|
Reference in New Issue
Block a user