Exemple #1
0
 /**
  * Ensures a non-void function has a return that is guaranteed to execute
  *
  * @see ASTNode#checkSemantics()
  */
 public void checkSemantics() throws Exception {
   SymbolsTables.enterNewScope();
   if (paramList != null) {
     for (ASTNode param : paramList) {
       param.checkSemantics();
     }
   }
   if (stmtList != null) {
     stmtList.checkSemantics();
   }
   if (!"void".equalsIgnoreCase(rtrnType) && !"return".equalsIgnoreCase(stmtList.getType())) {
     throw new Exception("Line " + this.getYyline() + ": Missing return statement");
   }
   setType(rtrnType);
   SymbolsTables.leaveCurrentScope();
 }