Changeset 63bde81


Ignore:
Timestamp:
Jul 19, 2021, 4:03:19 PM (3 years ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
f9b68d6
Parents:
12a1013 (diff), fcaa1e4 (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

Files:
8 added
31 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/andrew_beach_MMath/code/cond-catch.cpp

    r12a1013 r63bde81  
    1919                throw_exception();
    2020        } catch (EmptyException & exc) {
    21                 if (should_catch) {
     21                if (!should_catch) {
    2222                        throw;
    2323                }
  • doc/theses/andrew_beach_MMath/code/cond-fixup.cfa

    r12a1013 r63bde81  
    1212
    1313void throw_exception() {
    14         throw (empty_exception){&empty_vt};
     14        throwResume (empty_exception){&empty_vt};
    1515}
    1616
     
    1818        try {
    1919                throw_exception();
    20         } catch (empty_exception * exc ; should_catch) {
     20        } catchResume (empty_exception * exc ; should_catch) {
    2121                // ...
    2222        }
     
    3636                try {
    3737                        cond_catch();
    38                 } catch (empty_exception * exc) {
     38                } catchResume (empty_exception * exc) {
    3939                        // ...
    4040                }
  • doc/theses/andrew_beach_MMath/code/resume-empty.cfa

    r12a1013 r63bde81  
    1313                unwind_empty(frames - 1);
    1414        } else {
    15                 throw (empty_exception){&empty_vt};
     15                throwResume (empty_exception){&empty_vt};
    1616        }
    1717}
     
    3131                try {
    3232                        unwind_empty(total_frames);
    33                 } catch (empty_exception *) {
     33                } catchResume (empty_exception *) {
    3434                        // ...
    3535                }
  • doc/theses/andrew_beach_MMath/code/test.sh

    r12a1013 r63bde81  
    1818        *.cfa)
    1919                # Requires a symbolic link.
    20                 mmake "${1%.cfa}" "$1" ./cfa "$1" -o "${1%.cfa}"
     20                mmake "${1%.cfa}" "$1" ./cfa -DNDEBUG -nodebug -O3 "$1" -o "${1%.cfa}"
    2121                ;;
    2222        *.cpp)
    23                 mmake "${1%.cpp}-cpp" "$1" g++ "$1" -o "${1%.cpp}-cpp"
     23                mmake "${1%.cpp}-cpp" "$1" g++ -DNDEBUG -O3 "$1" -o "${1%.cpp}-cpp"
    2424                ;;
    2525        *.java)
     
    3939        exit 0
    4040elif [ 2 -eq "$#" ]; then
    41     TEST_LANG="$1"
    42     TEST_CASE="$2"
     41        TEST_LANG="$1"
     42        TEST_CASE="$2"
    4343else
    44     echo "Unknown call pattern." >&2
    45     exit 2
     44        echo "Unknown call pattern." >&2
     45        exit 2
    4646fi
    4747
     
    5858        CPP="./cond-catch-cpp $ITERATIONS 1"
    5959        JAVA="java CondCatch $ITERATIONS 1"
     60        PYTHON="./cond_catch.py $ITERATIONS 1"
    6061        ;;
    6162cond-match-none)
     
    6465        CPP="./cond-catch-cpp $ITERATIONS 0"
    6566        JAVA="java CondCatch $ITERATIONS 0"
     67        PYTHON="./cond_catch.py $ITERATIONS 0"
    6668        ;;
    6769cross-catch)
     
    7072        CPP="./cross-catch-cpp $ITERATIONS"
    7173        JAVA="java CrossCatch $ITERATIONS"
     74        PYTHON="./cross_catch.py $ITERATIONS"
    7275        ;;
    7376cross-finally)
     
    7679        CPP=unsupported
    7780        JAVA="java CrossFinally $ITERATIONS"
     81        PYTHON="./cross_finally.py $ITERATIONS"
    7882        ;;
    7983raise-detor)
     
    8286        CPP="./throw-detor-cpp $ITERATIONS $STACK_HEIGHT"
    8387        JAVA=unsupported
     88        PYTHON=unsupported
    8489        ;;
    8590raise-empty)
     
    8893        CPP="./throw-empty-cpp $ITERATIONS $STACK_HEIGHT"
    8994        JAVA="java ThrowEmpty $ITERATIONS $STACK_HEIGHT"
     95        PYTHON="./throw_empty.py $ITERATIONS $STACK_HEIGHT"
    9096        ;;
    9197raise-finally)
     
    94100        CPP=unsupported
    95101        JAVA="java ThrowFinally $ITERATIONS $STACK_HEIGHT"
     102        PYTHON="./throw_finally.py $ITERATIONS $STACK_HEIGHT"
    96103        ;;
    97104raise-other)
     
    100107        CPP="./throw-other-cpp $ITERATIONS $STACK_HEIGHT"
    101108        JAVA="java ThrowOther $ITERATIONS $STACK_HEIGHT"
     109        PYTHON="./throw_other.py $ITERATIONS $STACK_HEIGHT"
    102110        ;;
    103111*)
     
    112120cpp) echo $CPP; $CPP;;
    113121java) echo $JAVA; $JAVA;;
     122python) echo $PYTHON; $PYTHON;;
    114123*)
    115124        echo "No such language: $TEST_LANG" >&2
    116125        exit 2
     126        ;;
    117127esac
  • doc/theses/andrew_beach_MMath/intro.tex

    r12a1013 r63bde81  
    107107
    108108Exception handling is not a new concept,
    109 with papers on the subject dating back 70s.
    110 
    111 Their were popularised by \Cpp,
     109with papers on the subject dating back 70s.\cite{Goodenough}
     110
     111Early exceptions were often treated as signals. They carried no information
     112except their identity. Ada still uses this system.
     113
     114The modern flag-ship for termination exceptions is \Cpp,
    112115which added them in its first major wave of non-object-orientated features
    113116in 1990.
    114117% https://en.cppreference.com/w/cpp/language/history
    115 
    116 Java was the next popular language to use exceptions. It is also the most
    117 popular language with checked exceptions.
     118\Cpp has the ability to use any value of any type as an exception.
     119However that seems to immediately pushed aside for classes inherited from
     120\code{C++}{std::exception}.
     121Although there is a special catch-all syntax it does not allow anything to
     122be done with the caught value becuase nothing is known about it.
     123So instead a base type is defined with some common functionality (such as
     124the ability to describe the reason the exception was raised) and all
     125exceptions have that functionality.
     126This seems to be the standard now, as the garentied functionality is worth
     127any lost flexibility from limiting it to a single type.
     128
     129Java was the next popular language to use exceptions.
     130Its exception system largely reflects that of \Cpp, except that requires
     131you throw a child type of \code{Java}{java.lang.Throwable}
     132and it uses checked exceptions.
    118133Checked exceptions are part of the function interface they are raised from.
    119134This includes functions they propogate through, until a handler for that
     
    131146Resumption exceptions have been much less popular.
    132147Although resumption has a history as old as termination's, very few
    133 programming languages have implement them.
     148programming languages have implemented them.
    134149% http://bitsavers.informatik.uni-stuttgart.de/pdf/xerox/parc/techReports/
    135150%   CSL-79-3_Mesa_Language_Manual_Version_5.0.pdf
    136 Mesa is one programming languages that did and experiance with that
    137 languages is quoted as being one of the reasons resumptions were not
     151Mesa is one programming languages that did. Experiance with Mesa
     152is quoted as being one of the reasons resumptions were not
    138153included in the \Cpp standard.
    139154% https://en.wikipedia.org/wiki/Exception_handling
    140 \todo{A comment about why we did include them when they are so unpopular
    141 might be approprate.}
    142 
    143 %\subsection
    144 Functional languages, tend to use solutions like the return union, but some
    145 exception-like constructs still appear.
    146 
    147 For instance Haskell's built in error mechanism can make the result of any
    148 expression, including function calls. Any expression that examines an
    149 error value will in-turn produce an error. This continues until the main
    150 function produces an error or until it is handled by one of the catch
    151 functions.
     155Since then resumptions have been ignored in the main-stream.
     156
     157All of this does call into question the use of resumptions, is
     158something largely rejected decades ago worth revisiting now?
     159Yes, even if it was the right call at the time there have been decades
     160of other developments in computer science that have changed the situation
     161since then.
     162Some of these developments, such as in functional programming's resumption
     163equivalent: algebraic effects\cite{Zhang19}, are directly related to
     164resumptions as well.
     165A complete rexamination of resumptions is beyond a single paper, but it is
     166enough to try them again in \CFA.
     167% Especially considering how much easier they are to implement than
     168% termination exceptions.
     169
     170%\subsection
     171Functional languages tend to use other solutions for their primary error
     172handling mechanism, exception-like constructs still appear.
     173Termination appears in error construct, which marks the result of an
     174expression as an error, the result of any expression that tries to use it as
     175an error, and so on until an approprate handler is reached.
     176Resumption appears in algebric effects, where a function dispatches its
     177side-effects to its caller for handling.
    152178
    153179%\subsection
    154180More recently exceptions seem to be vanishing from newer programming
    155 languages.
    156 Rust and Go reduce this feature to panics.
    157 Panicing is somewhere between a termination exception and a program abort.
    158 Notably in Rust a panic can trigger either, a panic may unwind the stack or
    159 simply kill the process.
     181languages, replaced by ``panic".
     182In Rust a panic is just a program level abort that may be implemented by
     183unwinding the stack like in termination exception handling.
    160184% https://doc.rust-lang.org/std/panic/fn.catch_unwind.html
    161 Go's panic is much more similar to a termination exception but there is
    162 only a catch-all function with \code{Go}{recover()}.
    163 So exceptions still are appearing, just in reduced forms.
     185Go's panic through is very similar to a termination except it only supports
     186a catch-all by calling \code{Go}{recover()}, simplifying the interface at
     187the cost of flexability.
    164188
    165189%\subsection
  • driver/cc1.cc

    r12a1013 r63bde81  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jun  1 23:07:21 2021
    13 // Update Count     : 415
     12// Last Modified On : Wed Jul 14 15:42:08 2021
     13// Update Count     : 418
    1414//
    1515
     
    372372                        if ( prefix( arg, "-fdiagnostics-color=" ) ) {
    373373                                string choice = arg.substr(20);
    374                                      if(choice == "always") color_arg = Color_Always;
    375                                 else if(choice == "never" ) color_arg = Color_Never;
    376                                 else if(choice == "auto" ) color_arg = Color_Auto;
     374                                if ( choice == "always" ) color_arg = Color_Always;
     375                                else if ( choice == "never" ) color_arg = Color_Never;
     376                                else if ( choice == "auto" ) color_arg = Color_Auto;
    377377                        } else if ( arg == "-fno-diagnostics-color" ) {
    378378                                color_arg = Color_Auto;
  • driver/cfa.cc

    r12a1013 r63bde81  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jan 16 07:30:19 2021
    13 // Update Count     : 442
     12// Last Modified On : Wed Jul 14 21:55:12 2021
     13// Update Count     : 467
    1414//
    1515
     
    9494        // get executable path from /proc/self/exe
    9595        ssize_t size = readlink("/proc/self/exe", const_cast<char*>(abspath.c_str()), abspath.size());
    96         if(size <= 0) {
     96        if ( size <= 0 ) {
    9797                std::cerr << "Error could not evaluate absolute path from /proc/self/exe" << std::endl;
    9898                std::cerr << "Failed with " << std::strerror(errno) << std::endl;
    9999                std::exit(1);
    100         }
     100        } // if
    101101
    102102        // Trim extra characters
     
    104104
    105105        // Are we installed
    106         if(abspath.rfind(CFA_BINDIR  , 0) == 0) { return Installed; }
     106        if ( abspath.rfind(CFA_BINDIR, 0) == 0 ) { return Installed; }
    107107
    108108        // Is this the build tree
    109         if(abspath.rfind(TOP_BUILDDIR, 0) == 0) { return BuildTree; }
     109        if ( abspath.rfind(TOP_BUILDDIR, 0 ) == 0 ) { return BuildTree; }
    110110
    111111        // Does this look like distcc
    112         if(abspath.find("/.cfadistcc/") != std::string::npos) { return Distributed; }
     112        if ( abspath.find( "/.cfadistcc/" ) != std::string::npos ) { return Distributed; }
    113113
    114114        // None of the above? Give up since we don't know where the prelude or include directories are
     
    188188                                        i += 1;
    189189                                        if ( i == argc ) continue;                      // next argument available ?
    190                                         Putenv( argv, argv[i] );
     190                                        Putenv( argv, argv[i] );                        // make available for cc1
    191191                                } else if ( arg[5] == ',' ) {                   // CFA specific arguments
    192                                         Putenv( argv, argv[i] + 6 );
     192                                        string xcfargs = arg.substr( 6 ) + ","; // add sentinel
     193                                        for ( ;; ) {
     194                                                size_t posn = xcfargs.find_first_of( "," ); // find separator
     195                                          if ( posn == string::npos ) break; // any characters left ?
     196                                                string xcfarg = xcfargs.substr( 0, posn ); // remove XCFA argument
     197                                                Putenv( argv, xcfarg );                 // make available for cc1
     198                                                xcfargs.erase( 0, posn + 1 );   // remove first argument and comma
     199                                        } // for
    193200                                } else {                                                                // CFA specific arguments
     201                                        assert( false );                                        // this does not make sense
    194202                                        args[nargs++] = argv[i];
    195203                                } // if
     
    364372        args[nargs++] = "stdbool.h";
    365373
    366         if( compiling_libs ) {
     374        if ( compiling_libs ) {
    367375                Putenv( argv, "-t" );
    368376        } // if
  • src/AST/Convert.cpp

    r12a1013 r63bde81  
    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

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

    r12a1013 r63bde81  
    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

    r12a1013 r63bde81  
    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

    r12a1013 r63bde81  
    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

    r12a1013 r63bde81  
    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

    r12a1013 r63bde81  
    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

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

    r12a1013 r63bde81  
    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

    r12a1013 r63bde81  
    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/GenPoly/Box.cc

    r12a1013 r63bde81  
    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

    r12a1013 r63bde81  
    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

    r12a1013 r63bde81  
    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

    r12a1013 r63bde81  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Dec 16 07:56:46 2019
    13 // Update Count     : 662
     12// Last Modified On : Wed Jul 14 18:57:31 2021
     13// Update Count     : 672
    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 ) {
     
    945954        assert( td->typeexpr );
    946955        // assert( td->typeexpr->expr );
    947         return new TypeofType{
    948                 buildQualifiers( td ), td->typeexpr->build(), td->kind == TypeData::Basetypeof };
     956        return new TypeofType{ buildQualifiers( td ), td->typeexpr->build(), td->kind == TypeData::Basetypeof };
    949957} // buildTypeof
     958
     959
     960VTableType * buildVtable( const TypeData * td ) {
     961        assert( td->base );
     962        return new VTableType{ buildQualifiers( td ), typebuild( td->base ) };
     963} // buildVtable
    950964
    951965
  • src/Parser/TypeData.h

    r12a1013 r63bde81  
    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

    r12a1013 r63bde81  
    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 : Wed Jul 14 17:27:54 2021
     13// Update Count     : 5030
    1414//
    1515
     
    19231923
    19241924vtable:
    1925         VTABLE '(' type_list ')' default_opt
    1926                 { SemanticError( yylloc, "vtable is currently unimplemented." ); $$ = nullptr; }
     1925        VTABLE '(' typedef_name ')' default_opt
     1926                { $$ = DeclarationNode::newVtableType( $3 ); }
     1927                // { SemanticError( yylloc, "vtable is currently unimplemented." ); $$ = nullptr; }
    19271928        ;
    19281929
  • src/SynTree/Mutator.h

    r12a1013 r63bde81  
    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

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

    r12a1013 r63bde81  
    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

    r12a1013 r63bde81  
    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

    r12a1013 r63bde81  
    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;
  • tests/.expect/polymorphism.txt

    r12a1013 r63bde81  
    11123 456 456
    225 5
     3=== checkPlan9offsets
     4static:
     5  offset of inner double: 8
     6  offset of inner float:  16
     7dynamic:
     8  offset of inner double: 8
     9  offset of inner float:  16
  • tests/polymorphism.cfa

    r12a1013 r63bde81  
    5454        b.i = s.i;
    5555        return b.j;
     56}
     57
     58void checkPlan9offsets() {
     59
     60        forall( T )
     61        struct thing {
     62                T q;                // variable-sized padding
     63                inline double;
     64                inline float;
     65        };
     66
     67        #define SHOW_OFFSETS \
     68                double & x_inner_double = x; \
     69                float  & x_inner_float  = x; \
     70                printf("  offset of inner double: %ld\n", ((char *) & x_inner_double) - ((char *) & x) ); \
     71                printf("  offset of inner float:  %ld\n", ((char *) & x_inner_float ) - ((char *) & x) );
     72
     73        void showStatic( thing(int) & x ) {
     74                printf("static:\n");
     75                SHOW_OFFSETS
     76        }
     77
     78        forall( T )
     79        void showDynamic( thing(T) & x ) {
     80                printf("dynamic:\n");
     81                SHOW_OFFSETS
     82        }
     83
     84        #undef SHOW_OFFSETS
     85
     86        printf("=== checkPlan9offsets\n");
     87        thing(int) x;
     88        showStatic(x);
     89        showDynamic(x);
    5690}
    5791
     
    114148                assertf(ret == u.f2, "union operation fails in polymorphic context.");
    115149        }
     150
     151        checkPlan9offsets();
    116152}
    117153
  • tests/unified_locking/mutex_test.hfa

    r12a1013 r63bde81  
    88struct MutexObj {
    99        LOCK l;
    10         $thread * id;
     10        thread$ * id;
    1111        uint32_t sum;
    1212};
     
    2222
    2323uint32_t cs() {
    24         $thread * me = active_thread();
     24        thread$ * me = active_thread();
    2525        uint32_t value;
    2626        lock(mo.l);
Note: See TracChangeset for help on using the changeset viewer.