1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import org.graalvm.polyglot.*;
20 import java.io.*;
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 public class HelloPolyglot {
40 public static void main(
String[] args) {
41 try {
42
43 Context ctx =
Context.newBuilder().allowAllAccess(true).build();
44
45
46 File file =
new File(
"test.bc");
47 Source source =
Source.newBuilder(
"llvm", file).build();
48 Value c = ctx.eval(source);
49
50
51 c.getMember(
"main").execute();
52
53
54 Value add = c.getMember(
"add");
55 Value ret = add.execute(
10,
20);
56 System.out.println(ret.asInt());
57 }
catch (
IOException e) {
58 System.err.println(e);
59 }
60 }
61 }
62