Skip to content

Commit a7a527a

Browse files
committed
= syscall
1 parent 2554da0 commit a7a527a

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.falsepattern</groupId>
88
<artifactId>jfunge</artifactId>
9-
<version>0.3.0</version>
9+
<version>1.0.0</version>
1010

1111
<properties>
1212
<java.version>8</java.version>

src/main/java/com/falsepattern/jfunge/Globals.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.falsepattern.jfunge;
22

33
public class Globals {
4-
public static final String VERSION = "0.3.0";
5-
public static final int FUNGE_VERSION = 0 * 256 * 256 + 3 * 256 + 0;
6-
public static final int HANDPRINT = 0xfa15e9a7;
4+
public static final String VERSION = "1.0.0";
5+
public static final int FUNGE_VERSION = 1 * 256 * 256 + 0 * 256 + 0;
6+
public static final int HANDPRINT = 0xfa15e9a7; //"falsepat"
77
public static final String LICENSE = "JFunge - A standard-conforming Befunge-98 and Trefunge-98 interpreter\n" +
88
"Copyright (C) 2022 FalsePattern\n" +
99
"\n" +

src/main/java/com/falsepattern/jfunge/interpreter/ExecutionContext.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public interface ExecutionContext {
2121
void step(InstructionPointer ip);
2222
List<String> args();
2323
Map<String, String> env();
24-
int paradigm();
2524
int input(boolean stagger);
2625
OutputStream output();
2726
byte[] readFile(String file);

src/main/java/com/falsepattern/jfunge/interpreter/Interpreter.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,6 @@ public Map<String, String> env() {
191191
return Collections.unmodifiableMap(System.getenv());
192192
}
193193

194-
@Override
195-
public int paradigm() {
196-
return 0;
197-
}
198-
199194
@Override
200195
public int input(boolean stagger) {
201196
var value = -1;

src/main/java/com/falsepattern/jfunge/interpreter/instructions/Funge98.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,15 +455,15 @@ public static void sysInfo(ExecutionContext ctx) {
455455
//6 separator
456456
s.push(File.separatorChar);
457457
//5 operating paradigm
458-
s.push(ctx.paradigm());
458+
s.push(1);
459459
//4 version
460460
s.push(Globals.FUNGE_VERSION);
461461
//3 handprint
462462
s.push(Globals.HANDPRINT);
463463
//2 bpc
464464
s.push(4);
465465
//1 flags
466-
s.push(0b00000111);
466+
s.push(0b00001111);
467467
if (n > 0) {
468468
int curr = s.pick(n - 1);
469469
for (int i = s.size(); i >= tossSize; i--) {
@@ -572,6 +572,17 @@ public static void readChar(ExecutionContext ctx) {
572572
ctx.IP().stackStack.TOSS().push(ctx.input(false));
573573
}
574574

575+
@Instr('=')
576+
public static void sysCall(ExecutionContext ctx) {
577+
val command = ctx.IP().stackStack.TOSS().popString();
578+
try {
579+
val proc = Runtime.getRuntime().exec(command);
580+
ctx.IP().stackStack.TOSS().push(proc.waitFor());
581+
} catch (Exception e) {
582+
ctx.IP().stackStack.TOSS().push(-1);
583+
}
584+
}
585+
575586
@Override
576587
public void load(ObjIntConsumer<Instruction> instructionSet) {
577588
InstructionSet.super.load(instructionSet);

0 commit comments

Comments
 (0)