Skip to content

Commit f99d3db

Browse files
committed
Merge branch 'repl' of https://github.com/donaldh/nqp into rak-jvm-support
2 parents 9a087d2 + 211d54c commit f99d3db

File tree

7 files changed

+54
-15
lines changed

7 files changed

+54
-15
lines changed

3rdparty/jline/LICENSE.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Copyright (c) 2002-2006, Marc Prud'hommeaux <mwp1@cornell.edu>
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or
5+
without modification, are permitted provided that the following
6+
conditions are met:
7+
8+
Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
Redistributions in binary form must reproduce the above copyright
12+
notice, this list of conditions and the following disclaimer
13+
in the documentation and/or other materials provided with
14+
the distribution.
15+
16+
Neither the name of JLine nor the names of its contributors
17+
may be used to endorse or promote products derived from this
18+
software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
22+
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23+
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
24+
EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
25+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26+
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29+
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
31+
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
32+
OF THE POSSIBILITY OF SUCH DAMAGE.
33+

3rdparty/jline/jline-1.0.jar

89 KB
Binary file not shown.

src/vm/jvm/runners/nqp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/sh
2-
exec java -Xbootclasspath/a:.:nqp-runtime.jar:3rdparty/asm/asm-4.1.jar nqp "$@"
2+
exec java -Xbootclasspath/a:.:nqp-runtime.jar:3rdparty/asm/asm-4.1.jar:3rdparty/jline/jline-1.0.jar nqp "$@"

src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@
2222
import java.security.NoSuchAlgorithmException;
2323
import java.util.ArrayList;
2424
import java.util.Collections;
25+
import java.util.EnumSet;
2526
import java.util.HashMap;
2627
import java.util.List;
2728
import java.util.Map;
2829
import java.util.Set;
29-
import java.util.EnumSet;
3030
import java.util.concurrent.ThreadLocalRandom;
3131
import java.util.concurrent.TimeUnit;
3232

