Skip to content

Commit

Permalink
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions truffle/src/main/java/org/jruby/truffle/core/array/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -210,6 +210,8 @@ public MulNode(RubyContext context, SourceSection sourceSection) {
allocateObjectNode = AllocateObjectNodeGen.create(context, sourceSection, null, null);
}

protected abstract Object executeMul(VirtualFrame frame, DynamicObject array, int count);

@Specialization(guards = "isNullArray(array)")
public DynamicObject mulEmpty(DynamicObject array, int count) {
if (count < 0) {
@@ -297,7 +299,7 @@ public Object mulObject(VirtualFrame frame, DynamicObject array, DynamicObject s
return ruby(frame, "join(sep)", "sep", string);
}

@Specialization(guards = {"!isRubyString(object)"})
@Specialization(guards = { "!isInteger(object)", "!isRubyString(object)" })
public Object mulObjectCount(VirtualFrame frame, DynamicObject array, Object object) {
CompilerDirectives.transferToInterpreter();
if (respondToToStrNode == null) {
@@ -312,22 +314,7 @@ public Object mulObjectCount(VirtualFrame frame, DynamicObject array, Object obj
toIntNode = insert(ToIntNodeGen.create(getContext(), getSourceSection(), null));
}
final int count = toIntNode.doInt(frame, object);
if (count < 0) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().argumentError("negative argument", this));
}
if (getStore(array) instanceof int[]) {
return mulIntegerFixnum(array, count);
} else if (getStore(array) instanceof long[]) {
return mulLongFixnum(array, count);
} else if (getStore(array) instanceof double[]) {
return mulFloat(array, count);
} else if (getStore(array) == null) {
return mulEmpty(array, count);
} else {
return mulObject(array, count);
}

return executeMul(frame, array, count);
}
}

0 comments on commit 46e64d2

Please sign in to comment.