first stab at moms if
This commit is contained in:
@ -4,8 +4,19 @@ module Mom
|
||||
class Instruction
|
||||
end
|
||||
|
||||
# basically a label
|
||||
class Noop
|
||||
attr_reader :name
|
||||
def initialize(name)
|
||||
@name = name
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
require_relative "simple_call"
|
||||
require_relative "truth_check"
|
||||
require_relative "jump"
|
||||
require_relative "slot_load"
|
||||
require_relative "return_sequence"
|
||||
|
14
lib/mom/jump.rb
Normal file
14
lib/mom/jump.rb
Normal file
@ -0,0 +1,14 @@
|
||||
module Mom
|
||||
|
||||
# unconditional jump to the instruction given as target
|
||||
#
|
||||
class Jump < Instruction
|
||||
attr_reader :target
|
||||
|
||||
def initialize(target)
|
||||
@target = target
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
21
lib/mom/truth_check.rb
Normal file
21
lib/mom/truth_check.rb
Normal file
@ -0,0 +1,21 @@
|
||||
module Mom
|
||||
|
||||
# The funny thing about the ruby truth is that is is anything but false or nil
|
||||
#
|
||||
# To implement the normal ruby logic, we check for false or nil and jump
|
||||
# to the false branch. true_block follows implicitly
|
||||
#
|
||||
# The class only carries the blocks for analysis, and does
|
||||
# - NOT imply any order
|
||||
# - will not "handle" the blocks in subsequent processing.
|
||||
#
|
||||
class TruthCheck < Instruction
|
||||
attr_reader :condition , :true_block , :false_block , :merge_block
|
||||
|
||||
def initialize(condition , true_block , false_block , merge_block)
|
||||
@condition , @true_block , @false_block , @merge_block = condition , true_block , false_block , merge_block
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
Reference in New Issue
Block a user