removed the (too) fancy dsl. Also introduce register indirection

This commit is contained in:
Torsten Ruger
2014-06-07 17:59:44 +03:00
parent 6433a394e7
commit 36f237c633
26 changed files with 128 additions and 161 deletions

View File

@@ -9,15 +9,23 @@ module Vm
@value = value
@args = args
@function = function
raise "oh #{name} " unless value
end
attr_reader :function , :args , :name , :value
def load_args into
if value.is_a?(IntegerConstant) or value.is_a?(ObjectConstant)
function.receiver.load into , value
else
raise "meta #{name} " if value.is_a? MetaClass
function.receiver.move( into, value ) if value.register_symbol != function.receiver.register_symbol
end
raise "function call '#{name}' has #{args.length} arguments, but function has #{function.args.length}" if args.length != function.args.length
args.each_with_index do |arg , index|
if arg.is_a?(IntegerConstant) or arg.is_a?(StringConstant)
function.args[index].load into , arg
else
function.args[index].move( into, arg ) if arg.register != function.args[index].register
function.args[index].move( into, arg ) if arg.register_symbol != function.args[index].register_symbol
end
end
end