-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathJSMinusScript.java
36 lines (34 loc) · 1010 Bytes
/
JSMinusScript.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.*;
public class JSMinusScript {
static HashMap<String, Object> s_globals;
static Object print(Object args) {
for (Object arg : (ArrayList)args) System.out.print(arg + "\t");
return null;
}
static Object println(Object args) {
print(args);
System.out.println("");
return null;
}
static Object clock() {
return System.currentTimeMillis() / 1000.0;
}
static Object random() {
return (int)(Math.random() * (1 << 24));
}
@SuppressWarnings("unchecked")
static Object push(Object a, Object v) {
((ArrayList)a).add(v);
return a;
}
static Object format(Object fmt, Object args) {
return String.format((String)fmt, ((ArrayList)args).toArray());
}
static boolean __equals(Object a, Object b) {
if (a == null) return a == b;
else return a.equals(b);
}
static boolean __nequals(Object a, Object b) {
return !__equals(a, b);
}
}