Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parserutility.cc

    rbb7422a rd67cdb7  
    1010// Created On       : Sat May 16 15:30:39 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Mar  1 10:42:00 2023
    13 // Update Count     : 9
     12// Last Modified On : Tus Jul 18 10:12:00 2017
     13// Update Count     : 8
    1414//
    1515
     
    1919#include <string>                // for string
    2020
    21 #include "AST/Expr.hpp"          // for UntypedExpr, CastExpr, ConstantExpr
    22 #include "AST/Type.hpp"          // for BasicType, ZeroType, BasicType::Kind...
     21#include "SynTree/Constant.h"    // for Constant
     22#include "SynTree/Expression.h"  // for UntypedExpr, CastExpr, ConstantExpr
     23#include "SynTree/Type.h"        // for BasicType, ZeroType, BasicType::Kind...
    2324
    2425// rewrite
     
    2728//    if ( (int)(x != 0) ) ...
    2829
    29 ast::Expr * notZeroExpr( ast::Expr * orig ) {
    30         return ( !orig ) ? nullptr : new ast::CastExpr( orig->location,
    31                 ast::UntypedExpr::createCall( orig->location,
    32                         "?!=?",
    33                         {
    34                                 orig,
    35                                 new ast::ConstantExpr( orig->location,
    36                                         new ast::ZeroType(),
    37                                         "0",
    38                                         std::optional<unsigned long long>( 0 )
    39                                 ),
    40                         }
    41                 ),
    42                 new ast::BasicType( ast::BasicType::SignedInt )
    43         );
     30Expression *notZeroExpr( Expression *orig ) {
     31        if( !orig ) return nullptr;
     32        UntypedExpr *comparison = new UntypedExpr( new NameExpr( "?!=?" ) );
     33        comparison->get_args().push_back( orig );
     34        comparison->get_args().push_back( new ConstantExpr( Constant( new ZeroType( noQualifiers ), "0", (unsigned long long int)0 ) ) );
     35        return new CastExpr( comparison, new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    4436}
    4537
Note: See TracChangeset for help on using the changeset viewer.