-
Notifications
You must be signed in to change notification settings - Fork 0
/
StatementNode.java
40 lines (33 loc) · 1.01 KB
/
StatementNode.java
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
36
37
38
39
40
package org.bychan.core.langs.minilang;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class StatementNode implements LaiLaiNode {
@NotNull
private final LaiLaiNode left;
@NotNull
private final LaiLaiNode right;
public StatementNode(@NotNull final LaiLaiNode left, @NotNull final LaiLaiNode right) {
this.left = left;
this.right = right;
}
@NotNull
@Override
public Object evaluate(@Nullable ScopeNode currentScope) {
left.evaluate(currentScope);
return right.evaluate(currentScope);
}
@NotNull
@Override
public ExpressionType getExpressionType(@Nullable ScopeNode currentScope) {
return ExpressionType.union(left.getExpressionType(currentScope), right.getExpressionType(currentScope));
}
@Nullable
@Override
public Scope getScope() {
return left.getScope();
}
@Override
public String toString() {
return "(x " + left + " " + right + ")";
}
}