Changeset 44b4114


Ignore:
Timestamp:
Feb 14, 2018, 4:18:37 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
f5883bd
Parents:
490ff5c3
git-author:
Rob Schluntz <rschlunt@…> (02/14/18 16:17:36)
git-committer:
Rob Schluntz <rschlunt@…> (02/14/18 16:18:37)
Message:

Add DeletedExpr? node for use of deleted identifiers

Location:
src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r490ff5c3 r44b4114  
    764764
    765765        void CodeGenerator::postvisit( StmtExpr * stmtExpr ) {
    766                 std::list< Statement * > & stmts = stmtExpr->get_statements()->get_kids();
     766                std::list< Statement * > & stmts = stmtExpr->statements->kids;
    767767                output << "({" << endl;
    768768                ++indent;
     
    775775                                // cannot cast to void, otherwise the expression statement has no value
    776776                                if ( ExprStmt * exprStmt = dynamic_cast< ExprStmt * >( stmt ) ) {
    777                                         exprStmt->get_expr()->accept( *visitor );
     777                                        exprStmt->expr->accept( *visitor );
    778778                                        output << ";" << endl;
    779779                                        ++i;
     
    795795                assertf( ! genC, "Unique expressions should not reach code generation." );
    796796                expr->callExpr->accept( *visitor );
     797        }
     798
     799        void CodeGenerator::postvisit( DeletedExpr * expr ) {
     800                assertf( ! genC, "Deleted expressions should not reach code generation." );
     801                expr->expr->accept( *visitor );
    797802        }
    798803
  • src/CodeGen/CodeGenerator.h

    r490ff5c3 r44b4114  
    8888                void postvisit( StmtExpr * );
    8989                void postvisit( ConstructorExpr * );
     90                void postvisit( DeletedExpr * );
    9091
    9192                //*** Statements
  • src/Common/PassVisitor.h

    r490ff5c3 r44b4114  
    121121        virtual void visit( UntypedInitExpr *  initExpr ) override final;
    122122        virtual void visit( InitExpr *  initExpr ) override final;
     123        virtual void visit( DeletedExpr *  delExpr ) override final;
    123124
    124125        virtual void visit( VoidType * basicType ) override final;
     
    215216        virtual Expression * mutate( UntypedInitExpr *  initExpr ) override final;
    216217        virtual Expression * mutate( InitExpr *  initExpr ) override final;
     218        virtual Expression * mutate( DeletedExpr *  delExpr ) override final;
    217219
    218220        virtual Type * mutate( VoidType * basicType ) override final;
  • src/Common/PassVisitor.impl.h

    r490ff5c3 r44b4114  
    19761976}
    19771977
     1978//--------------------------------------------------------------------------
     1979// DeletedExpr
     1980template< typename pass_type >
     1981void PassVisitor< pass_type >::visit( DeletedExpr * node ) {
     1982        VISIT_START( node );
     1983
     1984        indexerScopedAccept( node->result, *this );
     1985        maybeAccept_impl( node->expr, *this );
     1986        // don't visit deleteStmt, because it is a pointer to somewhere else in the tree.
     1987
     1988        VISIT_END( node );
     1989}
     1990
     1991template< typename pass_type >
     1992Expression * PassVisitor< pass_type >::mutate( DeletedExpr * node ) {
     1993        MUTATE_START( node );
     1994
     1995        indexerScopedMutate( node->env, *this );
     1996        indexerScopedMutate( node->result, *this );
     1997        maybeMutate_impl( node->expr, *this );
     1998
     1999        MUTATE_END( Expression, node );
     2000}
     2001
     2002
    19782003template< typename pass_type >
    19792004void PassVisitor< pass_type >::visit( VoidType * node ) {
  • src/SynTree/Expression.cc

    r490ff5c3 r44b4114  
    710710}
    711711
     712DeletedExpr::DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt ) : expr( expr ), deleteStmt( deleteStmt ) {
     713        assert( expr->result );
     714        result = expr->result->clone();
     715}
     716DeletedExpr::DeletedExpr( const DeletedExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ), deleteStmt( other.deleteStmt ) {}
     717DeletedExpr::~DeletedExpr() {
     718        delete expr;
     719}
     720
     721void DeletedExpr::print( std::ostream & os, Indenter indent ) const {
     722        os << "Deleted Expression" << std::endl << indent+1;
     723        expr->print( os, indent+1 );
     724        os << std::endl << indent+1 << "... deleted by: ";
     725        deleteStmt->print( os, indent+1 );
     726}
     727
     728
    712729// Local Variables: //
    713730// tab-width: 4 //
  • src/SynTree/Expression.h

    r490ff5c3 r44b4114  
    822822};
    823823
     824/// expression that contains a deleted identifier - should never make it past the resolver.
     825class DeletedExpr : public Expression {
     826public:
     827        Expression * expr;
     828        BaseSyntaxNode * deleteStmt;
     829
     830        DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt );
     831        DeletedExpr( const DeletedExpr & other );
     832        ~DeletedExpr();
     833
     834        virtual DeletedExpr * clone() const { return new DeletedExpr( * this ); }
     835        virtual void accept( Visitor & v ) { v.visit( this ); }
     836        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     837        virtual void print( std::ostream & os, Indenter indent = {} ) const;
     838};
     839
    824840// Local Variables: //
    825841// tab-width: 4 //
  • src/SynTree/Mutator.h

    r490ff5c3 r44b4114  
    5555        virtual Statement * mutate( ImplicitCtorDtorStmt * impCtorDtorStmt );
    5656
    57         virtual Expression* mutate( ApplicationExpr * applicationExpr );
    58         virtual Expression* mutate( UntypedExpr * untypedExpr );
    59         virtual Expression* mutate( NameExpr * nameExpr );
    60         virtual Expression* mutate( AddressExpr * castExpr );
    61         virtual Expression* mutate( LabelAddressExpr * labAddressExpr );
    62         virtual Expression* mutate( CastExpr * castExpr );
    63         virtual Expression* mutate( VirtualCastExpr * castExpr );
    64         virtual Expression* mutate( UntypedMemberExpr * memberExpr );
    65         virtual Expression* mutate( MemberExpr * memberExpr );
    66         virtual Expression* mutate( VariableExpr * variableExpr );
    67         virtual Expression* mutate( ConstantExpr * constantExpr );
    68         virtual Expression* mutate( SizeofExpr * sizeofExpr );
    69         virtual Expression* mutate( AlignofExpr * alignofExpr );
    70         virtual Expression* mutate( UntypedOffsetofExpr * offsetofExpr );
    71         virtual Expression* mutate( OffsetofExpr * offsetofExpr );
    72         virtual Expression* mutate( OffsetPackExpr * offsetPackExpr );
    73         virtual Expression* mutate( AttrExpr * attrExpr );
    74         virtual Expression* mutate( LogicalExpr * logicalExpr );
    75         virtual Expression* mutate( ConditionalExpr * conditionalExpr );
    76         virtual Expression* mutate( CommaExpr * commaExpr );
    77         virtual Expression* mutate( TypeExpr * typeExpr );
    78         virtual Expression* mutate( AsmExpr * asmExpr );
    79         virtual Expression* mutate( ImplicitCopyCtorExpr * impCpCtorExpr );
    80         virtual Expression* mutate( ConstructorExpr * ctorExpr );
    81         virtual Expression* mutate( CompoundLiteralExpr * compLitExpr );
    82         virtual Expression* mutate( RangeExpr * rangeExpr );
    83         virtual Expression* mutate( UntypedTupleExpr * tupleExpr );
    84         virtual Expression* mutate( TupleExpr * tupleExpr );
    85         virtual Expression* mutate( TupleIndexExpr * tupleExpr );
    86         virtual Expression* mutate( TupleAssignExpr * assignExpr );
    87         virtual Expression* mutate( StmtExpr  * stmtExpr );
    88         virtual Expression* mutate( UniqueExpr  * uniqueExpr );
    89         virtual Expression* mutate( UntypedInitExpr  * initExpr );
    90         virtual Expression* mutate( InitExpr  * initExpr );
     57        virtual Expression * mutate( ApplicationExpr * applicationExpr );
     58        virtual Expression * mutate( UntypedExpr * untypedExpr );
     59        virtual Expression * mutate( NameExpr * nameExpr );
     60        virtual Expression * mutate( AddressExpr * castExpr );
     61        virtual Expression * mutate( LabelAddressExpr * labAddressExpr );
     62        virtual Expression * mutate( CastExpr * castExpr );
     63        virtual Expression * mutate( VirtualCastExpr * castExpr );
     64        virtual Expression * mutate( UntypedMemberExpr * memberExpr );
     65        virtual Expression * mutate( MemberExpr * memberExpr );
     66        virtual Expression * mutate( VariableExpr * variableExpr );
     67        virtual Expression * mutate( ConstantExpr * constantExpr );
     68        virtual Expression * mutate( SizeofExpr * sizeofExpr );
     69        virtual Expression * mutate( AlignofExpr * alignofExpr );
     70        virtual Expression * mutate( UntypedOffsetofExpr * offsetofExpr );
     71        virtual Expression * mutate( OffsetofExpr * offsetofExpr );
     72        virtual Expression * mutate( OffsetPackExpr * offsetPackExpr );
     73        virtual Expression * mutate( AttrExpr * attrExpr );
     74        virtual Expression * mutate( LogicalExpr * logicalExpr );
     75        virtual Expression * mutate( ConditionalExpr * conditionalExpr );
     76        virtual Expression * mutate( CommaExpr * commaExpr );
     77        virtual Expression * mutate( TypeExpr * typeExpr );
     78        virtual Expression * mutate( AsmExpr * asmExpr );
     79        virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr );
     80        virtual Expression * mutate( ConstructorExpr * ctorExpr );
     81        virtual Expression * mutate( CompoundLiteralExpr * compLitExpr );
     82        virtual Expression * mutate( RangeExpr * rangeExpr );
     83        virtual Expression * mutate( UntypedTupleExpr * tupleExpr );
     84        virtual Expression * mutate( TupleExpr * tupleExpr );
     85        virtual Expression * mutate( TupleIndexExpr * tupleExpr );
     86        virtual Expression * mutate( TupleAssignExpr * assignExpr );
     87        virtual Expression * mutate( StmtExpr  * stmtExpr );
     88        virtual Expression * mutate( UniqueExpr  * uniqueExpr );
     89        virtual Expression * mutate( UntypedInitExpr  * initExpr );
     90        virtual Expression * mutate( InitExpr  * initExpr );
     91        virtual Expression * mutate( DeletedExpr * delExpr ) = 0;
    9192
    9293        virtual Type * mutate( VoidType * basicType );
  • src/SynTree/Statement.cc

    r490ff5c3 r44b4114  
    468468void WithStmt::print( std::ostream & os, Indenter indent ) const {
    469469        os << "With statement" << endl;
     470        os << indent << "... with expressions: " << endl;
     471        printAll( exprs, os, indent+1 );
    470472        os << indent << "... with statement:" << endl << indent+1;
    471473        stmt->print( os, indent+1 );
  • src/SynTree/SynTree.h

    r490ff5c3 r44b4114  
    9797class UntypedInitExpr;
    9898class InitExpr;
     99class DeletedExpr;
    99100
    100101class Type;
  • src/SynTree/Visitor.h

    r490ff5c3 r44b4114  
    9191        virtual void visit( UntypedInitExpr *  initExpr );
    9292        virtual void visit( InitExpr *  initExpr );
     93        virtual void visit( DeletedExpr * delExpr ) = 0;
    9394
    9495        virtual void visit( VoidType * basicType );
Note: See TracChangeset for help on using the changeset viewer.