示例#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)
 {
 }