Changeset b4f8808


Ignore:
Timestamp:
Sep 26, 2019, 1:25:49 PM (5 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
70b4ea20, ea2074e
Parents:
849720f
Message:

Removed lvalue from types in the old ast.

Location:
src
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/GenType.cc

    r849720f rb4f8808  
    335335                        typeString = "_Atomic " + typeString;
    336336                } // if
    337                 if ( type->get_lvalue() && ! options.genC ) {
    338                         // when not generating C code, print lvalue for debugging.
    339                         typeString = "lvalue " + typeString;
    340                 }
    341337        }
    342338} // namespace CodeGen
  • src/GenPoly/Box.cc

    r849720f rb4f8808  
    837837                                        deref->args.push_back( new CastExpr( new VariableExpr( param ), new PointerType( Type::Qualifiers(), arg->get_type()->clone() ) ) );
    838838                                        deref->result = arg->get_type()->clone();
    839                                         deref->result->set_lvalue( true );
    840839                                        return deref;
    841840                                } // if
  • src/GenPoly/Lvalue.cc

    r849720f rb4f8808  
    5454                                delete ret->result;
    5555                                ret->result = base->clone();
    56                                 ret->result->set_lvalue( true );
    5756                                return ret;
    5857                        } else {
     
    167166                                ReferenceType * result = strict_dynamic_cast< ReferenceType * >( appExpr->result );
    168167                                appExpr->result = result->base->clone();
    169                                 appExpr->result->set_lvalue( true );
    170168                                if ( ! inIntrinsic ) {
    171169                                        // when not in an intrinsic function, add a cast to
     
    436434                                delete ret->result;
    437435                                ret->result = castExpr->result;
    438                                 ret->result->set_lvalue( true ); // ensure result is lvalue
     436                                assert( ret->get_lvalue() ); // ensure result is lvalue
    439437                                castExpr->env = nullptr;
    440438                                castExpr->arg = nullptr;
  • src/Makefile.in

    r849720f rb4f8808  
    231231        SynTree/Initializer.$(OBJEXT) \
    232232        SynTree/TypeSubstitution.$(OBJEXT) SynTree/Attribute.$(OBJEXT) \
    233         SynTree/DeclReplacer.$(OBJEXT) SynTree/TopLvalue.$(OBJEXT)
     233        SynTree/DeclReplacer.$(OBJEXT)
    234234am__objects_8 = CompilationState.$(OBJEXT) $(am__objects_1) \
    235235        $(am__objects_2) Concurrency/Keywords.$(OBJEXT) \
     
    696696      SynTree/TypeSubstitution.cc \
    697697      SynTree/Attribute.cc \
    698       SynTree/DeclReplacer.cc \
    699       SynTree/TopLvalue.cc
     698      SynTree/DeclReplacer.cc
    700699
    701700
     
    10261025SynTree/DeclReplacer.$(OBJEXT): SynTree/$(am__dirstamp) \
    10271026        SynTree/$(DEPDIR)/$(am__dirstamp)
    1028 SynTree/TopLvalue.$(OBJEXT): SynTree/$(am__dirstamp) \
    1029         SynTree/$(DEPDIR)/$(am__dirstamp)
    10301027Tuples/$(am__dirstamp):
    10311028        @$(MKDIR_P) Tuples
     
    13381335@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/ReferenceType.Po@am__quote@
    13391336@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/Statement.Po@am__quote@
    1340 @AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TopLvalue.Po@am__quote@
    13411337@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TupleExpr.Po@am__quote@
    13421338@AMDEP_TRUE@@am__include@ @am__quote@SynTree/$(DEPDIR)/TupleType.Po@am__quote@
  • src/ResolvExpr/ResolveAssertions.cc

    r849720f rb4f8808  
    156156                        for ( const auto& assn : x.assns ) {
    157157                                // compute conversion cost from satisfying decl to assertion
    158                                 assert( !assn.match.adjType->get_lvalue() );
    159158                                k += computeConversionCost(
    160159                                        assn.match.adjType, assn.decl->get_type(), false, indexer, x.env );
  • src/SymTab/Autogen.h

    r849720f rb4f8808  
    9797                        //   type->get_qualifiers() = Type::Qualifiers();
    9898                        Type * castType = addCast->clone();
    99                         castType->get_qualifiers() -= Type::Qualifiers( Type::Lvalue | Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
     99                        castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
    100100                        // castType->set_lvalue( true ); // xxx - might not need this
    101101                        dstParam = new CastExpr( dstParam, new ReferenceType( Type::Qualifiers(), castType ) );
  • src/SymTab/ManglerCommon.cc

    r849720f rb4f8808  
    8888                                { Type::Atomic, "DA" }, // A is array, so need something unique for atmoic. For now, go with multiletter DA
    8989                                { Type::Mutex, "X" },
    90                                 { Type::Lvalue, "L" },
    9190                        };
    9291
  • src/SymTab/Validate.cc

    r849720f rb4f8808  
    8181#include "SynTree/Label.h"             // for operator==, Label
    8282#include "SynTree/Mutator.h"           // for Mutator
    83 #include "SynTree/TopLvalue.h"         // for assertTopLvalue, clearInnerLvalue
    8483#include "SynTree/Type.h"              // for Type, TypeInstType, EnumInstType
    8584#include "SynTree/TypeSubstitution.h"  // for TypeSubstitution
     
    309308                PassVisitor<FixQualifiedTypes> fixQual;
    310309
    311                 assertTopLvalue( translationUnit );
    312310                {
    313311                        Stats::Heap::newPass("validate-A");
     
    318316                        acceptAll( translationUnit, epc ); // must happen before VerifyCtorDtorAssign, because void return objects should not exist; before LinkReferenceToTypes_old because it is an indexer and needs correct types for mangling
    319317                }
    320                 assertTopLvalue( translationUnit );
    321318                {
    322319                        Stats::Heap::newPass("validate-B");
    323320                        Stats::Time::BlockGuard guard("validate-B");
    324                         assertTopLvalue( translationUnit );
    325321                        Stats::Time::TimeBlock("Link Reference To Types", [&]() {
    326322                                acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions
    327323                        });
    328                         clearInnerLvalue( translationUnit );
    329                         assertTopLvalue( translationUnit );
    330324                        Stats::Time::TimeBlock("Fix Qualified Types", [&]() {
    331325                                mutateAll( translationUnit, fixQual ); // must happen after LinkReferenceToTypes_old, because aggregate members are accessed
    332326                        });
    333                         assertTopLvalue( translationUnit );
    334327                        Stats::Time::TimeBlock("Hoist Structs", [&]() {
    335328                                HoistStruct::hoistStruct( translationUnit ); // must happen after EliminateTypedef, so that aggregate typedefs occur in the correct order
    336329                        });
    337                         assertTopLvalue( translationUnit );
    338330                        Stats::Time::TimeBlock("Eliminate Typedefs", [&]() {
    339331                                EliminateTypedef::eliminateTypedef( translationUnit ); //
    340332                        });
    341333                }
    342                 assertTopLvalue( translationUnit );
    343334                {
    344335                        Stats::Heap::newPass("validate-C");
     
    349340                        InitTweak::fixReturnStatements( translationUnit ); // must happen before autogen
    350341                }
    351                 assertTopLvalue( translationUnit );
    352342                {
    353343                        Stats::Heap::newPass("validate-D");
    354344                        Stats::Time::BlockGuard guard("validate-D");
    355                         assertTopLvalue( translationUnit );
    356345                        Stats::Time::TimeBlock("Apply Concurrent Keywords", [&]() {
    357346                                Concurrency::applyKeywords( translationUnit );
    358347                        });
    359                         clearInnerLvalue( translationUnit );
    360                         assertTopLvalue( translationUnit );
    361348                        Stats::Time::TimeBlock("Forall Pointer Decay", [&]() {
    362349                                acceptAll( translationUnit, fpd ); // must happen before autogenerateRoutines, after Concurrency::applyKeywords because uniqueIds must be set on declaration before resolution
    363350                        });
    364                         assertTopLvalue( translationUnit );
    365351                        Stats::Time::TimeBlock("Hoist Control Declarations", [&]() {
    366352                                ControlStruct::hoistControlDecls( translationUnit );  // hoist initialization out of for statements; must happen before autogenerateRoutines
    367353                        });
    368                         assertTopLvalue( translationUnit );
    369354                        Stats::Time::TimeBlock("Generate Autogen routines", [&]() {
    370355                                autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecay_old
    371356                        });
    372                         clearInnerLvalue( translationUnit );
    373                 }
    374                 assertTopLvalue( translationUnit );
     357                }
    375358                {
    376359                        Stats::Heap::newPass("validate-E");
    377360                        Stats::Time::BlockGuard guard("validate-E");
    378                         assertTopLvalue( translationUnit );
    379361                        Stats::Time::TimeBlock("Implement Mutex Func", [&]() {
    380362                                Concurrency::implementMutexFuncs( translationUnit );
    381363                        });
    382                         clearInnerLvalue( translationUnit );
    383                         assertTopLvalue( translationUnit );
    384364                        Stats::Time::TimeBlock("Implement Thread Start", [&]() {
    385365                                Concurrency::implementThreadStarter( translationUnit );
    386366                        });
    387                         assertTopLvalue( translationUnit );
    388367                        Stats::Time::TimeBlock("Compound Literal", [&]() {
    389368                                mutateAll( translationUnit, compoundliteral );
    390369                        });
    391                         assertTopLvalue( translationUnit );
    392370                        Stats::Time::TimeBlock("Resolve With Expressions", [&]() {
    393371                                ResolvExpr::resolveWithExprs( translationUnit ); // must happen before FixObjectType because user-code is resolved and may contain with variables
    394372                        });
    395                         clearInnerLvalue( translationUnit );
    396                 }
    397                 assertTopLvalue( translationUnit );
     373                }
    398374                {
    399375                        Stats::Heap::newPass("validate-F");
    400376                        Stats::Time::BlockGuard guard("validate-F");
    401                         assertTopLvalue( translationUnit );
    402377                        Stats::Time::TimeBlock("Fix Object Type", [&]() {
    403378                                FixObjectType::fix( translationUnit );
    404379                        });
    405                         assertTopLvalue( translationUnit );
    406380                        Stats::Time::TimeBlock("Array Length", [&]() {
    407381                                ArrayLength::computeLength( translationUnit );
    408382                        });
    409                         clearInnerLvalue( translationUnit );
    410                         assertTopLvalue( translationUnit );
    411383                        Stats::Time::TimeBlock("Find Special Declarations", [&]() {
    412384                                Validate::findSpecialDecls( translationUnit );
    413385                        });
    414                         assertTopLvalue( translationUnit );
    415386                        Stats::Time::TimeBlock("Fix Label Address", [&]() {
    416387                                mutateAll( translationUnit, labelAddrFixer );
    417388                        });
    418                         assertTopLvalue( translationUnit );
    419389                        Stats::Time::TimeBlock("Handle Attributes", [&]() {
    420390                                Validate::handleAttributes( translationUnit );
    421391                        });
    422392                }
    423                 assertTopLvalue( translationUnit );
    424393        }
    425394
     
    13341303        void FixObjectType::previsit( ObjectDecl * objDecl ) {
    13351304                Type * new_type = ResolvExpr::resolveTypeof( objDecl->get_type(), indexer );
    1336                 new_type->get_qualifiers() -= Type::Lvalue; // even if typeof is lvalue, variable can never have lvalue-qualified type
    13371305                objDecl->set_type( new_type );
    13381306        }
     
    13401308        void FixObjectType::previsit( FunctionDecl * funcDecl ) {
    13411309                Type * new_type = ResolvExpr::resolveTypeof( funcDecl->type, indexer );
    1342                 new_type->get_qualifiers() -= Type::Lvalue; // even if typeof is lvalue, variable can never have lvalue-qualified type
    13431310                funcDecl->set_type( new_type );
    13441311        }
     
    13471314                if ( typeDecl->get_base() ) {
    13481315                        Type * new_type = ResolvExpr::resolveTypeof( typeDecl->get_base(), indexer );
    1349                         new_type->get_qualifiers() -= Type::Lvalue; // even if typeof is lvalue, variable can never have lvalue-qualified type
    13501316                        typeDecl->set_base( new_type );
    13511317                } // if
  • src/SynTree/AddressExpr.cc

    r849720f rb4f8808  
    5353                        } // if
    5454                }
    55                 // result of & is never an lvalue
    56                 get_result()->set_lvalue( false );
    5755        }
    5856}
  • src/SynTree/ArrayType.cc

    r849720f rb4f8808  
    2626ArrayType::ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes )
    2727        : Type( tq, attributes ), base( base ), dimension( dimension ), isVarLen( isVarLen ), isStatic( isStatic ) {
    28         base->set_lvalue( false );
    2928}
    3029
  • src/SynTree/CommaExpr.cc

    r849720f rb4f8808  
    2323CommaExpr::CommaExpr( Expression *arg1, Expression *arg2 )
    2424                : Expression(), arg1( arg1 ), arg2( arg2 ) {
    25         // xxx - result of a comma expression is never an lvalue, so should set lvalue
    26         // to false on all result types. Actually doing this causes some strange things
    27         // to happen in later passes (particularly, Specialize, Lvalue, and Box). This needs to be looked into.
    2825        set_result( maybeClone( arg2->get_result() ) );
    29         // get_type->set_isLvalue( false );
    3026}
    3127
     
    4137bool CommaExpr::get_lvalue() const {
    4238        // This is wrong by C, but the current implementation uses it.
     39        // (ex: Specialize, Lvalue and Box)
    4340        return arg2->get_lvalue();
    4441}
  • src/SynTree/Expression.cc

    r849720f rb4f8808  
    115115        assert( var->get_type() );
    116116        Type * type = var->get_type()->clone();
    117         type->set_lvalue( true );
    118117
    119118        // xxx - doesn't quite work yet - get different alternatives with the same cost
     
    125124        //      long long int value;
    126125        //      if ( decl->valueOf( var, value ) ) {
    127         //              type->set_lvalue( false );
     126        //              type->set_lvalue( false ); // Would have to move to get_lvalue.
    128127        //      }
    129128        // }
     
    384383        sub.apply( res );
    385384        result = res;
    386         result->set_lvalue( true );
    387385        result->get_qualifiers() |= aggregate->result->get_qualifiers();
    388386}
     
    433431                        // if references are still allowed in the AST, dereference returns a reference
    434432                        ret->set_result( new ReferenceType( Type::Qualifiers(), ret->get_result() ) );
    435                 } else {
    436                         // references have been removed, in which case dereference returns an lvalue of the base type.
    437                         ret->result->set_lvalue( true );
    438433                }
    439434        }
     
    591586CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : initializer( initializer ) {
    592587        assert( type && initializer );
    593         type->set_lvalue( true );
    594588        set_result( type );
    595589}
  • src/SynTree/TupleExpr.cc

    r849720f rb4f8808  
    7171        assertf( type->size() > index, "TupleIndexExpr index out of bounds: tuple size %d, requested index %d in expr %s", type->size(), index, toString( tuple ).c_str() );
    7272        set_result( (*std::next( type->get_types().begin(), index ))->clone() );
    73         // like MemberExpr, TupleIndexExpr is always an lvalue
    74         get_result()->set_lvalue( true );
    7573}
    7674
  • src/SynTree/Type.cc

    r849720f rb4f8808  
    8585const char * Type::FuncSpecifiersNames[] = { "inline", "_Noreturn", "fortran" };
    8686const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" };
    87 const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" };
     87const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "mutex", "_Atomic" };
    8888
    8989Type * Type::stripDeclarator() {
  • src/SynTree/Type.h

    r849720f rb4f8808  
    102102        }; // StorageClasses
    103103
    104         enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 };
     104        enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Mutex = 1 << 3, Atomic = 1 << 4, NumTypeQualifier = 5 };
    105105        static const char * QualifiersNames[];
    106106        union Qualifiers {
    107                 enum { Mask = ~(Restrict | Lvalue) };
     107                enum { Mask = ~Restrict };
    108108                unsigned int val;
    109109                struct {
     
    111111                        bool is_restrict : 1;
    112112                        bool is_volatile : 1;
    113                         bool is_lvalue : 1;
    114113                        bool is_mutex : 1;
    115114                        bool is_atomic : 1;
     
    153152        bool get_volatile() const { return tq.is_volatile; }
    154153        bool get_restrict() const { return tq.is_restrict; }
    155         bool get_lvalue() const { return tq.is_lvalue; }
    156154        bool get_mutex() const { return tq.is_mutex; }
    157155        bool get_atomic() const { return tq.is_atomic; }
     
    159157        void set_volatile( bool newValue ) { tq.is_volatile = newValue; }
    160158        void set_restrict( bool newValue ) { tq.is_restrict = newValue; }
    161         void set_lvalue( bool newValue ) { tq.is_lvalue = newValue; }
    162159        void set_mutex( bool newValue ) { tq.is_mutex = newValue; }
    163160        void set_atomic( bool newValue ) { tq.is_atomic = newValue; }
  • src/SynTree/module.mk

    r849720f rb4f8808  
    4949      SynTree/TypeSubstitution.cc \
    5050      SynTree/Attribute.cc \
    51       SynTree/DeclReplacer.cc \
    52       SynTree/TopLvalue.cc
     51      SynTree/DeclReplacer.cc
    5352
    5453SRC += $(SRC_SYNTREE)
  • src/Tuples/TupleExpansion.cc

    r849720f rb4f8808  
    304304                // produce the TupleType which aggregates the types of the exprs
    305305                std::list< Type * > types;
    306                 Type::Qualifiers qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Lvalue | Type::Atomic | Type::Mutex );
     306                Type::Qualifiers qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic | Type::Mutex );
    307307                for ( Expression * expr : exprs ) {
    308308                        assert( expr->get_result() );
  • src/main.cc

    r849720f rb4f8808  
    5959#include "ResolvExpr/Resolver.h"            // for resolve
    6060#include "SymTab/Validate.h"                // for validate
    61 #include "SynTree/TopLvalue.h"              // for assertTopLvalue, clearInn...
    6261#include "SynTree/Declaration.h"            // for Declaration
    6362#include "SynTree/Visitor.h"                // for acceptAll
     
    259258                Stats::Time::StopBlock();
    260259
    261                 //std::cerr << "Post-Parse Check" << std::endl;
    262                 clearInnerLvalue( translationUnit );
    263                 assertTopLvalue( translationUnit );
    264 
    265260                // add the assignment statement after the initialization of a type parameter
    266261                PASS( "Validate", SymTab::validate( translationUnit, symtabp ) );
     
    281276                } // if
    282277
    283                 assertTopLvalue( translationUnit );
    284278                PASS( "Fix Labels", ControlStruct::fixLabels( translationUnit ) );
    285                 assertTopLvalue( translationUnit );
    286279                PASS( "Fix Names", CodeGen::fixNames( translationUnit ) );
    287                 assertTopLvalue( translationUnit );
    288280                PASS( "Gen Init", InitTweak::genInit( translationUnit ) );
    289                 assertTopLvalue( translationUnit );
    290281                PASS( "Expand Member Tuples" , Tuples::expandMemberTuples( translationUnit ) );
    291                 assertTopLvalue( translationUnit );
    292282                if ( libcfap ) {
    293283                        // generate the bodies of cfa library functions
     
    313303                } // if
    314304
    315                 assertTopLvalue( translationUnit );
    316 
    317305                PASS( "Resolve", ResolvExpr::resolve( translationUnit ) );
    318306                if ( exprp ) {
     
    321309                } // if
    322310
    323                 clearInnerLvalue( translationUnit );
    324                 assertTopLvalue( translationUnit );
    325 
    326311                // fix ObjectDecl - replaces ConstructorInit nodes
    327312                PASS( "Fix Init", InitTweak::fix( translationUnit, buildingLibrary() ) );
    328                 clearInnerLvalue( translationUnit );
    329                 assertTopLvalue( translationUnit );
    330313                if ( ctorinitp ) {
    331314                        dump ( translationUnit );
     
    334317
    335318                PASS( "Expand Unique Expr", Tuples::expandUniqueExpr( translationUnit ) ); // xxx - is this the right place for this? want to expand ASAP so tha, sequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused
    336                 assertTopLvalue( translationUnit );
    337319
    338320                PASS( "Translate EHM" , ControlStruct::translateEHM( translationUnit ) );
    339                 assertTopLvalue( translationUnit );
    340321
    341322                PASS( "Gen Waitfor" , Concurrency::generateWaitFor( translationUnit ) );
    342                 clearInnerLvalue( translationUnit );
    343                 assertTopLvalue( translationUnit );
    344323
    345324                PASS( "Convert Specializations",  GenPoly::convertSpecializations( translationUnit ) ); // needs to happen before tuple types are expanded
    346                 clearInnerLvalue( translationUnit );
    347                 assertTopLvalue( translationUnit );
    348325
    349326                PASS( "Expand Tuples", Tuples::expandTuples( translationUnit ) ); // xxx - is this the right place for this?
    350                 assertTopLvalue( translationUnit );
    351327
    352328                if ( tuplep ) {
     
    356332
    357333                PASS( "Virtual Expand Casts", Virtual::expandCasts( translationUnit ) ); // Must come after translateEHM
    358                 assertTopLvalue( translationUnit );
    359334
    360335                PASS( "Instantiate Generics", GenPoly::instantiateGeneric( translationUnit ) );
     
    363338                        return EXIT_SUCCESS;
    364339                } // if
    365                 clearInnerLvalue( translationUnit );
    366                 assertTopLvalue( translationUnit );
     340
    367341                PASS( "Convert L-Value", GenPoly::convertLvalue( translationUnit ) );
    368                 clearInnerLvalue( translationUnit );
    369                 assertTopLvalue( translationUnit );
    370342
    371343                if ( bboxp ) {
     
    374346                } // if
    375347                PASS( "Box", GenPoly::box( translationUnit ) );
    376                 clearInnerLvalue( translationUnit );
    377                 assertTopLvalue( translationUnit );
    378348
    379349                if ( bcodegenp ) {
     
    387357
    388358                CodeTools::fillLocations( translationUnit );
    389                 assertTopLvalue( translationUnit );
    390359                PASS( "Code Gen", CodeGen::generate( translationUnit, *output, ! genproto, prettycodegenp, true, linemarks ) );
    391360
Note: See TracChangeset for help on using the changeset viewer.