Пример #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);
        }
Пример #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);
        }
Пример #3
0
 public virtual TResult Visit(IfStmtSyntax syntax)
 {
     return(DefaultResult);
 }
Пример #4
0
 public void LeaveIfStmt(IfStmtSyntax ifStmt, WaddleContext ctx)
 {
 }