-
Notifications
You must be signed in to change notification settings - Fork 0
/
Linker.java
85 lines (72 loc) · 1.92 KB
/
Linker.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
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
package com.destranix.glslang;
public class Linker extends PointerBoundObject {
private final EShExecutable language;
private final int debugOptions;
private final int constructorIndex;
public Linker(EShExecutable language, int debugOptions) {
this.language = language;
this.debugOptions = debugOptions;
this.constructorIndex = 0;
load();
}
protected Linker(byte[] ptr) {
this.ptr = ptr;
this.language = null;
this.debugOptions = -1;
this.constructorIndex = -1;
}
@Override
protected void load_intern() {
if (ptr == null) {
switch (constructorIndex) {
case -1:
throw new IllegalStateException(EXCEPTION_MSG_NOT_LOADABLE);
case 0:
ptr = Main.ShConstructLinker(language, debugOptions);
break;
default:
throw new AssertionError("Reached unreachable state!");
}
}
}
@Override
protected void free_intern() {
if (ptr != null) {
switch (constructorIndex) {
case -1:
throw new IllegalStateException(EXCEPTION_MSG_NOT_FREEABLE);
case 0:
Main.ShDestruct(ptr);
ptr = null;
break;
default:
throw new AssertionError("Reached unreachable state!");
}
}
}
public int linkExt(Compiler[] h) {
byte[][] hPtrArray = new byte[h.length][];
for (int i = 0; i < h.length; ++i) {
hPtrArray[i] = h[i].getPtr();
}
byte[] hPtr = Main.createArray(hPtrArray);
int ret = Main.ShLinkExt(ptr, hPtr, h.length);
Main.delete(hPtr);
return ret;
}
public String getInfoLog() {
return Main.ShGetInfoLog(ptr);
}
public byte[] getExecutable() {
return Main.ShGetExecutable(ptr);
}
public int setVirtualAttributeBindings(BindingTable table) {
return Main.ShSetVirtualAttributeBindings(ptr, table.getPtr());
}
public int setFixedAttributeBindings(BindingTable table) {
return Main.ShSetFixedAttributeBindings(ptr, table.getPtr());
}
public int excludeAttributes(int[] attributes) {
return Main.ShExcludeAttributes(ptr, attributes);
}
}