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: c70bbc97bdae
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 60374d7ab89c
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Dec 20, 2015

  1. [Truffle] Typo.

    chrisseaton committed Dec 20, 2015
    Copy the full SHA
    de2c2c5 View commit details
  2. [Truffle] Typo.

    chrisseaton committed Dec 20, 2015
    Copy the full SHA
    69cf3d7 View commit details
  3. Copy the full SHA
    60374d7 View commit details
Original file line number Diff line number Diff line change
@@ -23,6 +23,6 @@ MINUS : '-' ;
STAR : '*' ;
DOLLAR : '$' ;
DOT : '.' ;
CURLEY_KEY : '{' .*? '}' -> mode(DEFAULT_MODE) ;
CURLY_KEY : '{' .*? '}' -> mode(DEFAULT_MODE) ;
TYPE : [bBdiouxXeEfgGaAcps] -> mode(DEFAULT_MODE) ;
ESCAPED : '%' -> mode(DEFAULT_MODE) ;
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ options { tokenVocab=PrintfLexer; }

sequence : (FORMAT directive | literal)* ;

directive : CURLEY_KEY # string
directive : CURLY_KEY # string
| ESCAPED # escaped
| ANGLE_KEY?
flag*
Original file line number Diff line number Diff line change
@@ -34,7 +34,6 @@

public class PrintfTreeBuilder extends org.jruby.truffle.format.parser.PrintfParserBaseListener {

// TODO CS 19-Dec-15 this is never used, but the functionality seems useful
public static final int PADDING_FROM_ARGUMENT = -2;

public static final int DEFAULT = -1;
@@ -56,7 +55,7 @@ public void exitEscaped(org.jruby.truffle.format.parser.PrintfParser.EscapedCont

@Override
public void exitString(org.jruby.truffle.format.parser.PrintfParser.StringContext ctx) {
final ByteList keyBytes = tokenAsBytes(ctx.CURLEY_KEY().getSymbol(), 1);
final ByteList keyBytes = tokenAsBytes(ctx.CURLY_KEY().getSymbol(), 1);
final DynamicObject key = context.getSymbol(keyBytes);

sequence.add(
@@ -79,13 +78,26 @@ public void exitFormat(org.jruby.truffle.format.parser.PrintfParser.FormatContex
int spacePadding = DEFAULT;
int zeroPadding = DEFAULT;

for (org.jruby.truffle.format.parser.PrintfParser.FlagContext flag : ctx.flag()) {

for (int n = 0; n < ctx.flag().size(); n++) {
final org.jruby.truffle.format.parser.PrintfParser.FlagContext flag = ctx.flag(n);

if (flag.MINUS() != null) {
leftJustified = true;
} else if (flag.SPACE() != null) {
spacePadding = width;
if (n + 1 < ctx.flag().size() && ctx.flag(n + 1).STAR() != null) {
spacePadding = PADDING_FROM_ARGUMENT;
} else {
spacePadding = width;
}
} else if (flag.ZERO() != null) {
zeroPadding = width;
if (n + 1 < ctx.flag().size() && ctx.flag(n + 1).STAR() != null) {
zeroPadding = PADDING_FROM_ARGUMENT;
} else {
zeroPadding = width;
}
} else if (flag.STAR() != null) {
// Handled in space and zero, above
} else {
throw new UnsupportedOperationException();
}
Original file line number Diff line number Diff line change
@@ -1947,11 +1947,11 @@ public Long block() throws InterruptedException {

@CoreMethod(names = { "format", "sprintf" }, isModuleFunction = true, rest = true, required = 1, taintFromParameter = 0)
@ImportStatic(StringCachingGuards.class)
public abstract static class XFormatNode extends CoreMethodArrayArgumentsNode {
public abstract static class SprintfNode extends CoreMethodArrayArgumentsNode {

@Child private TaintNode taintNode;

public XFormatNode(RubyContext context, SourceSection sourceSection) {
public SprintfNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}