private void WaddleIfStmt(IfStmtSyntax ifStmt) { if (_currentFunction == null) { throw new SemanticErrorException($"can not use if statement outside of function."); } // check that expr is boolean var exprType = WaddleExpression(ifStmt.Expression); if (IsAssignableFrom(TypeSymbol.Bool, exprType) == false) { throw new SemanticErrorException("If-Statement expression must result in boolean value."); } WaddleBody(ifStmt.Body); }
public bool EnterIfStmt(IfStmtSyntax ifStmt, WaddleContext ctx) { if (_currentFunction == null) { throw new SemanticErrorException($"can not use if statement outside of function."); } // check that expr is boolean var exprType = ifStmt.Expression.Accept(TypeVisitor); if (TypeSymbol.Bool != exprType) { throw new SemanticErrorException("If-Statement expression must result in boolean value."); } return(true); }
public virtual TResult Visit(IfStmtSyntax syntax) { return(DefaultResult); }
public void LeaveIfStmt(IfStmtSyntax ifStmt, WaddleContext ctx) { }