aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/shedlang/compiler/backends/targets/WasmTarget.java
blob: 413cead5f5cb2983d1d5d486196db68345644585 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package org.shedlang.compiler.backends.targets;

import org.shedlang.compiler.backends.wasm.structure.ast.types.WasmIndexType;
import org.shedlang.compiler.backends.wasm.structure.ast.types.WasmValueType;

import java.util.List;

public enum WasmTarget {
    WASM32(
        "wasm32",
        WasmIndexType.I32,
        WasmValueType.I32,
        List.of(),
        List.of(),
        List.of(),
        List.of()
    ),
    WASM64(
        "wasm64",
        WasmIndexType.I64,
        WasmValueType.I64,
        List.of("-mwasm64"),
        List.of("--enable-memory64"),
        List.of(),
        List.of("--wasm64")
    );

    private final String targetName;
    private final WasmIndexType indexType;
    private final WasmValueType sizeT;
    private final List<String> linkerFlags;
    private final List<String> wabtFlags;
    private final List<String> nodeFlags;
    private final List<String> runWasmFlags;

    WasmTarget(
        String targetName,
        WasmIndexType indexType,
        WasmValueType sizeT,
        List<String> linkerFlags,
        List<String> wabtFlags,
        List<String> nodeFlags,
        List<String> runWasmFlags
    ) {
        this.targetName = targetName;
        this.indexType = indexType;
        this.sizeT = sizeT;
        this.linkerFlags = linkerFlags;
        this.wabtFlags = wabtFlags;
        this.nodeFlags = nodeFlags;
        this.runWasmFlags = runWasmFlags;
    }

    public String targetName() {
        return targetName;
    }

    public WasmIndexType indexType() {
        return indexType;
    }

    public WasmValueType sizeT() {
        return sizeT;
    }

    public WasmValueType dataPtrType() {
        return sizeT;
    }

    public WasmValueType functionPtrType() {
        return sizeT;
    }

    public WasmValueType patioIntType() {
        return sizeT;
    }

    public List<String> linkerFlags() {
        return linkerFlags;
    }

    public List<String> wabtFlags() {
        return wabtFlags;
    }

    public List<String> nodeFlags() {
        return this.nodeFlags;
    }

    public List<String> runWasmFlags() {
        return this.runWasmFlags;
    }
}