public Block cloneBlockAndFrame() { Binding oldBinding = binding; Binding binding = new Binding( oldBinding.getSelf(), oldBinding.getFrame().duplicate(), oldBinding.getVisibility(), oldBinding.getDynamicScope(), oldBinding.getMethod(), oldBinding.getFile(), oldBinding.getLine()); Block newBlock = new Block(body, binding); newBlock.type = type; newBlock.escapeBlock = this; return newBlock; }
public Block cloneBlockAndFrame() { Binding oldBinding = binding; Binding binding = new Binding( oldBinding.getSelf(), oldBinding.getFrame().duplicate(), oldBinding.getVisibility(), oldBinding.getDynamicScope(), oldBinding.getMethod(), oldBinding.getFile(), oldBinding.getLine()); Block newBlock = new Block(body, binding); newBlock.type = type; newBlock.escapeBlock = this; return newBlock; }
@JRubyMethod public IRubyObject source_location(ThreadContext context) { Ruby runtime = context.runtime; if (file != null) { return runtime.newArray(runtime.newString(file), runtime.newFixnum(line + 1 /*zero-based*/)); } if (block != null) { Binding binding = block.getBinding(); // block+binding may exist for a core method, which will have a null filename if (binding.getFile() != null) { return runtime.newArray( runtime.newString(binding.getFile()), runtime.newFixnum(binding.getLine() + 1 /*zero-based*/)); } } return context.nil; }
/** * Evaluate the given string under the specified binding object. If the binding is not a Proc or Binding object * (RubyProc or RubyBinding) throw an appropriate type error. * @param context the thread context for the current thread * @param self the self against which eval was called; used as self in the eval in 1.9 mode * @param src The string containing the text to be evaluated * @param binding The binding object under which to perform the evaluation * @return An IRubyObject result from the evaluation */ public static IRubyObject evalWithBinding(ThreadContext context, IRubyObject self, IRubyObject src, Binding binding) { Ruby runtime = context.runtime; DynamicScope evalScope = binding.getEvalScope(runtime); evalScope.getStaticScope().determineModule(); // FIXME: It would be nice to just set this or remove it from staticScope altogether Frame lastFrame = context.preEvalWithBinding(binding); try { return evalCommon(context, evalScope, self, src, binding.getFile(), binding.getLine(), binding.getMethod(), binding.getFrame().getBlock(), EvalType.BINDING_EVAL); } finally { context.postEvalWithBinding(binding, lastFrame); } }
@JRubyMethod public IRubyObject source_location(ThreadContext context) { Ruby runtime = context.runtime; if (file != null) { return runtime.newArray(runtime.newString(file), runtime.newFixnum(line + 1 /*zero-based*/)); } if (block != null) { Binding binding = block.getBinding(); // block+binding may exist for a core method, which will have a null filename if (binding.getFile() != null) { return runtime.newArray( runtime.newString(binding.getFile()), runtime.newFixnum(binding.getLine() + 1 /*zero-based*/)); } } return context.nil; }
@JRubyMethod(name = "source_location", compat = RUBY1_9) public IRubyObject source_location(ThreadContext context) { Ruby runtime = context.runtime; if (sourcePosition != null) { return runtime.newArray(runtime.newString(sourcePosition.getFile()), runtime.newFixnum(sourcePosition.getLine() + 1 /*zero-based*/)); } else if (block != null) { Binding binding = block.getBinding(); return runtime.newArray(runtime.newString(binding.getFile()), runtime.newFixnum(binding.getLine() + 1 /*zero-based*/)); } return runtime.getNil(); }
@JRubyMethod(name = "source_location", compat = RUBY1_9) public IRubyObject source_location(ThreadContext context) { Ruby runtime = context.runtime; if (sourcePosition != null) { return runtime.newArray(runtime.newString(sourcePosition.getFile()), runtime.newFixnum(sourcePosition.getLine() + 1 /*zero-based*/)); } else if (block != null) { Binding binding = block.getBinding(); return runtime.newArray(runtime.newString(binding.getFile()), runtime.newFixnum(binding.getLine() + 1 /*zero-based*/)); } return runtime.getNil(); }
/** * Evaluate the given string under the specified binding object. If the binding is not a Proc or Binding object * (RubyProc or RubyBinding) throw an appropriate type error. * @param context the thread context for the current thread * @param self the self against which eval was called; used as self in the eval in 1.9 mode * @param src The string containing the text to be evaluated * @param binding The binding object under which to perform the evaluation * @return An IRubyObject result from the evaluation */ public static IRubyObject evalWithBinding(ThreadContext context, IRubyObject self, IRubyObject src, Binding binding) { Ruby runtime = context.runtime; DynamicScope evalScope = binding.getEvalScope(runtime); evalScope.getStaticScope().determineModule(); // FIXME: It would be nice to just set this or remove it from staticScope altogether Frame lastFrame = context.preEvalWithBinding(binding); try { return evalCommon(context, evalScope, self, src, binding.getFile(), binding.getLine(), binding.getMethod(), binding.getFrame().getBlock(), EvalType.BINDING_EVAL); } finally { context.postEvalWithBinding(binding, lastFrame); } }
Node node = runtime.parseEval(source.getByteList(), binding.getFile(), evalScope, binding.getLine()); Block block = binding.getFrame().getBlock(); return Interpreter.interpretBindingEval(runtime, binding.getFile(), binding.getLine(), binding.getMethod(), node, self, block); } else { return INTERPRET_EVAL(runtime, context, binding.getFile(), binding.getLine(), node, binding.getMethod(), self, block);
Node node = runtime.parseEval(source.getByteList(), binding.getFile(), evalScope, binding.getLine()); Block block = binding.getFrame().getBlock(); return Interpreter.interpretBindingEval(runtime, binding.getFile(), binding.getLine(), binding.getMethod(), node, self, block); } else { return INTERPRET_EVAL(runtime, context, binding.getFile(), binding.getLine(), node, binding.getMethod(), self, block);
RubyModule frameClass = threadBlock.getFrame().getKlazz(); String file = threadBlock.getBinding().getFile(); int line = threadBlock.getBinding().getLine(); try { if (runtime.hasEventHooks()) context.trace(RubyEvent.THREAD_BEGIN, null, frameClass, file, line);
RubyModule frameClass = threadBlock.getFrame().getKlazz(); String file = threadBlock.getBinding().getFile(); int line = threadBlock.getBinding().getLine(); try { if (runtime.hasEventHooks()) context.trace(RubyEvent.THREAD_BEGIN, null, frameClass, file, line);
oldBinding.getMethod(), oldBinding.getFile(), oldBinding.getLine()); block = new Block(procBlock.getBody(), newBinding);
oldBinding.getMethod(), oldBinding.getFile(), oldBinding.getLine()); block = new Block(procBlock.getBody(), newBinding);