Exemplo n.º 1
0
 public object visitIfStatement(Statement.ifStmt ifStmt)
 {
     if (isTruthy(evaluate(ifStmt.condition)))
     {
         execute(ifStmt.thenBranch);
     }
     else if (ifStmt.elseBranch != null)
     {
         execute(ifStmt.elseBranch);
     }
     return(null);
 }
Exemplo n.º 2
0
 public object visitIfStatement(Statement.ifStmt ifStmt)
 {
     resolve(ifStmt.condition);
     resolve(ifStmt.thenBranch);
     if (returned)
     {
         returned = false;           //Code after a return statement inside an if-statement is not unreachable.
     }
     if (ifStmt.elseBranch != null)
     {
         resolve(ifStmt.elseBranch);
     }
     return(null);
 }