Skip to content

Commit

Permalink
Showing 7 changed files with 35 additions and 35 deletions.
50 changes: 25 additions & 25 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/RangeNodes.java
Original file line number Diff line number Diff line change
@@ -81,17 +81,17 @@ public EachNode(RubyContext context, SourceSection sourceSection) {
@Specialization(guards = "isIntegerFixnumRange(range)")
public Object eachInt(VirtualFrame frame, DynamicObject range, DynamicObject block) {
int result;
if (Layouts.INTEGER_FIXNUM_RANGE.getExcludedEnd(((DynamicObject) range))) {
result = Layouts.INTEGER_FIXNUM_RANGE.getEnd(((DynamicObject) range));
if (Layouts.INTEGER_FIXNUM_RANGE.getExcludedEnd(range)) {
result = Layouts.INTEGER_FIXNUM_RANGE.getEnd(range);
} else {
result = Layouts.INTEGER_FIXNUM_RANGE.getEnd(((DynamicObject) range)) + 1;
result = Layouts.INTEGER_FIXNUM_RANGE.getEnd(range) + 1;
}
final int exclusiveEnd = result;

int count = 0;

try {
for (int n = Layouts.INTEGER_FIXNUM_RANGE.getBegin(((DynamicObject) range)); n < exclusiveEnd; n++) {
for (int n = Layouts.INTEGER_FIXNUM_RANGE.getBegin(range); n < exclusiveEnd; n++) {
if (CompilerDirectives.inInterpreter()) {
count++;
}
@@ -110,17 +110,17 @@ public Object eachInt(VirtualFrame frame, DynamicObject range, DynamicObject blo
@Specialization(guards = "isLongFixnumRange(range)")
public Object eachLong(VirtualFrame frame, DynamicObject range, DynamicObject block) {
long result;
if (Layouts.LONG_FIXNUM_RANGE.getExcludedEnd(((DynamicObject) range))) {
result = Layouts.LONG_FIXNUM_RANGE.getEnd(((DynamicObject) range));
if (Layouts.LONG_FIXNUM_RANGE.getExcludedEnd(range)) {
result = Layouts.LONG_FIXNUM_RANGE.getEnd(range);
} else {
result = Layouts.LONG_FIXNUM_RANGE.getEnd(((DynamicObject) range)) + 1;
result = Layouts.LONG_FIXNUM_RANGE.getEnd(range) + 1;
}
final long exclusiveEnd = result;

int count = 0;

try {
for (long n = Layouts.LONG_FIXNUM_RANGE.getBegin(((DynamicObject) range)); n < exclusiveEnd; n++) {
for (long n = Layouts.LONG_FIXNUM_RANGE.getBegin(range); n < exclusiveEnd; n++) {
if (CompilerDirectives.inInterpreter()) {
count++;
}
@@ -171,17 +171,17 @@ public ExcludeEndNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "isIntegerFixnumRange(range)")
public boolean excludeEndInt(DynamicObject range) {
return Layouts.INTEGER_FIXNUM_RANGE.getExcludedEnd(((DynamicObject) range));
return Layouts.INTEGER_FIXNUM_RANGE.getExcludedEnd(range);
}

@Specialization(guards = "isLongFixnumRange(range)")
public boolean excludeEndLong(DynamicObject range) {
return Layouts.LONG_FIXNUM_RANGE.getExcludedEnd(((DynamicObject) range));
return Layouts.LONG_FIXNUM_RANGE.getExcludedEnd(range);
}

@Specialization(guards = "isObjectRange(range)")
public boolean excludeEndObject(DynamicObject range) {
return Layouts.OBJECT_RANGE.getExcludedEnd(((DynamicObject) range));
return Layouts.OBJECT_RANGE.getExcludedEnd(range);
}

}
@@ -195,17 +195,17 @@ public BeginNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "isIntegerFixnumRange(range)")
public int eachInt(DynamicObject range) {
return Layouts.INTEGER_FIXNUM_RANGE.getBegin(((DynamicObject) range));
return Layouts.INTEGER_FIXNUM_RANGE.getBegin(range);
}

@Specialization(guards = "isLongFixnumRange(range)")
public long eachLong(DynamicObject range) {
return Layouts.LONG_FIXNUM_RANGE.getBegin(((DynamicObject) range));
return Layouts.LONG_FIXNUM_RANGE.getBegin(range);
}

@Specialization(guards = "isObjectRange(range)")
public Object eachObject(DynamicObject range) {
return Layouts.OBJECT_RANGE.getBegin(((DynamicObject) range));
return Layouts.OBJECT_RANGE.getBegin(range);
}

}
@@ -259,17 +259,17 @@ public EndNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "isIntegerFixnumRange(range)")
public int lastInt(DynamicObject range) {
return Layouts.INTEGER_FIXNUM_RANGE.getEnd(((DynamicObject) range));
return Layouts.INTEGER_FIXNUM_RANGE.getEnd(range);
}

@Specialization(guards = "isLongFixnumRange(range)")
public long lastLong(DynamicObject range) {
return Layouts.LONG_FIXNUM_RANGE.getEnd(((DynamicObject) range));
return Layouts.LONG_FIXNUM_RANGE.getEnd(range);
}

@Specialization(guards = "isObjectRange(range)")
public Object lastObject(DynamicObject range) {
return Layouts.OBJECT_RANGE.getEnd(((DynamicObject) range));
return Layouts.OBJECT_RANGE.getEnd(range);
}

}
@@ -289,12 +289,12 @@ public Object stepInt(VirtualFrame frame, DynamicObject range, int step, Dynamic

try {
int result;
if (Layouts.INTEGER_FIXNUM_RANGE.getExcludedEnd(((DynamicObject) range))) {
result = Layouts.INTEGER_FIXNUM_RANGE.getEnd(((DynamicObject) range));
if (Layouts.INTEGER_FIXNUM_RANGE.getExcludedEnd(range)) {
result = Layouts.INTEGER_FIXNUM_RANGE.getEnd(range);
} else {
result = Layouts.INTEGER_FIXNUM_RANGE.getEnd(((DynamicObject) range)) + 1;
result = Layouts.INTEGER_FIXNUM_RANGE.getEnd(range) + 1;
}
for (int n = Layouts.INTEGER_FIXNUM_RANGE.getBegin(((DynamicObject) range)); n < result; n += step) {
for (int n = Layouts.INTEGER_FIXNUM_RANGE.getBegin(range); n < result; n += step) {
if (CompilerDirectives.inInterpreter()) {
count++;
}
@@ -316,12 +316,12 @@ public Object stepLong(VirtualFrame frame, DynamicObject range, int step, Dynami

try {
long result;
if (Layouts.LONG_FIXNUM_RANGE.getExcludedEnd(((DynamicObject) range))) {
result = Layouts.LONG_FIXNUM_RANGE.getEnd(((DynamicObject) range));
if (Layouts.LONG_FIXNUM_RANGE.getExcludedEnd(range)) {
result = Layouts.LONG_FIXNUM_RANGE.getEnd(range);
} else {
result = Layouts.LONG_FIXNUM_RANGE.getEnd(((DynamicObject) range)) + 1;
result = Layouts.LONG_FIXNUM_RANGE.getEnd(range) + 1;
}
for (long n = Layouts.LONG_FIXNUM_RANGE.getBegin(((DynamicObject) range)); n < result; n += step) {
for (long n = Layouts.LONG_FIXNUM_RANGE.getBegin(range); n < result; n += step) {
if (CompilerDirectives.inInterpreter()) {
count++;
}
Original file line number Diff line number Diff line change
@@ -355,7 +355,7 @@ public Object index(VirtualFrame frame, DynamicObject array, int index, NotProvi
readNode = insert(ArrayReadDenormalizedNodeGen.create(getContext(), getSourceSection(), null, null));
}

return readNode.executeRead(frame, (DynamicObject) array, index);
return readNode.executeRead(frame, array, index);
}

@Specialization
@@ -703,7 +703,7 @@ public Object at(VirtualFrame frame, DynamicObject array, int index) {
readNode = insert(ArrayReadDenormalizedNodeGen.create(getContext(), getSourceSection(), null, null));
}

return readNode.executeRead(frame, (DynamicObject) array, index);
return readNode.executeRead(frame, array, index);
}

}
@@ -838,7 +838,7 @@ public DynamicObject concatNull(DynamicObject array, DynamicObject other) {

@Specialization(guards = {"isRubyArray(other)", "!isNullArray(other)"})
public DynamicObject concat(DynamicObject array, DynamicObject other) {
appendManyNode.executeAppendMany((DynamicObject) array, Layouts.ARRAY.getSize(other), Layouts.ARRAY.getStore(other));
appendManyNode.executeAppendMany(array, Layouts.ARRAY.getSize(other), Layouts.ARRAY.getStore(other));
return array;
}

@@ -2510,7 +2510,7 @@ public Object pop(DynamicObject array, NotProvided n) {
popOneNode = insert(PopOneNodeGen.create(getContext(), getEncapsulatingSourceSection(), null));
}

return popOneNode.executePopOne((DynamicObject) array);
return popOneNode.executePopOne(array);
}

@Specialization(guards = { "isEmptyArray(array)", "wasProvided(object)" })
Original file line number Diff line number Diff line change
@@ -78,7 +78,7 @@ private Object handleException(VirtualFrame frame, RaiseException exception) {
CompilerDirectives.transferToInterpreter();

for (RescueNode rescue : rescueParts) {
if (rescue.canHandle(frame, (DynamicObject) exception.getRubyException())) {
if (rescue.canHandle(frame, exception.getRubyException())) {
return setLastExceptionAndRunRescue(frame, exception, rescue);
}
}
Original file line number Diff line number Diff line change
@@ -430,7 +430,7 @@ public InteropInstanceVariableReadNode(RubyContext context, SourceSection source

@Override
public Object execute(VirtualFrame frame) {
if (name.equals((String) ForeignAccess.getArguments(frame).get(labelIndex))) {
if (name.equals(ForeignAccess.getArguments(frame).get(labelIndex))) {
return read.execute(frame);
} else {
CompilerDirectives.transferToInterpreter();
@@ -454,7 +454,7 @@ public InteropInstanceVariableWriteNode(RubyContext context, SourceSection sourc

@Override
public Object execute(VirtualFrame frame) {
if (name.equals((String) ForeignAccess.getArguments(frame).get(labelIndex))) {
if (name.equals(ForeignAccess.getArguments(frame).get(labelIndex))) {
return write.execute(frame);
} else {
CompilerDirectives.transferToInterpreter();
Original file line number Diff line number Diff line change
@@ -153,7 +153,7 @@ private DynamicObject translate(UnsupportedSpecializationException exception) {
}

public DynamicObject translate(Throwable throwable) {
if (getContext().getOptions().EXCEPTIONS_PRINT_JAVA || (boolean) getContext().getOptions().EXCEPTIONS_PRINT_UNCAUGHT_JAVA) {
if (getContext().getOptions().EXCEPTIONS_PRINT_JAVA || getContext().getOptions().EXCEPTIONS_PRINT_UNCAUGHT_JAVA) {
throwable.printStackTrace();
}

Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ public long objectID(DynamicObject object,
return newId;
}

return (long) id;
return id;
}

protected ReadHeadObjectFieldNode createReadObjectIDNode() {
Original file line number Diff line number Diff line change
@@ -384,7 +384,7 @@ private static <R> R classVariableLookup(DynamicObject module, Function<DynamicO

// If singleton class, check attached module.
if (RubyGuards.isRubyClass(module)) {
DynamicObject klass = (DynamicObject) module;
DynamicObject klass = module;
if (Layouts.CLASS.getIsSingleton(klass) && Layouts.CLASS.getAttached(klass) != null) {
module = Layouts.CLASS.getAttached(klass);

2 comments on commit 0ea4fb8

@eregon
Copy link
Member

@eregon eregon commented on 0ea4fb8 Dec 25, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, how did you do it, IDE feature?

@nirvdrum
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. IntelliJ IDEA's code inspections.

Please sign in to comment.