forked from MarkusEble/Compilerbau25
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathASTCaseNode.java
More file actions
31 lines (22 loc) · 812 Bytes
/
ASTCaseNode.java
File metadata and controls
31 lines (22 loc) · 812 Bytes
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
package com.compiler.ast;
import com.compiler.CompileEnvIntf;
import java.io.OutputStreamWriter;
public class ASTCaseNode extends ASTStmtNode {
ASTIntegerLiteralNode m_value;
ASTStmtListNode m_stmtList;
int expressionValue; // Value gets written on Execution of Switch Block
public ASTCaseNode(ASTIntegerLiteralNode value, ASTStmtListNode stmtList) {
m_stmtList = stmtList;
m_value = value;
}
@Override
public void execute(OutputStreamWriter out) {
if(m_value.eval()==expressionValue) m_stmtList.execute(out);
}
@Override
public void print(OutputStreamWriter outStream, String indent) throws Exception {
outStream.write(indent);
outStream.write("ASTCaseNode\n");
m_stmtList.print(outStream, indent + " ");
}
}