Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix compilation of \n on JVM
  • Loading branch information
sorear committed Jun 7, 2013
1 parent f88d35c commit 3887f45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
17 changes: 4 additions & 13 deletions src/vm/jvm/QAST/Compiler.nqp
Expand Up @@ -4440,21 +4440,12 @@ class QAST::CompilerJAST {
$il.append($L2I);
$il.append(JAST::Instruction.new( :op($node.negate ?? 'ifne' !! 'ifeq'), %*REG<fail> ));

if $subtype == nqp::const::CCLASS_NEWLINE {
if $cclass == nqp::const::CCLASS_NEWLINE && !$node.negate {
$il.append(JAST::Instruction.new( :op('aload'), %*REG<tgt> ));
$il.append(JAST::Instruction.new( :op('lload'), %*REG<pos> ));
$il.append($L2I);
$il.append($DUP);
$il.append(JAST::PushIndex.new( :value(2) ));
$il.append($IADD);
$il.append(JAST::Instruction.new( :op('invokevirtual'),
$TYPE_STR, 'substring', $TYPE_STR, 'Integer', 'Integer' ));
$il.append(JAST::PushSVal.new( :value("\r\n") ));
$il.append(JAST::Instruction.new( :op('invokevirtual'),
$TYPE_STR, 'equals', 'Z', $TYPE_OBJ ));
$il.append($I2L);
$il.append(JAST::Instruction.new( :op('lload'), %*REG<pos> ));
$il.append($LADD);
$il.append(JAST::Instruction.new( :op('lload'), %*REG<eos> ));
$il.append(JAST::Instruction.new( :op('invokestatic'),
$TYPE_OPS, 'checkcrlf', 'Long', $TYPE_STR, 'Long', 'Long' ));
$il.append(JAST::Instruction.new( :op('lstore'), %*REG<pos> ));
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -2643,7 +2643,11 @@ public static long iscclass(long cclass, String target, long offset) {
return 0;
}
}


public static long checkcrlf(String tgt, long pos, long eos) {
return (pos <= eos-2 && tgt.substring((int)pos, ((int) pos)+2).equals("\r\n")) ? pos+1 : pos;
}

public static long findcclass(long cclass, String target, long offset, long count) {
long length = target.length();
long end = offset + count;
Expand Down

0 comments on commit 3887f45

Please sign in to comment.