aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/couscous/interpreter/values/MethodValue.java
blob: 239e7ef1ae406f0897ca1df095003234b39f0213 (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
package org.zwobble.couscous.interpreter.values;

import org.zwobble.couscous.types.Type;
import org.zwobble.couscous.interpreter.Environment;

import java.util.List;
import java.util.function.BiFunction;

public final class MethodValue implements Callable {
    private final List<Type> argumentTypes;
    private final BiFunction<Environment, MethodCallArguments<InterpreterValue>, InterpreterValue> apply;
    
    public InterpreterValue apply(Environment environment, MethodCallArguments<InterpreterValue> arguments) {
        return apply.apply(environment, arguments);
    }
    
    public MethodValue(final List<Type> argumentTypes, final BiFunction<Environment, MethodCallArguments<InterpreterValue>, InterpreterValue> apply) {
        this.argumentTypes = argumentTypes;
        this.apply = apply;
    }
    
    public List<Type> getArgumentTypes() {
        return this.argumentTypes;
    }
}