blob: d08393d6d8c126c69f7c63e8d0c7d202492d597d (
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
|
package org.zwobble.couscous.interpreter;
import java.util.List;
import org.zwobble.couscous.values.InterpreterValue;
import lombok.val;
public class Arguments {
private int index = 0;
private List<InterpreterValue> values;
public Arguments(List<InterpreterValue> values) {
this.values = values;
}
@SuppressWarnings("unchecked")
public <T extends InterpreterValue> T pop(Class<T> valueType) {
val value = values.get(index);
index++;
if (valueType.isInstance(value)) {
return (T) value;
} else {
// TODO: throw a more specific error
throw new UnsupportedOperationException();
}
}
}
|