Changes in / [63bde81:12a1013]


Ignore:
Files:
8 deleted
31 edited

Legend:

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

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

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

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

    r63bde81 r12a1013  
    1818        *.cfa)
    1919                # Requires a symbolic link.
    20                 mmake "${1%.cfa}" "$1" ./cfa -DNDEBUG -nodebug -O3 "$1" -o "${1%.cfa}"
     20                mmake "${1%.cfa}" "$1" ./cfa "$1" -o "${1%.cfa}"
    2121                ;;
    2222        *.cpp)
    23                 mmake "${1%.cpp}-cpp" "$1" g++ -DNDEBUG -O3 "$1" -o "${1%.cpp}-cpp"
     23                mmake "${1%.cpp}-cpp" "$1" g++ "$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"
    6160        ;;
    6261cond-match-none)
     
    6564        CPP="./cond-catch-cpp $ITERATIONS 0"
    6665        JAVA="java CondCatch $ITERATIONS 0"
    67         PYTHON="./cond_catch.py $ITERATIONS 0"
    6866        ;;
    6967cross-catch)
     
    7270        CPP="./cross-catch-cpp $ITERATIONS"
    7371        JAVA="java CrossCatch $ITERATIONS"
    74         PYTHON="./cross_catch.py $ITERATIONS"
    7572        ;;
    7673cross-finally)
     
    7976        CPP=unsupported
    8077        JAVA="java CrossFinally $ITERATIONS"
    81         PYTHON="./cross_finally.py $ITERATIONS"
    8278        ;;
    8379raise-detor)
     
    8682        CPP="./throw-detor-cpp $ITERATIONS $STACK_HEIGHT"
    8783        JAVA=unsupported
    88         PYTHON=unsupported
    8984        ;;
    9085raise-empty)
     
    9388        CPP="./throw-empty-cpp $ITERATIONS $STACK_HEIGHT"
    9489        JAVA="java ThrowEmpty $ITERATIONS $STACK_HEIGHT"
    95         PYTHON="./throw_empty.py $ITERATIONS $STACK_HEIGHT"
    9690        ;;
    9791raise-finally)
     
    10094        CPP=unsupported
    10195        JAVA="java ThrowFinally $ITERATIONS $STACK_HEIGHT"
    102         PYTHON="./throw_finally.py $ITERATIONS $STACK_HEIGHT"
    10396        ;;
    10497raise-other)
     
    107100        CPP="./throw-other-cpp $ITERATIONS $STACK_HEIGHT"
    108101        JAVA="java ThrowOther $ITERATIONS $STACK_HEIGHT"
    109         PYTHON="./throw_other.py $ITERATIONS $STACK_HEIGHT"
    110102        ;;
    111103*)
     
    120112cpp) echo $CPP; $CPP;;
    121113java) echo $JAVA; $JAVA;;
    122 python) echo $PYTHON; $PYTHON;;
    123114*)
    124115        echo "No such language: $TEST_LANG" >&2
    125116        exit 2
    126         ;;
    127117esac
  • doc/theses/andrew_beach_MMath/intro.tex

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

    r63bde81 r12a1013  
    1010// Created On       : Fri Aug 26 14:23:51 2005
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 14 15:42:08 2021
    13 // Update Count     : 418
     12// Last Modified On : Tue Jun  1 23:07:21 2021
     13// Update Count     : 415
    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

    r63bde81 r12a1013  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 14 21:55:12 2021
    13 // Update Count     : 467
     12// Last Modified On : Sat Jan 16 07:30:19 2021
     13// Update Count     : 442
    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         } // if
     100        }
    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] );                        // make available for cc1
     190                                        Putenv( argv, argv[i] );
    191191                                } else if ( arg[5] == ',' ) {                   // CFA specific arguments
    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
     192                                        Putenv( argv, argv[i] + 6 );
    200193                                } else {                                                                // CFA specific arguments
    201                                         assert( false );                                        // this does not make sense
    202194                                        args[nargs++] = argv[i];
    203195                                } // if
     
    372364        args[nargs++] = "stdbool.h";
    373365
    374         if ( compiling_libs ) {
     366        if( compiling_libs ) {
    375367                Putenv( argv, "-t" );
    376368        } // if
  • src/AST/Convert.cpp

    r63bde81 r12a1013  
    99// Author           : Thierry Delisle
    1010// Created On       : Thu May 09 15::37::05 2019
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jul 14 16:15:00 2021
    13 // Update Count     : 37
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Mar 12 18:43:51 2021
     13// Update Count     : 36
    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 
    13651358        const ast::Type * visit( const ast::VarArgsType * node ) override final {
    13661359                return visitType( node, new VarArgsType{ cv( node ) } );
     
    28062799        }
    28072800
    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 
    28152801        virtual void visit( const AttrType * ) override final {
    28162802                assertf( false, "AttrType deprecated in new AST." );
  • src/AST/Fwd.hpp

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

    r63bde81 r12a1013  
    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;
    216215        const ast::Type *             visit( const ast::VarArgsType          * ) override final;
    217216        const ast::Type *             visit( const ast::ZeroType             * ) override final;
  • src/AST/Pass.impl.hpp

    r63bde81 r12a1013  
    18731873
    18741874//--------------------------------------------------------------------------
    1875 // VTableType
    1876 template< typename core_t >
    1877 const 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 //--------------------------------------------------------------------------
    18881875// VarArgsType
    18891876template< typename core_t >
  • src/AST/Print.cpp

    r63bde81 r12a1013  
    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 
    14261418        virtual const ast::Type * visit( const ast::VarArgsType * node ) override final {
    14271419                preprint( node );
  • src/AST/Type.hpp

    r63bde81 r12a1013  
    1010// Created On       : Thu May 9 10:00:00 2019
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jul 14 15:54:00 2021
    13 // Update Count     : 7
     12// Last Modified On : Thu Jul 23 14:15:00 2020
     13// Update Count     : 6
    1414//
    1515
     
    491491};
    492492
    493 /// Virtual Table Type `vtable(T)`
    494 class VTableType final : public Type {
    495 public:
    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 ); }
    501 private:
    502         VTableType * clone() const override { return new VTableType{ *this }; }
    503         MUTATE_FRIEND
    504 };
    505 
    506493/// GCC built-in varargs type
    507494class VarArgsType final : public Type {
  • src/AST/Visitor.hpp

    r63bde81 r12a1013  
    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;
    108107    virtual const ast::Type *             visit( const ast::VarArgsType          * ) = 0;
    109108    virtual const ast::Type *             visit( const ast::ZeroType             * ) = 0;
  • src/Common/CodeLocationTools.cpp

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

    r63bde81 r12a1013  
    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;
    234232        virtual void visit( AttrType * attrType ) override final;
    235233        virtual void visit( const AttrType * attrType ) override final;
     
    345343        virtual Type * mutate( TupleType * tupleType ) override final;
    346344        virtual Type * mutate( TypeofType * typeofType ) override final;
    347         virtual Type * mutate( VTableType * vtableType ) override final;
    348345        virtual Type * mutate( AttrType * attrType ) override final;
    349346        virtual Type * mutate( VarArgsType * varArgsType ) override final;
  • src/Common/PassVisitor.impl.h

    r63bde81 r12a1013  
    36103610
    36113611//--------------------------------------------------------------------------
    3612 // VTableType
    3613 template< typename pass_type >
    3614 void 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 
    3624 template< typename pass_type >
    3625 void 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 
    3635 template< typename pass_type >
    3636 Type * 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 //--------------------------------------------------------------------------
    36473612// AttrType
    36483613template< typename pass_type >
  • src/GenPoly/Box.cc

    r63bde81 r12a1013  
    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() )
    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;
     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;
    15721555                        }
    15731556                        return -1;
  • src/Parser/DeclarationNode.cc

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

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

    r63bde81 r12a1013  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 14 18:57:31 2021
    13 // Update Count     : 672
     12// Last Modified On : Mon Dec 16 07:56:46 2019
     13// Update Count     : 662
    1414//
    1515
     
    100100                typeexpr = nullptr;
    101101                break;
    102           case Vtable:
    103                 break;
    104102          case Builtin:
    105103                // builtin = new Builtin_t;
     
    172170                // delete typeexpr->expr;
    173171                delete typeexpr;
    174                 break;
    175           case Vtable:
    176172                break;
    177173          case Builtin:
     
    253249          case Basetypeof:
    254250                newtype->typeexpr = maybeClone( typeexpr );
    255                 break;
    256           case Vtable:
    257251                break;
    258252          case Builtin:
     
    473467          case Basetypeof:
    474468          case Builtin:
    475           case Vtable:
    476469                assertf(false, "Tried to get leaf name from kind without a name: %d", kind);
    477470                break;
     
    553546          case TypeData::Basetypeof:
    554547                return buildTypeof( td );
    555           case TypeData::Vtable:
    556                 return buildVtable( td );
    557548          case TypeData::Builtin:
    558549                switch ( td->builtintype ) {
     
    954945        assert( td->typeexpr );
    955946        // assert( td->typeexpr->expr );
    956         return new TypeofType{ buildQualifiers( td ), td->typeexpr->build(), td->kind == TypeData::Basetypeof };
     947        return new TypeofType{
     948                buildQualifiers( td ), td->typeexpr->build(), td->kind == TypeData::Basetypeof };
    957949} // buildTypeof
    958 
    959 
    960 VTableType * buildVtable( const TypeData * td ) {
    961         assert( td->base );
    962         return new VTableType{ buildQualifiers( td ), typebuild( td->base ) };
    963 } // buildVtable
    964950
    965951
  • src/Parser/TypeData.h

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

    r63bde81 r12a1013  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 14 17:27:54 2021
    13 // Update Count     : 5030
     12// Last Modified On : Tue Jun 29 09:12:47 2021
     13// Update Count     : 5027
    1414//
    1515
     
    19231923
    19241924vtable:
    1925         VTABLE '(' typedef_name ')' default_opt
    1926                 { $$ = DeclarationNode::newVtableType( $3 ); }
    1927                 // { SemanticError( yylloc, "vtable is currently unimplemented." ); $$ = nullptr; }
     1925        VTABLE '(' type_list ')' default_opt
     1926                { SemanticError( yylloc, "vtable is currently unimplemented." ); $$ = nullptr; }
    19281927        ;
    19291928
  • src/SynTree/Mutator.h

    r63bde81 r12a1013  
    112112        virtual Type * mutate( TupleType * tupleType ) = 0;
    113113        virtual Type * mutate( TypeofType * typeofType ) = 0;
    114         virtual Type * mutate( VTableType * vtableType ) = 0;
    115114        virtual Type * mutate( AttrType * attrType ) = 0;
    116115        virtual Type * mutate( VarArgsType * varArgsType ) = 0;
  • src/SynTree/SynTree.h

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

    r63bde81 r12a1013  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jul 14 15:47:00 2021
    13 // Update Count     : 50
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Sun Dec 15 16:52:37 2019
     13// Update Count     : 49
    1414//
    1515#include "Type.h"
     
    178178}
    179179
    180 VTableType::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 
    185 VTableType::VTableType( const VTableType &other )
    186                 : Type( other ), base( other.base->clone() ) {
    187 }
    188 
    189 VTableType::~VTableType() {
    190         delete base;
    191 }
    192 
    193 void 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 
    201180// Local Variables: //
    202181// tab-width: 4 //
  • src/SynTree/Type.h

    r63bde81 r12a1013  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jul 14 15:40:00 2021
    13 // Update Count     : 171
     12// Last Modified On : Wed Sep  4 09:58:00 2019
     13// Update Count     : 170
    1414//
    1515
     
    651651};
    652652
    653 class VTableType : public Type {
    654 public:
    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 
    672653class AttrType : public Type {
    673654  public:
  • src/SynTree/Visitor.h

    r63bde81 r12a1013  
    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;
    202200        virtual void visit( AttrType * node ) { visit( const_cast<const AttrType *>(node) ); }
    203201        virtual void visit( const AttrType * attrType ) = 0;
  • tests/.expect/polymorphism.txt

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

    r63bde81 r12a1013  
    5454        b.i = s.i;
    5555        return b.j;
    56 }
    57 
    58 void 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);
    9056}
    9157
     
    148114                assertf(ret == u.f2, "union operation fails in polymorphic context.");
    149115        }
    150 
    151         checkPlan9offsets();
    152116}
    153117
  • tests/unified_locking/mutex_test.hfa

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