Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public virtual TResult Visit(IfStmtSyntax syntax)
 {
     return(DefaultResult);
 }
Exemplo n.º 4
0
 public void LeaveIfStmt(IfStmtSyntax ifStmt, WaddleContext ctx)
 {
 }