Skip to content

Commit 7345635

Browse files
committed
add System.out::println native method for CSEC machine
1 parent 7ad4180 commit 7345635

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/ec-evaluator/lib.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,19 @@ export class LFSR {
3535

3636
export const libraryClasses = `
3737
class Object {
38-
public static native void display(int s);
39-
4038
public native int hashCode();
4139
4240
public native String toString();
43-
}`
41+
}
42+
43+
class PrintStream {
44+
public static native void println(String s);
45+
}
46+
47+
class System {
48+
public static PrintStream out = new PrintStream();
49+
}
50+
`
4451

4552
// const disabled = `class PrintStream extends Object {
4653
// public native void println(String s);

src/ec-evaluator/natives.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const foreigns: {
4444
stash.push(stashItem)
4545
},
4646

47-
'Object::display(int s): void': ({ environment, interfaces }) => {
47+
'PrintStream::println(String s): void': ({ environment, interfaces }) => {
4848
// @ts-expect-error ts(2339): guaranteed valid by type checker
4949
const s = environment.getVariable('s').value.literalType.value
5050

0 commit comments

Comments
 (0)