Skip to content

Commit

Permalink
Showing 3 changed files with 48 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/ruby/truffle/truffle/bigdecimal.rb
Original file line number Diff line number Diff line change
@@ -252,7 +252,7 @@ def inspect
precs2
end

def _dump(level)
def _dump(level=nil)
# TODO (pitr 30-jun-2015): increase density
to_s
end
44 changes: 44 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/core/rope/RopeGuards.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/


package org.jruby.truffle.core.rope;

import com.oracle.truffle.api.object.DynamicObject;
import org.jruby.truffle.language.RubyGuards;

import static org.jruby.truffle.core.rope.CodeRange.CR_7BIT;
import static org.jruby.truffle.core.string.StringOperations.rope;

public class RopeGuards {

public static boolean isSingleByteString(Rope rope) {
return rope.byteLength() == 1;
}

public static boolean is7Bit(Rope rope) {
return rope.getCodeRange() == CR_7BIT;
}

public static boolean isRopeBuffer(Rope rope) {
return rope instanceof RopeBuffer;
}

protected boolean isRopeBuffer(DynamicObject string) {
assert RubyGuards.isRubyString(string);

return rope(string) instanceof RopeBuffer;
}

public static boolean isLeafRope(Rope rope) {
return rope instanceof LeafRope;
}

}
22 changes: 3 additions & 19 deletions truffle/src/main/java/org/jruby/truffle/core/rope/RopeNodes.java
Original file line number Diff line number Diff line change
@@ -17,10 +17,7 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.ExactMath;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.source.SourceSection;
@@ -506,6 +503,7 @@ protected static boolean isFixedWidth(Encoding encoding) {
@NodeChild(type = RubyNode.class, value = "base"),
@NodeChild(type = RubyNode.class, value = "times")
})
@ImportStatic(RopeGuards.class)
public abstract static class MakeRepeatingNode extends RubyNode {

public static MakeRepeatingNode create() {
@@ -564,13 +562,6 @@ public Rope repeat(Rope base, int times) {
return new RepeatingRope(base, times);
}

protected static boolean isSingleByteString(Rope rope) {
return rope.byteLength() == 1;
}

protected static boolean isRopeBuffer(Rope rope) {
return rope instanceof RopeBuffer;
}
}


@@ -756,10 +747,6 @@ protected static boolean isAsciiCompatbileChange(Rope rope, Encoding encoding) {
return rope.getCodeRange() == CR_7BIT && encoding.isAsciiCompatible();
}

protected static boolean is7Bit(Rope rope) {
return rope.getCodeRange() == CR_7BIT;
}

protected int getCacheLimit() {
return getContext().getOptions().ROPE_CLASS_CACHE;
}
@@ -833,6 +820,7 @@ public int getByteConcatRope(ConcatRope rope, int index,
@NodeChildren({
@NodeChild(type = RubyNode.class, value = "rope")
})
@ImportStatic(RopeGuards.class)
public abstract static class FlattenNode extends RubyNode {

@Child private MakeLeafRopeNode makeLeafRopeNode;
@@ -868,10 +856,6 @@ public LeafRope flatten(Rope rope) {
return makeLeafRopeNode.executeMake(bytes, rope.getEncoding(), rope.getCodeRange(), rope.characterLength());
}

protected static boolean isLeafRope(Rope rope) {
return rope instanceof LeafRope;
}

}

}

0 comments on commit ee9e666

Please sign in to comment.