rename left to first in instruction and started on logic instruction cleanup

This commit is contained in:
Torsten Ruger
2014-05-16 10:42:25 +03:00
parent 009c0895f4
commit ef17bbf9dd
11 changed files with 134 additions and 54 deletions

View File

@ -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 |left , options|
create_method(inst) do |first , options|
options = {} if options == nil
options.merge defaults
options[:opcode] = inst
clazz.new(left , options)
clazz.new(first , options)
end
end

View File

@ -25,8 +25,8 @@ module Vm
# Make hash attributes to object attributes
include Support::HashAttributes
def initialize left , options
@left = left
def initialize first , options
@first = first
@attributes = options
end
end
@ -44,7 +44,7 @@ module Vm
class MoveInstruction < Instruction
end
class CallInstruction < Instruction
def initialize left , options
def initialize first , options
super
opcode = @attributes[:opcode].to_s
if opcode.length == 3 and opcode[0] == "b"

View File

@ -63,11 +63,11 @@ module Vm
CMachine.instance.integer_less_or_equal block , self , right
end
def plus block , left , right
CMachine.instance.integer_plus block , self , left , right
def plus block , first , right
CMachine.instance.integer_plus block , self , first , right
end
def minus block , left , right
CMachine.instance.integer_minus block , self , left , right
def minus block , first , right
CMachine.instance.integer_minus block , self , first , right
end
def load block , right