Changes in / [63bde81:12a1013]
- Files:
-
- 8 deleted
- 31 edited
-
doc/theses/andrew_beach_MMath/code/.gitignore (deleted)
-
doc/theses/andrew_beach_MMath/code/cond-catch.cpp (modified) (1 diff)
-
doc/theses/andrew_beach_MMath/code/cond-fixup.cfa (modified) (3 diffs)
-
doc/theses/andrew_beach_MMath/code/cond_catch.py (deleted)
-
doc/theses/andrew_beach_MMath/code/cross_catch.py (deleted)
-
doc/theses/andrew_beach_MMath/code/cross_finally.py (deleted)
-
doc/theses/andrew_beach_MMath/code/resume-empty.cfa (modified) (2 diffs)
-
doc/theses/andrew_beach_MMath/code/test.sh (modified) (11 diffs)
-
doc/theses/andrew_beach_MMath/code/throw_empty.py (deleted)
-
doc/theses/andrew_beach_MMath/code/throw_finally.py (deleted)
-
doc/theses/andrew_beach_MMath/code/throw_other.py (deleted)
-
doc/theses/andrew_beach_MMath/code/throw_with.py (deleted)
-
doc/theses/andrew_beach_MMath/intro.tex (modified) (2 diffs)
-
driver/cc1.cc (modified) (2 diffs)
-
driver/cfa.cc (modified) (5 diffs)
-
src/AST/Convert.cpp (modified) (3 diffs)
-
src/AST/Fwd.hpp (modified) (1 diff)
-
src/AST/Pass.hpp (modified) (1 diff)
-
src/AST/Pass.impl.hpp (modified) (1 diff)
-
src/AST/Print.cpp (modified) (1 diff)
-
src/AST/Type.hpp (modified) (2 diffs)
-
src/AST/Visitor.hpp (modified) (1 diff)
-
src/Common/CodeLocationTools.cpp (modified) (1 diff)
-
src/Common/PassVisitor.h (modified) (2 diffs)
-
src/Common/PassVisitor.impl.h (modified) (1 diff)
-
src/GenPoly/Box.cc (modified) (1 diff)
-
src/Parser/DeclarationNode.cc (modified) (2 diffs)
-
src/Parser/ParseNode.h (modified) (2 diffs)
-
src/Parser/TypeData.cc (modified) (7 diffs)
-
src/Parser/TypeData.h (modified) (3 diffs)
-
src/Parser/parser.yy (modified) (2 diffs)
-
src/SynTree/Mutator.h (modified) (1 diff)
-
src/SynTree/SynTree.h (modified) (1 diff)
-
src/SynTree/Type.cc (modified) (2 diffs)
-
src/SynTree/Type.h (modified) (2 diffs)
-
src/SynTree/Visitor.h (modified) (1 diff)
-
tests/.expect/polymorphism.txt (modified) (1 diff)
-
tests/polymorphism.cfa (modified) (2 diffs)
-
tests/unified_locking/mutex_test.hfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/andrew_beach_MMath/code/cond-catch.cpp
r63bde81 r12a1013 19 19 throw_exception(); 20 20 } catch (EmptyException & exc) { 21 if ( !should_catch) {21 if (should_catch) { 22 22 throw; 23 23 } -
doc/theses/andrew_beach_MMath/code/cond-fixup.cfa
r63bde81 r12a1013 12 12 13 13 void throw_exception() { 14 throw Resume(empty_exception){&empty_vt};14 throw (empty_exception){&empty_vt}; 15 15 } 16 16 … … 18 18 try { 19 19 throw_exception(); 20 } catch Resume(empty_exception * exc ; should_catch) {20 } catch (empty_exception * exc ; should_catch) { 21 21 // ... 22 22 } … … 36 36 try { 37 37 cond_catch(); 38 } catch Resume(empty_exception * exc) {38 } catch (empty_exception * exc) { 39 39 // ... 40 40 } -
doc/theses/andrew_beach_MMath/code/resume-empty.cfa
r63bde81 r12a1013 13 13 unwind_empty(frames - 1); 14 14 } else { 15 throw Resume(empty_exception){&empty_vt};15 throw (empty_exception){&empty_vt}; 16 16 } 17 17 } … … 31 31 try { 32 32 unwind_empty(total_frames); 33 } catch Resume(empty_exception *) {33 } catch (empty_exception *) { 34 34 // ... 35 35 } -
doc/theses/andrew_beach_MMath/code/test.sh
r63bde81 r12a1013 18 18 *.cfa) 19 19 # 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}" 21 21 ;; 22 22 *.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" 24 24 ;; 25 25 *.java) … … 39 39 exit 0 40 40 elif [ 2 -eq "$#" ]; then 41 TEST_LANG="$1"42 TEST_CASE="$2"41 TEST_LANG="$1" 42 TEST_CASE="$2" 43 43 else 44 echo "Unknown call pattern." >&245 exit 244 echo "Unknown call pattern." >&2 45 exit 2 46 46 fi 47 47 … … 58 58 CPP="./cond-catch-cpp $ITERATIONS 1" 59 59 JAVA="java CondCatch $ITERATIONS 1" 60 PYTHON="./cond_catch.py $ITERATIONS 1"61 60 ;; 62 61 cond-match-none) … … 65 64 CPP="./cond-catch-cpp $ITERATIONS 0" 66 65 JAVA="java CondCatch $ITERATIONS 0" 67 PYTHON="./cond_catch.py $ITERATIONS 0"68 66 ;; 69 67 cross-catch) … … 72 70 CPP="./cross-catch-cpp $ITERATIONS" 73 71 JAVA="java CrossCatch $ITERATIONS" 74 PYTHON="./cross_catch.py $ITERATIONS"75 72 ;; 76 73 cross-finally) … … 79 76 CPP=unsupported 80 77 JAVA="java CrossFinally $ITERATIONS" 81 PYTHON="./cross_finally.py $ITERATIONS"82 78 ;; 83 79 raise-detor) … … 86 82 CPP="./throw-detor-cpp $ITERATIONS $STACK_HEIGHT" 87 83 JAVA=unsupported 88 PYTHON=unsupported89 84 ;; 90 85 raise-empty) … … 93 88 CPP="./throw-empty-cpp $ITERATIONS $STACK_HEIGHT" 94 89 JAVA="java ThrowEmpty $ITERATIONS $STACK_HEIGHT" 95 PYTHON="./throw_empty.py $ITERATIONS $STACK_HEIGHT"96 90 ;; 97 91 raise-finally) … … 100 94 CPP=unsupported 101 95 JAVA="java ThrowFinally $ITERATIONS $STACK_HEIGHT" 102 PYTHON="./throw_finally.py $ITERATIONS $STACK_HEIGHT"103 96 ;; 104 97 raise-other) … … 107 100 CPP="./throw-other-cpp $ITERATIONS $STACK_HEIGHT" 108 101 JAVA="java ThrowOther $ITERATIONS $STACK_HEIGHT" 109 PYTHON="./throw_other.py $ITERATIONS $STACK_HEIGHT"110 102 ;; 111 103 *) … … 120 112 cpp) echo $CPP; $CPP;; 121 113 java) echo $JAVA; $JAVA;; 122 python) echo $PYTHON; $PYTHON;;123 114 *) 124 115 echo "No such language: $TEST_LANG" >&2 125 116 exit 2 126 ;;127 117 esac -
doc/theses/andrew_beach_MMath/intro.tex
r63bde81 r12a1013 107 107 108 108 Exception 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, 109 with papers on the subject dating back 70s. 110 111 Their were popularised by \Cpp, 115 112 which added them in its first major wave of non-object-orientated features 116 113 in 1990. 117 114 % 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 116 Java was the next popular language to use exceptions. It is also the most 117 popular language with checked exceptions. 133 118 Checked exceptions are part of the function interface they are raised from. 134 119 This includes functions they propogate through, until a handler for that … … 146 131 Resumption exceptions have been much less popular. 147 132 Although resumption has a history as old as termination's, very few 148 programming languages have implement edthem.133 programming languages have implement them. 149 134 % http://bitsavers.informatik.uni-stuttgart.de/pdf/xerox/parc/techReports/ 150 135 % CSL-79-3_Mesa_Language_Manual_Version_5.0.pdf 151 Mesa is one programming languages that did . Experiance with Mesa152 is quoted as being one of the reasons resumptions were not136 Mesa is one programming languages that did and experiance with that 137 languages is quoted as being one of the reasons resumptions were not 153 138 included in the \Cpp standard. 154 139 % 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 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. 178 152 179 153 %\subsection 180 154 More 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. 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. 184 160 % 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 supports186 a catch-all by calling \code{Go}{recover()}, simplifying the interface at 187 the cost of flexability.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. 188 164 189 165 %\subsection -
driver/cc1.cc
r63bde81 r12a1013 10 10 // Created On : Fri Aug 26 14:23:51 2005 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 14 15:42:08202113 // Update Count : 41 812 // Last Modified On : Tue Jun 1 23:07:21 2021 13 // Update Count : 415 14 14 // 15 15 … … 372 372 if ( prefix( arg, "-fdiagnostics-color=" ) ) { 373 373 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; 377 377 } else if ( arg == "-fno-diagnostics-color" ) { 378 378 color_arg = Color_Auto; -
driver/cfa.cc
r63bde81 r12a1013 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 14 21:55:12202113 // Update Count : 4 6712 // Last Modified On : Sat Jan 16 07:30:19 2021 13 // Update Count : 442 14 14 // 15 15 … … 94 94 // get executable path from /proc/self/exe 95 95 ssize_t size = readlink("/proc/self/exe", const_cast<char*>(abspath.c_str()), abspath.size()); 96 if ( size <= 0) {96 if(size <= 0) { 97 97 std::cerr << "Error could not evaluate absolute path from /proc/self/exe" << std::endl; 98 98 std::cerr << "Failed with " << std::strerror(errno) << std::endl; 99 99 std::exit(1); 100 } // if100 } 101 101 102 102 // Trim extra characters … … 104 104 105 105 // Are we installed 106 if ( abspath.rfind(CFA_BINDIR, 0) == 0) { return Installed; }106 if(abspath.rfind(CFA_BINDIR , 0) == 0) { return Installed; } 107 107 108 108 // 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; } 110 110 111 111 // 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; } 113 113 114 114 // None of the above? Give up since we don't know where the prelude or include directories are … … 188 188 i += 1; 189 189 if ( i == argc ) continue; // next argument available ? 190 Putenv( argv, argv[i] ); // make available for cc1190 Putenv( argv, argv[i] ); 191 191 } 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 ); 200 193 } else { // CFA specific arguments 201 assert( false ); // this does not make sense202 194 args[nargs++] = argv[i]; 203 195 } // if … … 372 364 args[nargs++] = "stdbool.h"; 373 365 374 if ( compiling_libs ) {366 if( compiling_libs ) { 375 367 Putenv( argv, "-t" ); 376 368 } // if -
src/AST/Convert.cpp
r63bde81 r12a1013 9 9 // Author : Thierry Delisle 10 10 // Created On : Thu May 09 15::37::05 2019 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Jul 14 16:15:00202113 // Update Count : 3 711 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 12 18:43:51 2021 13 // Update Count : 36 14 14 // 15 15 … … 1356 1356 } 1357 1357 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 1365 1358 const ast::Type * visit( const ast::VarArgsType * node ) override final { 1366 1359 return visitType( node, new VarArgsType{ cv( node ) } ); … … 2806 2799 } 2807 2800 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 2815 2801 virtual void visit( const AttrType * ) override final { 2816 2802 assertf( false, "AttrType deprecated in new AST." ); -
src/AST/Fwd.hpp
r63bde81 r12a1013 117 117 class TupleType; 118 118 class TypeofType; 119 class VTableType;120 119 class VarArgsType; 121 120 class ZeroType; -
src/AST/Pass.hpp
r63bde81 r12a1013 213 213 const ast::Type * visit( const ast::TupleType * ) override final; 214 214 const ast::Type * visit( const ast::TypeofType * ) override final; 215 const ast::Type * visit( const ast::VTableType * ) override final;216 215 const ast::Type * visit( const ast::VarArgsType * ) override final; 217 216 const ast::Type * visit( const ast::ZeroType * ) override final; -
src/AST/Pass.impl.hpp
r63bde81 r12a1013 1873 1873 1874 1874 //-------------------------------------------------------------------------- 1875 // VTableType1876 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 //--------------------------------------------------------------------------1888 1875 // VarArgsType 1889 1876 template< typename core_t > -
src/AST/Print.cpp
r63bde81 r12a1013 1416 1416 } 1417 1417 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 1426 1418 virtual const ast::Type * visit( const ast::VarArgsType * node ) override final { 1427 1419 preprint( node ); -
src/AST/Type.hpp
r63bde81 r12a1013 10 10 // Created On : Thu May 9 10:00:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jul 14 15:54:00 202113 // Update Count : 712 // Last Modified On : Thu Jul 23 14:15:00 2020 13 // Update Count : 6 14 14 // 15 15 … … 491 491 }; 492 492 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_FRIEND504 };505 506 493 /// GCC built-in varargs type 507 494 class VarArgsType final : public Type { -
src/AST/Visitor.hpp
r63bde81 r12a1013 105 105 virtual const ast::Type * visit( const ast::TupleType * ) = 0; 106 106 virtual const ast::Type * visit( const ast::TypeofType * ) = 0; 107 virtual const ast::Type * visit( const ast::VTableType * ) = 0;108 107 virtual const ast::Type * visit( const ast::VarArgsType * ) = 0; 109 108 virtual const ast::Type * visit( const ast::ZeroType * ) = 0; -
src/Common/CodeLocationTools.cpp
r63bde81 r12a1013 176 176 macro(TupleType, Type) \ 177 177 macro(TypeofType, Type) \ 178 macro(VTableType, Type) \179 178 macro(VarArgsType, Type) \ 180 179 macro(ZeroType, Type) \ -
src/Common/PassVisitor.h
r63bde81 r12a1013 230 230 virtual void visit( TypeofType * typeofType ) override final; 231 231 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;234 232 virtual void visit( AttrType * attrType ) override final; 235 233 virtual void visit( const AttrType * attrType ) override final; … … 345 343 virtual Type * mutate( TupleType * tupleType ) override final; 346 344 virtual Type * mutate( TypeofType * typeofType ) override final; 347 virtual Type * mutate( VTableType * vtableType ) override final;348 345 virtual Type * mutate( AttrType * attrType ) override final; 349 346 virtual Type * mutate( VarArgsType * varArgsType ) override final; -
src/Common/PassVisitor.impl.h
r63bde81 r12a1013 3610 3610 3611 3611 //-------------------------------------------------------------------------- 3612 // VTableType3613 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 here3618 // 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 here3629 // 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 here3640 // maybeMutate_impl( node->forall, *this );3641 maybeMutate_impl( node->base, *this );3642 3643 MUTATE_END( Type, node );3644 }3645 3646 //--------------------------------------------------------------------------3647 3612 // AttrType 3648 3613 template< typename pass_type > -
src/GenPoly/Box.cc
r63bde81 r12a1013 1546 1546 long i = 0; 1547 1547 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; 1572 1555 } 1573 1556 return -1; -
src/Parser/DeclarationNode.cc
r63bde81 r12a1013 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 14 17:36:57202113 // Update Count : 11 5412 // Last Modified On : Tue Mar 23 08:44:08 2021 13 // Update Count : 1149 14 14 // 15 15 … … 385 385 newnode->type = new TypeData( basetypeof ? TypeData::Basetypeof : TypeData::Typeof ); 386 386 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 );394 387 return newnode; 395 388 } -
src/Parser/ParseNode.h
r63bde81 r12a1013 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 14 17:28:53202113 // Update Count : 90012 // Last Modified On : Fri Mar 12 15:19:04 2021 13 // Update Count : 897 14 14 // 15 15 … … 249 249 static DeclarationNode * newTuple( DeclarationNode * members ); 250 250 static DeclarationNode * newTypeof( ExpressionNode * expr, bool basetypeof = false ); 251 static DeclarationNode * newVtableType( DeclarationNode * expr );252 251 static DeclarationNode * newAttribute( const std::string *, ExpressionNode * expr = nullptr ); // gcc attributes 253 252 static DeclarationNode * newDirectiveStmt( StatementNode * stmt ); // gcc external directive statement -
src/Parser/TypeData.cc
r63bde81 r12a1013 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 14 18:57:31 202113 // Update Count : 6 7212 // Last Modified On : Mon Dec 16 07:56:46 2019 13 // Update Count : 662 14 14 // 15 15 … … 100 100 typeexpr = nullptr; 101 101 break; 102 case Vtable:103 break;104 102 case Builtin: 105 103 // builtin = new Builtin_t; … … 172 170 // delete typeexpr->expr; 173 171 delete typeexpr; 174 break;175 case Vtable:176 172 break; 177 173 case Builtin: … … 253 249 case Basetypeof: 254 250 newtype->typeexpr = maybeClone( typeexpr ); 255 break;256 case Vtable:257 251 break; 258 252 case Builtin: … … 473 467 case Basetypeof: 474 468 case Builtin: 475 case Vtable:476 469 assertf(false, "Tried to get leaf name from kind without a name: %d", kind); 477 470 break; … … 553 546 case TypeData::Basetypeof: 554 547 return buildTypeof( td ); 555 case TypeData::Vtable:556 return buildVtable( td );557 548 case TypeData::Builtin: 558 549 switch ( td->builtintype ) { … … 954 945 assert( td->typeexpr ); 955 946 // 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 }; 957 949 } // buildTypeof 958 959 960 VTableType * buildVtable( const TypeData * td ) {961 assert( td->base );962 return new VTableType{ buildQualifiers( td ), typebuild( td->base ) };963 } // buildVtable964 950 965 951 -
src/Parser/TypeData.h
r63bde81 r12a1013 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 14 17:44:05 202113 // Update Count : 20 212 // Last Modified On : Sat Mar 27 09:05:35 2021 13 // Update Count : 200 14 14 // 15 15 … … 27 27 struct TypeData { 28 28 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 }; 30 30 31 31 struct Aggregate_t { … … 128 128 TupleType * buildTuple( const TypeData * ); 129 129 TypeofType * buildTypeof( const TypeData * ); 130 VTableType * buildVtable( const TypeData * );131 130 Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, Expression * asmName, 132 131 Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); -
src/Parser/parser.yy
r63bde81 r12a1013 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jul 14 17:27:54202113 // Update Count : 50 3012 // Last Modified On : Tue Jun 29 09:12:47 2021 13 // Update Count : 5027 14 14 // 15 15 … … 1923 1923 1924 1924 vtable: 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; } 1928 1927 ; 1929 1928 -
src/SynTree/Mutator.h
r63bde81 r12a1013 112 112 virtual Type * mutate( TupleType * tupleType ) = 0; 113 113 virtual Type * mutate( TypeofType * typeofType ) = 0; 114 virtual Type * mutate( VTableType * vtableType ) = 0;115 114 virtual Type * mutate( AttrType * attrType ) = 0; 116 115 virtual Type * mutate( VarArgsType * varArgsType ) = 0; -
src/SynTree/SynTree.h
r63bde81 r12a1013 119 119 class TupleType; 120 120 class TypeofType; 121 class VTableType;122 121 class AttrType; 123 122 class VarArgsType; -
src/SynTree/Type.cc
r63bde81 r12a1013 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Jul 14 15:47:00 202113 // Update Count : 5011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Dec 15 16:52:37 2019 13 // Update Count : 49 14 14 // 15 15 #include "Type.h" … … 178 178 } 179 179 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 } // if199 }200 201 180 // Local Variables: // 202 181 // tab-width: 4 // -
src/SynTree/Type.h
r63bde81 r12a1013 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jul 14 15:40:00 202113 // Update Count : 17 112 // Last Modified On : Wed Sep 4 09:58:00 2019 13 // Update Count : 170 14 14 // 15 15 … … 651 651 }; 652 652 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 672 653 class AttrType : public Type { 673 654 public: -
src/SynTree/Visitor.h
r63bde81 r12a1013 198 198 virtual void visit( TypeofType * node ) { visit( const_cast<const TypeofType *>(node) ); } 199 199 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;202 200 virtual void visit( AttrType * node ) { visit( const_cast<const AttrType *>(node) ); } 203 201 virtual void visit( const AttrType * attrType ) = 0; -
tests/.expect/polymorphism.txt
r63bde81 r12a1013 1 1 123 456 456 2 2 5 5 3 === checkPlan9offsets4 static:5 offset of inner double: 86 offset of inner float: 167 dynamic:8 offset of inner double: 89 offset of inner float: 16 -
tests/polymorphism.cfa
r63bde81 r12a1013 54 54 b.i = s.i; 55 55 return b.j; 56 }57 58 void checkPlan9offsets() {59 60 forall( T )61 struct thing {62 T q; // variable-sized padding63 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_OFFSETS76 }77 78 forall( T )79 void showDynamic( thing(T) & x ) {80 printf("dynamic:\n");81 SHOW_OFFSETS82 }83 84 #undef SHOW_OFFSETS85 86 printf("=== checkPlan9offsets\n");87 thing(int) x;88 showStatic(x);89 showDynamic(x);90 56 } 91 57 … … 148 114 assertf(ret == u.f2, "union operation fails in polymorphic context."); 149 115 } 150 151 checkPlan9offsets();152 116 } 153 117 -
tests/unified_locking/mutex_test.hfa
r63bde81 r12a1013 8 8 struct MutexObj { 9 9 LOCK l; 10 thread$* id;10 $thread * id; 11 11 uint32_t sum; 12 12 }; … … 22 22 23 23 uint32_t cs() { 24 thread$* me = active_thread();24 $thread * me = active_thread(); 25 25 uint32_t value; 26 26 lock(mo.l);
Note:
See TracChangeset
for help on using the changeset viewer.