Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e1989e99654e
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4f1ab2a1ee84
Choose a head ref
  • 4 commits
  • 7 files changed
  • 1 contributor

Commits on May 5, 2016

  1. Copy the full SHA
    bf32724 View commit details
  2. Copy the full SHA
    8504640 View commit details
  3. Copy the full SHA
    7be8ca8 View commit details
  4. Copy the full SHA
    4f1ab2a View commit details
Original file line number Diff line number Diff line change
@@ -70,6 +70,10 @@ public DynamicObject argumentErrorNegativeArraySize(Node currentNode) {
return argumentError(coreStrings().NEGATIVE_ARRAY_SIZE.getRope(), currentNode, null);
}

public DynamicObject argumentErrorCantOmitPrecision(Node currentNode) {
return argumentError("can't omit precision for a Float.", currentNode);
}

@TruffleBoundary
public DynamicObject argumentErrorUnknownKeyword(Object name, Node currentNode) {
return argumentError("unknown keyword: " + name, currentNode);
@@ -260,6 +264,10 @@ public DynamicObject typeErrorCantDefineSingleton(Node currentNode) {
return typeError("can't define singleton", currentNode);
}

public DynamicObject typeErrorCantBeCastedToBigDecimal(Node currentNode) {
return typeError("could not be casted to BigDecimal", currentNode);
}

@TruffleBoundary
public DynamicObject typeErrorMustHaveWriteMethod(Object object, Node currentNode) {
return typeError(String.format("$stdout must have write method, %s given", Layouts.MODULE.getFields(context.getCoreLibrary().getLogicalClass(object)).getName()), currentNode);
Original file line number Diff line number Diff line change
@@ -28,6 +28,13 @@ public static CallDispatchHeadNode createMethodCall() {
MissingBehavior.CALL_METHOD_MISSING);
}

public static CallDispatchHeadNode createMethodCallIgnoreVisibility() {
return new CallDispatchHeadNode(
null,
true,
MissingBehavior.CALL_METHOD_MISSING);
}

public CallDispatchHeadNode(RubyContext context, boolean ignoreVisibility, MissingBehavior missingBehavior) {
super(context, ignoreVisibility, missingBehavior, DispatchAction.CALL_METHOD);
}
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ public static BigDecimalCoerceNode create(RubyNode value) {
protected DynamicObject createBigDecimal(VirtualFrame frame, Object value) {
if (createBigDecimal == null) {
CompilerDirectives.transferToInterpreter();
createBigDecimal = insert(CreateBigDecimalNodeFactory.create(null, null, null, null, null));
createBigDecimal = insert(CreateBigDecimalNodeFactory.create(null, null, null));
}

return createBigDecimal.executeCreate(frame, value);
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.jruby.truffle.stdlib.bigdecimal;

/*
* Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
@@ -9,11 +7,11 @@
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.stdlib.bigdecimal;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.CoreMethodNode;
import org.jruby.truffle.core.Layouts;
import org.jruby.truffle.core.cast.IntegerCastNode;
@@ -27,23 +25,11 @@

public abstract class BigDecimalCoreMethodNode extends CoreMethodNode {

@Child
private CreateBigDecimalNode createBigDecimal;
@Child
private CallDispatchHeadNode limitCall;
@Child
private IntegerCastNode limitIntegerCast;
@Child
private CallDispatchHeadNode roundModeCall;
@Child
private IntegerCastNode roundModeIntegerCast;

public BigDecimalCoreMethodNode() {
}

public BigDecimalCoreMethodNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
@Child private CreateBigDecimalNode createBigDecimal;
@Child private CallDispatchHeadNode limitCall;
@Child private IntegerCastNode limitIntegerCast;
@Child private CallDispatchHeadNode roundModeCall;
@Child private IntegerCastNode roundModeIntegerCast;

public static boolean isNormal(DynamicObject value) {
return Layouts.BIG_DECIMAL.getType(value) == BigDecimalType.NORMAL;
@@ -65,65 +51,18 @@ public static boolean isNan(DynamicObject value) {
return Layouts.BIG_DECIMAL.getType(value) == BigDecimalType.NAN;
}

private void setupCreateBigDecimal() {
if (createBigDecimal == null) {
CompilerDirectives.transferToInterpreter();
createBigDecimal = insert(CreateBigDecimalNodeFactory.create(getContext(), getSourceSection(), null, null, null));
}
}

protected DynamicObject createBigDecimal(VirtualFrame frame, Object value) {
setupCreateBigDecimal();
return createBigDecimal.executeCreate(frame, value);
return getCreateBigDecimal().executeCreate(frame, value);
}

protected DynamicObject initializeBigDecimal(VirtualFrame frame, Object value, DynamicObject self, Object digits) {
setupCreateBigDecimal();
return createBigDecimal.executeInitialize(frame, value, self, digits);
}

private void setupLimitCall() {
if (limitCall == null) {
CompilerDirectives.transferToInterpreter();
limitCall = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
}
}

private void setupLimitIntegerCast() {
if (limitIntegerCast == null) {
CompilerDirectives.transferToInterpreter();
limitIntegerCast = insert(IntegerCastNodeGen.create(getContext(), getSourceSection(), null));
}
}

protected int getLimit(VirtualFrame frame) {
setupLimitCall();
setupLimitIntegerCast();

return limitIntegerCast.executeCastInt(limitCall.call(frame, getBigDecimalClass(), "limit", null));
}

private void setupRoundModeCall() {
if (roundModeCall == null) {
CompilerDirectives.transferToInterpreter();
roundModeCall = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
}
}

private void setupRoundModeIntegerCast() {
if (roundModeIntegerCast == null) {
CompilerDirectives.transferToInterpreter();
roundModeIntegerCast = insert(IntegerCastNodeGen.create(getContext(), getSourceSection(), null));
}
return getCreateBigDecimal().executeInitialize(frame, value, self, digits);
}

protected RoundingMode getRoundMode(VirtualFrame frame) {
setupRoundModeCall();
setupRoundModeIntegerCast();

return toRoundingMode(roundModeIntegerCast.executeCastInt(
return toRoundingMode(getRoundModeIntegerCast().executeCastInt(
// TODO (pitr 21-Jun-2015): read the actual constant
roundModeCall.call(frame, getBigDecimalClass(), "mode", null, 256)));
getRoundModeCall().call(frame, getBigDecimalClass(), "mode", null, 256)));
}

protected DynamicObject getBigDecimalClass() {
@@ -164,4 +103,53 @@ protected static int defaultDivisionPrecision(BigDecimal a, BigDecimal b, int li
return defaultDivisionPrecision(a.precision(), b.precision(), limit);
}

protected int getLimit(VirtualFrame frame) {
return getLimitIntegerCast().executeCastInt(getLimitCall().call(frame, getBigDecimalClass(), "limit", null));
}

private CreateBigDecimalNode getCreateBigDecimal() {
if (createBigDecimal == null) {
CompilerDirectives.transferToInterpreter();
createBigDecimal = insert(CreateBigDecimalNodeFactory.create(null, null, null));
}

return createBigDecimal;
}

private CallDispatchHeadNode getLimitCall() {
if (limitCall == null) {
CompilerDirectives.transferToInterpreter();
limitCall = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
}

return limitCall;
}

private IntegerCastNode getLimitIntegerCast() {
if (limitIntegerCast == null) {
CompilerDirectives.transferToInterpreter();
limitIntegerCast = insert(IntegerCastNodeGen.create(getContext(), getSourceSection(), null));
}

return limitIntegerCast;
}

private CallDispatchHeadNode getRoundModeCall() {
if (roundModeCall == null) {
CompilerDirectives.transferToInterpreter();
roundModeCall = insert(DispatchHeadNodeFactory.createMethodCall(getContext()));
}

return roundModeCall;
}

private IntegerCastNode getRoundModeIntegerCast() {
if (roundModeIntegerCast == null) {
CompilerDirectives.transferToInterpreter();
roundModeIntegerCast = insert(IntegerCastNodeGen.create(getContext(), getSourceSection(), null));
}

return roundModeIntegerCast;
}

}
Original file line number Diff line number Diff line change
@@ -1048,7 +1048,7 @@ public int signSpecial(VirtualFrame frame, DynamicObject value) {
private int getConstant(VirtualFrame frame, String name) {
if (sign == null) {
CompilerDirectives.transferToInterpreter();
sign = insert(GetIntegerConstantNodeGen.create(null, null, null, null));
sign = insert(GetIntegerConstantNodeGen.create(null, null));
}

return sign.executeGetIntegerConstant(frame, getBigDecimalClass(), name);
Loading