33+
import jline.ConsoleReader;
34+
3335
import org.perl6.nqp.jast2bc.JASTToJVMBytecode;
3436
import org.perl6.nqp.sixmodel.BoolificationSpec;
3537
import org.perl6.nqp.sixmodel.InvocationSpec;
@@ -402,13 +404,10 @@ public static String readlineintfh(SixModelObject obj, String prompt, ThreadCont
402404
if (h.is == null)
403405
die_s("File handle is not opened for read", tc);
404406
try {
405-
if (h.isr == null)
406-
h.isr = new InputStreamReader(h.is, "UTF-8");
407-
if (h.br == null)
408-
h.br = new BufferedReader(h.isr);
409-
System.out.print(prompt);
410-
System.out.flush();
411-
String line = h.br.readLine();
407+
if (h.cr == null) {
408+
h.cr = new ConsoleReader(h.is, new OutputStreamWriter(System.out));
409+
}
410+
String line = h.cr.readLine(prompt);
412411
if (line == null) {
413412
h.eof = true;
414413
}

src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/IOHandleInstance.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import java.io.OutputStream;
77
import java.io.OutputStreamWriter;
88

9+
import jline.ConsoleReader;
10+
911
import org.perl6.nqp.sixmodel.SixModelObject;
1012

1113
public class IOHandleInstance extends SixModelObject {
@@ -29,5 +31,8 @@ public class IOHandleInstance extends SixModelObject {
2931
* This further wraps the input stream reader for the case of doing
3032
* line-based I/O.
3133
*/
32-
public BufferedReader br;
34+
public BufferedReader br;
35+
36+
/* This wraps the input stream for interactive readline */
37+
public ConsoleReader cr;
3338
}

tools/build/Makefile-JVM.in

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ RUNTIME_JAVAS = \
1919

2020
RUNTIME_JAR = nqp-runtime.jar
2121

22+
THIRDPARTY_JARS = 3rdparty/asm/asm-4.1.jar@cpsep@3rdparty/jline/jline-1.0.jar
2223
STAGE0 = src/vm/jvm/stage0
2324
STAGE1 = src/stage1
2425
STAGE2 = src/stage2
2526

26-
STAGE0_NQP = $(JAVA) -cp $(STAGE0) -Xbootclasspath/a:$(STAGE0)@cpsep@nqp-runtime.jar@cpsep@3rdparty/asm/asm-4.1.jar nqp --bootstrap
27-
STAGE1_NQP = $(JAVA) -cp $(STAGE1) -Xbootclasspath/a:$(STAGE1)@cpsep@nqp-runtime.jar@cpsep@3rdparty/asm/asm-4.1.jar nqp --bootstrap
27+
STAGE0_NQP = $(JAVA) -cp $(STAGE0) -Xbootclasspath/a:$(STAGE0)@cpsep@nqp-runtime.jar@cpsep@$(THIRDPARTY_JARS) nqp --bootstrap
28+
STAGE1_NQP = $(JAVA) -cp $(STAGE1) -Xbootclasspath/a:$(STAGE1)@cpsep@nqp-runtime.jar@cpsep@$(THIRDPARTY_JARS) nqp --bootstrap
2829

2930
NQP_MO_CLASS = nqpmo.class
3031
NQP_MO_COMBINED = gen/nqpmo.nqp
@@ -148,6 +149,7 @@ all: $(ALL_OUTPUT) $(RUNNER) $(P5QREGEX_CLASS)
148149
install: all
149150
$(MKPATH) $(PREFIX)
150151
$(CP) 3rdparty/asm/asm-4.1.jar $(PREFIX)
152+
$(CP) 3rdparty/jline/jline-1.0.jar $(PREFIX)
151153
$(CP) $(RUNTIME_JAR) $(PREFIX)
152154
$(CP) $(NQP_MO_CLASS) $(PREFIX)
153155
$(CP) $(MODULE_LOADER_CLASS) $(PREFIX)
@@ -164,7 +166,7 @@ install: all
164166

165167
$(RUNTIME_JAR): $(RUNTIME_JAVAS)
166168
$(PERL) -MExtUtils::Command -e mkpath bin
167-
$(JAVAC) -source 1.7 -cp 3rdparty/asm/asm-4.1.jar -g -d bin $(RUNTIME_JAVAS)
169+
$(JAVAC) -source 1.7 -cp $(THIRDPARTY_JARS) -g -d bin $(RUNTIME_JAVAS)
168170
$(JAR) cf0 nqp-runtime.jar -C bin/ .
169171

170172
clean:

tools/build/install-jvm-runner.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
my $install_to = File::Spec->catfile($prefix, 'nqp.bat');
1717
open my $fh, ">", $install_to;
1818
print $fh '@java -Xbootclasspath/a:' . $prefix . ';' . $prefix . '\\nqp-runtime.jar;' .
19-
$prefix . '\\asm-4.1.jar -cp ' . $prefix . ' nqp %*' . "\n";
19+
$prefix . '\\asm-4.1.jar;' . $prefix . '\\jline-1.0.jar -cp ' . $prefix . ' nqp %*' . "\n";
2020
close $fh;
2121
}
2222
else {
2323
my $install_to = File::Spec->catfile($prefix, 'nqp');
2424
open my $fh, ">", $install_to;
2525
print $fh "#!/bin/sh\n";
2626
print $fh 'exec java -Xbootclasspath/a:' . $prefix . ':' . $prefix . '/nqp-runtime.jar:' .
27-
$prefix . '/asm-4.1.jar -cp ' . $prefix . ' nqp "$@"' . "\n";
27+
$prefix . '/asm-4.1.jar:' . $prefix . '/jline-1.0.jar -cp ' . $prefix . ' nqp "$@"' . "\n";
2828
close $fh;
2929
chmod 0755, $install_to;
3030
}

0 commit comments

Comments
 (0)