Changeset bf4b4cf


Ignore:
Timestamp:
Oct 2, 2017, 4:53:32 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:
d29fa5f
Parents:
50377a4
git-author:
Rob Schluntz <rschlunt@…> (10/02/17 16:53:28)
git-committer:
Rob Schluntz <rschlunt@…> (10/02/17 16:53:32)
Message:

Remove argName from Expression.

If named arguments are ever considered again, they should be added in UntypedExpr? (and maybe also ApplicationExpr?) to avoid unnecessary fields in every Expression. Like designators on initializers, it should be much easier to work with argument names at the call expression level.

Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ExpressionNode.cc

    r50377a4 rbf4b4cf  
    8787                } else {
    8888                        assertf( false, "internal error, bad integral length %s", str.c_str() );
    89                 } // if         
     89                } // if
    9090                posn += 1;
    9191        } // if
     
    396396
    397397NameExpr * build_varref( const string * name ) {
    398         NameExpr * expr = new NameExpr( *name, nullptr );
     398        NameExpr * expr = new NameExpr( *name );
    399399        delete name;
    400400        return expr;
     
    487487        list< Expression * > args;
    488488        buildMoveList( expr_node, args );
    489         return new UntypedExpr( maybeMoveBuild< Expression >(function), args, nullptr );
     489        return new UntypedExpr( maybeMoveBuild< Expression >(function), args );
    490490} // build_func
    491491
  • src/ResolvExpr/AlternativeFinder.cc

    r50377a4 rbf4b4cf  
    973973                PRINT( std::cerr << "nameExpr is " << nameExpr->get_name() << std::endl; )
    974974                for ( std::list< DeclarationWithType* >::iterator i = declList.begin(); i != declList.end(); ++i ) {
    975                         VariableExpr newExpr( *i, nameExpr->get_argName() );
     975                        VariableExpr newExpr( *i );
    976976                        alternatives.push_back( Alternative( newExpr.clone(), env, Cost::zero ) );
    977977                        PRINT(
  • src/SynTree/AddressExpr.cc

    r50377a4 rbf4b4cf  
    4040}
    4141
    42 AddressExpr::AddressExpr( Expression *arg, Expression *_aname ) : Expression( _aname ), arg( arg ) {
     42AddressExpr::AddressExpr( Expression *arg ) : Expression(), arg( arg ) {
    4343        if ( arg->has_result() ) {
    4444                if ( arg->get_result()->get_lvalue() ) {
  • src/SynTree/CommaExpr.cc

    r50377a4 rbf4b4cf  
    2121#include "Type.h"            // for Type
    2222
    23 CommaExpr::CommaExpr( Expression *arg1, Expression *arg2, Expression *_aname )
    24                 : Expression( _aname ), arg1( arg1 ), arg2( arg2 ) {
     23CommaExpr::CommaExpr( Expression *arg1, Expression *arg2 )
     24                : Expression(), arg1( arg1 ), arg2( arg2 ) {
    2525        // xxx - result of a comma expression is never an lvalue, so should set lvalue
    2626        // to false on all result types. Actually doing this causes some strange things
  • src/SynTree/Expression.cc

    r50377a4 rbf4b4cf  
    3333#include "GenPoly/Lvalue.h"
    3434
    35 Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {}
    36 
    37 Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {
     35Expression::Expression() : result( 0 ), env( 0 ) {}
     36
     37Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ), result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), extension( other.extension ) {
    3838}
    3939
    4040Expression::~Expression() {
    4141        delete env;
    42         delete argName; // xxx -- there's a problem in cloning ConstantExpr I still don't know how to fix
    4342        delete result;
    4443}
     
    5554}
    5655
    57 ConstantExpr::ConstantExpr( Constant _c, Expression *_aname ) : Expression( _aname ), constant( _c ) {
     56ConstantExpr::ConstantExpr( Constant _c ) : Expression(), constant( _c ) {
    5857        set_result( constant.get_type()->clone() );
    5958}
     
    7069}
    7170
    72 VariableExpr::VariableExpr( DeclarationWithType *_var, Expression *_aname ) : Expression( _aname ), var( _var ) {
     71VariableExpr::VariableExpr( DeclarationWithType *_var ) : Expression(), var( _var ) {
    7372        assert( var );
    7473        assert( var->get_type() );
     
    9796}
    9897
    99 SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) :
    100                 Expression( _aname ), expr(expr_), type(0), isType(false) {
     98SizeofExpr::SizeofExpr( Expression *expr_ ) :
     99                Expression(), expr(expr_), type(0), isType(false) {
    101100        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    102101}
    103102
    104 SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) :
    105                 Expression( _aname ), expr(0), type(type_), isType(true) {
     103SizeofExpr::SizeofExpr( Type *type_ ) :
     104                Expression(), expr(0), type(type_), isType(true) {
    106105        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    107106}
     
    123122}
    124123
    125 AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) :
    126                 Expression( _aname ), expr(expr_), type(0), isType(false) {
     124AlignofExpr::AlignofExpr( Expression *expr_ ) :
     125                Expression(), expr(expr_), type(0), isType(false) {
    127126        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    128127}
    129128
    130 AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) :
    131                 Expression( _aname ), expr(0), type(type_), isType(true) {
     129AlignofExpr::AlignofExpr( Type *type_ ) :
     130                Expression(), expr(0), type(type_), isType(true) {
    132131        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    133132}
     
    149148}
    150149
    151 UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type, const std::string &member, Expression *_aname ) :
    152                 Expression( _aname ), type(type), member(member) {
     150UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type, const std::string &member ) :
     151                Expression(), type(type), member(member) {
    153152        assert( type );
    154153        set_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     
    168167}
    169168
    170 OffsetofExpr::OffsetofExpr( Type *type, DeclarationWithType *member, Expression *_aname ) :
    171                 Expression( _aname ), type(type), member(member) {
     169OffsetofExpr::OffsetofExpr( Type *type, DeclarationWithType *member ) :
     170                Expression(), type(type), member(member) {
    172171        assert( member );
    173172        assert( type );
     
    188187}
    189188
    190 OffsetPackExpr::OffsetPackExpr( StructInstType *type, Expression *aname_ ) : Expression( aname_ ), type( type ) {
     189OffsetPackExpr::OffsetPackExpr( StructInstType *type ) : Expression(), type( type ) {
    191190        assert( type );
    192191        set_result( new ArrayType( Type::Qualifiers(), new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ), 0, false, false ) );
     
    203202}
    204203
    205 AttrExpr::AttrExpr( Expression *attr, Expression *expr_, Expression *_aname ) :
    206                 Expression( _aname ), attr( attr ), expr(expr_), type(0), isType(false) {
    207 }
    208 
    209 AttrExpr::AttrExpr( Expression *attr, Type *type_, Expression *_aname ) :
    210                 Expression( _aname ), attr( attr ), expr(0), type(type_), isType(true) {
     204AttrExpr::AttrExpr( Expression *attr, Expression *expr_ ) :
     205                Expression(), attr( attr ), expr(expr_), type(0), isType(false) {
     206}
     207
     208AttrExpr::AttrExpr( Expression *attr, Type *type_ ) :
     209                Expression(), attr( attr ), expr(0), type(type_), isType(true) {
    211210}
    212211
     
    232231}
    233232
    234 CastExpr::CastExpr( Expression *arg_, Type *toType, Expression *_aname ) : Expression( _aname ), arg(arg_) {
     233CastExpr::CastExpr( Expression *arg_, Type *toType ) : Expression(), arg(arg_) {
    235234        set_result(toType);
    236235}
    237236
    238 CastExpr::CastExpr( Expression *arg_, Expression *_aname ) : Expression( _aname ), arg(arg_) {
     237CastExpr::CastExpr( Expression *arg_ ) : Expression(), arg(arg_) {
    239238        set_result( new VoidType( Type::Qualifiers() ) );
    240239}
     
    284283}
    285284
    286 UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression *aggregate, Expression *_aname ) :
    287                 Expression( _aname ), member(member), aggregate(aggregate) {
     285UntypedMemberExpr::UntypedMemberExpr( Expression * member, Expression *aggregate ) :
     286                Expression(), member(member), aggregate(aggregate) {
    288287        assert( aggregate );
    289288}
     
    321320
    322321
    323 MemberExpr::MemberExpr( DeclarationWithType *member, Expression *aggregate, Expression *_aname ) :
    324                 Expression( _aname ), member(member), aggregate(aggregate) {
     322MemberExpr::MemberExpr( DeclarationWithType *member, Expression *aggregate ) :
     323                Expression(), member(member), aggregate(aggregate) {
    325324        assert( member );
    326325        assert( aggregate );
     
    351350}
    352351
    353 UntypedExpr::UntypedExpr( Expression *_function, const std::list<Expression *> &_args, Expression *_aname ) :
    354                 Expression( _aname ), function(_function), args(_args) {}
     352UntypedExpr::UntypedExpr( Expression *function, const std::list<Expression *> &args ) :
     353                Expression(), function(function), args(args) {}
    355354
    356355UntypedExpr::UntypedExpr( const UntypedExpr &other ) :
     
    402401}
    403402
    404 NameExpr::NameExpr( std::string name, Expression *_aname ) : Expression( _aname ), name(name) {
     403NameExpr::NameExpr( std::string name ) : Expression(), name(name) {
    405404        assertf(name != "0", "Zero is not a valid name");
    406405        assertf(name != "1", "One is not a valid name");
     
    417416}
    418417
    419 LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp, Expression *_aname ) :
    420                 Expression( _aname ), arg1(arg1_), arg2(arg2_), isAnd(andp) {
     418LogicalExpr::LogicalExpr( Expression *arg1_, Expression *arg2_, bool andp ) :
     419                Expression(), arg1(arg1_), arg2(arg2_), isAnd(andp) {
    421420        set_result( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) );
    422421}
     
    439438}
    440439
    441 ConditionalExpr::ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3, Expression *_aname ) :
    442                 Expression( _aname ), arg1(arg1), arg2(arg2), arg3(arg3) {}
     440ConditionalExpr::ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 ) :
     441                Expression(), arg1(arg1), arg2(arg2), arg3(arg3) {}
    443442
    444443ConditionalExpr::ConditionalExpr( const ConditionalExpr &other ) :
  • src/SynTree/Expression.h

    r50377a4 rbf4b4cf  
    3636        Type * result;
    3737        TypeSubstitution * env;
    38         Expression * argName; // if expression is used as an argument, it can be "designated" by this name
    3938        bool extension = false;
    4039
    41         Expression( Expression * _aname = nullptr );
     40        Expression();
    4241        Expression( const Expression & other );
    4342        virtual ~Expression();
     
    5049        TypeSubstitution * get_env() const { return env; }
    5150        void set_env( TypeSubstitution * newValue ) { env = newValue; }
    52         Expression * get_argName() const { return argName; }
    53         void set_argName( Expression * name ) { argName = name; }
    5451        bool get_extension() const { return extension; }
    5552        Expression * set_extension( bool exten ) { extension = exten; return this; }
     
    112109        std::list<Expression*> args;
    113110
    114         UntypedExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >(), Expression *_aname = nullptr );
     111        UntypedExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() );
    115112        UntypedExpr( const UntypedExpr & other );
    116113        virtual ~UntypedExpr();
     
    137134        std::string name;
    138135
    139         NameExpr( std::string name, Expression *_aname = nullptr );
     136        NameExpr( std::string name );
    140137        NameExpr( const NameExpr & other );
    141138        virtual ~NameExpr();
     
    158155        Expression * arg;
    159156
    160         AddressExpr( Expression * arg, Expression *_aname = nullptr );
     157        AddressExpr( Expression * arg );
    161158        AddressExpr( const AddressExpr & other );
    162159        virtual ~AddressExpr();
     
    192189        Expression * arg;
    193190
    194         CastExpr( Expression * arg, Expression *_aname = nullptr );
    195         CastExpr( Expression * arg, Type * toType, Expression *_aname = nullptr );
     191        CastExpr( Expression * arg );
     192        CastExpr( Expression * arg, Type * toType );
    196193        CastExpr( const CastExpr & other );
    197194        virtual ~CastExpr();
     
    230227        Expression * aggregate;
    231228
    232         UntypedMemberExpr( Expression * member, Expression * aggregate, Expression *_aname = nullptr );
     229        UntypedMemberExpr( Expression * member, Expression * aggregate );
    233230        UntypedMemberExpr( const UntypedMemberExpr & other );
    234231        virtual ~UntypedMemberExpr();
     
    252249        Expression * aggregate;
    253250
    254         MemberExpr( DeclarationWithType * member, Expression * aggregate, Expression *_aname = nullptr );
     251        MemberExpr( DeclarationWithType * member, Expression * aggregate );
    255252        MemberExpr( const MemberExpr & other );
    256253        virtual ~MemberExpr();
     
    273270        DeclarationWithType * var;
    274271
    275         VariableExpr( DeclarationWithType * var, Expression *_aname = nullptr );
     272        VariableExpr( DeclarationWithType * var );
    276273        VariableExpr( const VariableExpr & other );
    277274        virtual ~VariableExpr();
     
    293290        Constant constant;
    294291
    295         ConstantExpr( Constant constant, Expression *_aname = nullptr );
     292        ConstantExpr( Constant constant );
    296293        ConstantExpr( const ConstantExpr & other );
    297294        virtual ~ConstantExpr();
     
    313310        bool isType;
    314311
    315         SizeofExpr( Expression * expr, Expression *_aname = nullptr );
     312        SizeofExpr( Expression * expr );
    316313        SizeofExpr( const SizeofExpr & other );
    317         SizeofExpr( Type * type, Expression *_aname = nullptr );
     314        SizeofExpr( Type * type );
    318315        virtual ~SizeofExpr();
    319316
     
    338335        bool isType;
    339336
    340         AlignofExpr( Expression * expr, Expression *_aname = nullptr );
     337        AlignofExpr( Expression * expr );
    341338        AlignofExpr( const AlignofExpr & other );
    342         AlignofExpr( Type * type, Expression *_aname = nullptr );
     339        AlignofExpr( Type * type );
    343340        virtual ~AlignofExpr();
    344341
     
    362359        std::string member;
    363360
    364         UntypedOffsetofExpr( Type * type, const std::string & member, Expression *_aname = nullptr );
     361        UntypedOffsetofExpr( Type * type, const std::string & member );
    365362        UntypedOffsetofExpr( const UntypedOffsetofExpr & other );
    366363        virtual ~UntypedOffsetofExpr();
     
    383380        DeclarationWithType * member;
    384381
    385         OffsetofExpr( Type * type, DeclarationWithType * member, Expression *_aname = nullptr );
     382        OffsetofExpr( Type * type, DeclarationWithType * member );
    386383        OffsetofExpr( const OffsetofExpr & other );
    387384        virtual ~OffsetofExpr();
     
    403400        StructInstType * type;
    404401
    405         OffsetPackExpr( StructInstType * type_, Expression * aname_ = 0 );
     402        OffsetPackExpr( StructInstType * type );
    406403        OffsetPackExpr( const OffsetPackExpr & other );
    407404        virtual ~OffsetPackExpr();
     
    424421        bool isType;
    425422
    426         AttrExpr(Expression * attr, Expression * expr, Expression *_aname = nullptr );
     423        AttrExpr(Expression * attr, Expression * expr );
    427424        AttrExpr( const AttrExpr & other );
    428         AttrExpr( Expression * attr, Type * type, Expression *_aname = nullptr );
     425        AttrExpr( Expression * attr, Type * type );
    429426        virtual ~AttrExpr();
    430427
     
    450447        Expression * arg2;
    451448
    452         LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true, Expression *_aname = nullptr );
     449        LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true );
    453450        LogicalExpr( const LogicalExpr & other );
    454451        virtual ~LogicalExpr();
     
    476473        Expression * arg3;
    477474
    478         ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3, Expression *_aname = nullptr );
     475        ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 );
    479476        ConditionalExpr( const ConditionalExpr & other );
    480477        virtual ~ConditionalExpr();
     
    499496        Expression * arg2;
    500497
    501         CommaExpr( Expression * arg1, Expression * arg2, Expression *_aname = nullptr );
     498        CommaExpr( Expression * arg1, Expression * arg2 );
    502499        CommaExpr( const CommaExpr & other );
    503500        virtual ~CommaExpr();
     
    646643        std::list<Expression*> exprs;
    647644
    648         UntypedTupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr );
     645        UntypedTupleExpr( const std::list< Expression * > & exprs );
    649646        UntypedTupleExpr( const UntypedTupleExpr & other );
    650647        virtual ~UntypedTupleExpr();
     
    663660        std::list<Expression*> exprs;
    664661
    665         TupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr );
     662        TupleExpr( const std::list< Expression * > & exprs );
    666663        TupleExpr( const TupleExpr & other );
    667664        virtual ~TupleExpr();
     
    701698        StmtExpr * stmtExpr = nullptr;
    702699
    703         TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname = nullptr );
     700        TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls );
    704701        TupleAssignExpr( const TupleAssignExpr & other );
    705702        virtual ~TupleAssignExpr();
  • src/SynTree/TupleExpr.cc

    r50377a4 rbf4b4cf  
    2828#include "Type.h"               // for TupleType, Type
    2929
    30 UntypedTupleExpr::UntypedTupleExpr( const std::list< Expression * > & exprs, Expression *_aname ) : Expression( _aname ), exprs( exprs ) {
     30UntypedTupleExpr::UntypedTupleExpr( const std::list< Expression * > & exprs ) : Expression(), exprs( exprs ) {
    3131}
    3232
     
    4545}
    4646
    47 TupleExpr::TupleExpr( const std::list< Expression * > & exprs, Expression *_aname ) : Expression( _aname ), exprs( exprs ) {
     47TupleExpr::TupleExpr( const std::list< Expression * > & exprs ) : Expression(), exprs( exprs ) {
    4848        set_result( Tuples::makeTupleType( exprs ) );
    4949}
     
    8686}
    8787
    88 TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ) {
     88TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls ) : Expression() {
    8989        // convert internally into a StmtExpr which contains the declarations and produces the tuple of the assignments
    9090        set_result( Tuples::makeTupleType( assigns ) );
Note: See TracChangeset for help on using the changeset viewer.