diff --git a/bin/ast b/bin/ast
index 5f12d5d8bd1..2ce305c077f 100755
--- a/bin/ast
+++ b/bin/ast
@@ -191,7 +191,7 @@ def ir_setup(root)
JRuby::IR.compiler_debug = true
- builder = org.jruby.ir.IRBuilder
+ builder = org.jruby.ir.builder.IRBuilderAST
scope = builder.build_root(manager, root).scope
scope.prepare_for_compilation
diff --git a/core/pom.rb b/core/pom.rb
index f98e1c1fdf1..50397f47bf7 100644
--- a/core/pom.rb
+++ b/core/pom.rb
@@ -53,7 +53,7 @@
jar 'org.jruby.joni:joni:2.2.1'
jar 'org.jruby.jcodings:jcodings:1.0.58'
- jar 'org.jruby:dirgra:0.3'
+ jar 'org.jruby:dirgra:0.5'
jar 'com.headius:invokebinder:1.13'
jar 'com.headius:options:1.6'
diff --git a/core/pom.xml b/core/pom.xml
index 1f276707474..f13d9ab4488 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -159,7 +159,7 @@ DO NOT MODIFY - GENERATED CODE
org.jrubydirgra
- 0.3
+ 0.5com.headius
diff --git a/core/src/main/java/org/jruby/ObjectFlags.java b/core/src/main/java/org/jruby/ObjectFlags.java
index e3cf10bb4ae..4b25eb54da8 100644
--- a/core/src/main/java/org/jruby/ObjectFlags.java
+++ b/core/src/main/java/org/jruby/ObjectFlags.java
@@ -22,6 +22,7 @@ public interface ObjectFlags {
int IS_OVERLAID_F = registry.newFlag(RubyModule.class);
int OMOD_SHARED = registry.newFlag(RubyModule.class);
int INCLUDED_INTO_REFINEMENT = registry.newFlag(RubyModule.class);
+ int TEMPORARY_NAME = registry.newFlag(RubyModule.class);
int CR_7BIT_F = registry.newFlag(RubyString.class);
int CR_VALID_F = registry.newFlag(RubyString.class);
diff --git a/core/src/main/java/org/jruby/RubyBasicObject.java b/core/src/main/java/org/jruby/RubyBasicObject.java
index 15646d75bbe..87e4ca665a1 100644
--- a/core/src/main/java/org/jruby/RubyBasicObject.java
+++ b/core/src/main/java/org/jruby/RubyBasicObject.java
@@ -840,7 +840,10 @@ private static void initCopy(ThreadContext context, IRubyObject clone, IRubyObje
original.copySpecialInstanceVariables(clone);
- if (original.hasVariables()) clone.syncVariables(original);
+ if (original.hasVariables()) {
+ clone.syncVariables(original);
+ ((RubyBasicObject) clone).dupFinalizer();
+ }
if (original instanceof RubyModule) {
RubyModule cloneMod = (RubyModule)clone;
cloneMod.syncConstants((RubyModule)original);
@@ -897,19 +900,16 @@ public IRubyObject rbClone(ThreadContext context, IRubyObject maybeOpts) {
return rbCloneInternal(context, kwfreeze);
}
- // freeze (false, true, nil)
- private RubyBasicObject rbCloneInternal(ThreadContext context, IRubyObject freeze) {
-
- // MRI: immutable_obj_clone
- if (isSpecialObject()) {
- final Ruby runtime = context.runtime;
- if (freeze == runtime.getFalse()) throw runtime.newArgumentError(str(runtime, "can't unfreeze ", types(runtime, getType())));
+ // MRI: rb_dup_setup
+ protected RubyBasicObject dupSetup(ThreadContext context, RubyBasicObject dup) {
+ initCopy(context, dup, this);
+ sites(context).initialize_dup.call(context, dup, dup, this);
- return this;
- }
+ return dup;
+ }
- // We're cloning ourselves, so we know the result should be a RubyObject
- RubyBasicObject clone = (RubyBasicObject) metaClass.getRealClass().allocate();
+ // MRI: rb_clone_setup
+ protected RubyBasicObject cloneSetup(ThreadContext context, RubyBasicObject clone, IRubyObject freeze) {
clone.setMetaClass(getSingletonClassCloneAndAttach(clone));
initCopy(context, clone, this);
@@ -930,6 +930,24 @@ private RubyBasicObject rbCloneInternal(ThreadContext context, IRubyObject freez
}
+ // freeze (false, true, nil)
+ private RubyBasicObject rbCloneInternal(ThreadContext context, IRubyObject freeze) {
+
+ // MRI: immutable_obj_clone
+ if (isSpecialObject()) {
+ final Ruby runtime = context.runtime;
+ if (freeze == runtime.getFalse()) throw runtime.newArgumentError(str(runtime, "can't unfreeze ", types(runtime, getType())));
+
+ return this;
+ }
+
+ // We're cloning ourselves, so we know the result should be a RubyObject
+ RubyBasicObject clone = (RubyBasicObject) metaClass.getRealClass().allocate();
+
+ return cloneSetup(context, clone, freeze);
+ }
+
+
protected RubyClass getSingletonClassClone() {
return getSingletonClassCloneAndAttach(null);
}
@@ -1226,14 +1244,7 @@ public boolean eql(IRubyObject other) {
public void addFinalizer(IRubyObject f) {
Finalizer finalizer = (Finalizer) getInternalVariable("__finalizer__");
if (finalizer == null) {
- // since this is the first time we're registering a finalizer, we
- // must also register this object in ObjectSpace, so that future
- // calls to undefine_finalizer, which takes an object symbol, can
- // locate the object properly. See JRUBY-4839.
- long id = getObjectId();
- IRubyObject fixnumId = id();
-
- getRuntime().getObjectSpace().registerObjectId(id, this);
+ IRubyObject fixnumId = registerWithObjectSpace();
finalizer = new Finalizer(fixnumId);
setInternalVariable("__finalizer__", finalizer);
@@ -1242,6 +1253,34 @@ public void addFinalizer(IRubyObject f) {
finalizer.addFinalizer(f);
}
+ private IRubyObject registerWithObjectSpace() {
+ // since this is the first time we're registering a finalizer, we
+ // must also register this object in ObjectSpace, so that future
+ // calls to undefine_finalizer, which takes an object symbol, can
+ // locate the object properly. See JRUBY-4839.
+ long id = getObjectId();
+ IRubyObject fixnumId = id();
+
+ getRuntime().getObjectSpace().registerObjectId(id, this);
+ return fixnumId;
+ }
+
+ /**
+ * Stange method. We will dup the __finalizer__ variable in a freshly dup'd object,
+ * but it needs to be set to this objects __finalizer__.
+ */
+ protected void dupFinalizer() {
+ Finalizer finalizer = (Finalizer) getInternalVariable("__finalizer__");
+ if (finalizer != null) {
+ // We need ObjectSpace to make this object reachable for the finalization
+ IRubyObject fixnumId = registerWithObjectSpace();
+
+ finalizer = new Finalizer(fixnumId, finalizer);
+ setInternalVariable("__finalizer__", finalizer);
+ getRuntime().addFinalizer(finalizer);
+ }
+ }
+
/**
* Remove all the finalizers for this object.
*/
@@ -1870,6 +1909,17 @@ public Finalizer(RubyFixnum id) {
this((IRubyObject) id);
}
+ /**
+ * Cloning finalizer needs new copy with its own id.
+ * @param id
+ * @param original
+ */
+ public Finalizer(IRubyObject id, Finalizer original) {
+ this(id);
+ this.firstFinalizer = original.firstFinalizer;
+ this.finalizers = original.finalizers == null ? null : new ArrayList<>(original.finalizers);
+ }
+
Finalizer(IRubyObject id) {
this.id = id;
this.finalized = new AtomicBoolean(false);
@@ -1879,7 +1929,7 @@ public void addFinalizer(IRubyObject finalizer) {
if (firstFinalizer == null) {
firstFinalizer = finalizer;
} else {
- if (finalizers == null) finalizers = new ArrayList(4);
+ if (finalizers == null) finalizers = new ArrayList<>(4);
finalizers.add(finalizer);
}
}
diff --git a/core/src/main/java/org/jruby/RubyBignum.java b/core/src/main/java/org/jruby/RubyBignum.java
index 08ebc536ca6..b0a443d4077 100644
--- a/core/src/main/java/org/jruby/RubyBignum.java
+++ b/core/src/main/java/org/jruby/RubyBignum.java
@@ -50,6 +50,8 @@
import org.jruby.runtime.marshal.MarshalStream;
import org.jruby.runtime.marshal.UnmarshalStream;
+import static org.jruby.RubyFixnum.zero;
+
/**
*
* @author jpetersen
@@ -224,9 +226,9 @@ public static double big2dbl(RubyBignum val) {
}
private RubyFixnum checkShiftDown(ThreadContext context, RubyBignum other) {
- if (other.value.signum() == 0) return RubyFixnum.zero(context.runtime);
+ if (other.value.signum() == 0) return zero(context.runtime);
if (value.compareTo(LONG_MIN) < 0 || value.compareTo(LONG_MAX) > 0) {
- return other.value.signum() >= 0 ? RubyFixnum.zero(context.runtime) : RubyFixnum.minus_one(context.runtime);
+ return other.value.signum() >= 0 ? zero(context.runtime) : RubyFixnum.minus_one(context.runtime);
}
return null;
}
@@ -332,47 +334,30 @@ public IRubyObject truncate(ThreadContext context, IRubyObject arg){
@Override
public RubyArray digits(ThreadContext context, IRubyObject base) {
BigInteger self = value;
- Ruby runtime = context.runtime;
- if (self.compareTo(BigInteger.ZERO) == -1) {
- throw runtime.newMathDomainError("out of domain");
- }
- if (!(base instanceof RubyInteger)) {
- try {
- base = base.convertToInteger();
- } catch (ClassCastException e) {
- String cname = getMetaClass(base).getRealClass().getName();
- throw runtime.newTypeError("wrong argument type " + cname + " (expected Integer)");
- }
- }
- BigInteger bigBase;
- if (base instanceof RubyBignum) {
- bigBase = ((RubyBignum) base).value;
- } else {
- bigBase = long2big( ((RubyFixnum) base).value );
- }
+ if (self.compareTo(BigInteger.ZERO) == -1) throw context.runtime.newMathDomainError("out of domain");
- if (bigBase.signum() == -1) {
- throw runtime.newArgumentError("negative radix");
- }
- if (bigBase.compareTo(BigInteger.valueOf(2)) == -1) {
- throw runtime.newArgumentError("invalid radix: " + bigBase);
- }
+ base = base.convertToInteger();
- RubyArray res = RubyArray.newArray(context.runtime, 0);
+ BigInteger bigBase = base instanceof RubyBignum ?
+ ((RubyBignum) base).value : long2big(((RubyFixnum) base).value);
+
+ if (bigBase.signum() == -1) throw context.runtime.newArgumentError("negative radix");
+ if (bigBase.compareTo(BigInteger.valueOf(2)) == -1) throw context.runtime.newArgumentError("invalid radix: " + bigBase);
if (self.signum() == 0) {
- res.append(RubyFixnum.newFixnum(context.getRuntime(), 0));
- return res;
- }
+ return RubyArray.newArray(context.runtime, zero(context.runtime));
+ } else {
+ RubyArray res = RubyArray.newArray(context.runtime, 0);
- while (self.signum() > 0) {
- BigInteger q = self.mod(bigBase);
- res.append(RubyBignum.newBignum(context.getRuntime(), q));
- self = self.divide(bigBase);
- }
+ while (self.signum() > 0) {
+ BigInteger q = self.mod(bigBase);
+ res.append(RubyBignum.newBignum(context.runtime, q));
+ self = self.divide(bigBase);
+ }
- return res;
+ return res;
+ }
}
/** rb_big_to_s
@@ -716,11 +701,11 @@ public IRubyObject quo(ThreadContext context, IRubyObject other) {
@JRubyMethod(name = {"**", "power"})
public IRubyObject op_pow(ThreadContext context, IRubyObject other) {
Ruby runtime = context.runtime;
- if (other == RubyFixnum.zero(runtime)) return RubyFixnum.one(runtime);
+ if (other == zero(runtime)) return RubyFixnum.one(runtime);
final double d;
if (other instanceof RubyFloat) {
d = ((RubyFloat) other).value;
- if (compareTo(RubyFixnum.zero(runtime)) == -1 && d != Math.round(d)) {
+ if (compareTo(zero(runtime)) == -1 && d != Math.round(d)) {
RubyComplex complex = RubyComplex.newComplexRaw(context.runtime, this);
return sites(context).op_exp.call(context, complex, complex, other);
}
@@ -848,7 +833,7 @@ public IRubyObject op_lshift(ThreadContext context, IRubyObject other) {
if (shift < 0) {
if (value.bitLength() <= -shift ) {
if (value.signum() >= 0) {
- return RubyFixnum.zero(context.runtime);
+ return zero(context.runtime);
} else {
return RubyFixnum.minus_one(context.runtime);
}
@@ -857,7 +842,7 @@ public IRubyObject op_lshift(ThreadContext context, IRubyObject other) {
break;
} else if (other instanceof RubyBignum) {
if (value.signum() == 0) {
- return RubyFixnum.zero(context.runtime);
+ return zero(context.runtime);
}
RubyBignum otherBignum = (RubyBignum) other;
@@ -882,7 +867,7 @@ public IRubyObject op_lshift(ThreadContext context, IRubyObject other) {
@Override
public RubyInteger op_lshift(ThreadContext context, long shift) {
if (value.signum() == 0) {
- return RubyFixnum.zero(context.runtime);
+ return zero(context.runtime);
}
if (shift > Integer.MAX_VALUE) {
@@ -904,7 +889,7 @@ public IRubyObject op_rshift(ThreadContext context, IRubyObject other) {
shift = ((RubyFixnum) other).value;
if (value.bitLength() <= shift ) {
if (value.signum() >= 0) {
- return RubyFixnum.zero(context.runtime);
+ return zero(context.runtime);
} else {
return RubyFixnum.minus_one(context.runtime);
}
@@ -912,7 +897,7 @@ public IRubyObject op_rshift(ThreadContext context, IRubyObject other) {
break;
} else if (other instanceof RubyBignum) {
if (value == BigInteger.ZERO) {
- return RubyFixnum.zero(context.runtime);
+ return zero(context.runtime);
}
RubyBignum otherBignum = (RubyBignum) other;
@@ -937,7 +922,7 @@ public IRubyObject op_rshift(ThreadContext context, IRubyObject other) {
@Override
public RubyInteger op_rshift(ThreadContext context, long shift) {
if (value.signum() == 0) {
- return RubyFixnum.zero(context.runtime);
+ return zero(context.runtime);
}
if (shift < Integer.MIN_VALUE) {
@@ -968,17 +953,17 @@ protected IRubyObject op_aref_subclass(ThreadContext context, IRubyObject other)
if (other instanceof RubyBignum) {
// '!=' for negative value
if ((((RubyBignum) other).value.signum() >= 0) != (value.signum() == -1)) {
- return RubyFixnum.zero(context.runtime);
+ return zero(context.runtime);
}
return RubyFixnum.one(context.runtime);
}
}
long position = num2long(other);
if (position < 0 || position > Integer.MAX_VALUE) {
- return RubyFixnum.zero(context.runtime);
+ return zero(context.runtime);
}
- return value.testBit((int)position) ? RubyFixnum.one(context.runtime) : RubyFixnum.zero(context.runtime);
+ return value.testBit((int)position) ? RubyFixnum.one(context.runtime) : zero(context.runtime);
}
private enum BIGNUM_OP_T {
@@ -1086,7 +1071,7 @@ private IRubyObject float_cmp(ThreadContext context, RubyFloat y) {
yf = yd - yi;
IRubyObject rel = op_cmp(context, newBignorm(runtime, yi));
- if (yf == 0.0 || !rel.equals(RubyFixnum.zero(runtime))) {
+ if (yf == 0.0 || !rel.equals(zero(runtime))) {
return rel;
}
if (yf < 0.0) {
@@ -1335,7 +1320,7 @@ public IRubyObject isNegative(ThreadContext context) {
if (op_lt_site.isBuiltin(metaClass)) {
return RubyBoolean.newBoolean(context, value.signum() < 0);
}
- return op_lt_site.call(context, this, this, RubyFixnum.zero(context.runtime));
+ return op_lt_site.call(context, this, this, zero(context.runtime));
}
@Override
@@ -1344,7 +1329,7 @@ public IRubyObject isPositive(ThreadContext context) {
if (op_gt_site.isBuiltin(metaClass)) {
return RubyBoolean.newBoolean(context, value.signum() > 0);
}
- return op_gt_site.call(context, this, this, RubyFixnum.zero(context.runtime));
+ return op_gt_site.call(context, this, this, zero(context.runtime));
}
@Override
diff --git a/core/src/main/java/org/jruby/RubyFixnum.java b/core/src/main/java/org/jruby/RubyFixnum.java
index 1d68a68c5b9..1c73bd4067f 100644
--- a/core/src/main/java/org/jruby/RubyFixnum.java
+++ b/core/src/main/java/org/jruby/RubyFixnum.java
@@ -372,44 +372,30 @@ public IRubyObject truncate(ThreadContext context, IRubyObject arg) {
*/
@Override
public RubyArray digits(ThreadContext context, IRubyObject base) {
- final Ruby runtime = context.runtime;
-
long value = getLongValue();
- if (value < 0) {
- throw runtime.newMathDomainError("out of domain");
- }
- if (!(base instanceof RubyInteger)) {
- try {
- base = base.convertToInteger();
- } catch (ClassCastException e) {
- String cname = getMetaClass(base).getRealClass().getName();
- throw runtime.newTypeError("wrong argument type " + cname + " (expected Integer)");
- }
- }
- if (base instanceof RubyBignum){
- return RubyArray.newArray(context.runtime, newFixnum(runtime, value));
- }
+ if (value < 0) throw context.runtime.newMathDomainError("out of domain");
+
+ base = base.convertToInteger();
+
+ if (base instanceof RubyBignum) return RubyArray.newArray(context.runtime, newFixnum(context.runtime, value));
+
long longBase = ((RubyFixnum) base).value;
- if (longBase < 0) {
- throw runtime.newArgumentError("negative radix");
- }
- if (longBase < 2) {
- throw runtime.newArgumentError("invalid radix: " + longBase);
- }
+ if (longBase < 0) throw context.runtime.newArgumentError("negative radix");
+ if (longBase < 2) throw context.runtime.newArgumentError("invalid radix: " + longBase);
if (value == 0) {
- return RubyArray.newArray(context.runtime, zero(runtime));
- }
+ return RubyArray.newArray(context.runtime, zero(context.runtime));
+ } else {
+ RubyArray res = RubyArray.newArray(context.runtime, 0);
- RubyArray res = RubyArray.newArray(context.runtime, 0);
+ while (value > 0) {
+ res.append(newFixnum(context.runtime, value % longBase));
+ value /= longBase;
+ }
- while (value > 0) {
- res.append(newFixnum(runtime, value % longBase));
- value /= longBase;
+ return res;
}
-
- return res;
}
diff --git a/core/src/main/java/org/jruby/RubyIO.java b/core/src/main/java/org/jruby/RubyIO.java
index b514700441c..6f44424df8f 100644
--- a/core/src/main/java/org/jruby/RubyIO.java
+++ b/core/src/main/java/org/jruby/RubyIO.java
@@ -2573,6 +2573,9 @@ public IRubyObject getline(ThreadContext context, RubyIO self, IRubyObject rs, i
private static final Getline.Callback GETLINE_YIELD = new Getline.Callback() {
@Override
public RubyIO getline(ThreadContext context, RubyIO self, IRubyObject rs, int limit, boolean chomp, Block block) {
+ if (limit == 0) {
+ throw context.runtime.newArgumentError("invalid limit: 0 for foreach");
+ }
IRubyObject line;
while ((line = self.getlineImpl(context, rs, limit, chomp)) != context.nil) {
@@ -3837,9 +3840,6 @@ private static IRubyObject foreachInternal(ThreadContext context, IRubyObject re
case 3:
Getline.getlineCall(context, GETLINE_YIELD, io, io.getReadEncoding(context), args[1], args[2], block);
break;
- case 4:
- Getline.getlineCall(context, GETLINE_YIELD, io, io.getReadEncoding(context), args[1], args[2], args[3], block);
- break;
}
} finally {
io.close();
@@ -4344,7 +4344,7 @@ static IRubyObject seekBeforeAccess(ThreadContext context, RubyIO io, IRubyObjec
}
// rb_io_s_readlines
- @JRubyMethod(name = "readlines", required = 1, optional = 3, checkArity = false, meta = true)
+ @JRubyMethod(name = "readlines", required = 1, optional = 2, checkArity = false, meta = true)
public static IRubyObject readlines(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
IRubyObject opt = ArgsUtil.getOptionsArg(context.runtime, args);
final RubyIO io = openKeyArgs(context, recv, args, opt);
@@ -4359,11 +4359,8 @@ public static IRubyObject readlines(ThreadContext context, IRubyObject recv, IRu
case 3:
if (opt != context.nil) return io.readlines(context, args[1], opt);
return io.readlines(context, args[1], args[2]);
- case 4:
- if (opt != context.nil) return io.readlines(context, args[1], args[2], opt);
- return io.readlines(context, args[1], args[2], args[3]);
default:
- Arity.raiseArgumentError(context, args.length, 1, 4);
+ Arity.raiseArgumentError(context, args.length, 1, 3);
throw new AssertionError("BUG");
}
} finally { io.close(); }
diff --git a/core/src/main/java/org/jruby/RubyMethod.java b/core/src/main/java/org/jruby/RubyMethod.java
index 2bc9e876dad..b109a525abe 100644
--- a/core/src/main/java/org/jruby/RubyMethod.java
+++ b/core/src/main/java/org/jruby/RubyMethod.java
@@ -214,9 +214,16 @@ private long hashCodeImpl() {
@Override
public RubyMethod rbClone() {
RubyMethod newMethod = newMethod(implementationModule, methodName, originModule, originName, entry, receiver);
- newMethod.setMetaClass(getMetaClass());
- if (isFrozen()) newMethod.setFrozen(true);
- return newMethod;
+ ThreadContext context = getRuntime().getCurrentContext();
+
+ return (RubyMethod) cloneSetup(context, newMethod, context.nil);
+ }
+
+ @JRubyMethod
+ public RubyMethod dup(ThreadContext context) {
+ RubyMethod newMethod = newMethod(implementationModule, methodName, originModule, originName, entry, receiver);
+
+ return (RubyMethod) dupSetup(context, newMethod);
}
/** Create a Proc object.
diff --git a/core/src/main/java/org/jruby/RubyModule.java b/core/src/main/java/org/jruby/RubyModule.java
index f4df06cdd17..5c34f3e5497 100644
--- a/core/src/main/java/org/jruby/RubyModule.java
+++ b/core/src/main/java/org/jruby/RubyModule.java
@@ -166,6 +166,7 @@ public class RubyModule extends RubyObject {
public static final int IS_OVERLAID_F = ObjectFlags.IS_OVERLAID_F;
public static final int OMOD_SHARED = ObjectFlags.OMOD_SHARED;
public static final int INCLUDED_INTO_REFINEMENT = ObjectFlags.INCLUDED_INTO_REFINEMENT;
+ public static final int TEMPORARY_NAME = ObjectFlags.TEMPORARY_NAME;
public static final String BUILTIN_CONSTANT = "";
@@ -687,7 +688,7 @@ private RubyString calculateRubyName() {
if (getBaseName() == null) return calculateAnonymousRubyName(); // no name...anonymous!
- if (!IdUtil.isValidConstantName(baseName)) { // temporary name
+ if (usingTemporaryName()) { // temporary name
cachedRubyName = getRuntime().newSymbol(baseName).toRubyString(getRuntime().getCurrentContext());
return cachedRubyName;
}
@@ -831,6 +832,8 @@ public IRubyObject set_temporary_name(ThreadContext context, IRubyObject arg) {
if (name.length() == 0) throw context.runtime.newArgumentError("empty class/module name");
if (isValidConstantPath(name)) throw context.runtime.newArgumentError("the temporary name must not be a constant path to avoid confusion");
+ setFlag(TEMPORARY_NAME, true);
+
// We make sure we generate ISO_8859_1 String and also guarantee when we want to print this name
// later it does not lose track of the orignal encoding.
RubySymbol symbol = context.runtime.newSymbol(name.getByteList());
@@ -4570,6 +4573,13 @@ private IRubyObject getRefinedClassOrThrow(ThreadContext context, boolean nameIs
}
return refinedClass;
}
+
+ @JRubyMethod(name = "used_refinements")
+ public IRubyObject used_refinements(ThreadContext context) {
+ // TODO: not implemented
+ return RubyArray.newEmptyArray(context.runtime);
+ }
+
//
////////////////// CLASS VARIABLE API METHODS ////////////////
//
@@ -5006,7 +5016,7 @@ private void setParentForModule(final String name, final IRubyObject value) {
// if adding a module under a constant name, set that module's basename to the constant name
if ( value instanceof RubyModule ) {
RubyModule module = (RubyModule) value;
- if (module != this && module.getBaseName() == null) {
+ if (module != this && (module.getBaseName() == null || module.usingTemporaryName())) {
module.setBaseName(name);
module.setParent(this);
}
@@ -5990,6 +6000,10 @@ public boolean isRefinement() {
return getFlag(REFINED_MODULE_F);
}
+ public boolean usingTemporaryName() {
+ return getFlag(TEMPORARY_NAME);
+ }
+
public boolean isIncludedIntoRefinement() {
return getFlag(INCLUDED_INTO_REFINEMENT);
}
diff --git a/core/src/main/java/org/jruby/RubyProc.java b/core/src/main/java/org/jruby/RubyProc.java
index de19cf61d30..ace8ac3c197 100644
--- a/core/src/main/java/org/jruby/RubyProc.java
+++ b/core/src/main/java/org/jruby/RubyProc.java
@@ -219,16 +219,12 @@ private void setup(Block procBlock) {
@JRubyMethod(name = "clone")
public IRubyObject rbClone(ThreadContext context) {
- RubyProc clone = procDup();
- sites(context).initialize_clone.call(context, clone, clone, this);
- return clone;
+ return cloneSetup(context, procDup(), context.nil);
}
@JRubyMethod(name = "dup")
public IRubyObject dup(ThreadContext context) {
- RubyProc dup = procDup();
- sites(context).initialize_dup.call(context, dup, dup, this);
- return dup;
+ return dupSetup(context, procDup());
}
private RubyProc procDup() {
diff --git a/core/src/main/java/org/jruby/RubyRange.java b/core/src/main/java/org/jruby/RubyRange.java
index edcc40929c5..08f9cc56fa8 100644
--- a/core/src/main/java/org/jruby/RubyRange.java
+++ b/core/src/main/java/org/jruby/RubyRange.java
@@ -1167,6 +1167,13 @@ public IRubyObject call(ThreadContext ctx, IRubyObject larg, Block blk) {
public IRubyObject count(ThreadContext context, Block block) {
if (isBeginless || isEndless) return RubyFloat.newFloat(context.runtime, RubyFloat.INFINITY);
+ if (begin instanceof RubyInteger) {
+ IRubyObject size = size(context);
+ if (!size.isNil()) {
+ return size;
+ }
+ }
+
return RubyEnumerable.count(context, this, block);
}
diff --git a/core/src/main/java/org/jruby/RubyUnboundMethod.java b/core/src/main/java/org/jruby/RubyUnboundMethod.java
index 3e19a9f81bd..1ab01988511 100644
--- a/core/src/main/java/org/jruby/RubyUnboundMethod.java
+++ b/core/src/main/java/org/jruby/RubyUnboundMethod.java
@@ -147,11 +147,18 @@ private CacheEntry convertUnboundMethodToCallableEntry(ThreadContext context, Ru
}
@JRubyMethod(name = "clone")
- @Override
public RubyUnboundMethod rbClone() {
RubyUnboundMethod unboundMethod = newUnboundMethod(implementationModule, methodName, originModule, originName, entry);
- if (isFrozen()) unboundMethod.setFrozen(true);
- return unboundMethod;
+ ThreadContext context = getRuntime().getCurrentContext();
+
+ return (RubyUnboundMethod) cloneSetup(context, unboundMethod, context.nil);
+ }
+
+ @JRubyMethod
+ public RubyUnboundMethod dup(ThreadContext context) {
+ RubyUnboundMethod unboundMethod = newUnboundMethod(implementationModule, methodName, originModule, originName, entry);
+
+ return (RubyUnboundMethod) dupSetup(context, unboundMethod);
}
@JRubyMethod(required = 1, rest = true, checkArity = false, keywords = true)
diff --git a/core/src/main/java/org/jruby/ast/ErrorNode.java b/core/src/main/java/org/jruby/ast/ErrorNode.java
new file mode 100644
index 00000000000..1275f9cba72
--- /dev/null
+++ b/core/src/main/java/org/jruby/ast/ErrorNode.java
@@ -0,0 +1,31 @@
+package org.jruby.ast;
+
+import org.jruby.ast.visitor.NodeVisitor;
+import org.jruby.parser.ProductionState;
+
+import java.util.List;
+
+public class ErrorNode extends Node {
+ ProductionState loc;
+ // FIXME: Perhaps we can store real location object and not just leak production state.
+ public ErrorNode(ProductionState loc) {
+ super(loc.start(), false);
+
+ this.loc = loc;
+ }
+
+ @Override
+ public T accept(NodeVisitor visitor) {
+ return null;
+ }
+
+ @Override
+ public List childNodes() {
+ return null;
+ }
+
+ @Override
+ public NodeType getNodeType() {
+ return null;
+ }
+}
diff --git a/core/src/main/java/org/jruby/ast/Node.java b/core/src/main/java/org/jruby/ast/Node.java
index 5021a0bb50f..80e6f9122e5 100644
--- a/core/src/main/java/org/jruby/ast/Node.java
+++ b/core/src/main/java/org/jruby/ast/Node.java
@@ -39,7 +39,6 @@
import java.util.List;
import org.jruby.ast.types.INameNode;
-import org.jruby.ast.visitor.AbstractNodeVisitor;
import org.jruby.ast.visitor.NodeVisitor;
/**
@@ -192,9 +191,9 @@ public String toString(boolean indent, int indentation) {
/**
* Overridden by nodes that have additional internal state to be displated in toString.
- *
+ *
* For nodes that have it, name is handled separately, by implementing INameNode.
- *
+ *
* Child nodes are handled via iterating #childNodes.
*
* @return A string representing internal node state, or null if none.
@@ -204,9 +203,7 @@ protected String toStringInternal() {
}
private static void indent(int indentation, StringBuilder builder) {
- for (int n = 0; n < indentation; n++) {
- builder.append(" ");
- }
+ builder.append(" ".repeat(Math.max(0, indentation)));
}
protected String getNodeName() {
@@ -214,21 +211,6 @@ protected String getNodeName() {
return name.substring(name.lastIndexOf('.') + 1);
}
- public T findFirstChild(final Class nodeClass) {
- return accept(new AbstractNodeVisitor() {
-
- @Override
- protected T defaultVisit(Node node) {
- if (nodeClass.isAssignableFrom(node.getClass())) {
- return (T) node;
- } else {
- return visitFirstChild(node);
- }
- }
-
- });
- }
-
/**
* @return the nodeId
*/
diff --git a/core/src/main/java/org/jruby/ast/visitor/AbstractNodeVisitor.java b/core/src/main/java/org/jruby/ast/visitor/AbstractNodeVisitor.java
index 5b7b2d0ae97..881ffeeba62 100644
--- a/core/src/main/java/org/jruby/ast/visitor/AbstractNodeVisitor.java
+++ b/core/src/main/java/org/jruby/ast/visitor/AbstractNodeVisitor.java
@@ -249,6 +249,11 @@ public T visitEnsureNode(EnsureNode node) {
return defaultVisit(node);
}
+ @Override
+ public T visitErrorNode(ErrorNode node) {
+ return defaultVisit(node);
+ }
+
@Override
public T visitEvStrNode(EvStrNode node) {
return defaultVisit(node);
diff --git a/core/src/main/java/org/jruby/ast/visitor/NodeVisitor.java b/core/src/main/java/org/jruby/ast/visitor/NodeVisitor.java
index 7cfddbcfc38..e9e1d5c83f5 100644
--- a/core/src/main/java/org/jruby/ast/visitor/NodeVisitor.java
+++ b/core/src/main/java/org/jruby/ast/visitor/NodeVisitor.java
@@ -80,6 +80,7 @@ public interface NodeVisitor {
T visitDotNode(DotNode iVisited);
T visitEncodingNode(EncodingNode iVisited);
T visitEnsureNode(EnsureNode iVisited);
+ T visitErrorNode(ErrorNode iVisited);
T visitEvStrNode(EvStrNode iVisited);
T visitFCallNode(FCallNode iVisited);
T visitFalseNode(FalseNode iVisited);
diff --git a/core/src/main/java/org/jruby/ext/ripper/RubyLexer.java b/core/src/main/java/org/jruby/ext/ripper/RubyLexer.java
index 7a6188f4105..599067cd3fd 100644
--- a/core/src/main/java/org/jruby/ext/ripper/RubyLexer.java
+++ b/core/src/main/java/org/jruby/ext/ripper/RubyLexer.java
@@ -401,7 +401,7 @@ protected void set_yylval_val(ByteList name) {
public int tokenize_ident(int result) {
String value = createTokenString();
- if (!isLexState(last_state, EXPR_DOT|EXPR_FNAME) && parser.getCurrentScope().isDefined(value) >= 0) {
+ if (!IS_lex_state(last_state, EXPR_DOT|EXPR_FNAME) && parser.getCurrentScope().isDefined(value) >= 0) {
setState(EXPR_END);
}
@@ -1071,9 +1071,9 @@ private int yylex() throws IOException {
/* fall through */
case '\n': {
this.tokenSeen = tokenSeen;
- boolean normalArg = isLexState(lex_state, EXPR_BEG | EXPR_CLASS | EXPR_FNAME | EXPR_DOT) &&
- !isLexState(lex_state, EXPR_LABELED);
- if (normalArg || isLexStateAll(lex_state, EXPR_ARG | EXPR_LABELED)) {
+ boolean normalArg = IS_lex_state(lex_state, EXPR_BEG | EXPR_CLASS | EXPR_FNAME | EXPR_DOT) &&
+ !IS_lex_state(lex_state, EXPR_LABELED);
+ if (normalArg || IS_lex_state_all(lex_state, EXPR_ARG | EXPR_LABELED)) {
if (!fallthru) dispatchScanEvent(tIGNORED_NL);
fallthru = false;
if (!normalArg && getLexContext().in_kwarg) {
@@ -1162,7 +1162,7 @@ private int yylex() throws IOException {
}
}
- setState(isAfterOperator() ? EXPR_ARG : EXPR_BEG);
+ setState(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG);
c = nextc();
if (c == '=') {
@@ -1276,7 +1276,7 @@ private RubySymbol symbol(ByteList name) {
}
private int identifierToken(int last_state, int result, String value) {
- if (result == tIDENTIFIER && !isLexState(last_state, EXPR_DOT|EXPR_FNAME) &&
+ if (result == tIDENTIFIER && !IS_lex_state(last_state, EXPR_DOT|EXPR_FNAME) &&
parser.getCurrentScope().isDefined(value) >= 0) {
setState(EXPR_END|EXPR_LABEL);
}
@@ -1314,16 +1314,16 @@ private int ampersand(boolean spaceSeen) {
}
pushback(c);
- if (isSpaceArg(c, spaceSeen)) {
+ if (IS_SPCARG(c, spaceSeen)) {
if (isVerbose()) warning("`&' interpreted as argument prefix");
c = tAMPER;
- } else if (isBEG()) {
+ } else if (IS_BEG()) {
c = warn_balanced(c, spaceSeen, tAMPER, "&", "argument prefix");
} else {
c = '&';
}
- setState(isAfterOperator() ? EXPR_ARG : EXPR_BEG);
+ setState(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG);
yaccValue = AMPERSAND;
return c;
@@ -1339,7 +1339,7 @@ private int at() {
} else {
result = tIVAR;
}
- setState(isLexState(last_state, EXPR_FNAME) ? EXPR_ENDFN : EXPR_END);
+ setState(IS_lex_state(last_state, EXPR_FNAME) ? EXPR_ENDFN : EXPR_END);
if (c == EOF || !isIdentifierChar(c)) {
if (result == tIVAR) {
@@ -1370,11 +1370,11 @@ private int at() {
private int backtick(boolean commandState) {
yaccValue = BACKTICK;
- if (isLexState(lex_state, EXPR_FNAME)) {
+ if (IS_lex_state(lex_state, EXPR_FNAME)) {
setState(EXPR_ENDFN);
return '`';
}
- if (isLexState(lex_state, EXPR_DOT)) {
+ if (IS_lex_state(lex_state, EXPR_DOT)) {
setState(commandState ? EXPR_CMDARG : EXPR_ARG);
return '`';
@@ -1387,7 +1387,7 @@ private int backtick(boolean commandState) {
private int bang() {
int c = nextc();
- if (isAfterOperator()) {
+ if (IS_AFTER_OPERATOR()) {
setState(EXPR_ARG);
if (c == '@') {
yaccValue = BANG;
@@ -1424,7 +1424,7 @@ private int caret() {
return tOP_ASGN;
}
- setState(isAfterOperator() ? EXPR_ARG : EXPR_BEG);
+ setState(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG);
pushback(c);
return '^';
@@ -1434,7 +1434,7 @@ private int colon(boolean spaceSeen) {
int c = nextc();
if (c == ':') {
- if (isBEG() || isLexState(lex_state, EXPR_CLASS) || (isARG() && spaceSeen)) {
+ if (IS_BEG() || IS_lex_state(lex_state, EXPR_CLASS) || (IS_ARG() && spaceSeen)) {
setState(EXPR_BEG);
yaccValue = COLON_COLON;
return tCOLON3;
@@ -1445,7 +1445,7 @@ private int colon(boolean spaceSeen) {
return tCOLON2;
}
- if (isEND() || Character.isWhitespace(c) || c == '#') {
+ if (IS_END() || Character.isWhitespace(c) || c == '#') {
pushback(c);
setState(EXPR_BEG);
yaccValue = COLON;
@@ -1481,7 +1481,7 @@ private int doKeyword(int state) {
if (conditionState.set_p()) return keyword_do_cond;
- if (cmdArgumentState.set_p() && !isLexState(state, EXPR_CMDARG)) {
+ if (cmdArgumentState.set_p() && !IS_lex_state(state, EXPR_CMDARG)) {
return keyword_do_block;
}
@@ -1544,7 +1544,7 @@ private int dollar() {
case '\'': /* $': string after last match */
case '+': /* $+: string matches last paren. */
// Explicit reference to these vars as symbols...
- if (isLexState(last_state, EXPR_FNAME)) {
+ if (IS_lex_state(last_state, EXPR_FNAME)) {
identValue = "$" + (char) c;
set_yylval_name(new ByteList(new byte[] {'$', (byte) c}));
return tGVAR;
@@ -1559,7 +1559,7 @@ private int dollar() {
c = nextc();
} while (Character.isDigit(c));
pushback(c);
- if (isLexState(last_state, EXPR_FNAME)) {
+ if (IS_lex_state(last_state, EXPR_FNAME)) {
identValue = createTokenString().intern();
set_yylval_name(new ByteList(new byte[] {'$', (byte) c}));
return tGVAR;
@@ -1602,7 +1602,7 @@ private int dollar() {
private int dot() {
int c;
- boolean isBeg = isBEG();
+ boolean isBeg = IS_BEG();
setState(EXPR_BEG);
if ((c = nextc()) == '.') {
if ((c = nextc()) == '.') {
@@ -1616,7 +1616,7 @@ private int dot() {
if (parenNest == 0 && isLookingAtEOL()) {
warn("... at EOL, should be parenthesized?");
} else if (getLeftParenBegin() >= 0 && getLeftParenBegin() + 1 == parenNest) {
- if (isLexState(last_state, EXPR_LABEL)) {
+ if (IS_lex_state(last_state, EXPR_LABEL)) {
return tDOT3;
}
}
@@ -1638,14 +1638,14 @@ private int dot() {
}
private int doubleQuote(boolean commandState) {
- int label = isLabelPossible(commandState) ? str_label : 0;
+ int label = IS_LABEL_POSSIBLE(commandState) ? str_label : 0;
lex_strterm = new StringTerm(str_dquote|label, '\0', '"', ruby_sourceline);
yaccValue = QQ;
return tSTRING_BEG;
}
private int greaterThan() {
- setState(isAfterOperator() ? EXPR_ARG : EXPR_BEG);
+ setState(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG);
int c = nextc();
@@ -1711,7 +1711,7 @@ private int identifier(int c, boolean commandState) {
result = tFID;
tempVal = createTokenString();
} else {
- if (isLexState(lex_state, EXPR_FNAME)) {
+ if (IS_lex_state(lex_state, EXPR_FNAME)) {
if ((c = nextc()) == '=') {
int c2 = nextc();
@@ -1736,8 +1736,8 @@ private int identifier(int c, boolean commandState) {
}
}
- if (isLabelPossible(commandState)) {
- if (isLabelSuffix()) {
+ if (IS_LABEL_POSSIBLE(commandState)) {
+ if (IS_LABEL_SUFFIX()) {
setState(EXPR_ARG|EXPR_LABELED);
yaccValue = tempVal;
identValue = tempVal.intern();
@@ -1755,17 +1755,17 @@ private int identifier(int c, boolean commandState) {
setState(keyword.state);
set_yylval_name(createTokenByteList());
- if (isLexState(state, EXPR_FNAME)) {
+ if (IS_lex_state(state, EXPR_FNAME)) {
setState(EXPR_ENDFN);
identValue = tempVal;
return keyword.id0;
}
- if (isLexState(lex_state, EXPR_BEG)) commandStart = true;
+ if (IS_lex_state(lex_state, EXPR_BEG)) commandStart = true;
if (keyword.id0 == keyword_do) return doKeyword(state);
- if (isLexState(state, EXPR_BEG|EXPR_LABELED)) {
+ if (IS_lex_state(state, EXPR_BEG|EXPR_LABELED)) {
return keyword.id0;
} else {
if (keyword.id0 != keyword.id1) setState(EXPR_BEG|EXPR_LABEL);
@@ -1774,7 +1774,7 @@ private int identifier(int c, boolean commandState) {
}
}
- if (isLexState(lex_state, EXPR_BEG_ANY|EXPR_ARG_ANY|EXPR_DOT)) {
+ if (IS_lex_state(lex_state, EXPR_BEG_ANY|EXPR_ARG_ANY|EXPR_DOT)) {
setState(commandState ? EXPR_CMDARG : EXPR_ARG);
} else if (lex_state == EXPR_FNAME) {
setState(EXPR_ENDFN);
@@ -1788,7 +1788,7 @@ private int identifier(int c, boolean commandState) {
private int leftBracket(boolean spaceSeen) {
parenNest++;
int c = '[';
- if (isAfterOperator()) {
+ if (IS_AFTER_OPERATOR()) {
if ((c = nextc()) == ']') {
setState(EXPR_ARG);
if (peek('=')) {
@@ -1803,7 +1803,7 @@ private int leftBracket(boolean spaceSeen) {
setState(EXPR_ARG|EXPR_LABEL);
yaccValue = LBRACKET;
return '[';
- } else if (isBEG() || (isARG() && (spaceSeen || isLexState(lex_state, EXPR_LABELED)))) {
+ } else if (IS_BEG() || (IS_ARG() && (spaceSeen || IS_lex_state(lex_state, EXPR_LABELED)))) {
c = tLBRACK;
}
@@ -1819,11 +1819,11 @@ private int leftCurly() {
char c;
if (isLambdaBeginning()) {
c = tLAMBEG;
- } else if (isLexState(lex_state, EXPR_LABELED)) {
+ } else if (IS_lex_state(lex_state, EXPR_LABELED)) {
c = tLBRACE;
- } else if (isLexState(lex_state, EXPR_ARG_ANY|EXPR_END|EXPR_ENDFN)) { // block (primary)
+ } else if (IS_lex_state(lex_state, EXPR_ARG_ANY|EXPR_END|EXPR_ENDFN)) { // block (primary)
c = '{';
- } else if (isLexState(lex_state, EXPR_ENDARG)) { // block (expr)
+ } else if (IS_lex_state(lex_state, EXPR_ENDARG)) { // block (expr)
c = tLBRACE_ARG;
} else { // hash
c = tLBRACE;
@@ -1847,13 +1847,13 @@ private int leftCurly() {
private int leftParen(boolean spaceSeen) {
int result;
- if (isBEG()) {
+ if (IS_BEG()) {
result = tLPAREN;
} else if (!spaceSeen) {
result = '(';
- } else if (isARG() || isLexStateAll(lex_state, EXPR_END|EXPR_LABEL)) {
+ } else if (IS_ARG() || IS_lex_state_all(lex_state, EXPR_END|EXPR_LABEL)) {
result = tLPAREN_ARG;
- } else if (isLexState(lex_state, EXPR_ENDFN) && !isLambdaBeginning()) {
+ } else if (IS_lex_state(lex_state, EXPR_ENDFN) && !isLambdaBeginning()) {
warn("parentheses after method name is interpreted as an argument list, not a decomposed argument");
result = '(';
} else {
@@ -1871,17 +1871,17 @@ private int leftParen(boolean spaceSeen) {
private int lessThan(boolean spaceSeen) {
last_state = lex_state;
int c = nextc();
- if (c == '<' && !isLexState(lex_state, EXPR_DOT|EXPR_CLASS) &&
- !isEND() && (!isARG() || isLexState(lex_state, EXPR_LABELED) || spaceSeen)) {
+ if (c == '<' && !IS_lex_state(lex_state, EXPR_DOT|EXPR_CLASS) &&
+ !IS_END() && (!IS_ARG() || IS_lex_state(lex_state, EXPR_LABELED) || spaceSeen)) {
int tok = hereDocumentIdentifier();
if (tok != 0) return tok;
}
- if (isAfterOperator()) {
+ if (IS_AFTER_OPERATOR()) {
setState(EXPR_ARG);
} else {
- if (isLexState(lex_state, EXPR_CLASS)) commandStart = true;
+ if (IS_lex_state(lex_state, EXPR_CLASS)) commandStart = true;
setState(EXPR_BEG);
}
@@ -1913,7 +1913,7 @@ private int lessThan(boolean spaceSeen) {
private int minus(boolean spaceSeen) {
int c = nextc();
- if (isAfterOperator()) {
+ if (IS_AFTER_OPERATOR()) {
setState(EXPR_ARG);
if (c == '@') {
yaccValue = MINUS_AT;
@@ -1934,7 +1934,7 @@ private int minus(boolean spaceSeen) {
yaccValue = MINUS_GT;
return tLAMBDA;
}
- if (isBEG() || (isSpaceArg(c, spaceSeen) && arg_ambiguous('-'))) {
+ if (IS_BEG() || (IS_SPCARG(c, spaceSeen) && arg_ambiguous('-'))) {
setState(EXPR_BEG);
pushback(c);
yaccValue = MINUS_AT;
@@ -1951,7 +1951,7 @@ private int minus(boolean spaceSeen) {
}
private int percent(boolean spaceSeen) {
- if (isBEG()) return parseQuote(nextc());
+ if (IS_BEG()) return parseQuote(nextc());
int c = nextc();
@@ -1962,9 +1962,9 @@ private int percent(boolean spaceSeen) {
return tOP_ASGN;
}
- if (isSpaceArg(c, spaceSeen) || (isLexState(lex_state, EXPR_FITEM) && c == 's')) return parseQuote(c);
+ if (IS_SPCARG(c, spaceSeen) || (IS_lex_state(lex_state, EXPR_FITEM) && c == 's')) return parseQuote(c);
- setState(isAfterOperator() ? EXPR_ARG : EXPR_BEG);
+ setState(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG);
pushback(c);
yaccValue = PERCENT;
@@ -1984,7 +1984,7 @@ private int pipe() {
return tOP_ASGN;
}
pushback(c);
- if (isLexStateAll(last_state, EXPR_BEG)) {
+ if (IS_lex_state_all(last_state, EXPR_BEG)) {
yaccValue = OR;
pushback('|');
return '|';
@@ -1997,7 +1997,7 @@ private int pipe() {
set_yylval_id(OR);
return tOP_ASGN;
default:
- setState(isAfterOperator() ? EXPR_ARG : EXPR_BEG|EXPR_LABEL);
+ setState(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG|EXPR_LABEL);
pushback(c);
yaccValue = OR;
@@ -2007,7 +2007,7 @@ private int pipe() {
private int plus(boolean spaceSeen) {
int c = nextc();
- if (isAfterOperator()) {
+ if (IS_AFTER_OPERATOR()) {
setState(EXPR_ARG);
if (c == '@') {
yaccValue = PLUS_AT;
@@ -2026,7 +2026,7 @@ private int plus(boolean spaceSeen) {
return tOP_ASGN;
}
- if (isBEG() || (isSpaceArg(c, spaceSeen) && arg_ambiguous('+'))) {
+ if (IS_BEG() || (IS_SPCARG(c, spaceSeen) && arg_ambiguous('+'))) {
setState(EXPR_BEG);
pushback(c);
if (Character.isDigit(c)) {
@@ -2051,7 +2051,7 @@ private int plus(boolean spaceSeen) {
private int questionMark() throws IOException {
int c;
- if (isEND()) {
+ if (IS_END()) {
setState(EXPR_VALUE);
yaccValue = QUESTION;
return '?';
@@ -2064,7 +2064,7 @@ private int questionMark() throws IOException {
}
if (Character.isWhitespace(c)){
- if (!isARG()) {
+ if (!IS_ARG()) {
int c2 = 0;
switch (c) {
case ' ':
@@ -2164,7 +2164,7 @@ private int rightParen() {
}
private int singleQuote(boolean commandState) {
- int label = isLabelPossible(commandState) ? str_label : 0;
+ int label = IS_LABEL_POSSIBLE(commandState) ? str_label : 0;
lex_strterm = new StringTerm(str_squote|label, '\0', '\'', ruby_sourceline);
yaccValue = Q;
@@ -2172,7 +2172,7 @@ private int singleQuote(boolean commandState) {
}
private int slash(boolean spaceSeen) {
- if (isBEG()) {
+ if (IS_BEG()) {
lex_strterm = new StringTerm(str_regexp, '\0', '/', ruby_sourceline);
return tREGEXP_BEG;
}
@@ -2185,13 +2185,13 @@ private int slash(boolean spaceSeen) {
return tOP_ASGN;
}
pushback(c);
- if (isSpaceArg(c, spaceSeen)) {
+ if (IS_SPCARG(c, spaceSeen)) {
arg_ambiguous('/');
lex_strterm = new StringTerm(str_regexp, '\0', '/', ruby_sourceline);
return tREGEXP_BEG;
}
- setState(isAfterOperator() ? EXPR_ARG : EXPR_BEG);
+ setState(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG);
return warn_balanced(c, spaceSeen, '/', "/", "regexp literal");
}
@@ -2211,10 +2211,10 @@ private int star(boolean spaceSeen) {
pushback(c);
yaccValue = STAR_STAR;
- if (isSpaceArg(c, spaceSeen)) {
+ if (IS_SPCARG(c, spaceSeen)) {
if (isVerbose() && Options.PARSER_WARN_ARGUMENT_PREFIX.load()) warning("`**' interpreted as argument prefix");
c = tDSTAR;
- } else if (isBEG()) {
+ } else if (IS_BEG()) {
c = tDSTAR;
} else {
c = warn_balanced(c, spaceSeen, tPOW, "**", "argument prefix");
@@ -2227,10 +2227,10 @@ private int star(boolean spaceSeen) {
return tOP_ASGN;
default:
pushback(c);
- if (isSpaceArg(c, spaceSeen)) {
+ if (IS_SPCARG(c, spaceSeen)) {
if (isVerbose() && Options.PARSER_WARN_ARGUMENT_PREFIX.load()) warning("`*' interpreted as argument prefix");
c = tSTAR;
- } else if (isBEG()) {
+ } else if (IS_BEG()) {
c = tSTAR;
} else {
c = warn_balanced(c, spaceSeen, '*', "*", "argument prefix");
@@ -2238,14 +2238,14 @@ private int star(boolean spaceSeen) {
yaccValue = STAR;
}
- setState(isAfterOperator() ? EXPR_ARG : EXPR_BEG);
+ setState(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG);
return c;
}
private int tilde() {
int c;
- if (isAfterOperator()) {
+ if (IS_AFTER_OPERATOR()) {
if ((c = nextc()) != '@') pushback(c);
setState(EXPR_ARG);
} else {
diff --git a/core/src/main/java/org/jruby/ext/ripper/StringTerm.java b/core/src/main/java/org/jruby/ext/ripper/StringTerm.java
index 9b5872ec9a8..3291d284686 100644
--- a/core/src/main/java/org/jruby/ext/ripper/StringTerm.java
+++ b/core/src/main/java/org/jruby/ext/ripper/StringTerm.java
@@ -97,7 +97,7 @@ private int endFound(RubyLexer lexer) throws IOException {
return RipperParser.tREGEXP_END;
}
- if ((flags & STR_FUNC_LABEL) != 0 && lexer.isLabelSuffix()) {
+ if ((flags & STR_FUNC_LABEL) != 0 && lexer.IS_LABEL_SUFFIX()) {
lexer.nextc();
lexer.setState(EXPR_BEG | EXPR_LABEL);
return RipperParser.tLABEL_END;
diff --git a/core/src/main/java/org/jruby/ext/tracepoint/TracePoint.java b/core/src/main/java/org/jruby/ext/tracepoint/TracePoint.java
index 5d551900f19..60b5f2a34ce 100644
--- a/core/src/main/java/org/jruby/ext/tracepoint/TracePoint.java
+++ b/core/src/main/java/org/jruby/ext/tracepoint/TracePoint.java
@@ -80,10 +80,11 @@ public IRubyObject initialize(ThreadContext context, IRubyObject[] _events, fina
if (!block.isGiven()) throw runtime.newArgumentError("must be called with a block");
+ final ThreadContext threadToTrace = context;
hook = new EventHook() {
@Override
public void event(ThreadContext context, RubyEvent event, String file, int line, String name, IRubyObject type) {
- if (!enabled || context.isWithinTrace()) return;
+ if (!enabled || threadToTrace != context || context.isWithinTrace()) return;
synchronized (this) {
inside = true;
diff --git a/core/src/main/java/org/jruby/ir/builder/IRBuilder.java b/core/src/main/java/org/jruby/ir/builder/IRBuilder.java
index 11f601345e9..43fa13bba21 100644
--- a/core/src/main/java/org/jruby/ir/builder/IRBuilder.java
+++ b/core/src/main/java/org/jruby/ir/builder/IRBuilder.java
@@ -70,10 +70,10 @@ public abstract class IRBuilder {
private final IRManager manager;
protected final IRScope scope;
- protected final IRBuilder parent;
+ protected final IRBuilder parent;
protected final List instructions;
protected int coverageMode;
- protected IRBuilder variableBuilder;
+ protected IRBuilder variableBuilder;
protected List
* Ordinary BasicBlocks will follow FollowThrough edges and just concatenate
* together eliminating the need for executing a jump instruction during
* execution.
- *
+ *