Changeset 28f3a19 for src/SynTree


Ignore:
Timestamp:
Jun 27, 2018, 3:28:41 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
new-env, with_gc
Children:
b21c77a
Parents:
0182bfa (diff), 63238a4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into with_gc

Location:
src/SynTree
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/BasicType.cc

    r0182bfa r28f3a19  
    5555          case DoubleImaginary:
    5656          case LongDoubleImaginary:
     57          case Float80:
     58          case Float128:
    5759                return false;
    5860          case NUMBER_OF_BASIC_TYPES:
  • src/SynTree/Declaration.cc

    r0182bfa r28f3a19  
    9292}
    9393
     94
    9495// Local Variables: //
    9596// tab-width: 4 //
  • src/SynTree/Declaration.h

    r0182bfa r28f3a19  
    8383        Expression *asmName;
    8484        std::list< Attribute * > attributes;
     85        bool isDeleted = false;
    8586
    8687        DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
  • src/SynTree/Expression.cc

    r0182bfa r28f3a19  
    640640
    641641
     642DefaultArgExpr::DefaultArgExpr( Expression * expr ) : expr( expr ) {
     643        assert( expr->result );
     644        result = expr->result->clone();
     645}
     646DefaultArgExpr::DefaultArgExpr( const DefaultArgExpr & other ) : Expression( other ), expr( maybeClone( other.expr ) ) {}
     647
     648void DefaultArgExpr::print( std::ostream & os, Indenter indent ) const {
     649        os << "Default Argument Expression" << std::endl << indent+1;
     650        expr->print( os, indent+1 );
     651}
     652
     653GenericExpr::Association::Association( Type * type, Expression * expr ) : type( type ), expr( expr ), isDefault( false ) {}
     654GenericExpr::Association::Association( Expression * expr ) : type( nullptr ), expr( expr ), isDefault( true ) {}
     655GenericExpr::Association::Association( const Association & other ) : type( maybeClone( other.type ) ), expr( maybeClone( other.expr ) ), isDefault( other.isDefault ) {}
     656
     657GenericExpr::GenericExpr( Expression * control, const std::list<Association> & assoc ) : Expression(), control( control ), associations( assoc ) {}
     658GenericExpr::GenericExpr( const GenericExpr & other ) : Expression(other), control( maybeClone( other.control ) ), associations( other.associations ) {}
     659GenericExpr::~GenericExpr() {}
     660
     661void GenericExpr::print( std::ostream & os, Indenter indent ) const {
     662        os << "C11 _Generic Expression" << std::endl << indent+1;
     663        control->print( os, indent+1 );
     664        os << std::endl << indent+1 << "... with associations: " << std::endl;
     665        for ( const Association & assoc : associations ) {
     666                os << indent+1;
     667                if (assoc.isDefault) {
     668                        os << "... default: ";
     669                        assoc.expr->print( os, indent+1 );
     670                } else {
     671                        os << "... type: ";
     672                        assoc.type->print( os, indent+1 );
     673                        os << std::endl << indent+1 << "... expression: ";
     674                        assoc.expr->print( os, indent+1 );
     675                        os << std::endl;
     676                }
     677                os << std::endl;
     678        }
     679}
     680
    642681// Local Variables: //
    643682// tab-width: 4 //
  • src/SynTree/Expression.h

    r0182bfa r28f3a19  
    833833};
    834834
     835/// expression wrapping the use of a default argument - should never make it past the resolver.
     836class DefaultArgExpr : public Expression {
     837public:
     838        Expression * expr;
     839
     840        DefaultArgExpr( Expression * expr );
     841        DefaultArgExpr( const DefaultArgExpr & other );
     842
     843        virtual DefaultArgExpr * clone() const { return new DefaultArgExpr( * this ); }
     844        virtual void accept( Visitor & v ) { v.visit( this ); }
     845        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     846        virtual void print( std::ostream & os, Indenter indent = {} ) const;
     847};
     848
     849/// C11 _Generic expression
     850class GenericExpr : public Expression {
     851public:
     852        struct Association {
     853                Type * type = nullptr;
     854                Expression * expr = nullptr;
     855                bool isDefault = false;
     856
     857                Association( Type * type, Expression * expr );
     858                Association( Expression * expr );
     859                Association( const Association & other );
     860                Association & operator=( const Association & other ) = delete; // at the moment this isn't used, and I don't want to implement it
     861        };
     862
     863        Expression * control;
     864        std::list<Association> associations;
     865
     866        GenericExpr( Expression * control, const std::list<Association> & assoc );
     867        GenericExpr( const GenericExpr & other );
     868        ~GenericExpr();
     869
     870        virtual GenericExpr * clone() const { return new GenericExpr( * this ); }
     871        virtual void accept( Visitor & v ) { v.visit( this ); }
     872        virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }
     873        virtual void print( std::ostream & os, Indenter indent = {} ) const;
     874};
     875
    835876// Local Variables: //
    836877// tab-width: 4 //
  • src/SynTree/Mutator.h

    r0182bfa r28f3a19  
    9393        virtual Expression * mutate( InitExpr  * initExpr ) = 0;
    9494        virtual Expression * mutate( DeletedExpr * delExpr ) = 0;
     95        virtual Expression * mutate( DefaultArgExpr * argExpr ) = 0;
     96        virtual Expression * mutate( GenericExpr * genExpr ) = 0;
    9597
    9698        virtual Type * mutate( VoidType * basicType ) = 0;
  • src/SynTree/ReferenceToType.cc

    r0182bfa r28f3a19  
    4646
    4747namespace {
    48         void doLookup( const std::list< Declaration* > &members, const std::string &name, std::list< Declaration* > &foundDecls ) {
    49                 for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i ) {
    50                         if ( (*i)->get_name() == name ) {
    51                                 foundDecls.push_back( *i );
     48        void doLookup( const std::list< Declaration * > & members, const std::string & name, std::list< Declaration* > & foundDecls ) {
     49                for ( Declaration * decl : members ) {
     50                        if ( decl->name == name ) {
     51                                foundDecls.push_back( decl );
    5252                        } // if
    5353                } // for
     
    5656
    5757StructInstType::StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes ) :
    58                 Parent( tq, baseStruct->get_name(), attributes ), baseStruct( baseStruct ) {}
     58                Parent( tq, baseStruct->name, attributes ), baseStruct( baseStruct ) {}
    5959
    6060std::string StructInstType::typeString() const { return "struct"; }
     
    8080void StructInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const {
    8181        assert( baseStruct );
    82         doLookup( baseStruct->get_members(), name, foundDecls );
     82        doLookup( baseStruct->members, name, foundDecls );
    8383}
    8484
     
    9999
    100100UnionInstType::UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes ) :
    101                 Parent( tq, baseUnion->get_name(), attributes ), baseUnion( baseUnion ) {}
     101                Parent( tq, baseUnion->name, attributes ), baseUnion( baseUnion ) {}
    102102
    103103std::string UnionInstType::typeString() const { return "union"; }
     
    123123void UnionInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const {
    124124        assert( baseUnion );
    125         doLookup( baseUnion->get_members(), name, foundDecls );
     125        doLookup( baseUnion->members, name, foundDecls );
    126126}
    127127
  • src/SynTree/Statement.cc

    r0182bfa r28f3a19  
    208208}
    209209
    210 WhileStmt::WhileStmt( Expression *condition, Statement *body, bool isDoWhile ):
    211         Statement(), condition( condition), body( body), isDoWhile( isDoWhile) {
     210WhileStmt::WhileStmt( Expression *condition, Statement *body, std::list< Statement * > & initialization, bool isDoWhile ):
     211        Statement(), condition( condition), body( body), initialization( initialization ), isDoWhile( isDoWhile) {
    212212}
    213213
  • src/SynTree/Statement.h

    r0182bfa r28f3a19  
    213213        Expression *condition;
    214214        Statement *body;
     215        std::list<Statement *> initialization;
    215216        bool isDoWhile;
    216217
    217218        WhileStmt( Expression *condition,
    218                Statement *body, bool isDoWhile = false );
     219               Statement *body, std::list<Statement *> & initialization, bool isDoWhile = false );
    219220        WhileStmt( const WhileStmt &other );
    220221
  • src/SynTree/SynTree.h

    r0182bfa r28f3a19  
    101101class InitExpr;
    102102class DeletedExpr;
     103class DefaultArgExpr;
     104class GenericExpr;
    103105
    104106class Type;
  • src/SynTree/Type.cc

    r0182bfa r28f3a19  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep 25 15:16:32 2017
    13 // Update Count     : 38
     12// Last Modified On : Fri Jun 22 10:17:19 2018
     13// Update Count     : 39
    1414//
    1515#include "Type.h"
     
    2424using namespace std;
    2525
    26 const char *BasicType::typeNames[BasicType::NUMBER_OF_BASIC_TYPES] = {
     26const char *BasicType::typeNames[] = {
    2727        "_Bool",
    2828        "char",
     
    4848        "__int128",
    4949        "unsigned __int128",
     50        "__float80",
     51        "__float128"
    5052};
     53static_assert(
     54        sizeof(BasicType::typeNames)/sizeof(BasicType::typeNames[0]) == BasicType::NUMBER_OF_BASIC_TYPES,
     55        "Each basic type name should have a corresponding kind enum value"
     56);
    5157
    5258Type::Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ) : tq( tq ), attributes( attributes ) {}
     
    5864
    5965// These must remain in the same order as the corresponding bit fields.
    60 const char * Type::FuncSpecifiersNames[] = { "inline", "fortran", "_Noreturn" };
     66const char * Type::FuncSpecifiersNames[] = { "inline", "_Noreturn", "fortran" };
    6167const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" };
    6268const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" };
  • src/SynTree/Type.h

    r0182bfa r28f3a19  
    230230                SignedInt128,
    231231                UnsignedInt128,
     232                Float80,
     233                Float128,
    232234                NUMBER_OF_BASIC_TYPES
    233235        } kind;
  • src/SynTree/Visitor.h

    r0182bfa r28f3a19  
    9595        virtual void visit( InitExpr *  initExpr ) = 0;
    9696        virtual void visit( DeletedExpr * delExpr ) = 0;
     97        virtual void visit( DefaultArgExpr * argExpr ) = 0;
     98        virtual void visit( GenericExpr * genExpr ) = 0;
    9799
    98100        virtual void visit( VoidType * basicType ) = 0;
Note: See TracChangeset for help on using the changeset viewer.