aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/couscous/interpreter/values/MethodValue.java
blob: 01b2f3589d2437bd0efa0e9f09275f70698537f7 (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.ast.TypeName;
import org.zwobble.couscous.interpreter.Environment;

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

public final class MethodValue implements Callable {
    private final List<TypeName> 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<TypeName> argumentTypes, final BiFunction<Environment, MethodCallArguments<InterpreterValue>, InterpreterValue> apply) {
        this.argumentTypes = argumentTypes;
        this.apply = apply;
    }
    
    public List<TypeName> getArgumentTypes() {
        return this.argumentTypes;
    }
}