forked from EB-wilson/JavaDynamilizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionEntry.java
More file actions
58 lines (50 loc) · 1.24 KB
/
Copy pathFunctionEntry.java
File metadata and controls
58 lines (50 loc) · 1.24 KB
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
package dynamilize;
public class FunctionEntry<S, R> implements IFunctionEntry{
private final String name;
private final boolean modifiable;
private final Function<S, R> func;
private final FunctionType type;
private final DataPool owner;
public FunctionEntry(String name, boolean modifiable, Function<S, R> func, FunctionType type, DataPool owner){
this.name = name;
this.modifiable = modifiable;
this.func = func;
this.type = type;
this.owner = owner;
}
public FunctionEntry(String name, boolean modifiable, Function.SuperGetFunction<S, R> func, FunctionType type, DataPool owner){
this(
name,
modifiable,
(s, a) -> {
DataPool.ReadOnlyPool p;
R res = func.invoke(s, p = owner.getSuper(s, s.baseSuperPointer()), a);
p.recycle();
return res;
},
type,
owner
);
}
@Override
public String getName(){
return name;
}
@Override
public boolean modifiable(){
return modifiable;
}
@Override
public DataPool owner(){
return owner;
}
@Override
@SuppressWarnings("unchecked")
public Function<S, R> getFunction(){
return func;
}
@Override
public FunctionType getType(){
return type;
}
}