-
Notifications
You must be signed in to change notification settings - Fork 0
/
Function.java
137 lines (112 loc) · 3.18 KB
/
Function.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package com.destranix.glslang;
public class Function extends PointerBoundObject {
protected final long id;
protected final long resultType;
protected final long functionType;
protected final long firstParam;
protected final Module parent;
private final int constructorIndex;
public Function(long id, long resultType, long functionType, long firstParam, Module parent) {
this.id = id;
this.resultType = resultType;
this.functionType = functionType;
this.firstParam = firstParam;
this.parent = parent;
this.constructorIndex = 0;
load();
}
protected Function(byte[] ptr) {
this.ptr = ptr;
this.id = -1;
this.resultType = -1;
this.functionType = -1;
this.firstParam = -1;
this.parent = null;
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.Function(id, resultType, functionType, firstParam, parent.getPtr());
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.delete(ptr);
ptr = null;
break;
default:
throw new AssertionError("Reached unreachable state!");
}
}
}
public long getId() {
return Main.Function_getId(ptr);
}
public long getParamId(int p) {
return Main.Function_getParamId(ptr, p);
}
public long getParamType(int p) {
return Main.Function_getParamType(ptr, p);
}
public void addBlock(Block block) {
Main.Function_addBlock(ptr, block.getPtr());
}
public void removeBlock(Block block) {
Main.Function_removeBlock(ptr, block.getPtr());
}
public Module getParent() {
return fromPtr(Main.Function_getParent(ptr), Module.class);
}
public Block getEntryBlock() {
return fromPtr(Main.Function_getEntryBlock(ptr), Block.class);
}
public Block getLastBlock() {
return fromPtr(Main.Function_getLastBlock(ptr), Block.class);
}
public CVector<Block> getBlocks() {
@SuppressWarnings("unchecked")
CVector<Block> ret = (CVector<Block>) fromPtr(Main.Function_getBlocks(ptr), CVector.class);
return ret;
}
public void addLocalVariable(Instruction inst) {
Main.Function_addLocalVariable(ptr, inst.getPtr());
}
public long getReturnType() {
return Main.Function_getReturnType(ptr);
}
public void setReturnPrecision(Decoration precision) {
Main.Function_setReturnPrecision(ptr, precision);
}
public Decoration getReturnPrecision() {
return Decoration.valueByConstant(Main.Function_getReturnPrecision(ptr));
}
public void setImplicitThis() {
Main.Function_setImplicitThis(ptr);
}
public boolean hasImplicitThis() {
return Main.Function_hasImplicitThis(ptr);
}
public void addParamPrecision(long param, Decoration precision) {
Main.Function_addParamPrecision(ptr, param, precision);
}
public Decoration getParamPrecision(long param) {
return Decoration.valueByConstant(Main.Function_getParamPrecision(ptr, param));
}
public void dump(long[][] out) {
Main.Function_dump(ptr, out);
}
}