fixed method_missing to check whether local var exists (not gobble everything up)

This commit is contained in:
Torsten Ruger 2014-05-21 12:44:36 +03:00
parent 53cfeb72a4
commit 16a07d5aa2

View File

@ -99,12 +99,16 @@ module Vm
# mov and add will be called on Machine and generate Inststuction that are then added # mov and add will be called on Machine and generate Inststuction that are then added
# to the block # to the block
def method_missing(meth, *args, &block) def method_missing(meth, *args, &block)
if( meth.to_s[-1] == "=" && args.length == 1) var = meth.to_s[0 ... -1]
l_val = @scope.eval meth.to_s[0 ... -1] if( args.length == 1) and ( meth.to_s[-1] == "=" )
add_code l_val.assign(args[0]) if @scope.local_variable_defined? var.to_sym
else l_val = @scope.local_variable_get var.to_sym
add_code CMachine.instance.send(meth , *args) return add_code l_val.assign(args[0])
else
return super
end
end end
add_code CMachine.instance.send(meth , *args)
end end
end end