Changeset d83b266 for src


Ignore:
Timestamp:
Jul 26, 2021, 2:42:34 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
0a061c0
Parents:
c86ee4c (diff), 98233b3 (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' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src
Files:
2 added
26 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    rc86ee4c rd83b266  
    99// Author           : Thierry Delisle
    1010// Created On       : Thu May 09 15::37::05 2019
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 12 18:43:51 2021
    13 // Update Count     : 36
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jul 14 16:15:00 2021
     13// Update Count     : 37
    1414//
    1515
     
    13561356        }
    13571357
     1358        const ast::Type * visit( const ast::VTableType * node ) override final {
     1359                return visitType( node, new VTableType{
     1360                        cv( node ),
     1361                        get<Type>().accept1( node->base )
     1362                } );
     1363        }
     1364
    13581365        const ast::Type * visit( const ast::VarArgsType * node ) override final {
    13591366                return visitType( node, new VarArgsType{ cv( node ) } );
     
    27992806        }
    28002807
     2808        virtual void visit( const VTableType * old ) override final {
     2809                visitType( old, new ast::VTableType{
     2810                        GET_ACCEPT_1( base, Type ),
     2811                        cv( old )
     2812                } );
     2813        }
     2814
    28012815        virtual void visit( const AttrType * ) override final {
    28022816                assertf( false, "AttrType deprecated in new AST." );
  • src/AST/Fwd.hpp

    rc86ee4c rd83b266  
    117117class TupleType;
    118118class TypeofType;
     119class VTableType;
    119120class VarArgsType;
    120121class ZeroType;
  • src/AST/Pass.hpp

    rc86ee4c rd83b266  
    213213        const ast::Type *             visit( const ast::TupleType            * ) override final;
    214214        const ast::Type *             visit( const ast::TypeofType           * ) override final;
     215        const ast::Type *             visit( const ast::VTableType           * ) override final;
    215216        const ast::Type *             visit( const ast::VarArgsType          * ) override final;
    216217        const ast::Type *             visit( const ast::ZeroType             * ) override final;
  • src/AST/Pass.impl.hpp

    rc86ee4c rd83b266  
    18731873
    18741874//--------------------------------------------------------------------------
     1875// VTableType
     1876template< typename core_t >
     1877const ast::Type * ast::Pass< core_t >::visit( const ast::VTableType * node ) {
     1878        VISIT_START( node );
     1879
     1880        VISIT(
     1881                maybe_accept( node, &VTableType::base );
     1882        )
     1883
     1884        VISIT_END( Type, node );
     1885}
     1886
     1887//--------------------------------------------------------------------------
    18751888// VarArgsType
    18761889template< typename core_t >
  • src/AST/Print.cpp

    rc86ee4c rd83b266  
    14161416        }
    14171417
     1418        virtual const ast::Type * visit( const ast::VTableType * node ) override final {
     1419                preprint( node );
     1420                os << "vtable for ";
     1421                safe_print( node->base );
     1422
     1423                return node;
     1424        }
     1425
    14181426        virtual const ast::Type * visit( const ast::VarArgsType * node ) override final {
    14191427                preprint( node );
  • src/AST/Type.hpp

    rc86ee4c rd83b266  
    1010// Created On       : Thu May 9 10:00:00 2019
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thu Jul 23 14:15:00 2020
    13 // Update Count     : 6
     12// Last Modified On : Wed Jul 14 15:54:00 2021
     13// Update Count     : 7
    1414//
    1515
     
    491491};
    492492
     493/// Virtual Table Type `vtable(T)`
     494class VTableType final : public Type {
     495public:
     496        ptr<Type> base;
     497
     498        VTableType( const Type * b, CV::Qualifiers q = {} ) : Type(q), base(b) {}
     499
     500        const Type * accept( Visitor & v ) const override { return v.visit( this ); }
     501private:
     502        VTableType * clone() const override { return new VTableType{ *this }; }
     503        MUTATE_FRIEND
     504};
     505
    493506/// GCC built-in varargs type
    494507class VarArgsType final : public Type {
  • src/AST/Visitor.hpp

    rc86ee4c rd83b266  
    105105    virtual const ast::Type *             visit( const ast::TupleType            * ) = 0;
    106106    virtual const ast::Type *             visit( const ast::TypeofType           * ) = 0;
     107    virtual const ast::Type *             visit( const ast::VTableType           * ) = 0;
    107108    virtual const ast::Type *             visit( const ast::VarArgsType          * ) = 0;
    108109    virtual const ast::Type *             visit( const ast::ZeroType             * ) = 0;
  • src/Common/CodeLocationTools.cpp

    rc86ee4c rd83b266  
    176176    macro(TupleType, Type) \
    177177    macro(TypeofType, Type) \
     178    macro(VTableType, Type) \
    178179    macro(VarArgsType, Type) \
    179180    macro(ZeroType, Type) \
  • src/Common/PassVisitor.h

    rc86ee4c rd83b266  
    230230        virtual void visit( TypeofType * typeofType ) override final;
    231231        virtual void visit( const TypeofType * typeofType ) override final;
     232        virtual void visit( VTableType * vtableType ) override final;
     233        virtual void visit( const VTableType * vtableType ) override final;
    232234        virtual void visit( AttrType * attrType ) override final;
    233235        virtual void visit( const AttrType * attrType ) override final;
     
    343345        virtual Type * mutate( TupleType * tupleType ) override final;
    344346        virtual Type * mutate( TypeofType * typeofType ) override final;
     347        virtual Type * mutate( VTableType * vtableType ) override final;
    345348        virtual Type * mutate( AttrType * attrType ) override final;
    346349        virtual Type * mutate( VarArgsType * varArgsType ) override final;
  • src/Common/PassVisitor.impl.h

    rc86ee4c rd83b266  
    36103610
    36113611//--------------------------------------------------------------------------
     3612// VTableType
     3613template< typename pass_type >
     3614void PassVisitor< pass_type >::visit( VTableType * node ) {
     3615        VISIT_START( node );
     3616
     3617        // Forall qualifiers should be on base type, not here
     3618        // maybeAccept_impl( node->forall, *this );
     3619        maybeAccept_impl( node->base, *this );
     3620
     3621        VISIT_END( node );
     3622}
     3623
     3624template< typename pass_type >
     3625void PassVisitor< pass_type >::visit( const VTableType * node ) {
     3626        VISIT_START( node );
     3627
     3628        // Forall qualifiers should be on base type, not here
     3629        // maybeAccept_impl( node->forall, *this );
     3630        maybeAccept_impl( node->base, *this );
     3631
     3632        VISIT_END( node );
     3633}
     3634
     3635template< typename pass_type >
     3636Type * PassVisitor< pass_type >::mutate( VTableType * node ) {
     3637        MUTATE_START( node );
     3638
     3639        // Forall qualifiers should be on base type, not here
     3640        // maybeMutate_impl( node->forall, *this );
     3641        maybeMutate_impl( node->base, *this );
     3642
     3643        MUTATE_END( Type, node );
     3644}
     3645
     3646//--------------------------------------------------------------------------
    36123647// AttrType
    36133648template< typename pass_type >
  • src/CompilationState.cc

    rc86ee4c rd83b266  
    99// Author           : Rob Schluntz
    1010// Created On       : Mon Ju1 30 10:47:01 2018
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri May  3 13:45:23 2019
    13 // Update Count     : 4
     11// Last Modified By : Henry Xue
     12// Last Modified On : Tue Jul 20 04:27:35 2021
     13// Update Count     : 5
    1414//
    1515
     
    2323        ctorinitp = false,
    2424        declstatsp = false,
     25        exdeclp = false,
    2526        exprp = false,
    2627        expraltp = false,
  • src/CompilationState.h

    rc86ee4c rd83b266  
    99// Author           : Rob Schluntz
    1010// Created On       : Mon Ju1 30 10:47:01 2018
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri May  3 13:43:21 2019
    13 // Update Count     : 4
     11// Last Modified By : Henry Xue
     12// Last Modified On : Tue Jul 20 04:27:35 2021
     13// Update Count     : 5
    1414//
    1515
     
    2222        ctorinitp,
    2323        declstatsp,
     24        exdeclp,
    2425        exprp,
    2526        expraltp,
  • src/ControlStruct/module.mk

    rc86ee4c rd83b266  
    1010## Author           : Richard C. Bilson
    1111## Created On       : Mon Jun  1 17:49:17 2015
    12 ## Last Modified By : Andrew Beach
    13 ## Last Modified On : Wed Jun 28 16:15:00 2017
    14 ## Update Count     : 4
     12## Last Modified By : Henry Xue
     13## Last Modified On : Tue Jul 20 04:10:50 2021
     14## Update Count     : 5
    1515###############################################################################
    1616
    1717SRC_CONTROLSTRUCT = \
     18        ControlStruct/ExceptDecl.cc \
     19        ControlStruct/ExceptDecl.h \
    1820        ControlStruct/ForExprMutator.cc \
    1921        ControlStruct/ForExprMutator.h \
  • src/GenPoly/Box.cc

    rc86ee4c rd83b266  
    15461546                        long i = 0;
    15471547                        for(std::list< Declaration* >::const_iterator decl = baseDecls.begin(); decl != baseDecls.end(); ++decl, ++i ) {
    1548                                 if ( memberDecl->get_name() != (*decl)->get_name() ) continue;
    1549 
    1550                                 if ( DeclarationWithType *declWithType = dynamic_cast< DeclarationWithType* >( *decl ) ) {
    1551                                         if ( memberDecl->get_mangleName().empty() || declWithType->get_mangleName().empty()
    1552                                              || memberDecl->get_mangleName() == declWithType->get_mangleName() ) return i;
    1553                                         else continue;
    1554                                 } else return i;
     1548                                if ( memberDecl->get_name() != (*decl)->get_name() )
     1549                                        continue;
     1550
     1551                                if ( memberDecl->get_name().empty() ) {
     1552                                        // plan-9 field: match on unique_id
     1553                                        if ( memberDecl->get_uniqueId() == (*decl)->get_uniqueId() )
     1554                                                return i;
     1555                                        else
     1556                                                continue;
     1557                                }
     1558
     1559                                DeclarationWithType *declWithType = strict_dynamic_cast< DeclarationWithType* >( *decl );
     1560
     1561                                if ( memberDecl->get_mangleName().empty() || declWithType->get_mangleName().empty() ) {
     1562                                        // tuple-element field: expect neither had mangled name; accept match on simple name (like field_2) only
     1563                                        assert( memberDecl->get_mangleName().empty() && declWithType->get_mangleName().empty() );
     1564                                        return i;
     1565                                }
     1566
     1567                                // ordinary field: use full name to accommodate overloading
     1568                                if ( memberDecl->get_mangleName() == declWithType->get_mangleName() )
     1569                                        return i;
     1570                                else
     1571                                        continue;
    15551572                        }
    15561573                        return -1;
  • src/Parser/DeclarationNode.cc

    rc86ee4c rd83b266  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 23 08:44:08 2021
    13 // Update Count     : 1149
     12// Last Modified On : Wed Jul 14 17:36:57 2021
     13// Update Count     : 1154
    1414//
    1515
     
    385385        newnode->type = new TypeData( basetypeof ? TypeData::Basetypeof : TypeData::Typeof );
    386386        newnode->type->typeexpr = expr;
     387        return newnode;
     388}
     389
     390DeclarationNode * DeclarationNode::newVtableType( DeclarationNode * decl ) {
     391        DeclarationNode * newnode = new DeclarationNode;
     392        newnode->type = new TypeData( TypeData::Vtable );
     393        newnode->setBase( decl->type );
    387394        return newnode;
    388395}
  • src/Parser/ParseNode.h

    rc86ee4c rd83b266  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 12 15:19:04 2021
    13 // Update Count     : 897
     12// Last Modified On : Wed Jul 14 17:28:53 2021
     13// Update Count     : 900
    1414//
    1515
     
    249249        static DeclarationNode * newTuple( DeclarationNode * members );
    250250        static DeclarationNode * newTypeof( ExpressionNode * expr, bool basetypeof = false );
     251        static DeclarationNode * newVtableType( DeclarationNode * expr );
    251252        static DeclarationNode * newAttribute( const std::string *, ExpressionNode * expr = nullptr ); // gcc attributes
    252253        static DeclarationNode * newDirectiveStmt( StatementNode * stmt ); // gcc external directive statement
  • src/Parser/TypeData.cc

    rc86ee4c rd83b266  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 15:12:51 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Dec 16 07:56:46 2019
    13 // Update Count     : 662
     11// Last Modified By : Henry Xue
     12// Last Modified On : Tue Jul 20 04:10:50 2021
     13// Update Count     : 673
    1414//
    1515
     
    100100                typeexpr = nullptr;
    101101                break;
     102          case Vtable:
     103                break;
    102104          case Builtin:
    103105                // builtin = new Builtin_t;
     
    170172                // delete typeexpr->expr;
    171173                delete typeexpr;
     174                break;
     175          case Vtable:
    172176                break;
    173177          case Builtin:
     
    249253          case Basetypeof:
    250254                newtype->typeexpr = maybeClone( typeexpr );
     255                break;
     256          case Vtable:
    251257                break;
    252258          case Builtin:
     
    467473          case Basetypeof:
    468474          case Builtin:
     475          case Vtable:
    469476                assertf(false, "Tried to get leaf name from kind without a name: %d", kind);
    470477                break;
     
    546553          case TypeData::Basetypeof:
    547554                return buildTypeof( td );
     555          case TypeData::Vtable:
     556                return buildVtable( td );
    548557          case TypeData::Builtin:
    549558                switch ( td->builtintype ) {
     
    769778          case AggregateDecl::Struct:
    770779          case AggregateDecl::Coroutine:
     780          case AggregateDecl::Exception:
    771781          case AggregateDecl::Generator:
    772782          case AggregateDecl::Monitor:
     
    945955        assert( td->typeexpr );
    946956        // assert( td->typeexpr->expr );
    947         return new TypeofType{
    948                 buildQualifiers( td ), td->typeexpr->build(), td->kind == TypeData::Basetypeof };
     957        return new TypeofType{ buildQualifiers( td ), td->typeexpr->build(), td->kind == TypeData::Basetypeof };
    949958} // buildTypeof
     959
     960
     961VTableType * buildVtable( const TypeData * td ) {
     962        assert( td->base );
     963        return new VTableType{ buildQualifiers( td ), typebuild( td->base ) };
     964} // buildVtable
    950965
    951966
  • src/Parser/TypeData.h

    rc86ee4c rd83b266  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Mar 27 09:05:35 2021
    13 // Update Count     : 200
     12// Last Modified On : Wed Jul 14 17:44:05 2021
     13// Update Count     : 202
    1414//
    1515
     
    2727struct TypeData {
    2828        enum Kind { Basic, Pointer, Reference, Array, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic,
    29                                 SymbolicInst, Tuple, Typeof, Basetypeof, Builtin, GlobalScope, Qualified, Unknown };
     29                                SymbolicInst, Tuple, Typeof, Basetypeof, Vtable, Builtin, GlobalScope, Qualified, Unknown };
    3030
    3131        struct Aggregate_t {
     
    128128TupleType * buildTuple( const TypeData * );
    129129TypeofType * buildTypeof( const TypeData * );
     130VTableType * buildVtable( const TypeData * );
    130131Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, Expression * asmName,
    131132                                                 Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() );
  • src/Parser/parser.yy

    rc86ee4c rd83b266  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun 29 09:12:47 2021
    13 // Update Count     : 5027
     12// Last Modified On : Tue Jul 20 22:03:04 2021
     13// Update Count     : 5031
    1414//
    1515
     
    19231923
    19241924vtable:
    1925         VTABLE '(' type_list ')' default_opt
    1926                 { SemanticError( yylloc, "vtable is currently unimplemented." ); $$ = nullptr; }
     1925        VTABLE '(' type_name ')' default_opt
     1926                { $$ = DeclarationNode::newVtableType( $3 ); }
     1927                // { SemanticError( yylloc, "vtable is currently unimplemented." ); $$ = nullptr; }
    19271928        ;
    19281929
  • src/SynTree/Declaration.h

    rc86ee4c rd83b266  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 12 18:35:36 2021
    13 // Update Count     : 159
     11// Last Modified By : Henry Xue
     12// Last Modified On : Tue Jul 20 04:10:50 2021
     13// Update Count     : 160
    1414//
    1515
     
    300300
    301301        bool is_coroutine() { return kind == Coroutine; }
     302        bool is_exception() { return kind == Exception; }
    302303        bool is_generator() { return kind == Generator; }
    303304        bool is_monitor  () { return kind == Monitor  ; }
  • src/SynTree/Mutator.h

    rc86ee4c rd83b266  
    112112        virtual Type * mutate( TupleType * tupleType ) = 0;
    113113        virtual Type * mutate( TypeofType * typeofType ) = 0;
     114        virtual Type * mutate( VTableType * vtableType ) = 0;
    114115        virtual Type * mutate( AttrType * attrType ) = 0;
    115116        virtual Type * mutate( VarArgsType * varArgsType ) = 0;
  • src/SynTree/SynTree.h

    rc86ee4c rd83b266  
    119119class TupleType;
    120120class TypeofType;
     121class VTableType;
    121122class AttrType;
    122123class VarArgsType;
  • src/SynTree/Type.cc

    rc86ee4c rd83b266  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Dec 15 16:52:37 2019
    13 // Update Count     : 49
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jul 14 15:47:00 2021
     13// Update Count     : 50
    1414//
    1515#include "Type.h"
     
    178178}
    179179
     180VTableType::VTableType( const Type::Qualifiers &tq, Type *base, const std::list< Attribute * > & attributes )
     181                : Type( tq, attributes ), base( base ) {
     182        assertf( base, "VTableType with a null base created." );
     183}
     184
     185VTableType::VTableType( const VTableType &other )
     186                : Type( other ), base( other.base->clone() ) {
     187}
     188
     189VTableType::~VTableType() {
     190        delete base;
     191}
     192
     193void VTableType::print( std::ostream &os, Indenter indent ) const {
     194        Type::print( os, indent );
     195        os << "get virtual-table type of ";
     196        if ( base ) {
     197                base->print( os, indent );
     198        } // if
     199}
     200
    180201// Local Variables: //
    181202// tab-width: 4 //
  • src/SynTree/Type.h

    rc86ee4c rd83b266  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Sep  4 09:58:00 2019
    13 // Update Count     : 170
     12// Last Modified On : Wed Jul 14 15:40:00 2021
     13// Update Count     : 171
    1414//
    1515
     
    651651};
    652652
     653class VTableType : public Type {
     654public:
     655        Type *base;
     656
     657        VTableType( const Type::Qualifiers & tq, Type *base,
     658                const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     659        VTableType( const VTableType & );
     660        virtual ~VTableType();
     661
     662        Type *get_base() { return base; }
     663        void set_base( Type *newValue ) { base = newValue; }
     664
     665        virtual VTableType *clone() const override { return new VTableType( *this ); }
     666        virtual void accept( Visitor & v ) override { v.visit( this ); }
     667        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     668        virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     669        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     670};
     671
    653672class AttrType : public Type {
    654673  public:
  • src/SynTree/Visitor.h

    rc86ee4c rd83b266  
    198198        virtual void visit( TypeofType * node ) { visit( const_cast<const TypeofType *>(node) ); }
    199199        virtual void visit( const TypeofType * typeofType ) = 0;
     200        virtual void visit( VTableType * node ) { visit( const_cast<const VTableType *>(node) ); }
     201        virtual void visit( const VTableType * vtableType ) = 0;
    200202        virtual void visit( AttrType * node ) { visit( const_cast<const AttrType *>(node) ); }
    201203        virtual void visit( const AttrType * attrType ) = 0;
  • src/main.cc

    rc86ee4c rd83b266  
    99// Author           : Peter Buhr and Rob Schluntz
    1010// Created On       : Fri May 15 23:12:02 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Mar  6 15:49:00 2021
    13 // Update Count     : 656
     11// Last Modified By : Henry Xue
     12// Last Modified On : Tue Jul 20 04:27:35 2021
     13// Update Count     : 658
    1414//
    1515
     
    4949#include "Common/utility.h"                 // for deleteAll, filter, printAll
    5050#include "Concurrency/Waitfor.h"            // for generateWaitfor
     51#include "ControlStruct/ExceptDecl.h"       // for translateExcept
    5152#include "ControlStruct/ExceptTranslate.h"  // for translateEHM
    5253#include "ControlStruct/Mutate.h"           // for mutate
     
    305306                CodeTools::fillLocations( translationUnit );
    306307                Stats::Time::StopBlock();
     308
     309                PASS( "Translate Exception Declarations", ControlStruct::translateExcept( translationUnit ) );
     310                if ( exdeclp ) {
     311                        dump( translationUnit );
     312                        return EXIT_SUCCESS;
     313                } // if
    307314
    308315                // add the assignment statement after the initialization of a type parameter
     
    549556        // code dumps
    550557        { "ast", astp, true, "print AST after parsing" },
     558        { "exdecl", exdeclp, true, "print AST after translating exception decls" },
    551559        { "symevt", symtabp, true, "print AST after symbol table events" },
    552560        { "altexpr", expraltp, true, "print alternatives for expressions" },
Note: See TracChangeset for help on using the changeset viewer.