aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/couscous/interpreter/values/ObjectInterpreterValue.java
blob: e15c01d51b09bd67fc825c96dcc7b5567cab20ea (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
30
31
32
33
34
35
package org.zwobble.couscous.interpreter.values;

import org.zwobble.couscous.values.PrimitiveValue;

import java.util.Optional;

public class ObjectInterpreterValue implements InterpreterValue {
    private final ConcreteType type;
    private final InterpreterFields fields;
    
    public ObjectInterpreterValue(ConcreteType type) {
        this.type = type;
        this.fields = InterpreterFields.forInstanceOf(type);
    }
    
    @Override
    public ConcreteType getType() {
        return type;
    }
    
    @Override
    public Optional<PrimitiveValue> toPrimitiveValue() {
        return Optional.empty();
    }
    
    @Override
    public InterpreterValue getField(String fieldName) {
        return fields.getField(fieldName);
    }
    
    @Override
    public void setField(String fieldName, InterpreterValue value) {
        fields.setField(fieldName, value);
    }
}