Changeset 0c327ce for src/AST


Ignore:
Timestamp:
Jul 12, 2024, 3:30:06 PM (5 months ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
76b507d
Parents:
9c447e2
Message:
  1. Add bound check to Serial function: now compiler generates the unchecked functions in ImplementEnumFunc?, and enum.hfa implements the bound check on top. Todo: Wrapped the checked version into a trait; 2. countof is now works on any type that implement Countof(). Because Countof() is implemented in enum.hfa for all CfaEnum?, we can call countof on { T | CfaEnum?(T) }
Location:
src/AST
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Expr.cpp

    r9c447e2 r0c327ce  
    284284// --- CountExpr
    285285
     286CountExpr::CountExpr( const CodeLocation & loc, const Expr * e )
     287: Expr( loc, new BasicType( BasicKind::LongUnsignedInt) ), expr(e), type( nullptr ) {}
     288
    286289CountExpr::CountExpr( const CodeLocation & loc, const Type * t )
    287 : Expr( loc, new BasicType( BasicKind::LongUnsignedInt) ), type( t ) {}
     290: Expr( loc, new BasicType( BasicKind::LongUnsignedInt) ), expr(nullptr), type( t ) {}
    288291
    289292// --- AlignofExpr
  • src/AST/Expr.hpp

    r9c447e2 r0c327ce  
    496496class CountExpr final : public Expr {
    497497public:
     498        ptr<Expr> expr;
    498499        ptr<Type> type;
    499500
     501        CountExpr( const CodeLocation & loc, const Expr * t );
    500502        CountExpr( const CodeLocation & loc, const Type * t );
    501503
  • src/AST/Pass.impl.hpp

    r9c447e2 r0c327ce  
    13391339                        maybe_accept( node, &CountExpr::result );
    13401340                }
    1341                 maybe_accept( node, &CountExpr::type );
     1341                if ( node->type ) {
     1342                        maybe_accept( node, &CountExpr::type );
     1343                } else {
     1344                        maybe_accept( node, &CountExpr::expr );
     1345                }
    13421346        }
    13431347        VISIT_END( Expr, node );
  • src/AST/Print.cpp

    r9c447e2 r0c327ce  
    11461146                os << "Count Expression on: ";
    11471147                ++indent;
    1148                 node->type->accept( *this );
     1148                if ( node->type ) node->type->accept( *this );
     1149                else safe_print( node->expr );
    11491150                --indent;
    11501151                postprint( node );
Note: See TracChangeset for help on using the changeset viewer.