blob: f2e7b8d0804502cbc0cf86eff9020795a06e88b2 (
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
|
package com.jantuomi.interpreter.main.core.parser.ast;
import com.jantuomi.interpreter.main.core.parser.datatype.DataContainer;
import com.jantuomi.interpreter.main.core.runtime.State;
import com.jantuomi.interpreter.main.core.tokenizer.token.Token;
import com.jantuomi.interpreter.main.exception.InterpreterException;
import java.util.Arrays;
import java.util.List;
/**
* Created by jan on 21.6.2016.
*/
public class AssignmentNode extends BinaryOperatorNode {
public AssignmentNode(Token token, SymbolNode lhs, ASTNode rhs) {
super(token, lhs, rhs);
}
@Override
public DataContainer evaluate() throws InterpreterException {
SymbolNode symbol = (SymbolNode) lhs;
DataContainer rValue = rhs.evaluate();
State.getInstance().setSymbolValueToScope(
symbol.getName(),
rValue
);
return rValue;
}
@Override
List<ASTNode> getChildren() {
return Arrays.asList(lhs, rhs);
}
}
|