TypeCheck.jrag 653 Bytes
Newer Older
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
aspect TypeCheck {
  public void ASTNode.typeCheck() {
    for (int i = 0; i < getNumChild(); i++) {
      getChild(i).typeCheck();
    }
  }
  
  syn boolean Type.isNull();
  eq Type.isNull() = false;
  eq VoidType.isNull() = true;
  
  public void Field.nullTypeCheck() {
    if(getType().isNull()) {
      error(getName() + ": fields cannot be of type void");
    }
  }

  public void ParseArrayType.nullTypeCheck() {
    if(getType().isNull()) {
      error("array elements cannot be of type void");
    }
  }

  public void ArrayType.nullTypeCheck() {
    if(getType().isNull()) {
      error("array elements cannot be of type void");
    }
  }
}