From 16a07d5aa2656fab0f16104148a8f70559bdda21 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 21 May 2014 12:44:36 +0300 Subject: [PATCH] fixed method_missing to check whether local var exists (not gobble everything up) --- lib/vm/block.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/vm/block.rb b/lib/vm/block.rb index d2af8647..f4d2bf75 100644 --- a/lib/vm/block.rb +++ b/lib/vm/block.rb @@ -99,12 +99,16 @@ module Vm # mov and add will be called on Machine and generate Inststuction that are then added # to the block 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.assign(args[0]) - else - add_code CMachine.instance.send(meth , *args) + var = meth.to_s[0 ... -1] + if( args.length == 1) and ( meth.to_s[-1] == "=" ) + if @scope.local_variable_defined? var.to_sym + l_val = @scope.local_variable_get var.to_sym + return add_code l_val.assign(args[0]) + else + return super + end end + add_code CMachine.instance.send(meth , *args) end end