1
|
1 module ast.Stmt;
|
|
2
|
|
3 import ast.Exp,
|
|
4 ast.Decl;
|
|
5
|
|
6 import sema.SymbolTable;
|
|
7
|
|
8 enum StmtType
|
|
9 {
|
|
10 Stmt,
|
|
11 Decl,
|
|
12 Exp,
|
|
13 Return,
|
|
14 }
|
|
15
|
|
16 class Stmt
|
|
17 {
|
|
18 this(StmtType stmtType = StmtType.Stmt)
|
|
19 {
|
|
20 this.stmtType = stmtType;
|
|
21 }
|
|
22
|
|
23 StmtType stmtType;
|
|
24 Scope env;
|
|
25 }
|
|
26
|
|
27 class ReturnStmt : Stmt
|
|
28 {
|
|
29 this()
|
|
30 {
|
|
31 super(StmtType.Return);
|
|
32 }
|
|
33
|
|
34 public Exp exp;
|
|
35 }
|
|
36
|
|
37 class DeclStmt : Stmt
|
|
38 {
|
|
39 this(Decl decl)
|
|
40 {
|
|
41 super(StmtType.Decl);
|
|
42 this.decl = decl;
|
|
43 }
|
|
44
|
|
45 public Decl decl;
|
|
46 }
|
|
47
|
|
48 class ExpStmt : Stmt
|
|
49 {
|
|
50 this(Exp exp)
|
|
51 {
|
|
52 super(StmtType.Exp);
|
|
53 this.exp = exp;
|
|
54 }
|
|
55
|
|
56 public Exp exp;
|
|
57 }
|