named the first intruction constructor argument
This commit is contained in:
@ -66,7 +66,7 @@ module Vm
|
||||
# sugar to create instructions easily. Any method with one arg is sent to the machine and the result
|
||||
# (hopefully an instruction) added as code
|
||||
def method_missing(meth, *args, &block)
|
||||
if args.length == 1
|
||||
if args.length == 2
|
||||
add_code CMachine.instance.send(meth , *args)
|
||||
else
|
||||
super
|
||||
|
@ -81,11 +81,11 @@ module Vm
|
||||
# defaults gets merged into the instructions options hash, ie passed on to the (machine specific)
|
||||
# Instruction constructor and as such can be used to influence that classes behaviour
|
||||
def define_instruction(inst , clazz , defaults = {} )
|
||||
create_method(inst) do |options|
|
||||
create_method(inst) do |left , options|
|
||||
options = {} if options == nil
|
||||
options.merge defaults
|
||||
options[:opcode] = inst
|
||||
clazz.new(options)
|
||||
clazz.new(left , options)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -25,7 +25,8 @@ module Vm
|
||||
# Make hash attributes to object attributes
|
||||
include Support::HashAttributes
|
||||
|
||||
def initialize options
|
||||
def initialize left , options
|
||||
@left = left
|
||||
@attributes = options
|
||||
end
|
||||
end
|
||||
@ -43,7 +44,7 @@ module Vm
|
||||
class MoveInstruction < Instruction
|
||||
end
|
||||
class CallInstruction < Instruction
|
||||
def initialize options
|
||||
def initialize left , options
|
||||
super
|
||||
opcode = @attributes[:opcode].to_s
|
||||
if opcode.length == 3 and opcode[0] == "b"
|
||||
|
Reference in New Issue
Block a user