-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNabeatsu.java
35 lines (28 loc) · 877 Bytes
/
Nabeatsu.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
import org.graalvm.polyglot.*;
import java.io.*;
public class Nabeatsu{
public static void main(String[] args) throws Exception{
int max = 0;
if((args.length != 1) ||
((max = Integer.parseInt(args[0])) <= 0)){
System.err.println("baka");
System.exit(3);
}
Source src = Source.newBuilder("llvm", new File("../native/lib/libnabeatsu.so"))
.build();
try(Context ctx = Context.newBuilder("llvm")
.allowNativeAccess(true)
.build()){
ctx.eval(src);
Value is_aho = ctx.getBindings("llvm")
.getMember("is_aho");
for(int i = 1; i <= max; i++){
System.out.print(i);
if(is_aho.execute(i).asInt() == 1){
System.out.print(" [aho]");
}
System.out.println();
}
}
}
}