Changeset 63bde81
- Timestamp:
- Jul 19, 2021, 4:03:19 PM (3 years ago)
- 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. - Files:
-
- 8 added
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/andrew_beach_MMath/code/cond-catch.cpp
r12a1013 r63bde81 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
r12a1013 r63bde81 12 12 13 13 void throw_exception() { 14 throw (empty_exception){&empty_vt};14 throwResume (empty_exception){&empty_vt}; 15 15 } 16 16 … … 18 18 try { 19 19 throw_exception(); 20 } catch (empty_exception * exc ; should_catch) {20 } catchResume (empty_exception * exc ; should_catch) { 21 21 // ... 22 22 } … … 36 36 try { 37 37 cond_catch(); 38 } catch (empty_exception * exc) {38 } catchResume (empty_exception * exc) { 39 39 // ... 40 40 } -
doc/theses/andrew_beach_MMath/code/resume-empty.cfa
r12a1013 r63bde81 13 13 unwind_empty(frames - 1); 14 14 } else { 15 throw (empty_exception){&empty_vt};15 throwResume (empty_exception){&empty_vt}; 16 16 } 17 17 } … … 31 31 try { 32 32 unwind_empty(total_frames); 33 } catch (empty_exception *) {33 } catchResume (empty_exception *) { 34 34 // ... 35 35 } -
doc/theses/andrew_beach_MMath/code/test.sh
r12a1013 r63bde81 18 18 *.cfa) 19 19 # 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}" 21 21 ;; 22 22 *.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" 24 24 ;; 25 25 *.java) … … 39 39 exit 0 40 40 elif [ 2 -eq "$#" ]; then 41 42 41 TEST_LANG="$1" 42 TEST_CASE="$2" 43 43 else 44 45 44 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" 60 61 ;; 61 62 cond-match-none) … … 64 65 CPP="./cond-catch-cpp $ITERATIONS 0" 65 66 JAVA="java CondCatch $ITERATIONS 0" 67 PYTHON="./cond_catch.py $ITERATIONS 0" 66 68 ;; 67 69 cross-catch) … … 70 72 CPP="./cross-catch-cpp $ITERATIONS" 71 73 JAVA="java CrossCatch $ITERATIONS" 74 PYTHON="./cross_catch.py $ITERATIONS" 72 75 ;; 73 76 cross-finally) … … 76 79 CPP=unsupported 77 80 JAVA="java CrossFinally $ITERATIONS" 81 PYTHON="./cross_finally.py $ITERATIONS" 78 82 ;; 79 83 raise-detor) … … 82 86 CPP="./throw-detor-cpp $ITERATIONS $STACK_HEIGHT" 83 87 JAVA=unsupported 88 PYTHON=unsupported 84 89 ;; 85 90 raise-empty) … … 88 93 CPP="./throw-empty-cpp $ITERATIONS $STACK_HEIGHT" 89 94 JAVA="java ThrowEmpty $ITERATIONS $STACK_HEIGHT" 95 PYTHON="./throw_empty.py $ITERATIONS $STACK_HEIGHT" 90 96 ;; 91 97 raise-finally) … … 94 100 CPP=unsupported 95 101 JAVA="java ThrowFinally $ITERATIONS $STACK_HEIGHT" 102 PYTHON="./throw_finally.py $ITERATIONS $STACK_HEIGHT" 96 103 ;; 97 104 raise-other) … … 100 107 CPP="./throw-other-cpp $ITERATIONS $STACK_HEIGHT" 101 108 JAVA="java ThrowOther $ITERATIONS $STACK_HEIGHT" 109 PYTHON="./throw_other.py $ITERATIONS $STACK_HEIGHT" 102 110 ;; 103 111 *) … … 112 120 cpp) echo $CPP; $CPP;; 113 121 java) echo $JAVA; $JAVA;; 122 python) echo $PYTHON; $PYTHON;; 114 123 *) 115 124 echo "No such language: $TEST_LANG" >&2 116 125 exit 2 126 ;; 117 127 esac -
doc/theses/andrew_beach_MMath/intro.tex
r12a1013 r63bde81 107 107 108 108 Exception handling is not a new concept, 109 with papers on the subject dating back 70s. 110 111 Their were popularised by \Cpp, 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, 112 115 which added them in its first major wave of non-object-orientated features 113 116 in 1990. 114 117 % 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. 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. 118 133 Checked exceptions are part of the function interface they are raised from. 119 134 This includes functions they propogate through, until a handler for that … … 131 146 Resumption exceptions have been much less popular. 132 147 Although resumption has a history as old as termination's, very few 133 programming languages have implement them.148 programming languages have implemented them. 134 149 % http://bitsavers.informatik.uni-stuttgart.de/pdf/xerox/parc/techReports/ 135 150 % CSL-79-3_Mesa_Language_Manual_Version_5.0.pdf 136 Mesa is one programming languages that did and experiance with that137 languagesis quoted as being one of the reasons resumptions were not151 Mesa is one programming languages that did. Experiance with Mesa 152 is quoted as being one of the reasons resumptions were not 138 153 included in the \Cpp standard. 139 154 % 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. 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. 152 178 153 179 %\subsection 154 180 More 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. 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. 160 184 % 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 is162 only a catch-all function with \code{Go}{recover()}. 163 So exceptions still are appearing, just in reduced forms.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. 164 188 165 189 %\subsection -
driver/cc1.cc
r12a1013 r63bde81 10 10 // Created On : Fri Aug 26 14:23:51 2005 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jun 1 23:07:21202113 // Update Count : 41 512 // Last Modified On : Wed Jul 14 15:42:08 2021 13 // Update Count : 418 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
r12a1013 r63bde81 10 10 // Created On : Tue Aug 20 13:44:49 2002 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jan 16 07:30:19202113 // Update Count : 4 4212 // Last Modified On : Wed Jul 14 21:55:12 2021 13 // Update Count : 467 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 } 100 } // if 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] ); 190 Putenv( argv, argv[i] ); // make available for cc1 191 191 } 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 193 200 } else { // CFA specific arguments 201 assert( false ); // this does not make sense 194 202 args[nargs++] = argv[i]; 195 203 } // if … … 364 372 args[nargs++] = "stdbool.h"; 365 373 366 if ( compiling_libs ) {374 if ( compiling_libs ) { 367 375 Putenv( argv, "-t" ); 368 376 } // if -
src/AST/Convert.cpp
r12a1013 r63bde81 9 9 // Author : Thierry Delisle 10 10 // Created On : Thu May 09 15::37::05 2019 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Mar 12 18:43:51202113 // Update Count : 3 611 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jul 14 16:15:00 2021 13 // Update Count : 37 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 1358 1365 const ast::Type * visit( const ast::VarArgsType * node ) override final { 1359 1366 return visitType( node, new VarArgsType{ cv( node ) } ); … … 2799 2806 } 2800 2807 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 2801 2815 virtual void visit( const AttrType * ) override final { 2802 2816 assertf( false, "AttrType deprecated in new AST." ); -
src/AST/Fwd.hpp
r12a1013 r63bde81 117 117 class TupleType; 118 118 class TypeofType; 119 class VTableType; 119 120 class VarArgsType; 120 121 class ZeroType; -
src/AST/Pass.hpp
r12a1013 r63bde81 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; 215 216 const ast::Type * visit( const ast::VarArgsType * ) override final; 216 217 const ast::Type * visit( const ast::ZeroType * ) override final; -
src/AST/Pass.impl.hpp
r12a1013 r63bde81 1873 1873 1874 1874 //-------------------------------------------------------------------------- 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 //-------------------------------------------------------------------------- 1875 1888 // VarArgsType 1876 1889 template< typename core_t > -
src/AST/Print.cpp
r12a1013 r63bde81 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 1418 1426 virtual const ast::Type * visit( const ast::VarArgsType * node ) override final { 1419 1427 preprint( node ); -
src/AST/Type.hpp
r12a1013 r63bde81 10 10 // Created On : Thu May 9 10:00:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thu Jul 23 14:15:00 202013 // Update Count : 612 // Last Modified On : Wed Jul 14 15:54:00 2021 13 // Update Count : 7 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_FRIEND 504 }; 505 493 506 /// GCC built-in varargs type 494 507 class VarArgsType final : public Type { -
src/AST/Visitor.hpp
r12a1013 r63bde81 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; 107 108 virtual const ast::Type * visit( const ast::VarArgsType * ) = 0; 108 109 virtual const ast::Type * visit( const ast::ZeroType * ) = 0; -
src/Common/CodeLocationTools.cpp
r12a1013 r63bde81 176 176 macro(TupleType, Type) \ 177 177 macro(TypeofType, Type) \ 178 macro(VTableType, Type) \ 178 179 macro(VarArgsType, Type) \ 179 180 macro(ZeroType, Type) \ -
src/Common/PassVisitor.h
r12a1013 r63bde81 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; 232 234 virtual void visit( AttrType * attrType ) override final; 233 235 virtual void visit( const AttrType * attrType ) override final; … … 343 345 virtual Type * mutate( TupleType * tupleType ) override final; 344 346 virtual Type * mutate( TypeofType * typeofType ) override final; 347 virtual Type * mutate( VTableType * vtableType ) override final; 345 348 virtual Type * mutate( AttrType * attrType ) override final; 346 349 virtual Type * mutate( VarArgsType * varArgsType ) override final; -
src/Common/PassVisitor.impl.h
r12a1013 r63bde81 3610 3610 3611 3611 //-------------------------------------------------------------------------- 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 //-------------------------------------------------------------------------- 3612 3647 // AttrType 3613 3648 template< typename pass_type > -
src/GenPoly/Box.cc
r12a1013 r63bde81 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() ) 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; 1555 1572 } 1556 1573 return -1; -
src/Parser/DeclarationNode.cc
r12a1013 r63bde81 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 23 08:44:08202113 // Update Count : 11 4912 // Last Modified On : Wed Jul 14 17:36:57 2021 13 // Update Count : 1154 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 ); 387 394 return newnode; 388 395 } -
src/Parser/ParseNode.h
r12a1013 r63bde81 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 12 15:19:04202113 // Update Count : 89712 // Last Modified On : Wed Jul 14 17:28:53 2021 13 // Update Count : 900 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 ); 251 252 static DeclarationNode * newAttribute( const std::string *, ExpressionNode * expr = nullptr ); // gcc attributes 252 253 static DeclarationNode * newDirectiveStmt( StatementNode * stmt ); // gcc external directive statement -
src/Parser/TypeData.cc
r12a1013 r63bde81 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Dec 16 07:56:46 201913 // Update Count : 6 6212 // Last Modified On : Wed Jul 14 18:57:31 2021 13 // Update Count : 672 14 14 // 15 15 … … 100 100 typeexpr = nullptr; 101 101 break; 102 case Vtable: 103 break; 102 104 case Builtin: 103 105 // builtin = new Builtin_t; … … 170 172 // delete typeexpr->expr; 171 173 delete typeexpr; 174 break; 175 case Vtable: 172 176 break; 173 177 case Builtin: … … 249 253 case Basetypeof: 250 254 newtype->typeexpr = maybeClone( typeexpr ); 255 break; 256 case Vtable: 251 257 break; 252 258 case Builtin: … … 467 473 case Basetypeof: 468 474 case Builtin: 475 case Vtable: 469 476 assertf(false, "Tried to get leaf name from kind without a name: %d", kind); 470 477 break; … … 546 553 case TypeData::Basetypeof: 547 554 return buildTypeof( td ); 555 case TypeData::Vtable: 556 return buildVtable( td ); 548 557 case TypeData::Builtin: 549 558 switch ( td->builtintype ) { … … 945 954 assert( td->typeexpr ); 946 955 // 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 }; 949 957 } // buildTypeof 958 959 960 VTableType * buildVtable( const TypeData * td ) { 961 assert( td->base ); 962 return new VTableType{ buildQualifiers( td ), typebuild( td->base ) }; 963 } // buildVtable 950 964 951 965 -
src/Parser/TypeData.h
r12a1013 r63bde81 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Mar 27 09:05:35 202113 // Update Count : 20 012 // Last Modified On : Wed Jul 14 17:44:05 2021 13 // Update Count : 202 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, Builtin, GlobalScope, Qualified, Unknown };29 SymbolicInst, Tuple, Typeof, Basetypeof, Vtable, 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 * ); 130 131 Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, Expression * asmName, 131 132 Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); -
src/Parser/parser.yy
r12a1013 r63bde81 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jun 29 09:12:47202113 // Update Count : 50 2712 // Last Modified On : Wed Jul 14 17:27:54 2021 13 // Update Count : 5030 14 14 // 15 15 … … 1923 1923 1924 1924 vtable: 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; } 1927 1928 ; 1928 1929 -
src/SynTree/Mutator.h
r12a1013 r63bde81 112 112 virtual Type * mutate( TupleType * tupleType ) = 0; 113 113 virtual Type * mutate( TypeofType * typeofType ) = 0; 114 virtual Type * mutate( VTableType * vtableType ) = 0; 114 115 virtual Type * mutate( AttrType * attrType ) = 0; 115 116 virtual Type * mutate( VarArgsType * varArgsType ) = 0; -
src/SynTree/SynTree.h
r12a1013 r63bde81 119 119 class TupleType; 120 120 class TypeofType; 121 class VTableType; 121 122 class AttrType; 122 123 class VarArgsType; -
src/SynTree/Type.cc
r12a1013 r63bde81 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sun Dec 15 16:52:37 201913 // Update Count : 4911 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jul 14 15:47:00 2021 13 // Update Count : 50 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 } // if 199 } 200 180 201 // Local Variables: // 181 202 // tab-width: 4 // -
src/SynTree/Type.h
r12a1013 r63bde81 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Sep 4 09:58:00 201913 // Update Count : 17 012 // Last Modified On : Wed Jul 14 15:40:00 2021 13 // Update Count : 171 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 653 672 class AttrType : public Type { 654 673 public: -
src/SynTree/Visitor.h
r12a1013 r63bde81 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; 200 202 virtual void visit( AttrType * node ) { visit( const_cast<const AttrType *>(node) ); } 201 203 virtual void visit( const AttrType * attrType ) = 0; -
tests/.expect/polymorphism.txt
r12a1013 r63bde81 1 1 123 456 456 2 2 5 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
r12a1013 r63bde81 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 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); 56 90 } 57 91 … … 114 148 assertf(ret == u.f2, "union operation fails in polymorphic context."); 115 149 } 150 151 checkPlan9offsets(); 116 152 } 117 153 -
tests/unified_locking/mutex_test.hfa
r12a1013 r63bde81 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.