public IRubyObject getInstanceVariable(IRubyObject obj, String variableName) { BiVariableMap map = container.getVarMap(); synchronized (map) { if (map.containsKey(variableName)) { BiVariable bv = map.getVariable( (RubyObject) container.getProvider().getRuntime().getTopSelf(), variableName); return bv.getRubyObject(); } } return null; }
public IRubyObject setInstanceVariable(IRubyObject obj, String variableName, IRubyObject value) { BiVariableMap map = container.getVarMap(); synchronized (map) { if (map.containsKey(variableName)) { BiVariable bv = map.getVariable( (RubyObject) container.getProvider().getRuntime().getTopSelf(), variableName); bv.setRubyObject(value); } else { InstanceVariable iv = new InstanceVariable(obj, variableName, value); map.update(variableName, iv); } } return obj.getInstanceVariables().setInstanceVariable(variableName, value); }