Changeset 46da46b for src/AST


Ignore:
Timestamp:
May 2, 2023, 3:44:31 AM (2 years ago)
Author:
Fangren Yu <f37yu@…>
Branches:
ast-experimental, master
Children:
0c840fc
Parents:
1ab773e0
Message:

current progress

Location:
src/AST
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r1ab773e0 r46da46b  
    23312331                                old->location,
    23322332                                GET_ACCEPT_1(arg, Expr),
    2333                                 old->isGenerated ? ast::GeneratedCast : ast::ExplicitCast
     2333                                old->isGenerated ? ast::GeneratedCast : ast::ExplicitCast,
     2334                                (ast::CastExpr::CastKind) old->kind
    23342335                        )
    23352336                );
  • src/AST/Expr.cpp

    r1ab773e0 r46da46b  
    186186// --- CastExpr
    187187
    188 CastExpr::CastExpr( const CodeLocation & loc, const Expr * a, GeneratedFlag g )
    189 : Expr( loc, new VoidType{} ), arg( a ), isGenerated( g ) {}
     188CastExpr::CastExpr( const CodeLocation & loc, const Expr * a, GeneratedFlag g, CastKind kind )
     189: Expr( loc, new VoidType{} ), arg( a ), isGenerated( g ), kind( kind ) {}
    190190
    191191bool CastExpr::get_lvalue() const {
  • src/AST/Expr.hpp

    r1ab773e0 r46da46b  
    5555                const Expr * e )
    5656        : decl( id ), declptr( declptr ), actualType( actual ), formalType( formal ), expr( e ) {}
     57
     58        operator bool() {return declptr;}
    5759};
    5860
     
    334336        GeneratedFlag isGenerated;
    335337
     338        enum CastKind {
     339                Default, // C
     340                Coerce, // reinterpret cast
     341                Return  // overload selection
     342        };
     343
     344        CastKind kind = Default;
     345
    336346        CastExpr( const CodeLocation & loc, const Expr * a, const Type * to,
    337                 GeneratedFlag g = GeneratedCast ) : Expr( loc, to ), arg( a ), isGenerated( g ) {}
     347                GeneratedFlag g = GeneratedCast, CastKind kind = Default ) : Expr( loc, to ), arg( a ), isGenerated( g ), kind( kind ) {}
    338348        /// Cast-to-void
    339         CastExpr( const CodeLocation & loc, const Expr * a, GeneratedFlag g = GeneratedCast );
     349        CastExpr( const CodeLocation & loc, const Expr * a, GeneratedFlag g = GeneratedCast, CastKind kind = Default );
    340350
    341351        /// Wrap a cast expression around an existing expression (always generated)
  • src/AST/Type.hpp

    r1ab773e0 r46da46b  
    454454        bool operator==(const TypeEnvKey & other) const;
    455455        bool operator<(const TypeEnvKey & other) const;
    456 };
     456        operator bool() {return base;}
     457};
     458
    457459
    458460/// tuple type e.g. `[int, char]`
  • src/AST/TypeEnvironment.cpp

    r1ab773e0 r46da46b  
    135135                }
    136136        }
    137         sub.normalize();
     137        // sub.normalize();
    138138}
    139139
Note: See TracChangeset for help on using the changeset viewer.