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

import org.zwobble.couscous.values.BooleanValue;
import org.zwobble.couscous.values.IntegerValue;
import org.zwobble.couscous.values.ObjectValues;

import static java.util.Arrays.asList;

public class InternalCouscousInterpreterValue {
    public static final ConcreteType TYPE = ConcreteType.classBuilder("_couscous")
        .staticMethod("same", asList(ObjectValues.OBJECT, ObjectValues.OBJECT),
            (environment, arguments) ->
                new BooleanInterpreterValue(arguments.get(0) == arguments.get(1)))

        .staticMethod("boxBoolean", asList(BooleanValue.REF),
            ((environment, arguments) ->  arguments.get(0)))

        .staticMethod("unboxBoolean", asList(BooleanValue.REF),
            ((environment, arguments) ->  arguments.get(0)))

        .staticMethod("boxInt", asList(IntegerValue.REF),
            ((environment, arguments) ->  arguments.get(0)))

        .staticMethod("unboxInt", asList(IntegerValue.REF),
            ((environment, arguments) ->  arguments.get(0)))

        .build();
}