phase one, assignment for constants (moves) work

This commit is contained in:
Torsten Ruger
2014-05-20 11:14:18 +03:00
parent 7056f6f05c
commit c3c6928dc8
3 changed files with 17 additions and 3 deletions

View File

@ -101,9 +101,10 @@ module Vm
def method_missing(meth, *args, &block)
if( meth.to_s[-1] == "=" && args.length == 1)
l_val = @scope.eval meth.to_s[0 ... -1]
add_code l_val.asign(args[0])
add_code l_val.assign(args[0])
else
add_code CMachine.instance.send(meth , *args)
end
add_code CMachine.instance.send(meth , *args)
end
end

View File

@ -70,6 +70,19 @@ module Vm
class Integer < Word
# part of the dsl.
# Gets called with either fixnum/IntegerConstant or an Instruction (usually logic, iw add...)
# For instructions we flip, ie call the assign on the instruction
# but for constants we have to create instruction first (mov)
def assign other
other = Vm::IntegerConstant.new(other) if other.is_a? Fixnum
if other.is_a? Vm::IntegerConstant
class_for(MoveInstruction).new( self , other , :opcode => :mov)
else
other.assign(self)
end
end
def less_or_equal block , right
CMachine.instance.integer_less_or_equal block , self , right
end