MCPcopy Create free account
hub / github.com/bnjbvr/trinity / TrinityModule

Class TrinityModule

java-module/TrinityModule.java:11–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9import org.teavm.interop.Export;
10
11public final class TrinityModule {
12 private TrinityModule() {}
13
14 public static final class Message {
15 public final String content;
16 public final String to;
17
18 public Message(String content, String to) {
19 this.content = content;
20 this.to = to;
21 }
22 }
23
24 @Export(name = "init")
25 private static void wasmExportInit() {
26
27 TrinityModuleImpl.init();
28
29 }
30
31 @Export(name = "help")
32 private static int wasmExportHelp(int p0, int p1, int p2) {
33
34 String lifted;
35
36 switch (p0) {
37 case 0: {
38 lifted = null;
39 break;
40 }
41
42 case 1: {
43
44 byte[] bytes = new byte[p2];
45 Memory.getBytes(Address.fromInt(p1), bytes, 0, p2);
46
47 lifted = new String(bytes, StandardCharsets.UTF_8);
48 break;
49 }
50
51 default: throw new AssertionError("invalid discriminant: " + (p0));
52 }
53
54 String result = TrinityModuleImpl.help(lifted);
55
56 byte[] bytes2 = (result).getBytes(StandardCharsets.UTF_8);
57
58 Address address = Memory.malloc(bytes2.length, 1);
59 Memory.putBytes(address, bytes2, 0, bytes2.length);
60 Address.fromInt((TrinityModuleWorld.RETURN_AREA) + 4).putInt(bytes2.length);
61 Address.fromInt((TrinityModuleWorld.RETURN_AREA) + 0).putInt(address.toInt());
62 return TrinityModuleWorld.RETURN_AREA;
63
64 }
65
66 @Export(name = "cabi_post_help")
67 private static void wasmExportHelpPostReturn(int p0) {
68 Memory.free(Address.fromInt(Address.fromInt((p0) + 0).getInt()), Address.fromInt((p0) + 4).getInt(), 1);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected