コード例 #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
ファイル: BaseSyntaxVisitor.cs プロジェクト: smackem/waddle
 public virtual TResult Visit(IfStmtSyntax syntax)
 {
     return(DefaultResult);
 }
コード例 #4
0
 public void LeaveIfStmt(IfStmtSyntax ifStmt, WaddleContext ctx)
 {
 }