protected IRubyObject deepCopy(ThreadContext context) { RubyMap newMap = newThisType(context); switch (valueType) { case MESSAGE: for (IRubyObject key : table.keySet()) { RubyMessage message = (RubyMessage) table.get(key); newMap.table.put(key.dup(), message.deepCopy(context)); } break; default: for (IRubyObject key : table.keySet()) { newMap.table.put(key.dup(), table.get(key).dup()); } } return newMap; }
public static IRubyObject encodedDup(ThreadContext context, IRubyObject newstr, IRubyObject str, Encoding encindex) { if (encindex == null) return str.dup(); if (newstr == str) { newstr = str.dup(); } else { // set to same superclass ((RubyBasicObject)newstr).setMetaClass(str.getMetaClass()); } ((RubyString)newstr).modify19(); return strEncodeAssociate(context, newstr, encindex); }
public static IRubyObject encodedDup(ThreadContext context, IRubyObject newstr, IRubyObject str, Encoding encindex) { if (encindex == null) return str.dup(); if (newstr == str) { newstr = str.dup(); } else { // set to same superclass ((RubyBasicObject)newstr).setMetaClass(str.getMetaClass()); } ((RubyString)newstr).modify19(); return strEncodeAssociate(context, newstr, encindex); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { IRubyObject javaInterfaces = self.getInstanceVariables().getInstanceVariable("@java_interfaces"); if (javaInterfaces != null) return javaInterfaces.dup(); return context.nil; } });
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { IRubyObject javaInterfaces = self.getInstanceVariables().getInstanceVariable("@java_interfaces"); if (javaInterfaces != null) return javaInterfaces.dup(); return context.nil; } });
public static IRubyObject encodedDup(ThreadContext context, IRubyObject newstr, IRubyObject str, Encoding encindex) { if (encindex == null) return str.dup(); if (newstr == str) { newstr = str.dup(); } else { // set to same superclass ((RubyBasicObject)newstr).setMetaClass(str.getMetaClass()); } ((RubyString)newstr).modify19(); return strEncodeAssociate(context, newstr, encindex); }
public static IRubyObject encodedDup(ThreadContext context, IRubyObject newstr, IRubyObject str, Encoding encindex) { if (encindex == null) return str.dup(); if (newstr == str) { newstr = str.dup(); } else { // set to same superclass ((RubyBasicObject)newstr).setMetaClass(str.getMetaClass()); } ((RubyString)newstr).modify19(); return strEncodeAssociate(context, newstr, encindex); }
@JIT public static RubyArray argsPush(IRubyObject first, IRubyObject second) { return ((RubyArray)first.dup()).append(second); }
@JIT public static RubyArray argsPush(IRubyObject first, IRubyObject second) { return ((RubyArray)first.dup()).append(second); }
public IRubyObject backtrace() { IRubyObject rubyTrace = super.backtrace(); if (rubyTrace.isNil()) { return rubyTrace; } RubyArray array = (RubyArray) rubyTrace.dup(); StackTraceElement[] stackTrace = cause.getStackTrace(); for (int i = stackTrace.length - 1; i >= 0; i--) { StackTraceElement element = stackTrace[i]; String className = element.getClassName(); String line = null; if (element.getFileName() == null) { line = className + ":" + element.getLineNumber() + ":in `" + element.getMethodName() + "'"; } else { int index = className.lastIndexOf("."); String packageName = null; if (index == -1) { packageName = ""; } else { packageName = className.substring(0, index) + "/"; } line = packageName.replace(".", "/") + element.getFileName() + ":" + element.getLineNumber() + ":in `" + element.getMethodName() + "'"; } RubyString string = runtime.newString(line); array.unshift(string); } return array; }
@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { RubyArray args = (RubyArray) firstNode.interpret(runtime, context, self, aBlock).dup(); return args.append(secondNode.interpret(runtime, context, self, aBlock)); } }
@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { RubyArray args = (RubyArray) firstNode.interpret(runtime, context, self, aBlock).dup(); return args.append(secondNode.interpret(runtime, context, self, aBlock)); } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { IRubyObject javaInterfaces = self.getInstanceVariables().getInstanceVariable("@java_interfaces"); if (javaInterfaces != null) return javaInterfaces.dup(); return context.runtime.getNil(); } });
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name) { IRubyObject javaInterfaces = self.getInstanceVariables().getInstanceVariable("@java_interfaces"); if (javaInterfaces != null) return javaInterfaces.dup(); return context.runtime.getNil(); } });
public IRubyObject yield(ThreadContext context, IRubyObject arg) { synchronized (result) { if (i == 0) { // While iterating over an RubyEnumerator, "arg" // gets overwritten by the new value, leading to JRUBY-6892. // So call .dup() whenever appropriate. result.append(arg.isImmediate() ? arg : arg.dup()); } else { --i; } } return runtime.getNil(); } });
public IRubyObject yield(ThreadContext context, IRubyObject arg) { synchronized (result) { if (i == 0) { // While iterating over an RubyEnumerator, "arg" // gets overwritten by the new value, leading to JRUBY-6892. // So call .dup() whenever appropriate. result.append(arg.isImmediate() ? arg : arg.dup()); } else { --i; } } return runtime.getNil(); } });
@JRubyMethod(visibility = Visibility.PRIVATE) public IRubyObject initialize(ThreadContext context, IRubyObject src,IRubyObject file, IRubyObject line) { filename = filenameAsString(context, file).dup(); parser = new RipperParser(context, this, source(context, src, filename.asJavaString(), lineAsInt(context, line))); return context.nil; }
@JRubyMethod(visibility = Visibility.PRIVATE) public IRubyObject initialize(ThreadContext context, IRubyObject src,IRubyObject file, IRubyObject line) { filename = filenameAsString(context, file).dup(); parser = new RipperParser(context, this, source(context, src, filename.asJavaString(), lineAsInt(context, line))); return context.nil; }
@JIT @Interp public static IRubyObject mergeKeywordArguments(ThreadContext context, IRubyObject restKwarg, IRubyObject explicitKwarg) { RubyHash hash = (RubyHash) TypeConverter.checkHashType(context.runtime, restKwarg).dup(); hash.modify(); final RubyHash otherHash = explicitKwarg.convertToHash(); if (otherHash.empty_p().isTrue()) return hash; otherHash.visitAll(context, new KwargMergeVisitor(hash), Block.NULL_BLOCK); return hash; }
@JIT @Interp public static IRubyObject mergeKeywordArguments(ThreadContext context, IRubyObject restKwarg, IRubyObject explicitKwarg) { RubyHash hash = (RubyHash) TypeConverter.checkHashType(context.runtime, restKwarg).dup(); hash.modify(); final RubyHash otherHash = explicitKwarg.convertToHash(); if (otherHash.empty_p().isTrue()) return hash; otherHash.visitAll(context, new KwargMergeVisitor(hash), Block.NULL_BLOCK); return hash; }