Changes in / [2ed94a9:997185e]
- Files:
-
- 22 deleted
- 61 edited
-
libcfa/prelude/builtins.c (modified) (2 diffs)
-
libcfa/prelude/prelude-gen.cc (modified) (2 diffs)
-
libcfa/src/Makefile.am (modified) (1 diff)
-
libcfa/src/bits/containers.hfa (modified) (2 diffs)
-
libcfa/src/concurrency/actor.hfa (deleted)
-
libcfa/src/concurrency/coroutine.hfa (modified) (2 diffs)
-
libcfa/src/concurrency/locks.hfa (modified) (3 diffs)
-
libcfa/src/concurrency/monitor.hfa (modified) (2 diffs)
-
libcfa/src/concurrency/mutex.hfa (modified) (2 diffs)
-
libcfa/src/concurrency/thread.hfa (modified) (2 diffs)
-
libcfa/src/containers/list.hfa (modified) (2 diffs)
-
libcfa/src/containers/vector.hfa (modified) (2 diffs)
-
libcfa/src/exception.h (modified) (3 diffs)
-
libcfa/src/iostream.hfa (modified) (7 diffs)
-
libcfa/src/iterator.hfa (modified) (3 diffs)
-
libcfa/src/math.trait.hfa (modified) (6 diffs)
-
libcfa/src/stdlib.hfa (modified) (2 diffs)
-
src/AST/Expr.cpp (modified) (1 diff)
-
src/AST/Node.hpp (modified) (2 diffs)
-
src/AST/SymbolTable.cpp (modified) (2 diffs)
-
src/Common/ScopedMap.h (modified) (6 diffs)
-
src/Common/SemanticError.h (modified) (3 diffs)
-
src/Concurrency/Actors.cpp (deleted)
-
src/Concurrency/Actors.hpp (deleted)
-
src/Concurrency/module.mk (modified) (2 diffs)
-
src/GenPoly/Box.cc (modified) (10 diffs)
-
src/GenPoly/ErasableScopedMap.h (modified) (4 diffs)
-
src/GenPoly/GenPoly.cc (modified) (6 diffs)
-
src/GenPoly/InstantiateGeneric.cc (modified) (1 diff)
-
src/GenPoly/InstantiateGenericNew.cpp (modified) (1 diff)
-
src/GenPoly/ScopedSet.h (modified) (1 diff)
-
src/GenPoly/ScrubTyVars.cc (modified) (1 diff)
-
src/InitTweak/FixInit.cc (modified) (1 diff)
-
src/InitTweak/FixInitNew.cpp (modified) (1 diff)
-
src/InitTweak/InitTweak.cc (modified) (1 diff)
-
src/Parser/lex.ll (modified) (3 diffs)
-
src/Parser/parser.yy (modified) (30 diffs)
-
src/ResolvExpr/AdjustExprType.hpp (deleted)
-
src/ResolvExpr/AlternativeFinder.cc (modified) (3 diffs)
-
src/ResolvExpr/AlternativeFinder.h (modified) (1 diff)
-
src/ResolvExpr/CandidateFinder.cpp (modified) (1 diff)
-
src/ResolvExpr/CandidateFinder.hpp (modified) (1 diff)
-
src/ResolvExpr/CastCost.cc (modified) (2 diffs)
-
src/ResolvExpr/CastCost.hpp (deleted)
-
src/ResolvExpr/CommonType.cc (modified) (1 diff)
-
src/ResolvExpr/CommonType.hpp (deleted)
-
src/ResolvExpr/ConversionCost.cc (modified) (1 diff)
-
src/ResolvExpr/ConversionCost.h (modified) (3 diffs)
-
src/ResolvExpr/PolyCost.hpp (deleted)
-
src/ResolvExpr/PtrsAssignable.cc (modified) (1 diff)
-
src/ResolvExpr/PtrsAssignable.hpp (deleted)
-
src/ResolvExpr/PtrsCastable.cc (modified) (4 diffs)
-
src/ResolvExpr/PtrsCastable.hpp (deleted)
-
src/ResolvExpr/ResolveAssertions.cc (modified) (2 diffs)
-
src/ResolvExpr/SatisfyAssertions.cpp (modified) (1 diff)
-
src/ResolvExpr/SpecCost.hpp (deleted)
-
src/ResolvExpr/Unify.cc (modified) (4 diffs)
-
src/ResolvExpr/Unify.h (modified) (2 diffs)
-
src/ResolvExpr/WidenMode.h (modified) (2 diffs)
-
src/ResolvExpr/module.mk (modified) (4 diffs)
-
src/ResolvExpr/typeops.h (modified) (7 diffs)
-
src/SymTab/Indexer.cc (modified) (1 diff)
-
src/SymTab/Validate.cc (modified) (2 diffs)
-
src/SynTree/ApplicationExpr.cc (modified) (2 diffs)
-
src/Validate/FixReturnTypes.cpp (modified) (1 diff)
-
src/Validate/ReplaceTypedef.cpp (modified) (2 diffs)
-
src/main.cc (modified) (2 diffs)
-
tests/.expect/forall.txt (modified) (1 diff)
-
tests/Makefile.am (modified) (3 diffs)
-
tests/concurrent/actors/.expect/dynamic.txt (deleted)
-
tests/concurrent/actors/.expect/executor.txt (deleted)
-
tests/concurrent/actors/.expect/matrix.txt (deleted)
-
tests/concurrent/actors/.expect/pingpong.txt (deleted)
-
tests/concurrent/actors/.expect/static.txt (deleted)
-
tests/concurrent/actors/.expect/types.txt (deleted)
-
tests/concurrent/actors/dynamic.cfa (deleted)
-
tests/concurrent/actors/executor.cfa (deleted)
-
tests/concurrent/actors/matrix.cfa (deleted)
-
tests/concurrent/actors/pingpong.cfa (deleted)
-
tests/concurrent/actors/static.cfa (deleted)
-
tests/concurrent/actors/types.cfa (deleted)
-
tests/concurrent/channels/parallel_harness.hfa (modified) (2 diffs)
-
tests/forall.cfa (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/prelude/builtins.c
r2ed94a9 r997185e 10 10 // Created On : Fri Jul 21 16:21:03 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:33:56 202313 // Update Count : 13 512 // Last Modified On : Sat Aug 14 08:45:54 2021 13 // Update Count : 133 14 14 // 15 15 … … 64 64 static inline void ^?{}(generator$ &) {} 65 65 66 forall( T & ) 67 trait is_generator { 66 trait is_generator(T &) { 68 67 void main(T & this); 69 68 generator$ * get_generator(T & this); -
libcfa/prelude/prelude-gen.cc
r2ed94a9 r997185e 10 10 // Created On : Sat Feb 16 08:44:58 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 2 11:40:01 202313 // Update Count : 3 812 // Last Modified On : Tue Apr 2 17:18:24 2019 13 // Update Count : 37 14 14 // 15 15 … … 159 159 int main() { 160 160 cout << "# 2 \"prelude.cfa\" // needed for error messages from this file" << endl; 161 cout << " forall( T & ) trait sized{};" << endl;161 cout << "trait sized(T &) {};" << endl; 162 162 163 163 cout << "//////////////////////////" << endl; -
libcfa/src/Makefile.am
r2ed94a9 r997185e 115 115 concurrency/mutex_stmt.hfa \ 116 116 concurrency/select.hfa \ 117 concurrency/channel.hfa \ 118 concurrency/actor.hfa 117 concurrency/channel.hfa 119 118 120 119 inst_thread_headers_src = \ -
libcfa/src/bits/containers.hfa
r2ed94a9 r997185e 10 10 // Created On : Tue Oct 31 16:38:50 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:33:08 202313 // Update Count : 2 912 // Last Modified On : Wed Jan 15 07:42:35 2020 13 // Update Count : 28 14 14 15 15 #pragma once … … 69 69 70 70 #ifdef __cforall 71 forall( T & ) 72 trait is_node { 71 trait is_node(T &) { 73 72 T *& get_next( T & ); 74 73 }; -
libcfa/src/concurrency/coroutine.hfa
r2ed94a9 r997185e 10 10 // Created On : Mon Nov 28 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:31:42 202313 // Update Count : 1 312 // Last Modified On : Thu Jan 6 16:33:16 2022 13 // Update Count : 12 14 14 // 15 15 … … 38 38 // Anything that implements this trait can be resumed. 39 39 // Anything that is resumed is a coroutine. 40 forall( T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled(T)) ) 41 trait is_coroutine { 40 trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled(T))) { 42 41 void main(T & this); 43 42 coroutine$ * get_coroutine(T & this); -
libcfa/src/concurrency/locks.hfa
r2ed94a9 r997185e 511 511 // flag showing if lock is held 512 512 volatile bool held; 513 514 #ifdef __CFA_DEBUG__ 515 // for deadlock detection 516 struct thread$ * owner; 517 #endif 513 518 }; 514 519 … … 521 526 static inline void ?=?( spin_queue_lock & this, spin_queue_lock this2 ) = void; 522 527 523 // if this is called recursively IT WILL DEADLOCK! 528 // if this is called recursively IT WILL DEADLOCK!!!!! 524 529 static inline void lock(spin_queue_lock & this) with(this) { 525 530 mcs_spin_node node; … … 640 645 //----------------------------------------------------------------------------- 641 646 // is_blocking_lock 642 forall( L & | sized(L) ) 643 trait is_blocking_lock { 647 trait is_blocking_lock(L & | sized(L)) { 644 648 // For synchronization locks to use when acquiring 645 649 void on_notify( L &, struct thread$ * ); -
libcfa/src/concurrency/monitor.hfa
r2ed94a9 r997185e 10 10 // Created On : Thd Feb 23 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:29:21 202313 // Update Count : 1 212 // Last Modified On : Wed Dec 4 07:55:32 2019 13 // Update Count : 11 14 14 // 15 15 … … 22 22 #include "stdlib.hfa" 23 23 24 forall( T & ) 25 trait is_monitor { 24 trait is_monitor(T &) { 26 25 monitor$ * get_monitor( T & ); 27 26 void ^?{}( T & mutex ); -
libcfa/src/concurrency/mutex.hfa
r2ed94a9 r997185e 12 12 // Created On : Fri May 25 01:24:09 2018 13 13 // Last Modified By : Peter A. Buhr 14 // Last Modified On : Thu Feb 2 11:46:08 202315 // Update Count : 214 // Last Modified On : Wed Dec 4 09:16:53 2019 15 // Update Count : 1 16 16 // 17 17 … … 70 70 void unlock(recursive_mutex_lock & this) __attribute__((deprecated("use concurrency/locks.hfa instead"))); 71 71 72 forall( L & | sized(L) ) 73 trait is_lock { 72 trait is_lock(L & | sized(L)) { 74 73 void lock (L &); 75 74 void unlock(L &); -
libcfa/src/concurrency/thread.hfa
r2ed94a9 r997185e 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 2 11:27:59 202313 // Update Count : 3 712 // Last Modified On : Tue Nov 22 22:18:34 2022 13 // Update Count : 35 14 14 // 15 15 … … 27 27 //----------------------------------------------------------------------------- 28 28 // thread trait 29 forall( T & ) 30 trait is_thread { 29 trait is_thread(T &) { 31 30 void ^?{}(T& mutex this); 32 31 void main(T& this); -
libcfa/src/containers/list.hfa
r2ed94a9 r997185e 9 9 // Author : Michael Brooks 10 10 // Created On : Wed Apr 22 18:00:00 2020 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Thu Feb 2 11:32:26 202313 // Update Count : 211 // Last Modified By : Michael Brooks 12 // Last Modified On : Wed Apr 22 18:00:00 2020 13 // Update Count : 1 14 14 // 15 15 … … 23 23 }; 24 24 25 forall( tOuter &, tMid &, tInner & ) 26 trait embedded { 25 trait embedded( tOuter &, tMid &, tInner & ) { 27 26 tytagref( tMid, tInner ) ?`inner( tOuter & ); 28 27 }; -
libcfa/src/containers/vector.hfa
r2ed94a9 r997185e 10 10 // Created On : Tue Jul 5 18:00:07 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:41:24 202313 // Update Count : 512 // Last Modified On : Wed Jun 17 11:02:46 2020 13 // Update Count : 4 14 14 // 15 15 … … 50 50 //------------------------------------------------------------------------------ 51 51 //Declaration 52 forall( T, allocator_t)53 trait allocator_c{52 trait allocator_c(T, allocator_t) 53 { 54 54 void realloc_storage(allocator_t*, size_t); 55 55 T* data(allocator_t*); -
libcfa/src/exception.h
r2ed94a9 r997185e 9 9 // Author : Andrew Beach 10 10 // Created On : Mon Jun 26 15:11:00 2017 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Th u Feb 2 11:20:19 202313 // Update Count : 1 311 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Apr 8 15:20:00 2021 13 // Update Count : 12 14 14 // 15 15 … … 101 101 // implemented in the .c file either so they all have to be inline. 102 102 103 forall( exceptT &, virtualT & ) 104 trait is_exception { 103 trait is_exception(exceptT &, virtualT &) { 105 104 /* The first field must be a pointer to a virtual table. 106 105 * That virtual table must be a decendent of the base exception virtual table. … … 110 109 }; 111 110 112 forall( exceptT &, virtualT & | is_exception(exceptT, virtualT) ) 113 trait is_termination_exception { 111 trait is_termination_exception(exceptT &, virtualT & | is_exception(exceptT, virtualT)) { 114 112 void defaultTerminationHandler(exceptT &); 115 113 }; 116 114 117 forall( exceptT &, virtualT & | is_exception(exceptT, virtualT) ) 118 trait is_resumption_exception { 115 trait is_resumption_exception(exceptT &, virtualT & | is_exception(exceptT, virtualT)) { 119 116 void defaultResumptionHandler(exceptT &); 120 117 }; -
libcfa/src/iostream.hfa
r2ed94a9 r997185e 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:25:39 202313 // Update Count : 4 1012 // Last Modified On : Sun Oct 10 10:02:07 2021 13 // Update Count : 407 14 14 // 15 15 … … 22 22 23 23 24 forall( ostype & ) 25 trait basic_ostream { 24 trait basic_ostream( ostype & ) { 26 25 // private 27 26 bool sepPrt$( ostype & ); // get separator state (on/off) … … 52 51 }; // basic_ostream 53 52 54 forall( ostype & | basic_ostream( ostype ) ) 55 trait ostream { 53 trait ostream( ostype & | basic_ostream( ostype ) ) { 56 54 bool fail( ostype & ); // operation failed? 57 55 void clear( ostype & ); … … 62 60 }; // ostream 63 61 64 // forall( T ) 65 // trait writeable { 62 // trait writeable( T ) { 66 63 // forall( ostype & | ostream( ostype ) ) ostype & ?|?( ostype &, T ); 67 64 // }; // writeable 68 65 69 forall( T, ostype & | ostream( ostype ) ) 70 trait writeable { 66 trait writeable( T, ostype & | ostream( ostype ) ) { 71 67 ostype & ?|?( ostype &, T ); 72 68 }; // writeable … … 294 290 295 291 296 forall( istype & ) 297 trait basic_istream { 292 trait basic_istream( istype & ) { 298 293 // private 299 294 bool getANL$( istype & ); // get scan newline (on/off) … … 307 302 }; // basic_istream 308 303 309 forall( istype & | basic_istream( istype ) ) 310 trait istream { 304 trait istream( istype & | basic_istream( istype ) ) { 311 305 bool fail( istype & ); 312 306 void clear( istype & ); … … 316 310 }; // istream 317 311 318 forall( T ) 319 trait readable { 312 trait readable( T ) { 320 313 forall( istype & | istream( istype ) ) istype & ?|?( istype &, T ); 321 314 }; // readable -
libcfa/src/iterator.hfa
r2ed94a9 r997185e 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:21:50 202313 // Update Count : 1 112 // Last Modified On : Fri Jul 7 08:37:25 2017 13 // Update Count : 10 14 14 // 15 15 … … 17 17 18 18 // An iterator can be used to traverse a data structure. 19 forall( iterator_type, elt_type ) 20 trait iterator { 19 trait iterator( iterator_type, elt_type ) { 21 20 // point to the next element 22 21 // iterator_type ?++( iterator_type & ); … … 32 31 }; 33 32 34 forall( iterator_type, collection_type, elt_type | iterator( iterator_type, elt_type ) ) 35 trait iterator_for { 33 trait iterator_for( iterator_type, collection_type, elt_type | iterator( iterator_type, elt_type ) ) { 36 34 // [ iterator_type begin, iterator_type end ] get_iterators( collection_type ); 37 35 iterator_type begin( collection_type ); -
libcfa/src/math.trait.hfa
r2ed94a9 r997185e 10 10 // Created On : Fri Jul 16 15:40:52 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Feb 2 11:36:56 202313 // Update Count : 2012 // Last Modified On : Tue Jul 20 17:47:19 2021 13 // Update Count : 19 14 14 // 15 15 16 16 #pragma once 17 17 18 forall( U ) 19 trait Not { 18 trait Not( U ) { 20 19 void ?{}( U &, zero_t ); 21 20 int !?( U ); 22 21 }; // Not 23 22 24 forall( T | Not( T ) ) 25 trait Equality { 23 trait Equality( T | Not( T ) ) { 26 24 int ?==?( T, T ); 27 25 int ?!=?( T, T ); 28 26 }; // Equality 29 27 30 forall( U | Equality( U ) ) 31 trait Relational { 28 trait Relational( U | Equality( U ) ) { 32 29 int ?<?( U, U ); 33 30 int ?<=?( U, U ); … … 36 33 }; // Relational 37 34 38 forall ( T ) 39 trait Signed { 35 trait Signed( T ) { 40 36 T +?( T ); 41 37 T -?( T ); … … 43 39 }; // Signed 44 40 45 forall( U | Signed( U ) ) 46 trait Additive { 41 trait Additive( U | Signed( U ) ) { 47 42 U ?+?( U, U ); 48 43 U ?-?( U, U ); … … 51 46 }; // Additive 52 47 53 forall( T | Additive( T ) ) 54 trait Incdec { 48 trait Incdec( T | Additive( T ) ) { 55 49 void ?{}( T &, one_t ); 56 50 // T ?++( T & ); … … 60 54 }; // Incdec 61 55 62 forall( U | Incdec( U ) ) 63 trait Multiplicative { 56 trait Multiplicative( U | Incdec( U ) ) { 64 57 U ?*?( U, U ); 65 58 U ?/?( U, U ); … … 68 61 }; // Multiplicative 69 62 70 forall( T | Relational( T ) | Multiplicative( T ) ) 71 trait Arithmetic { 63 trait Arithmetic( T | Relational( T ) | Multiplicative( T ) ) { 72 64 }; // Arithmetic 73 65 -
libcfa/src/stdlib.hfa
r2ed94a9 r997185e 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:30:04 202313 // Update Count : 76 612 // Last Modified On : Sun Dec 11 18:25:53 2022 13 // Update Count : 765 14 14 // 15 15 … … 404 404 // calls( sprng ); 405 405 406 forall( PRNG &, R ) 407 trait basic_prng { 406 trait basic_prng( PRNG &, R ) { 408 407 void set_seed( PRNG & prng, R seed ); // set seed 409 408 R get_seed( PRNG & prng ); // get seed -
src/AST/Expr.cpp
r2ed94a9 r997185e 30 30 #include "Common/SemanticError.h" 31 31 #include "GenPoly/Lvalue.h" // for referencesPermissable 32 #include "ResolvExpr/ Unify.h"// for extractResultType32 #include "ResolvExpr/typeops.h" // for extractResultType 33 33 #include "Tuples/Tuples.h" // for makeTupleType 34 34 -
src/AST/Node.hpp
r2ed94a9 r997185e 19 19 #include <cstddef> // for nullptr_t 20 20 #include <iosfwd> 21 #include <type_traits> // for remove_reference 21 22 22 23 #include "Common/ErrorObjects.h" // for SemanticErrorException … … 35 36 Node(const Node&) : strong_count(0), weak_count(0) {} 36 37 Node(Node&&) : strong_count(0), weak_count(0) {} 37 Node& operator= (const Node&) = delete;38 Node& operator= (Node&&) = delete;38 Node& operator= (const Node&) = delete; 39 Node& operator= (Node&&) = delete; 39 40 virtual ~Node() {} 40 41 -
src/AST/SymbolTable.cpp
r2ed94a9 r997185e 22 22 #include "Inspect.hpp" 23 23 #include "Type.hpp" 24 #include "CodeGen/OperatorTable.h" // for isCtorDtorAssign24 #include "CodeGen/OperatorTable.h" // for isCtorDtorAssign 25 25 #include "Common/SemanticError.h" 26 26 #include "Common/Stats/Counter.h" … … 28 28 #include "InitTweak/InitTweak.h" 29 29 #include "ResolvExpr/Cost.h" 30 #include "ResolvExpr/CandidateFinder.hpp" // for referenceToRvalueConversion 31 #include "ResolvExpr/Unify.h" 30 #include "ResolvExpr/typeops.h" 32 31 #include "SymTab/Mangler.h" 33 32 -
src/Common/ScopedMap.h
r2ed94a9 r997185e 37 37 template<typename N> 38 38 Scope(N && n) : map(), note(std::forward<N>(n)) {} 39 39 40 40 Scope() = default; 41 41 Scope(const Scope &) = default; … … 46 46 typedef std::vector< Scope > ScopeList; 47 47 48 /// Scoped list of maps. 49 ScopeList scopes; 48 ScopeList scopes; ///< scoped list of maps 50 49 public: 51 50 typedef typename MapType::key_type key_type; … … 59 58 typedef typename MapType::const_pointer const_pointer; 60 59 61 // Both iterator types are complete bidrectional iterators, see below. 62 class iterator; 63 class const_iterator; 60 class iterator : public std::iterator< std::bidirectional_iterator_tag, value_type > { 61 friend class ScopedMap; 62 friend class const_iterator; 63 typedef typename ScopedMap::MapType::iterator wrapped_iterator; 64 typedef typename ScopedMap::ScopeList scope_list; 65 typedef typename scope_list::size_type size_type; 66 67 /// Checks if this iterator points to a valid item 68 bool is_valid() const { 69 return it != (*scopes)[level].map.end(); 70 } 71 72 /// Increments on invalid 73 iterator & next_valid() { 74 if ( ! is_valid() ) { ++(*this); } 75 return *this; 76 } 77 78 /// Decrements on invalid 79 iterator & prev_valid() { 80 if ( ! is_valid() ) { --(*this); } 81 return *this; 82 } 83 84 iterator(scope_list & _scopes, const wrapped_iterator & _it, size_type inLevel) 85 : scopes(&_scopes), it(_it), level(inLevel) {} 86 public: 87 iterator(const iterator & that) : scopes(that.scopes), it(that.it), level(that.level) {} 88 iterator & operator= (const iterator & that) { 89 scopes = that.scopes; level = that.level; it = that.it; 90 return *this; 91 } 92 93 reference operator* () { return *it; } 94 pointer operator-> () const { return it.operator->(); } 95 96 iterator & operator++ () { 97 if ( it == (*scopes)[level].map.end() ) { 98 if ( level == 0 ) return *this; 99 --level; 100 it = (*scopes)[level].map.begin(); 101 } else { 102 ++it; 103 } 104 return next_valid(); 105 } 106 iterator operator++ (int) { iterator tmp = *this; ++(*this); return tmp; } 107 108 iterator & operator-- () { 109 // may fail if this is the begin iterator; allowed by STL spec 110 if ( it == (*scopes)[level].map.begin() ) { 111 ++level; 112 it = (*scopes)[level].map.end(); 113 } 114 --it; 115 return prev_valid(); 116 } 117 iterator operator-- (int) { iterator tmp = *this; --(*this); return tmp; } 118 119 bool operator== (const iterator & that) const { 120 return scopes == that.scopes && level == that.level && it == that.it; 121 } 122 bool operator!= (const iterator & that) const { return !( *this == that ); } 123 124 size_type get_level() const { return level; } 125 126 Note & get_note() { return (*scopes)[level].note; } 127 const Note & get_note() const { return (*scopes)[level].note; } 128 129 private: 130 scope_list *scopes; 131 wrapped_iterator it; 132 size_type level; 133 }; 134 135 class const_iterator : public std::iterator< std::bidirectional_iterator_tag, 136 value_type > { 137 friend class ScopedMap; 138 typedef typename ScopedMap::MapType::iterator wrapped_iterator; 139 typedef typename ScopedMap::MapType::const_iterator wrapped_const_iterator; 140 typedef typename ScopedMap::ScopeList scope_list; 141 typedef typename scope_list::size_type size_type; 142 143 /// Checks if this iterator points to a valid item 144 bool is_valid() const { 145 return it != (*scopes)[level].map.end(); 146 } 147 148 /// Increments on invalid 149 const_iterator & next_valid() { 150 if ( ! is_valid() ) { ++(*this); } 151 return *this; 152 } 153 154 /// Decrements on invalid 155 const_iterator & prev_valid() { 156 if ( ! is_valid() ) { --(*this); } 157 return *this; 158 } 159 160 const_iterator(scope_list const & _scopes, const wrapped_const_iterator & _it, size_type inLevel) 161 : scopes(&_scopes), it(_it), level(inLevel) {} 162 public: 163 const_iterator(const iterator & that) : scopes(that.scopes), it(that.it), level(that.level) {} 164 const_iterator(const const_iterator & that) : scopes(that.scopes), it(that.it), level(that.level) {} 165 const_iterator & operator= (const iterator & that) { 166 scopes = that.scopes; level = that.level; it = that.it; 167 return *this; 168 } 169 const_iterator & operator= (const const_iterator & that) { 170 scopes = that.scopes; level = that.level; it = that.it; 171 return *this; 172 } 173 174 const_reference operator* () { return *it; } 175 const_pointer operator-> () { return it.operator->(); } 176 177 const_iterator & operator++ () { 178 if ( it == (*scopes)[level].map.end() ) { 179 if ( level == 0 ) return *this; 180 --level; 181 it = (*scopes)[level].map.begin(); 182 } else { 183 ++it; 184 } 185 return next_valid(); 186 } 187 const_iterator operator++ (int) { const_iterator tmp = *this; ++(*this); return tmp; } 188 189 const_iterator & operator-- () { 190 // may fail if this is the begin iterator; allowed by STL spec 191 if ( it == (*scopes)[level].map.begin() ) { 192 ++level; 193 it = (*scopes)[level].map.end(); 194 } 195 --it; 196 return prev_valid(); 197 } 198 const_iterator operator-- (int) { const_iterator tmp = *this; --(*this); return tmp; } 199 200 bool operator== (const const_iterator & that) const { 201 return scopes == that.scopes && level == that.level && it == that.it; 202 } 203 bool operator!= (const const_iterator & that) const { return !( *this == that ); } 204 205 size_type get_level() const { return level; } 206 207 const Note & get_note() const { return (*scopes)[level].note; } 208 209 private: 210 scope_list const *scopes; 211 wrapped_const_iterator it; 212 size_type level; 213 }; 64 214 65 215 /// Starts a new scope … … 147 297 } 148 298 299 template< typename value_type_t > 300 std::pair< iterator, bool > insert( iterator at, value_type_t && value ) { 301 MapType & scope = (*at.scopes)[ at.level ].map; 302 std::pair< typename MapType::iterator, bool > res = scope.insert( std::forward<value_type_t>( value ) ); 303 return std::make_pair( iterator(scopes, std::move( res.first ), at.level), std::move( res.second ) ); 304 } 305 149 306 template< typename value_t > 150 307 std::pair< iterator, bool > insert( const Key & key, value_t && value ) { return insert( std::make_pair( key, std::forward<value_t>( value ) ) ); } … … 167 324 } 168 325 169 /// Erases element with key in the innermost scope that has it. 170 size_type erase( const Key & key ) { 171 for ( auto it = scopes.rbegin() ; it != scopes.rend() ; ++it ) { 172 size_type i = it->map.erase( key ); 173 if ( 0 != i ) return i; 174 } 175 return 0; 326 iterator erase( iterator pos ) { 327 MapType & scope = (*pos.scopes)[ pos.level ].map; 328 const typename iterator::wrapped_iterator & new_it = scope.erase( pos.it ); 329 iterator it( *pos.scopes, new_it, pos.level ); 330 return it.next_valid(); 176 331 } 177 332 … … 188 343 return c; 189 344 } 190 191 bool contains( const Key & key ) const {192 return find( key ) != cend();193 }194 };195 196 template<typename Key, typename Value, typename Note>197 class ScopedMap<Key, Value, Note>::iterator :198 public std::iterator< std::bidirectional_iterator_tag, value_type > {199 friend class ScopedMap;200 friend class const_iterator;201 typedef typename ScopedMap::MapType::iterator wrapped_iterator;202 typedef typename ScopedMap::ScopeList scope_list;203 typedef typename scope_list::size_type size_type;204 205 /// Checks if this iterator points to a valid item206 bool is_valid() const {207 return it != (*scopes)[level].map.end();208 }209 210 /// Increments on invalid211 iterator & next_valid() {212 if ( ! is_valid() ) { ++(*this); }213 return *this;214 }215 216 /// Decrements on invalid217 iterator & prev_valid() {218 if ( ! is_valid() ) { --(*this); }219 return *this;220 }221 222 iterator(scope_list & _scopes, const wrapped_iterator & _it, size_type inLevel)223 : scopes(&_scopes), it(_it), level(inLevel) {}224 public:225 iterator(const iterator & that) : scopes(that.scopes), it(that.it), level(that.level) {}226 iterator & operator= (const iterator & that) {227 scopes = that.scopes; level = that.level; it = that.it;228 return *this;229 }230 231 reference operator* () { return *it; }232 pointer operator-> () const { return it.operator->(); }233 234 iterator & operator++ () {235 if ( it == (*scopes)[level].map.end() ) {236 if ( level == 0 ) return *this;237 --level;238 it = (*scopes)[level].map.begin();239 } else {240 ++it;241 }242 return next_valid();243 }244 iterator operator++ (int) { iterator tmp = *this; ++(*this); return tmp; }245 246 iterator & operator-- () {247 // may fail if this is the begin iterator; allowed by STL spec248 if ( it == (*scopes)[level].map.begin() ) {249 ++level;250 it = (*scopes)[level].map.end();251 }252 --it;253 return prev_valid();254 }255 iterator operator-- (int) { iterator tmp = *this; --(*this); return tmp; }256 257 bool operator== (const iterator & that) const {258 return scopes == that.scopes && level == that.level && it == that.it;259 }260 bool operator!= (const iterator & that) const { return !( *this == that ); }261 262 size_type get_level() const { return level; }263 264 Note & get_note() { return (*scopes)[level].note; }265 const Note & get_note() const { return (*scopes)[level].note; }266 267 private:268 scope_list *scopes;269 wrapped_iterator it;270 size_type level;271 };272 273 template<typename Key, typename Value, typename Note>274 class ScopedMap<Key, Value, Note>::const_iterator :275 public std::iterator< std::bidirectional_iterator_tag, value_type > {276 friend class ScopedMap;277 typedef typename ScopedMap::MapType::iterator wrapped_iterator;278 typedef typename ScopedMap::MapType::const_iterator wrapped_const_iterator;279 typedef typename ScopedMap::ScopeList scope_list;280 typedef typename scope_list::size_type size_type;281 282 /// Checks if this iterator points to a valid item283 bool is_valid() const {284 return it != (*scopes)[level].map.end();285 }286 287 /// Increments on invalid288 const_iterator & next_valid() {289 if ( ! is_valid() ) { ++(*this); }290 return *this;291 }292 293 /// Decrements on invalid294 const_iterator & prev_valid() {295 if ( ! is_valid() ) { --(*this); }296 return *this;297 }298 299 const_iterator(scope_list const & _scopes, const wrapped_const_iterator & _it, size_type inLevel)300 : scopes(&_scopes), it(_it), level(inLevel) {}301 public:302 const_iterator(const iterator & that) : scopes(that.scopes), it(that.it), level(that.level) {}303 const_iterator(const const_iterator & that) : scopes(that.scopes), it(that.it), level(that.level) {}304 const_iterator & operator= (const iterator & that) {305 scopes = that.scopes; level = that.level; it = that.it;306 return *this;307 }308 const_iterator & operator= (const const_iterator & that) {309 scopes = that.scopes; level = that.level; it = that.it;310 return *this;311 }312 313 const_reference operator* () { return *it; }314 const_pointer operator-> () { return it.operator->(); }315 316 const_iterator & operator++ () {317 if ( it == (*scopes)[level].map.end() ) {318 if ( level == 0 ) return *this;319 --level;320 it = (*scopes)[level].map.begin();321 } else {322 ++it;323 }324 return next_valid();325 }326 const_iterator operator++ (int) { const_iterator tmp = *this; ++(*this); return tmp; }327 328 const_iterator & operator-- () {329 // may fail if this is the begin iterator; allowed by STL spec330 if ( it == (*scopes)[level].map.begin() ) {331 ++level;332 it = (*scopes)[level].map.end();333 }334 --it;335 return prev_valid();336 }337 const_iterator operator-- (int) { const_iterator tmp = *this; --(*this); return tmp; }338 339 bool operator== (const const_iterator & that) const {340 return scopes == that.scopes && level == that.level && it == that.it;341 }342 bool operator!= (const const_iterator & that) const { return !( *this == that ); }343 344 size_type get_level() const { return level; }345 346 const Note & get_note() const { return (*scopes)[level].note; }347 348 private:349 scope_list const *scopes;350 wrapped_const_iterator it;351 size_type level;352 345 }; 353 346 -
src/Common/SemanticError.h
r2ed94a9 r997185e 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 10:59:10 202313 // Update Count : 3 612 // Last Modified On : Wed May 4 14:08:26 2022 13 // Update Count : 35 14 14 // 15 15 … … 54 54 55 55 constexpr WarningData WarningFormats[] = { 56 {"self-assign" , Severity::Warn , "self assignment of expression: %s" }, 57 {"reference-conversion" , Severity::Warn , "rvalue to reference conversion of rvalue: %s" }, 58 {"qualifiers-zero_t-one_t" , Severity::Warn , "questionable use of type qualifier %s with %s" }, 59 {"aggregate-forward-decl" , Severity::Warn , "forward declaration of nested aggregate: %s" }, 60 {"superfluous-decl" , Severity::Warn , "declaration does not allocate storage: %s" }, 61 {"superfluous-else" , Severity::Warn , "else clause never executed for empty loop conditional" }, 62 {"gcc-attributes" , Severity::Warn , "invalid attribute: %s" }, 63 {"c++-like-copy" , Severity::Warn , "Constructor from reference is not a valid copy constructor" }, 64 {"depreciated-trait-syntax" , Severity::Warn , "trait type-parameters are now specified using the forall clause" }, 56 {"self-assign" , Severity::Warn , "self assignment of expression: %s" }, 57 {"reference-conversion" , Severity::Warn , "rvalue to reference conversion of rvalue: %s" }, 58 {"qualifiers-zero_t-one_t", Severity::Warn , "questionable use of type qualifier %s with %s" }, 59 {"aggregate-forward-decl" , Severity::Warn , "forward declaration of nested aggregate: %s" }, 60 {"superfluous-decl" , Severity::Warn , "declaration does not allocate storage: %s" }, 61 {"superfluous-else" , Severity::Warn , "else clause never executed for empty loop conditional" }, 62 {"gcc-attributes" , Severity::Warn , "invalid attribute: %s" }, 63 {"c++-like-copy" , Severity::Warn , "Constructor from reference is not a valid copy constructor" }, 65 64 }; 66 65 … … 74 73 GccAttributes, 75 74 CppCopy, 76 DeprecTraitSyntax,77 75 NUMBER_OF_WARNINGS, // This MUST be the last warning 78 76 }; -
src/Concurrency/module.mk
r2ed94a9 r997185e 16 16 17 17 SRC += \ 18 Concurrency/Actors.cpp \19 Concurrency/Actors.hpp \20 18 Concurrency/KeywordsNew.cpp \ 21 19 Concurrency/Keywords.cc \ … … 23 21 Concurrency/WaitforNew.cpp \ 24 22 Concurrency/Waitfor.cc \ 25 Concurrency/Waitfor.h 23 Concurrency/Waitfor.h -
src/GenPoly/Box.cc
r2ed94a9 r997185e 14 14 // 15 15 16 #include "Box.h"17 18 16 #include <algorithm> // for mismatch 19 17 #include <cassert> // for assert, strict_dynamic_cast … … 25 23 #include <string> // for string, allocator, basic_string 26 24 #include <utility> // for pair 25 26 #include "Box.h" 27 27 28 28 #include "CodeGen/OperatorTable.h" … … 37 37 #include "InitTweak/InitTweak.h" // for getFunctionName, isAssignment 38 38 #include "Lvalue.h" // for generalizedLvalue 39 #include "ResolvExpr/ Unify.h"// for typesCompatible39 #include "ResolvExpr/typeops.h" // for typesCompatible 40 40 #include "ScopedSet.h" // for ScopedSet, ScopedSet<>::iter... 41 41 #include "ScrubTyVars.h" // for ScrubTyVars … … 488 488 for ( FunctionType const * const funType : functions ) { 489 489 std::string mangleName = mangleAdapterName( funType, scopeTyVars ); 490 if ( !adapters.contains( mangleName) ) {490 if ( adapters.find( mangleName ) == adapters.end() ) { 491 491 std::string adapterName = makeAdapterName( mangleName ); 492 492 adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, new ObjectDecl( adapterName, Type::StorageClasses(), LinkageSpec::C, nullptr, new PointerType( Type::Qualifiers(), makeAdapterType( funType, scopeTyVars ) ), nullptr ) ) ); … … 911 911 912 912 for ( FunctionType const * const funType : functions ) { 913 std::string mangleName = SymTab::Mangler::mangle( funType ); 913 FunctionType *originalFunction = funType->clone(); 914 FunctionType *realFunction = funType->clone(); 915 std::string mangleName = SymTab::Mangler::mangle( realFunction ); 914 916 915 917 // only attempt to create an adapter or pass one as a parameter if we haven't already done so for this 916 918 // pre-substitution parameter function type. 917 919 // The second part of the insert result is "is the value new". 918 if ( !adaptersDone.insert( mangleName ).second ) continue; 919 920 // Apply substitution to type variables to figure out what the adapter's type should look like. 921 assert( env ); 922 FunctionType *realType = funType->clone(); 923 env->apply( realType ); 924 mangleName = SymTab::Mangler::mangle( realType ); 925 mangleName += makePolyMonoSuffix( funType, exprTyVars ); 926 927 typedef ScopedMap< std::string, DeclarationWithType* >::iterator AdapterIter; 928 AdapterIter adapter = adapters.find( mangleName ); 929 if ( adapter == adapters.end() ) { 930 // Adapter has not been created yet in the current scope, so define it. 931 FunctionDecl *newAdapter = makeAdapter( funType, realType, mangleName, exprTyVars ); 932 std::pair< AdapterIter, bool > answer = adapters.insert( mangleName, newAdapter ); 933 adapter = answer.first; 934 stmtsToAddBefore.push_back( new DeclStmt( newAdapter ) ); 920 if ( adaptersDone.insert( mangleName ).second ) { 921 922 // apply substitution to type variables to figure out what the adapter's type should look like 923 assert( env ); 924 env->apply( realFunction ); 925 mangleName = SymTab::Mangler::mangle( realFunction ); 926 mangleName += makePolyMonoSuffix( originalFunction, exprTyVars ); 927 928 typedef ScopedMap< std::string, DeclarationWithType* >::iterator AdapterIter; 929 AdapterIter adapter = adapters.find( mangleName ); 930 if ( adapter == adapters.end() ) { 931 // adapter has not been created yet in the current scope, so define it 932 FunctionDecl *newAdapter = makeAdapter( funType, realFunction, mangleName, exprTyVars ); 933 std::pair< AdapterIter, bool > answer = adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, newAdapter ) ); 934 adapter = answer.first; 935 stmtsToAddBefore.push_back( new DeclStmt( newAdapter ) ); 936 } // if 937 assert( adapter != adapters.end() ); 938 939 // add the appropriate adapter as a parameter 940 appExpr->get_args().push_front( new VariableExpr( adapter->second ) ); 935 941 } // if 936 assert( adapter != adapters.end() );937 938 // Add the appropriate adapter as a parameter.939 appExpr->args.push_front( new VariableExpr( adapter->second ) );940 942 } // for 941 943 } // passAdapters … … 1487 1489 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType* >( ty ) ) { 1488 1490 // do not try to monomorphize generic parameters 1489 if ( scopeTyVars. contains( typeInst->get_name()) && ! genericParams.count( typeInst->name ) ) {1491 if ( scopeTyVars.find( typeInst->get_name() ) != scopeTyVars.end() && ! genericParams.count( typeInst->name ) ) { 1490 1492 // polymorphic aggregate members should be converted into monomorphic members. 1491 1493 // Using char[size_T] here respects the expected sizing rules of an aggregate type. … … 1696 1698 1697 1699 if ( auto typeInst = dynamic_cast< TypeInstType const * >( ty ) ) { 1698 if ( scopeTyVars. contains( typeInst->get_name()) ) {1700 if ( scopeTyVars.find( typeInst->get_name() ) != scopeTyVars.end() ) { 1699 1701 // NOTE assumes here that getting put in the scopeTyVars included having the layout variables set 1700 1702 return true; … … 1704 1706 // check if this type already has a layout generated for it 1705 1707 std::string typeName = mangleType( ty ); 1706 if ( knownLayouts. contains( typeName) ) return true;1708 if ( knownLayouts.find( typeName ) != knownLayouts.end() ) return true; 1707 1709 1708 1710 // check if any of the type parameters have dynamic layout; if none do, this type is (or will be) monomorphized … … 1741 1743 // check if this type already has a layout generated for it 1742 1744 std::string typeName = mangleType( ty ); 1743 if ( knownLayouts. contains( typeName) ) return true;1745 if ( knownLayouts.find( typeName ) != knownLayouts.end() ) return true; 1744 1746 1745 1747 // check if any of the type parameters have dynamic layout; if none do, this type is (or will be) monomorphized … … 1832 1834 } else { 1833 1835 std::string offsetName = offsetofName( mangleType( ty ) ); 1834 if ( knownOffsets. contains( offsetName) ) {1836 if ( knownOffsets.find( offsetName ) != knownOffsets.end() ) { 1835 1837 // use the already-generated offsets for this type 1836 1838 ret = new NameExpr( offsetName ); -
src/GenPoly/ErasableScopedMap.h
r2ed94a9 r997185e 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ErasableScopedMap.h --7 // ScopedMap.h -- 8 8 // 9 9 // Author : Aaron B. Moss … … 51 51 typedef typename Scope::const_pointer const_pointer; 52 52 53 // Both iterator types are complete bidirection al iterators, seebelow.53 // Both iterator types are complete bidirection iterators, defined below. 54 54 class iterator; 55 55 class const_iterator; … … 118 118 std::pair< iterator, bool > insert( const Key &key, const Value &value ) { return insert( std::make_pair( key, value ) ); } 119 119 120 Value& operator[] ( const Key &key ) {121 iterator slot = find( key );122 if ( slot != end() ) return slot->second;123 return insert( key, Value() ).first->second;124 }125 126 120 /// Marks the given element as erased from this scope inward; returns 1 for erased an element, 0 otherwise 127 121 size_type erase( const Key &key ) { … … 136 130 } 137 131 138 bool contains( const Key & key ) const { 139 return find( key ) != cend(); 132 Value& operator[] ( const Key &key ) { 133 iterator slot = find( key ); 134 if ( slot != end() ) return slot->second; 135 return insert( key, Value() ).first->second; 140 136 } 141 137 }; -
src/GenPoly/GenPoly.cc
r2ed94a9 r997185e 24 24 #include <vector> // for vector 25 25 26 #include "AST/Expr.hpp"27 26 #include "AST/Type.hpp" 28 #include "AST/TypeSubstitution.hpp"29 27 #include "GenPoly/ErasableScopedMap.h" // for ErasableScopedMap<>::const_it... 30 28 #include "ResolvExpr/typeops.h" // for flatten … … 172 170 173 171 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) { 174 if ( tyVars. contains( typeInst->get_name()) ) {172 if ( tyVars.find( typeInst->get_name() ) != tyVars.end() ) { 175 173 return type; 176 174 } … … 189 187 190 188 if ( auto typeInst = dynamic_cast< const ast::TypeInstType * >( type ) ) { 191 if ( tyVars.contains( typeInst->typeString() ) ) return type;189 return tyVars.find(typeInst->typeString()) != tyVars.end() ? type : nullptr; 192 190 } else if ( auto arrayType = dynamic_cast< const ast::ArrayType * >( type ) ) { 193 191 return isPolyType( arrayType->base, env ); … … 205 203 206 204 if ( auto inst = dynamic_cast< const ast::TypeInstType * >( type ) ) { 207 if ( typeVars. contains( *inst) ) return type;205 if ( typeVars.find( *inst ) != typeVars.end() ) return type; 208 206 } else if ( auto array = dynamic_cast< const ast::ArrayType * >( type ) ) { 209 207 return isPolyType( array->base, subst ); … … 393 391 394 392 if ( TypeInstType *typeInstType = dynamic_cast< TypeInstType * >( type ) ) { 395 if ( tyVars. contains( typeInstType->get_name()) ) {393 if ( tyVars.find( typeInstType->get_name() ) != tyVars.end() ) { 396 394 return true; 397 395 } … … 492 490 } 493 491 494 /// Flattens a list of types.495 // There is another flattenList in Unify.496 492 void flattenList( vector<ast::ptr<ast::Type>> const & src, 497 493 vector<ast::ptr<ast::Type>> & out ) { -
src/GenPoly/InstantiateGeneric.cc
r2ed94a9 r997185e 28 28 #include "GenPoly.h" // for isPolyType, typesPolyCompatible 29 29 #include "InitTweak/InitTweak.h" 30 #include "ResolvExpr/AdjustExprType.hpp" // for adjustExprType 31 #include "ResolvExpr/Unify.h" // for typesCompatible 30 #include "ResolvExpr/typeops.h" 32 31 #include "ScopedSet.h" // for ScopedSet, ScopedSet<>::iterator 33 32 #include "ScrubTyVars.h" // for ScrubTyVars -
src/GenPoly/InstantiateGenericNew.cpp
r2ed94a9 r997185e 32 32 #include "GenPoly/GenPoly.h" // for isPolyType, typesPolyCompatible 33 33 #include "GenPoly/ScrubTyVars.h" // for scrubAll 34 #include "ResolvExpr/AdjustExprType.hpp" // for adjustExprType 35 #include "ResolvExpr/Unify.h" // for typesCompatible 34 #include "ResolvExpr/typeops.h" // for typesCompatible 36 35 37 36 namespace GenPoly { -
src/GenPoly/ScopedSet.h
r2ed94a9 r997185e 21 21 22 22 namespace GenPoly { 23 24 /// A set where the items are placed into nested scopes; 25 /// inserted items are placed into the innermost scope, lookup looks from the innermost scope outward 26 template<typename Value> 27 class ScopedSet { 28 typedef std::set< Value > Scope; 29 typedef std::vector< Scope > ScopeList; 30 31 /// Scoped list of sets. 32 ScopeList scopes; 33 public: 34 typedef typename Scope::key_type key_type; 35 typedef typename Scope::value_type value_type; 36 typedef typename ScopeList::size_type size_type; 37 typedef typename ScopeList::difference_type difference_type; 38 typedef typename Scope::reference reference; 39 typedef typename Scope::const_reference const_reference; 40 typedef typename Scope::pointer pointer; 41 typedef typename Scope::const_pointer const_pointer; 42 43 // Both iterator types are complete bidirectional iterators, see below. 44 class iterator; 45 class const_iterator; 46 47 /// Starts a new scope 48 void beginScope() { 49 Scope scope; 50 scopes.push_back(scope); 51 } 52 53 /// Ends a scope; invalidates any iterators pointing to elements of that scope 54 void endScope() { 55 scopes.pop_back(); 56 } 57 58 /// Default constructor initializes with one scope 59 ScopedSet() { beginScope(); } 60 61 iterator begin() { return iterator(scopes, scopes.back().begin(), scopes.size()-1).next_valid(); } 62 const_iterator begin() const { return const_iterator(scopes, scopes.back().begin(), scopes.size()-1).next_valid(); } 63 const_iterator cbegin() const { return const_iterator(scopes, scopes.back().begin(), scopes.size()-1).next_valid(); } 64 iterator end() { return iterator(scopes, scopes[0].end(), 0); } 65 const_iterator end() const { return const_iterator(scopes, scopes[0].end(), 0); } 66 const_iterator cend() const { return const_iterator(scopes, scopes[0].end(), 0); } 67 68 /// Gets the index of the current scope (counted from 1) 69 size_type currentScope() const { return scopes.size(); } 70 71 /// Finds the given key in the outermost scope it occurs; returns end() for none such 72 iterator find( const Value &key ) { 73 for ( size_type i = scopes.size() - 1; ; --i ) { 74 typename Scope::iterator val = scopes[i].find( key ); 75 if ( val != scopes[i].end() ) return iterator( scopes, val, i ); 76 if ( i == 0 ) break; 77 } 78 return end(); 79 } 80 const_iterator find( const Value &key ) const { 81 return const_iterator( const_cast< ScopedSet< Value >* >(this)->find( key ) ); 82 } 83 84 /// Finds the given key in the outermost scope inside the given scope where it occurs 85 iterator findNext( const_iterator &it, const Value &key ) { 86 if ( it.i == 0 ) return end(); 23 /// A set where the items are placed into nested scopes; 24 /// inserted items are placed into the innermost scope, lookup looks from the innermost scope outward 25 template<typename Value> 26 class ScopedSet { 27 typedef std::set< Value > Scope; 28 typedef std::vector< Scope > ScopeList; 29 30 ScopeList scopes; ///< scoped list of sets 31 public: 32 typedef typename Scope::key_type key_type; 33 typedef typename Scope::value_type value_type; 34 typedef typename ScopeList::size_type size_type; 35 typedef typename ScopeList::difference_type difference_type; 36 typedef typename Scope::reference reference; 37 typedef typename Scope::const_reference const_reference; 38 typedef typename Scope::pointer pointer; 39 typedef typename Scope::const_pointer const_pointer; 40 41 class iterator : public std::iterator< std::bidirectional_iterator_tag, 42 value_type > { 43 friend class ScopedSet; 44 friend class const_iterator; 45 typedef typename std::set< Value >::iterator wrapped_iterator; 46 typedef typename std::vector< std::set< Value > > scope_list; 47 typedef typename scope_list::size_type size_type; 48 49 /// Checks if this iterator points to a valid item 50 bool is_valid() const { 51 return it != (*scopes)[i].end(); 52 } 53 54 /// Increments on invalid 55 iterator& next_valid() { 56 if ( ! is_valid() ) { ++(*this); } 57 return *this; 58 } 59 60 /// Decrements on invalid 61 iterator& prev_valid() { 62 if ( ! is_valid() ) { --(*this); } 63 return *this; 64 } 65 66 iterator(scope_list const &_scopes, const wrapped_iterator &_it, size_type _i) 67 : scopes(&_scopes), it(_it), i(_i) {} 68 public: 69 iterator(const iterator &that) : scopes(that.scopes), it(that.it), i(that.i) {} 70 iterator& operator= (const iterator &that) { 71 scopes = that.scopes; i = that.i; it = that.it; 72 return *this; 73 } 74 75 reference operator* () { return *it; } 76 pointer operator-> () { return it.operator->(); } 77 78 iterator& operator++ () { 79 if ( it == (*scopes)[i].end() ) { 80 if ( i == 0 ) return *this; 81 --i; 82 it = (*scopes)[i].begin(); 83 } else { 84 ++it; 85 } 86 return next_valid(); 87 } 88 iterator operator++ (int) { iterator tmp = *this; ++(*this); return tmp; } 89 90 iterator& operator-- () { 91 // may fail if this is the begin iterator; allowed by STL spec 92 if ( it == (*scopes)[i].begin() ) { 93 ++i; 94 it = (*scopes)[i].end(); 95 } 96 --it; 97 return prev_valid(); 98 } 99 iterator operator-- (int) { iterator tmp = *this; --(*this); return tmp; } 100 101 bool operator== (const iterator &that) { 102 return scopes == that.scopes && i == that.i && it == that.it; 103 } 104 bool operator!= (const iterator &that) { return !( *this == that ); } 105 106 size_type get_level() const { return i; } 107 108 private: 109 scope_list const *scopes; 110 wrapped_iterator it; 111 size_type i; 112 }; 113 114 class const_iterator : public std::iterator< std::bidirectional_iterator_tag, 115 value_type > { 116 friend class ScopedSet; 117 typedef typename std::set< Value >::iterator wrapped_iterator; 118 typedef typename std::set< Value >::const_iterator wrapped_const_iterator; 119 typedef typename std::vector< std::set< Value > > scope_list; 120 typedef typename scope_list::size_type size_type; 121 122 /// Checks if this iterator points to a valid item 123 bool is_valid() const { 124 return it != (*scopes)[i].end(); 125 } 126 127 /// Increments on invalid 128 const_iterator& next_valid() { 129 if ( ! is_valid() ) { ++(*this); } 130 return *this; 131 } 132 133 /// Decrements on invalid 134 const_iterator& prev_valid() { 135 if ( ! is_valid() ) { --(*this); } 136 return *this; 137 } 138 139 const_iterator(scope_list const &_scopes, const wrapped_const_iterator &_it, size_type _i) 140 : scopes(&_scopes), it(_it), i(_i) {} 141 public: 142 const_iterator(const iterator &that) : scopes(that.scopes), it(that.it), i(that.i) {} 143 const_iterator(const const_iterator &that) : scopes(that.scopes), it(that.it), i(that.i) {} 144 const_iterator& operator= (const iterator &that) { 145 scopes = that.scopes; i = that.i; it = that.it; 146 return *this; 147 } 148 const_iterator& operator= (const const_iterator &that) { 149 scopes = that.scopes; i = that.i; it = that.it; 150 return *this; 151 } 152 153 const_reference operator* () { return *it; } 154 const_pointer operator-> () { return it.operator->(); } 155 156 const_iterator& operator++ () { 157 if ( it == (*scopes)[i].end() ) { 158 if ( i == 0 ) return *this; 159 --i; 160 it = (*scopes)[i].begin(); 161 } else { 162 ++it; 163 } 164 return next_valid(); 165 } 166 const_iterator operator++ (int) { const_iterator tmp = *this; ++(*this); return tmp; } 167 168 const_iterator& operator-- () { 169 // may fail if this is the begin iterator; allowed by STL spec 170 if ( it == (*scopes)[i].begin() ) { 171 ++i; 172 it = (*scopes)[i].end(); 173 } 174 --it; 175 return prev_valid(); 176 } 177 const_iterator operator-- (int) { const_iterator tmp = *this; --(*this); return tmp; } 178 179 bool operator== (const const_iterator &that) { 180 return scopes == that.scopes && i == that.i && it == that.it; 181 } 182 bool operator!= (const const_iterator &that) { return !( *this == that ); } 183 184 size_type get_level() const { return i; } 185 186 private: 187 scope_list const *scopes; 188 wrapped_const_iterator it; 189 size_type i; 190 }; 191 192 /// Starts a new scope 193 void beginScope() { 194 Scope scope; 195 scopes.push_back(scope); 196 } 197 198 /// Ends a scope; invalidates any iterators pointing to elements of that scope 199 void endScope() { 200 scopes.pop_back(); 201 } 202 203 /// Default constructor initializes with one scope 204 ScopedSet() { beginScope(); } 205 206 iterator begin() { return iterator(scopes, scopes.back().begin(), scopes.size()-1).next_valid(); } 207 const_iterator begin() const { return const_iterator(scopes, scopes.back().begin(), scopes.size()-1).next_valid(); } 208 const_iterator cbegin() const { return const_iterator(scopes, scopes.back().begin(), scopes.size()-1).next_valid(); } 209 iterator end() { return iterator(scopes, scopes[0].end(), 0); } 210 const_iterator end() const { return const_iterator(scopes, scopes[0].end(), 0); } 211 const_iterator cend() const { return const_iterator(scopes, scopes[0].end(), 0); } 212 213 /// Gets the index of the current scope (counted from 1) 214 size_type currentScope() const { return scopes.size(); } 215 216 /// Finds the given key in the outermost scope it occurs; returns end() for none such 217 iterator find( const Value &key ) { 218 for ( size_type i = scopes.size() - 1; ; --i ) { 219 typename Scope::iterator val = scopes[i].find( key ); 220 if ( val != scopes[i].end() ) return iterator( scopes, val, i ); 221 if ( i == 0 ) break; 222 } 223 return end(); 224 } 225 const_iterator find( const Value &key ) const { 226 return const_iterator( const_cast< ScopedSet< Value >* >(this)->find( key ) ); 227 } 228 229 /// Finds the given key in the outermost scope inside the given scope where it occurs 230 iterator findNext( const_iterator &it, const Value &key ) { 231 if ( it.i == 0 ) return end(); 87 232 for ( size_type i = it.i - 1; ; --i ) { 88 typename Scope::iterator val = scopes[i].find( key ); 89 if ( val != scopes[i].end() ) return iterator( scopes, val, i ); 90 if ( i == 0 ) break; 91 } 92 return end(); 93 } 94 const_iterator findNext( const_iterator &it, const Value &key ) const { 95 return const_iterator( const_cast< ScopedSet< Value >* >(this)->findNext( it, key ) ); 96 } 97 98 /// Inserts the given value into the outermost scope 99 std::pair< iterator, bool > insert( const value_type &value ) { 100 std::pair< typename Scope::iterator, bool > res = scopes.back().insert( value ); 101 return std::make_pair( iterator(scopes, res.first, scopes.size()-1), res.second ); 102 } 103 104 bool contains( const Value & key ) const { 105 return find( key ) != cend(); 106 } 107 }; 108 109 template<typename Value> 110 class ScopedSet<Value>::iterator : 111 public std::iterator< std::bidirectional_iterator_tag, value_type > { 112 friend class ScopedSet; 113 friend class const_iterator; 114 typedef typename std::set< Value >::iterator wrapped_iterator; 115 typedef typename std::vector< std::set< Value > > scope_list; 116 typedef typename scope_list::size_type size_type; 117 118 /// Checks if this iterator points to a valid item 119 bool is_valid() const { 120 return it != (*scopes)[i].end(); 121 } 122 123 /// Increments on invalid 124 iterator& next_valid() { 125 if ( ! is_valid() ) { ++(*this); } 126 return *this; 127 } 128 129 /// Decrements on invalid 130 iterator& prev_valid() { 131 if ( ! is_valid() ) { --(*this); } 132 return *this; 133 } 134 135 iterator(scope_list const &_scopes, const wrapped_iterator &_it, size_type _i) 136 : scopes(&_scopes), it(_it), i(_i) {} 137 public: 138 iterator(const iterator &that) : scopes(that.scopes), it(that.it), i(that.i) {} 139 iterator& operator= (const iterator &that) { 140 scopes = that.scopes; i = that.i; it = that.it; 141 return *this; 142 } 143 144 reference operator* () { return *it; } 145 pointer operator-> () { return it.operator->(); } 146 147 iterator& operator++ () { 148 if ( it == (*scopes)[i].end() ) { 149 if ( i == 0 ) return *this; 150 --i; 151 it = (*scopes)[i].begin(); 152 } else { 153 ++it; 154 } 155 return next_valid(); 156 } 157 iterator operator++ (int) { iterator tmp = *this; ++(*this); return tmp; } 158 159 iterator& operator-- () { 160 // may fail if this is the begin iterator; allowed by STL spec 161 if ( it == (*scopes)[i].begin() ) { 162 ++i; 163 it = (*scopes)[i].end(); 164 } 165 --it; 166 return prev_valid(); 167 } 168 iterator operator-- (int) { iterator tmp = *this; --(*this); return tmp; } 169 170 bool operator== (const iterator &that) { 171 return scopes == that.scopes && i == that.i && it == that.it; 172 } 173 bool operator!= (const iterator &that) { return !( *this == that ); } 174 175 size_type get_level() const { return i; } 176 177 private: 178 scope_list const *scopes; 179 wrapped_iterator it; 180 size_type i; 181 }; 182 183 template<typename Value> 184 class ScopedSet<Value>::const_iterator : 185 public std::iterator< std::bidirectional_iterator_tag, value_type > { 186 friend class ScopedSet; 187 typedef typename std::set< Value >::iterator wrapped_iterator; 188 typedef typename std::set< Value >::const_iterator wrapped_const_iterator; 189 typedef typename std::vector< std::set< Value > > scope_list; 190 typedef typename scope_list::size_type size_type; 191 192 /// Checks if this iterator points to a valid item 193 bool is_valid() const { 194 return it != (*scopes)[i].end(); 195 } 196 197 /// Increments on invalid 198 const_iterator& next_valid() { 199 if ( ! is_valid() ) { ++(*this); } 200 return *this; 201 } 202 203 /// Decrements on invalid 204 const_iterator& prev_valid() { 205 if ( ! is_valid() ) { --(*this); } 206 return *this; 207 } 208 209 const_iterator(scope_list const &_scopes, const wrapped_const_iterator &_it, size_type _i) 210 : scopes(&_scopes), it(_it), i(_i) {} 211 public: 212 const_iterator(const iterator &that) : scopes(that.scopes), it(that.it), i(that.i) {} 213 const_iterator(const const_iterator &that) : scopes(that.scopes), it(that.it), i(that.i) {} 214 const_iterator& operator= (const iterator &that) { 215 scopes = that.scopes; i = that.i; it = that.it; 216 return *this; 217 } 218 const_iterator& operator= (const const_iterator &that) { 219 scopes = that.scopes; i = that.i; it = that.it; 220 return *this; 221 } 222 223 const_reference operator* () { return *it; } 224 const_pointer operator-> () { return it.operator->(); } 225 226 const_iterator& operator++ () { 227 if ( it == (*scopes)[i].end() ) { 228 if ( i == 0 ) return *this; 229 --i; 230 it = (*scopes)[i].begin(); 231 } else { 232 ++it; 233 } 234 return next_valid(); 235 } 236 const_iterator operator++ (int) { const_iterator tmp = *this; ++(*this); return tmp; } 237 238 const_iterator& operator-- () { 239 // may fail if this is the begin iterator; allowed by STL spec 240 if ( it == (*scopes)[i].begin() ) { 241 ++i; 242 it = (*scopes)[i].end(); 243 } 244 --it; 245 return prev_valid(); 246 } 247 const_iterator operator-- (int) { const_iterator tmp = *this; --(*this); return tmp; } 248 249 bool operator== (const const_iterator &that) { 250 return scopes == that.scopes && i == that.i && it == that.it; 251 } 252 bool operator!= (const const_iterator &that) { return !( *this == that ); } 253 254 size_type get_level() const { return i; } 255 256 private: 257 scope_list const *scopes; 258 wrapped_const_iterator it; 259 size_type i; 260 }; 261 233 typename Scope::iterator val = scopes[i].find( key ); 234 if ( val != scopes[i].end() ) return iterator( scopes, val, i ); 235 if ( i == 0 ) break; 236 } 237 return end(); 238 } 239 const_iterator findNext( const_iterator &it, const Value &key ) const { 240 return const_iterator( const_cast< ScopedSet< Value >* >(this)->findNext( it, key ) ); 241 } 242 243 /// Inserts the given value into the outermost scope 244 std::pair< iterator, bool > insert( const value_type &value ) { 245 std::pair< typename Scope::iterator, bool > res = scopes.back().insert( value ); 246 return std::make_pair( iterator(scopes, res.first, scopes.size()-1), res.second ); 247 } 248 249 }; 262 250 } // namespace GenPoly 263 251 -
src/GenPoly/ScrubTyVars.cc
r2ed94a9 r997185e 178 178 179 179 ast::Type const * ScrubTypeVars::postvisit( ast::TypeInstType const * type ) { 180 ast::TypeDecl::Kind kind;181 180 // This implies that mode == ScrubMode::All. 182 181 if ( !typeVars ) { 183 kind = type->kind; 184 } else { 185 // Otherwise, only scrub the type var if it is in map. 186 auto typeVar = typeVars->find( *type ); 187 if ( typeVar == typeVars->end() ) { 188 return type; 189 } 190 kind = typeVar->second.kind; 191 } 192 193 switch ( kind ) { 194 case ast::TypeDecl::Dtype: 195 case ast::TypeDecl::Ttype: 182 if ( ast::TypeDecl::Ftype == type->kind ) { 183 return new ast::PointerType( 184 new ast::FunctionType( ast::FixedArgs ) ); 185 } else { 186 return new ast::PointerType( 187 new ast::VoidType( type->qualifiers ) ); 188 } 189 } 190 191 auto typeVar = typeVars->find( *type ); 192 if ( typeVar == typeVars->end() ) { 193 return type; 194 } 195 196 switch ( typeVar->second.kind ) { 197 case ::TypeDecl::Dtype: 198 case ::TypeDecl::Ttype: 196 199 return new ast::PointerType( 197 200 new ast::VoidType( type->qualifiers ) ); 198 case ast::TypeDecl::Ftype:201 case ::TypeDecl::Ftype: 199 202 return new ast::PointerType( 200 203 new ast::FunctionType( ast::VariableArgs ) ); 201 204 default: 202 assertf( false, "Unhandled type variable kind: %d", kind ); 205 assertf( false, 206 "Unhandled type variable kind: %d", typeVar->second.kind ); 203 207 throw; // Just in case the assert is removed, stop here. 204 208 } -
src/InitTweak/FixInit.cc
r2ed94a9 r997185e 39 39 #include "InitTweak.h" // for getFunctionName, getCallArg 40 40 #include "ResolvExpr/Resolver.h" // for findVoidExpression 41 #include "ResolvExpr/ Unify.h"// for typesCompatible41 #include "ResolvExpr/typeops.h" // for typesCompatible 42 42 #include "SymTab/Autogen.h" // for genImplicitCall 43 43 #include "SymTab/Indexer.h" // for Indexer -
src/InitTweak/FixInitNew.cpp
r2ed94a9 r997185e 26 26 #include "GenPoly/GenPoly.h" // for getFunctionType 27 27 #include "ResolvExpr/Resolver.h" // for findVoidExpression 28 #include "ResolvExpr/ Unify.h"// for typesCompatible28 #include "ResolvExpr/typeops.h" // for typesCompatible 29 29 #include "SymTab/Autogen.h" // for genImplicitCall 30 30 #include "SymTab/Indexer.h" // for Indexer -
src/InitTweak/InitTweak.cc
r2ed94a9 r997185e 35 35 #include "GenPoly/GenPoly.h" // for getFunctionType 36 36 #include "InitTweak.h" 37 #include "ResolvExpr/ Unify.h"// for typesCompatibleIgnoreQualifiers37 #include "ResolvExpr/typeops.h" // for typesCompatibleIgnoreQualifiers 38 38 #include "SymTab/Autogen.h" 39 39 #include "SymTab/Indexer.h" // for Indexer -
src/Parser/lex.ll
r2ed94a9 r997185e 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Mon Jan 30 19:03:34 202313 * Update Count : 76 712 * Last Modified On : Thu Oct 13 20:46:04 2022 13 * Update Count : 764 14 14 */ 15 15 … … 340 340 vtable { KEYWORD_RETURN(VTABLE); } // CFA 341 341 waitfor { KEYWORD_RETURN(WAITFOR); } // CFA 342 waituntil { KEYWORD_RETURN(WAITUNTIL); } // CFA343 342 when { KEYWORD_RETURN(WHEN); } // CFA 344 343 while { KEYWORD_RETURN(WHILE); } … … 503 502 SemanticErrorThrow = true; 504 503 cerr << (yyfilename ? yyfilename : "*unknown file*") << ':' << yylineno << ':' << column - yyleng + 1 505 << ": " << ErrorHelpers::error_str() << errmsg << " beforetoken \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl;504 << ": " << ErrorHelpers::error_str() << errmsg << " at token \"" << (yytext[0] == '\0' ? "EOF" : yytext) << '"' << endl; 506 505 } 507 506 -
src/Parser/parser.yy
r2ed94a9 r997185e 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 21:36:16 202313 // Update Count : 58 6512 // Last Modified On : Mon Nov 21 22:34:30 2022 13 // Update Count : 5848 14 14 // 15 15 … … 331 331 %token ATTRIBUTE EXTENSION // GCC 332 332 %token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN 333 %token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR WAITUNTIL// CFA333 %token CHOOSE FALLTHRU FALLTHROUGH WITH WHEN WAITFOR // CFA 334 334 %token DISABLE ENABLE TRY THROW THROWRESUME AT // CFA 335 335 %token ASM // C99, extension ISO/IEC 9899:1999 Section J.5.10(1) … … 1645 1645 exception_statement: 1646 1646 TRY compound_statement handler_clause %prec THEN 1647 { $$ = new StatementNode( build_try( $2, $3, nullptr) ); }1647 { $$ = new StatementNode( build_try( $2, $3, 0 ) ); } 1648 1648 | TRY compound_statement finally_clause 1649 { $$ = new StatementNode( build_try( $2, nullptr, $3 ) ); }1649 { $$ = new StatementNode( build_try( $2, 0, $3 ) ); } 1650 1650 | TRY compound_statement handler_clause finally_clause 1651 1651 { $$ = new StatementNode( build_try( $2, $3, $4 ) ); } … … 1699 1699 asm_statement: 1700 1700 ASM asm_volatile_opt '(' string_literal ')' ';' 1701 { $$ = new StatementNode( build_asm( $2, $4, nullptr) ); }1701 { $$ = new StatementNode( build_asm( $2, $4, 0 ) ); } 1702 1702 | ASM asm_volatile_opt '(' string_literal ':' asm_operands_opt ')' ';' // remaining GCC 1703 1703 { $$ = new StatementNode( build_asm( $2, $4, $6 ) ); } … … 1707 1707 { $$ = new StatementNode( build_asm( $2, $4, $6, $8, $10 ) ); } 1708 1708 | ASM asm_volatile_opt GOTO '(' string_literal ':' ':' asm_operands_opt ':' asm_clobbers_list_opt ':' label_list ')' ';' 1709 { $$ = new StatementNode( build_asm( $2, $5, nullptr, $8, $10, $12 ) ); }1709 { $$ = new StatementNode( build_asm( $2, $5, 0, $8, $10, $12 ) ); } 1710 1710 ; 1711 1711 … … 1880 1880 // '[' ']' identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' // S/R conflict 1881 1881 // { 1882 // $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, nullptr, true );1882 // $$ = DeclarationNode::newFunction( $3, DeclarationNode::newTuple( 0 ), $6, 0, true ); 1883 1883 // } 1884 1884 // '[' ']' identifier '(' push cfa_parameter_ellipsis_list_opt pop ')' 1885 1885 // { 1886 1886 // typedefTable.setNextIdentifier( *$5 ); 1887 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, nullptr, true );1887 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true ); 1888 1888 // } 1889 1889 // | '[' ']' TYPEDEFname '(' push cfa_parameter_ellipsis_list_opt pop ')' 1890 1890 // { 1891 1891 // typedefTable.setNextIdentifier( *$5 ); 1892 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, nullptr, true );1892 // $$ = DeclarationNode::newFunction( $5, DeclarationNode::newTuple( 0 ), $8, 0, true ); 1893 1893 // } 1894 1894 // | '[' ']' typegen_name … … 1902 1902 cfa_abstract_tuple identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' attribute_list_opt 1903 1903 // To obtain LR(1 ), this rule must be factored out from function return type (see cfa_abstract_declarator). 1904 { $$ = DeclarationNode::newFunction( $2, $1, $5, nullptr)->addQualifiers( $8 ); }1904 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 )->addQualifiers( $8 ); } 1905 1905 | cfa_function_return identifier_or_type_name '(' push cfa_parameter_ellipsis_list_opt pop ')' attribute_list_opt 1906 { $$ = DeclarationNode::newFunction( $2, $1, $5, nullptr)->addQualifiers( $8 ); }1906 { $$ = DeclarationNode::newFunction( $2, $1, $5, 0 )->addQualifiers( $8 ); } 1907 1907 ; 1908 1908 … … 1939 1939 TYPEDEF type_specifier declarator 1940 1940 { 1941 // if type_specifier is an anon aggregate => name1942 1941 typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" ); 1943 1942 $$ = $3->addType( $2 )->addTypedef(); … … 1996 1995 declaration_specifier: // type specifier + storage class 1997 1996 basic_declaration_specifier 1997 | sue_declaration_specifier 1998 1998 | type_declaration_specifier 1999 | sue_declaration_specifier2000 | sue_declaration_specifier invalid_types2001 {2002 SemanticError( yylloc,2003 ::toString( "Missing ';' after end of ",2004 $1->type->enumeration.name ? "enum" : AggregateDecl::aggrString( $1->type->aggregate.kind ),2005 " declaration" ) );2006 $$ = nullptr;2007 }2008 ;2009 2010 invalid_types:2011 aggregate_key2012 | basic_type_name2013 | indirect_type2014 1999 ; 2015 2000 … … 2080 2065 { $$ = DeclarationNode::newTypeQualifier( Type::Atomic ); } 2081 2066 | forall 2082 { $$ = DeclarationNode::newForall( $1 ); }2083 2067 ; 2084 2068 2085 2069 forall: 2086 2070 FORALL '(' type_parameter_list ')' // CFA 2087 { $$ = $3; }2071 { $$ = DeclarationNode::newForall( $3 ); } 2088 2072 ; 2089 2073 … … 2489 2473 | EXTENSION type_specifier field_declaring_list_opt ';' // GCC 2490 2474 { $$ = fieldDecl( $2, $3 ); distExt( $$ ); } 2491 | STATIC type_specifier field_declaring_list_opt ';' // CFA2492 { SemanticError( yylloc, "STATIC aggregate field qualifier currently unimplemented." ); $$ = nullptr; }2493 2475 | INLINE type_specifier field_abstract_list_opt ';' // CFA 2494 2476 { … … 2613 2595 enum_type_nobody: // enum - {...} 2614 2596 ENUM attribute_list_opt identifier 2615 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, nullptr, false, false )->addQualifiers( $2 ); }2597 { typedefTable.makeTypedef( *$3 ); $$ = DeclarationNode::newEnum( $3, 0, false, false )->addQualifiers( $2 ); } 2616 2598 | ENUM attribute_list_opt type_name 2617 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, nullptr, false, false )->addQualifiers( $2 ); }2599 { typedefTable.makeTypedef( *$3->type->symbolic.name ); $$ = DeclarationNode::newEnum( $3->type->symbolic.name, 0, false, false )->addQualifiers( $2 ); } 2618 2600 ; 2619 2601 … … 2956 2938 { 2957 2939 typedefTable.addToEnclosingScope( *$1, TYPEDEFname, "10" ); 2958 $$ = DeclarationNode::newTypeDecl( $1, nullptr);2940 $$ = DeclarationNode::newTypeDecl( $1, 0 ); 2959 2941 } 2960 2942 | identifier_or_type_name '(' type_parameter_list ')' … … 2967 2949 trait_specifier: // CFA 2968 2950 TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' '}' 2969 { 2970 SemanticWarning( yylloc, Warning::DeprecTraitSyntax, "" ); 2971 $$ = DeclarationNode::newTrait( $2, $4, nullptr ); 2972 } 2973 | forall TRAIT identifier_or_type_name '{' '}' // alternate 2974 { $$ = DeclarationNode::newTrait( $3, $1, nullptr ); } 2951 { $$ = DeclarationNode::newTrait( $2, $4, 0 ); } 2975 2952 | TRAIT identifier_or_type_name '(' type_parameter_list ')' '{' push trait_declaration_list pop '}' 2976 { 2977 SemanticWarning( yylloc, Warning::DeprecTraitSyntax, "" ); 2978 $$ = DeclarationNode::newTrait( $2, $4, $8 ); 2979 } 2980 | forall TRAIT identifier_or_type_name '{' push trait_declaration_list pop '}' // alternate 2981 { $$ = DeclarationNode::newTrait( $3, $1, $6 ); } 2953 { $$ = DeclarationNode::newTrait( $2, $4, $8 ); } 2982 2954 ; 2983 2955 … … 3059 3031 } 3060 3032 | ASM '(' string_literal ')' ';' // GCC, global assembler statement 3061 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, nullptr) ) ); }3033 { $$ = DeclarationNode::newAsmStmt( new StatementNode( build_asm( false, $3, 0 ) ) ); } 3062 3034 | EXTERN STRINGliteral 3063 3035 { … … 3303 3275 variable_ptr: 3304 3276 ptrref_operator variable_declarator 3305 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }3277 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 3306 3278 | ptrref_operator type_qualifier_list variable_declarator 3307 3279 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3367 3339 function_ptr: 3368 3340 ptrref_operator function_declarator 3369 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }3341 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 3370 3342 | ptrref_operator type_qualifier_list function_declarator 3371 3343 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3419 3391 KR_function_ptr: 3420 3392 ptrref_operator KR_function_declarator 3421 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }3393 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 3422 3394 | ptrref_operator type_qualifier_list KR_function_declarator 3423 3395 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3475 3447 type_ptr: 3476 3448 ptrref_operator variable_type_redeclarator 3477 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }3449 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 3478 3450 | ptrref_operator type_qualifier_list variable_type_redeclarator 3479 3451 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3533 3505 identifier_parameter_ptr: 3534 3506 ptrref_operator identifier_parameter_declarator 3535 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }3507 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 3536 3508 | ptrref_operator type_qualifier_list identifier_parameter_declarator 3537 3509 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3590 3562 type_parameter_ptr: 3591 3563 ptrref_operator type_parameter_redeclarator 3592 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }3564 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 3593 3565 | ptrref_operator type_qualifier_list type_parameter_redeclarator 3594 3566 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3633 3605 abstract_ptr: 3634 3606 ptrref_operator 3635 { $$ = DeclarationNode::newPointer( nullptr, $1 ); }3607 { $$ = DeclarationNode::newPointer( 0, $1 ); } 3636 3608 | ptrref_operator type_qualifier_list 3637 3609 { $$ = DeclarationNode::newPointer( $2, $1 ); } 3638 3610 | ptrref_operator abstract_declarator 3639 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }3611 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 3640 3612 | ptrref_operator type_qualifier_list abstract_declarator 3641 3613 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3666 3638 // Only the first dimension can be empty. 3667 3639 '[' ']' 3668 { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); }3640 { $$ = DeclarationNode::newArray( 0, 0, false ); } 3669 3641 | '[' ']' multi_array_dimension 3670 { $$ = DeclarationNode::newArray( nullptr, nullptr, false )->addArray( $3 ); }3642 { $$ = DeclarationNode::newArray( 0, 0, false )->addArray( $3 ); } 3671 3643 // Cannot use constant_expression because of tuples => semantic check 3672 3644 | '[' push assignment_expression pop ',' comma_expression ']' // CFA 3673 { $$ = DeclarationNode::newArray( $3, nullptr, false )->addArray( DeclarationNode::newArray( $6, nullptr, false ) ); }3645 { $$ = DeclarationNode::newArray( $3, 0, false )->addArray( DeclarationNode::newArray( $6, 0, false ) ); } 3674 3646 // { SemanticError( yylloc, "New array dimension is currently unimplemented." ); $$ = nullptr; } 3675 3647 | '[' push array_type_list pop ']' // CFA … … 3700 3672 multi_array_dimension: 3701 3673 '[' push assignment_expression pop ']' 3702 { $$ = DeclarationNode::newArray( $3, nullptr, false ); }3674 { $$ = DeclarationNode::newArray( $3, 0, false ); } 3703 3675 | '[' push '*' pop ']' // C99 3704 3676 { $$ = DeclarationNode::newVarArray( 0 ); } 3705 3677 | multi_array_dimension '[' push assignment_expression pop ']' 3706 { $$ = $1->addArray( DeclarationNode::newArray( $4, nullptr, false ) ); }3678 { $$ = $1->addArray( DeclarationNode::newArray( $4, 0, false ) ); } 3707 3679 | multi_array_dimension '[' push '*' pop ']' // C99 3708 3680 { $$ = $1->addArray( DeclarationNode::newVarArray( 0 ) ); } … … 3801 3773 array_parameter_1st_dimension: 3802 3774 '[' ']' 3803 { $$ = DeclarationNode::newArray( nullptr, nullptr, false ); }3775 { $$ = DeclarationNode::newArray( 0, 0, false ); } 3804 3776 // multi_array_dimension handles the '[' '*' ']' case 3805 3777 | '[' push type_qualifier_list '*' pop ']' // remaining C99 3806 3778 { $$ = DeclarationNode::newVarArray( $3 ); } 3807 3779 | '[' push type_qualifier_list pop ']' 3808 { $$ = DeclarationNode::newArray( nullptr, $3, false ); }3780 { $$ = DeclarationNode::newArray( 0, $3, false ); } 3809 3781 // multi_array_dimension handles the '[' assignment_expression ']' case 3810 3782 | '[' push type_qualifier_list assignment_expression pop ']' … … 3835 3807 variable_abstract_ptr: 3836 3808 ptrref_operator 3837 { $$ = DeclarationNode::newPointer( nullptr, $1 ); }3809 { $$ = DeclarationNode::newPointer( 0, $1 ); } 3838 3810 | ptrref_operator type_qualifier_list 3839 3811 { $$ = DeclarationNode::newPointer( $2, $1 ); } 3840 3812 | ptrref_operator variable_abstract_declarator 3841 { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }3813 { $$ = $2->addPointer( DeclarationNode::newPointer( 0, $1 ) ); } 3842 3814 | ptrref_operator type_qualifier_list variable_abstract_declarator 3843 3815 { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); } … … 3881 3853 // No SUE declaration in parameter list. 3882 3854 ptrref_operator type_specifier_nobody 3883 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }3855 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); } 3884 3856 | type_qualifier_list ptrref_operator type_specifier_nobody 3885 3857 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3886 3858 | ptrref_operator cfa_abstract_function 3887 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }3859 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); } 3888 3860 | type_qualifier_list ptrref_operator cfa_abstract_function 3889 3861 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3890 3862 | ptrref_operator cfa_identifier_parameter_declarator_tuple 3891 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }3863 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); } 3892 3864 | type_qualifier_list ptrref_operator cfa_identifier_parameter_declarator_tuple 3893 3865 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } … … 3898 3870 // shift/reduce conflict with new-style empty (void) function return type. 3899 3871 '[' ']' type_specifier_nobody 3900 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }3872 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 3901 3873 | cfa_array_parameter_1st_dimension type_specifier_nobody 3902 3874 { $$ = $2->addNewArray( $1 ); } 3903 3875 | '[' ']' multi_array_dimension type_specifier_nobody 3904 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }3876 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 3905 3877 | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier_nobody 3906 3878 { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); } … … 3909 3881 3910 3882 | '[' ']' cfa_identifier_parameter_ptr 3911 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }3883 { $$ = $3->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 3912 3884 | cfa_array_parameter_1st_dimension cfa_identifier_parameter_ptr 3913 3885 { $$ = $2->addNewArray( $1 ); } 3914 3886 | '[' ']' multi_array_dimension cfa_identifier_parameter_ptr 3915 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); }3887 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( 0, 0, false ) ); } 3916 3888 | cfa_array_parameter_1st_dimension multi_array_dimension cfa_identifier_parameter_ptr 3917 3889 { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); } … … 3969 3941 cfa_abstract_ptr: // CFA 3970 3942 ptrref_operator type_specifier 3971 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }3943 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); } 3972 3944 | type_qualifier_list ptrref_operator type_specifier 3973 3945 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3974 3946 | ptrref_operator cfa_abstract_function 3975 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }3947 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); } 3976 3948 | type_qualifier_list ptrref_operator cfa_abstract_function 3977 3949 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } 3978 3950 | ptrref_operator cfa_abstract_declarator_tuple 3979 { $$ = $2->addNewPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }3951 { $$ = $2->addNewPointer( DeclarationNode::newPointer( 0, $1 ) ); } 3980 3952 | type_qualifier_list ptrref_operator cfa_abstract_declarator_tuple 3981 3953 { $$ = $3->addNewPointer( DeclarationNode::newPointer( $1, $2 ) ); } -
src/ResolvExpr/AlternativeFinder.cc
r2ed94a9 r997185e 14 14 // 15 15 16 #include "AlternativeFinder.h"17 18 16 #include <algorithm> // for copy 19 17 #include <cassert> // for strict_dynamic_cast, assert, assertf … … 28 26 29 27 #include "CompilationState.h" // for resolvep 30 #include "AdjustExprType.hpp" // for adjustExprType31 28 #include "Alternative.h" // for AltList, Alternative 29 #include "AlternativeFinder.h" 32 30 #include "AST/Expr.hpp" 33 31 #include "AST/SymbolTable.hpp" 34 32 #include "AST/Type.hpp" 35 #include "CastCost.hpp" // for castCost36 33 #include "Common/SemanticError.h" // for SemanticError 37 34 #include "Common/utility.h" // for deleteAll, printAll, CodeLocation 38 #include "ConversionCost.h" // for conversionCost39 35 #include "Cost.h" // for Cost, Cost::zero, operator<<, Cost... 40 36 #include "ExplodedActual.h" // for ExplodedActual 41 37 #include "InitTweak/InitTweak.h" // for getFunctionName 42 #include "PolyCost.hpp" // for polyCost43 38 #include "RenameVars.h" // for RenameVars, global_renamer 44 39 #include "ResolveAssertions.h" // for resolveAssertions 45 40 #include "ResolveTypeof.h" // for resolveTypeof 46 41 #include "Resolver.h" // for resolveStmtExpr 47 #include "SpecCost.hpp" // for specCost48 42 #include "SymTab/Indexer.h" // for Indexer 49 43 #include "SymTab/Mangler.h" // for Mangler … … 57 51 #include "Tuples/Explode.h" // for explode 58 52 #include "Tuples/Tuples.h" // for isTtype, handleTupleAssignment 59 #include "typeops.h" // for combos60 53 #include "Unify.h" // for unify 54 #include "typeops.h" // for adjustExprType, polyCost, castCost 61 55 62 56 #define PRINT( text ) if ( resolvep ) { text } -
src/ResolvExpr/AlternativeFinder.h
r2ed94a9 r997185e 34 34 namespace ResolvExpr { 35 35 struct ArgPack; 36 37 Cost computeConversionCost( Type * actualType, Type * formalType, bool actualIsLvalue,38 const SymTab::Indexer & indexer, const TypeEnvironment & env );39 40 void referenceToRvalueConversion( Expression *& expr, Cost & cost );41 36 42 37 /// First index is which argument, second index is which alternative for that argument, -
src/ResolvExpr/CandidateFinder.cpp
r2ed94a9 r997185e 23 23 #include <vector> 24 24 25 #include "AdjustExprType.hpp"26 25 #include "Candidate.hpp" 27 #include "CastCost.hpp" // for castCost28 26 #include "CompilationState.h" 29 #include "ConversionCost.h" // for conversionCast30 27 #include "Cost.h" 31 28 #include "ExplodedArg.hpp" 32 #include "PolyCost.hpp"33 29 #include "RenameVars.h" // for renameTyVars 34 30 #include "Resolver.h" 35 31 #include "ResolveTypeof.h" 36 32 #include "SatisfyAssertions.hpp" 37 #include "SpecCost.hpp" 38 #include "typeops.h" // for combos 33 #include "typeops.h" // for adjustExprType, conversionCost, polyCost, specCost 39 34 #include "Unify.h" 40 35 #include "AST/Expr.hpp" -
src/ResolvExpr/CandidateFinder.hpp
r2ed94a9 r997185e 63 63 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ); 64 64 65 /// Create an expression that preforms reference to rvalue conversion on66 /// the given expression and update the cost of the expression.67 const ast::Expr * referenceToRvalueConversion(68 const ast::Expr * expr, Cost & cost );69 70 65 } // namespace ResolvExpr 71 66 -
src/ResolvExpr/CastCost.cc
r2ed94a9 r997185e 13 13 // Update Count : 9 14 14 // 15 16 #include "CastCost.hpp"17 15 18 16 #include <cassert> // for assert … … 24 22 #include "ConversionCost.h" // for ConversionCost 25 23 #include "Cost.h" // for Cost, Cost::infinity 26 #include "ResolvExpr/ConversionCost.h" // for conversionCost27 #include "ResolvExpr/PtrsCastable.hpp" // for ptrsCastable28 24 #include "ResolvExpr/TypeEnvironment.h" // for TypeEnvironment, EqvClass 29 #include "ResolvExpr/typeops.h" // for ptrsCastable30 #include "ResolvExpr/Unify.h" // for typesCompatibleIgnoreQualifiers31 25 #include "SymTab/Indexer.h" // for Indexer 32 26 #include "SynTree/Declaration.h" // for TypeDecl, NamedTypeDecl 33 27 #include "SynTree/Type.h" // for PointerType, Type, TypeInstType 28 #include "typeops.h" // for typesCompatibleIgnoreQualifiers 34 29 35 30 #if 0 -
src/ResolvExpr/CommonType.cc
r2ed94a9 r997185e 13 13 // Update Count : 24 14 14 // 15 16 #include "CommonType.hpp"17 15 18 16 #include <cassert> // for strict_dynamic_cast -
src/ResolvExpr/ConversionCost.cc
r2ed94a9 r997185e 22 22 #include "ResolvExpr/Cost.h" // for Cost 23 23 #include "ResolvExpr/TypeEnvironment.h" // for EqvClass, TypeEnvironment 24 #include "ResolvExpr/Unify.h" // for typesCompatibleIgnoreQualifiers 25 #include "ResolvExpr/PtrsAssignable.hpp" // for ptrsAssignable 24 #include "ResolvExpr/Unify.h" 26 25 #include "SymTab/Indexer.h" // for Indexer 27 26 #include "SynTree/Declaration.h" // for TypeDecl, NamedTypeDecl 28 27 #include "SynTree/Type.h" // for Type, BasicType, TypeInstType 28 #include "typeops.h" // for typesCompatibleIgnoreQualifiers 29 29 30 30 -
src/ResolvExpr/ConversionCost.h
r2ed94a9 r997185e 32 32 namespace ResolvExpr { 33 33 class TypeEnvironment; 34 35 Cost conversionCost(36 const Type * src, const Type * dest, bool srcIsLvalue,37 const SymTab::Indexer & indexer, const TypeEnvironment & env );38 34 39 35 typedef std::function<Cost(const Type *, const Type *, bool, … … 84 80 const ast::SymbolTable &, const ast::TypeEnvironment &)>; 85 81 86 Cost conversionCost(87 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue,88 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env );89 90 Cost convertToReferenceCost( const ast::Type * src, const ast::ReferenceType * dest,91 bool srcIsLvalue, const ast::SymbolTable & indexer, const ast::TypeEnvironment & env,92 PtrsCalculation func );93 94 82 #warning when the old ConversionCost is removed, get ride of the _new suffix. 95 83 class ConversionCost_new : public ast::WithShortCircuiting { … … 131 119 }; 132 120 121 Cost convertToReferenceCost( const ast::Type * src, const ast::ReferenceType * dest, 122 bool srcIsLvalue, const ast::SymbolTable & indexer, const ast::TypeEnvironment & env, 123 PtrsCalculation func ); 124 133 125 } // namespace ResolvExpr 134 126 -
src/ResolvExpr/PtrsAssignable.cc
r2ed94a9 r997185e 14 14 // 15 15 16 #include " PtrsAssignable.hpp"16 #include "typeops.h" 17 17 18 18 #include "AST/Pass.hpp" -
src/ResolvExpr/PtrsCastable.cc
r2ed94a9 r997185e 14 14 // 15 15 16 #include "PtrsCastable.hpp"17 18 16 #include "AST/Decl.hpp" 19 17 #include "AST/Pass.hpp" … … 21 19 #include "AST/TypeEnvironment.hpp" 22 20 #include "Common/PassVisitor.h" 23 #include "ResolvExpr/PtrsAssignable.hpp" // for ptrsAssignable24 21 #include "ResolvExpr/TypeEnvironment.h" // for EqvClass, TypeEnvironment 25 22 #include "SymTab/Indexer.h" // for Indexer … … 27 24 #include "SynTree/Type.h" // for TypeInstType, Type, BasicType 28 25 #include "SynTree/Visitor.h" // for Visitor 26 #include "typeops.h" // for ptrsAssignable 29 27 30 28 namespace ResolvExpr { … … 293 291 return objectCast( src, env, symtab ); 294 292 } else { 295 return ast::Pass<PtrsCastable_new>::read( src, dst, env, symtab ); 293 ast::Pass< PtrsCastable_new > ptrs{ dst, env, symtab }; 294 src->accept( ptrs ); 295 return ptrs.core.result; 296 296 } 297 297 } -
src/ResolvExpr/ResolveAssertions.cc
r2ed94a9 r997185e 26 26 #include <vector> // for vector 27 27 28 #include "AdjustExprType.hpp" // for adjustExprType29 28 #include "Alternative.h" // for Alternative, AssertionItem, AssertionList 30 29 #include "Common/FilterCombos.h" // for filterCombos … … 32 31 #include "Common/utility.h" // for sort_mins 33 32 #include "GenPoly/GenPoly.h" // for getFunctionType 34 #include "ResolvExpr/AlternativeFinder.h" // for computeConversionCost35 33 #include "ResolvExpr/RenameVars.h" // for renameTyVars 36 #include "SpecCost.hpp" // for specCost37 34 #include "SymTab/Indexer.h" // for Indexer 38 35 #include "SymTab/Mangler.h" // for Mangler 39 36 #include "SynTree/Expression.h" // for InferredParams 40 37 #include "TypeEnvironment.h" // for TypeEnvironment, etc. 38 #include "typeops.h" // for adjustExprType, specCost 41 39 #include "Unify.h" // for unify 42 40 -
src/ResolvExpr/SatisfyAssertions.cpp
r2ed94a9 r997185e 23 23 #include <vector> 24 24 25 #include "AdjustExprType.hpp"26 25 #include "Candidate.hpp" 27 26 #include "CandidateFinder.hpp" 28 #include "CommonType.hpp"29 27 #include "Cost.h" 30 28 #include "RenameVars.h" 31 #include "SpecCost.hpp"32 29 #include "typeops.h" 33 30 #include "Unify.h" -
src/ResolvExpr/Unify.cc
r2ed94a9 r997185e 33 33 #include "AST/TypeEnvironment.hpp" 34 34 #include "Common/PassVisitor.h" // for PassVisitor 35 #include "CommonType.hpp" // for commonType36 35 #include "FindOpenVars.h" // for findOpenVars 37 #include "SpecCost.hpp" // for SpecCost38 36 #include "SynTree/LinkageSpec.h" // for C 39 37 #include "SynTree/Constant.h" // for Constant … … 45 43 #include "Tuples/Tuples.h" // for isTtype 46 44 #include "TypeEnvironment.h" // for EqvClass, AssertionSet, OpenVarSet 47 #include "typeops.h" // for flatten, occurs 45 #include "typeops.h" // for flatten, occurs, commonType 48 46 49 47 namespace ast { … … 52 50 53 51 namespace SymTab { 54 class Indexer;52 class Indexer; 55 53 } // namespace SymTab 56 54 … … 58 56 59 57 namespace ResolvExpr { 60 61 // Template Helpers:62 template< typename Iterator1, typename Iterator2 >63 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, std::list< Type* > &commonTypes ) {64 for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) {65 Type *commonType = 0;66 if ( ! unify( *list1Begin, *list2Begin, env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) {67 return false;68 } // if69 commonTypes.push_back( commonType );70 } // for71 return ( list1Begin == list1End && list2Begin == list2End );72 }73 74 template< typename Iterator1, typename Iterator2 >75 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) {76 std::list< Type* > commonTypes;77 if ( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) {78 deleteAll( commonTypes );79 return true;80 } else {81 return false;82 } // if83 }84 58 85 59 struct Unify_old : public WithShortCircuiting { -
src/ResolvExpr/Unify.h
r2ed94a9 r997185e 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 13:09:04 2015 11 // Last Modified By : A ndrew Beach12 // Last Modified On : Tue Jan 17 11:12:00 202313 // Update Count : 511 // Last Modified By : Aaron B. Moss 12 // Last Modified On : Mon Jun 18 11:58:00 2018 13 // Update Count : 4 14 14 // 15 15 … … 37 37 38 38 namespace ResolvExpr { 39 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 40 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType ); 41 bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 42 bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer, Type *&common ); 39 43 40 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 41 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType ); 42 bool unifyExact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 43 bool unifyInexact( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widen, const SymTab::Indexer &indexer, Type *&common ); 44 template< typename Iterator1, typename Iterator2 > 45 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, std::list< Type* > &commonTypes ) { 46 for ( ; list1Begin != list1End && list2Begin != list2End; ++list1Begin, ++list2Begin ) { 47 Type *commonType = 0; 48 if ( ! unify( *list1Begin, *list2Begin, env, needAssertions, haveAssertions, openVars, indexer, commonType ) ) { 49 return false; 50 } // if 51 commonTypes.push_back( commonType ); 52 } // for 53 if ( list1Begin != list1End || list2Begin != list2End ) { 54 return false; 55 } else { 56 return true; 57 } // if 58 } 44 59 45 bool typesCompatible( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env ); 46 bool typesCompatibleIgnoreQualifiers( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env ); 60 template< typename Iterator1, typename Iterator2 > 61 bool unifyList( Iterator1 list1Begin, Iterator1 list1End, Iterator2 list2Begin, Iterator2 list2End, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ) { 62 std::list< Type* > commonTypes; 63 if ( unifyList( list1Begin, list1End, list2Begin, list2End, env, needAssertions, haveAssertions, openVars, indexer, commonTypes ) ) { 64 deleteAll( commonTypes ); 65 return true; 66 } else { 67 return false; 68 } // if 69 } 47 70 48 inline bool typesCompatible( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) { 49 TypeEnvironment env;50 return typesCompatible( t1, t2, indexer, env );51 } 71 bool unify( 72 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 73 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 74 ast::OpenVarSet & open, const ast::SymbolTable & symtab ); 52 75 53 inline bool typesCompatibleIgnoreQualifiers( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) { 54 TypeEnvironment env;55 return typesCompatibleIgnoreQualifiers( t1, t2, indexer, env );56 } 76 bool unify( 77 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 78 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 79 ast::OpenVarSet & open, const ast::SymbolTable & symtab, ast::ptr<ast::Type> & common ); 57 80 58 bool unify( 59 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2,60 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have,61 ast::OpenVarSet & open, const ast::SymbolTable & symtab );81 bool unifyExact( 82 const ast::Type * type1, const ast::Type * type2, ast::TypeEnvironment & env, 83 ast::AssertionSet & need, ast::AssertionSet & have, const ast::OpenVarSet & open, 84 WidenMode widen, const ast::SymbolTable & symtab ); 62 85 63 bool unify( 64 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 65 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 66 ast::OpenVarSet & open, const ast::SymbolTable & symtab, ast::ptr<ast::Type> & common ); 67 68 bool unifyExact( 69 const ast::Type * type1, const ast::Type * type2, ast::TypeEnvironment & env, 70 ast::AssertionSet & need, ast::AssertionSet & have, const ast::OpenVarSet & open, 71 WidenMode widen, const ast::SymbolTable & symtab ); 72 73 bool unifyInexact( 74 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 75 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 76 const ast::OpenVarSet & open, WidenMode widen, const ast::SymbolTable & symtab, 77 ast::ptr<ast::Type> & common ); 78 79 bool typesCompatible( 80 const ast::Type *, const ast::Type *, const ast::SymbolTable & symtab = {}, 81 const ast::TypeEnvironment & env = {} ); 82 83 bool typesCompatibleIgnoreQualifiers( 84 const ast::Type *, const ast::Type *, const ast::SymbolTable & symtab = {}, 85 const ast::TypeEnvironment & env = {} ); 86 87 /// Creates the type represented by the list of returnVals in a FunctionType. 88 /// The caller owns the return value. 89 Type * extractResultType( FunctionType * functionType ); 90 /// Creates or extracts the type represented by returns in a `FunctionType`. 91 ast::ptr<ast::Type> extractResultType( const ast::FunctionType * func ); 92 93 std::vector<ast::ptr<ast::Type>> flattenList( 94 const std::vector<ast::ptr<ast::Type>> & src, ast::TypeEnvironment & env 95 ); 86 bool unifyInexact( 87 const ast::ptr<ast::Type> & type1, const ast::ptr<ast::Type> & type2, 88 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 89 const ast::OpenVarSet & open, WidenMode widen, const ast::SymbolTable & symtab, 90 ast::ptr<ast::Type> & common ); 96 91 97 92 } // namespace ResolvExpr -
src/ResolvExpr/WidenMode.h
r2ed94a9 r997185e 19 19 struct WidenMode { 20 20 WidenMode( bool first, bool second ): first( first ), second( second ) {} 21 21 22 22 WidenMode &operator|=( const WidenMode &other ) { 23 23 first |= other.first; second |= other.second; return *this; … … 35 35 WidenMode newWM( *this ); newWM &= other; return newWM; 36 36 } 37 37 38 38 operator bool() { return first && second; } 39 39 -
src/ResolvExpr/module.mk
r2ed94a9 r997185e 17 17 SRC_RESOLVEXPR = \ 18 18 ResolvExpr/AdjustExprType.cc \ 19 ResolvExpr/AdjustExprType.hpp \20 19 ResolvExpr/Alternative.cc \ 21 20 ResolvExpr/AlternativeFinder.cc \ … … 27 26 ResolvExpr/Candidate.hpp \ 28 27 ResolvExpr/CastCost.cc \ 29 ResolvExpr/CastCost.hpp \30 28 ResolvExpr/CommonType.cc \ 31 ResolvExpr/CommonType.hpp \32 29 ResolvExpr/ConversionCost.cc \ 33 30 ResolvExpr/ConversionCost.h \ … … 43 40 ResolvExpr/Occurs.cc \ 44 41 ResolvExpr/PolyCost.cc \ 45 ResolvExpr/PolyCost.hpp \46 42 ResolvExpr/PtrsAssignable.cc \ 47 ResolvExpr/PtrsAssignable.hpp \48 43 ResolvExpr/PtrsCastable.cc \ 49 ResolvExpr/PtrsCastable.hpp \50 44 ResolvExpr/RenameVars.cc \ 51 45 ResolvExpr/RenameVars.h \ … … 60 54 ResolvExpr/SatisfyAssertions.hpp \ 61 55 ResolvExpr/SpecCost.cc \ 62 ResolvExpr/SpecCost.hpp \63 56 ResolvExpr/TypeEnvironment.cc \ 64 57 ResolvExpr/TypeEnvironment.h \ -
src/ResolvExpr/typeops.h
r2ed94a9 r997185e 10 10 // Created On : Sun May 17 07:28:22 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Wed Jan 18 11:54:00 202313 // Update Count : 712 // Last Modified On : Tue Oct 1 09:45:00 2019 13 // Update Count : 6 14 14 // 15 15 … … 18 18 #include <vector> 19 19 20 #include "Cost.h" 21 #include "TypeEnvironment.h" 22 #include "WidenMode.h" 23 #include "AST/Fwd.hpp" 24 #include "AST/Node.hpp" 25 #include "AST/SymbolTable.hpp" 20 26 #include "AST/Type.hpp" 27 #include "AST/TypeEnvironment.hpp" 28 #include "SynTree/SynTree.h" 21 29 #include "SynTree/Type.h" 22 30 … … 26 34 27 35 namespace ResolvExpr { 28 class TypeEnvironment;29 30 36 // combos: takes a list of sets and returns a set of lists representing every possible way of forming a list by 31 37 // picking one element out of each set … … 55 61 } 56 62 63 // in AdjustExprType.cc 64 /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function 65 void adjustExprType( Type *& type, const TypeEnvironment & env, const SymTab::Indexer & indexer ); 66 67 /// Replaces array types with the equivalent pointer, and function types with a pointer-to-function using empty TypeEnvironment and Indexer 68 void adjustExprType( Type *& type ); 69 70 template< typename ForwardIterator > 71 void adjustExprTypeList( ForwardIterator begin, ForwardIterator end, const TypeEnvironment & env, const SymTab::Indexer & indexer ) { 72 while ( begin != end ) { 73 adjustExprType( *begin++, env, indexer ); 74 } // while 75 } 76 77 /// Replaces array types with equivalent pointer, and function types with a pointer-to-function 78 const ast::Type * adjustExprType( 79 const ast::Type * type, const ast::TypeEnvironment & env, const ast::SymbolTable & symtab ); 80 81 // in CastCost.cc 82 Cost castCost( const Type * src, const Type * dest, bool srcIsLvalue, 83 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 84 Cost castCost( 85 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue, 86 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ); 87 88 // in ConversionCost.cc 89 Cost conversionCost( const Type * src, const Type * dest, bool srcIsLvalue, 90 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 91 Cost conversionCost( 92 const ast::Type * src, const ast::Type * dst, bool srcIsLvalue, 93 const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ); 94 95 // in AlternativeFinder.cc 96 Cost computeConversionCost( Type * actualType, Type * formalType, bool actualIsLvalue, 97 const SymTab::Indexer & indexer, const TypeEnvironment & env ); 98 99 // in PtrsAssignable.cc 100 int ptrsAssignable( const Type * src, const Type * dest, const TypeEnvironment & env ); 101 int ptrsAssignable( const ast::Type * src, const ast::Type * dst, 102 const ast::TypeEnvironment & env ); 103 104 // in PtrsCastable.cc 105 int ptrsCastable( const Type * src, const Type * dest, const TypeEnvironment & env, const SymTab::Indexer & indexer ); 106 int ptrsCastable( 107 const ast::Type * src, const ast::Type * dst, const ast::SymbolTable & symtab, 108 const ast::TypeEnvironment & env ); 109 110 // in Unify.cc 111 bool typesCompatible( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env ); 112 bool typesCompatibleIgnoreQualifiers( const Type *, const Type *, const SymTab::Indexer & indexer, const TypeEnvironment & env ); 113 114 inline bool typesCompatible( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) { 115 TypeEnvironment env; 116 return typesCompatible( t1, t2, indexer, env ); 117 } 118 119 inline bool typesCompatibleIgnoreQualifiers( const Type * t1, const Type * t2, const SymTab::Indexer & indexer ) { 120 TypeEnvironment env; 121 return typesCompatibleIgnoreQualifiers( t1, t2, indexer, env ); 122 } 123 124 bool typesCompatible( 125 const ast::Type *, const ast::Type *, const ast::SymbolTable & symtab = {}, 126 const ast::TypeEnvironment & env = {} ); 127 128 bool typesCompatibleIgnoreQualifiers( 129 const ast::Type *, const ast::Type *, const ast::SymbolTable &, 130 const ast::TypeEnvironment & env = {} ); 131 132 /// creates the type represented by the list of returnVals in a FunctionType. The caller owns the return value. 133 Type * extractResultType( FunctionType * functionType ); 134 /// Creates or extracts the type represented by the list of returns in a `FunctionType`. 135 ast::ptr<ast::Type> extractResultType( const ast::FunctionType * func ); 136 137 // in CommonType.cc 138 Type * commonType( Type * type1, Type * type2, bool widenFirst, bool widenSecond, const SymTab::Indexer & indexer, TypeEnvironment & env, const OpenVarSet & openVars ); 139 ast::ptr< ast::Type > commonType( 140 const ast::ptr< ast::Type > & type1, const ast::ptr< ast::Type > & type2, 141 ast::TypeEnvironment & env, ast::AssertionSet & need, ast::AssertionSet & have, 142 const ast::OpenVarSet & open, WidenMode widen, const ast::SymbolTable & symtab 143 ); 144 // in Unify.cc 145 std::vector< ast::ptr< ast::Type > > flattenList( 146 const std::vector< ast::ptr< ast::Type > > & src, ast::TypeEnvironment & env 147 ); 148 149 // in PolyCost.cc 150 int polyCost( Type * type, const TypeEnvironment & env, const SymTab::Indexer & indexer ); 151 int polyCost( 152 const ast::Type * type, const ast::SymbolTable & symtab, const ast::TypeEnvironment & env ); 153 154 // in SpecCost.cc 155 int specCost( Type * type ); 156 int specCost( const ast::Type * type ); 157 57 158 // in Occurs.cc 58 159 bool occurs( const Type * type, const std::string & varName, const TypeEnvironment & env ); … … 67 168 return false; 68 169 } 170 171 // in AlternativeFinder.cc 172 void referenceToRvalueConversion( Expression *& expr, Cost & cost ); 173 // in CandidateFinder.cpp 174 const ast::Expr * referenceToRvalueConversion( const ast::Expr * expr, Cost & cost ); 69 175 70 176 /// flatten tuple type into list of types … … 112 218 } 113 219 220 114 221 return new ast::TupleType{ std::move(types) }; 115 222 } … … 120 227 return tupleFromTypes( tys.begin(), tys.end() ); 121 228 } 229 230 122 231 123 232 // in TypeEnvironment.cc -
src/SymTab/Indexer.cc
r2ed94a9 r997185e 31 31 #include "InitTweak/InitTweak.h" // for isConstructor, isCopyFunction, isC... 32 32 #include "Mangler.h" // for Mangler 33 #include "ResolvExpr/AlternativeFinder.h" // for referenceToRvalueConversion 34 #include "ResolvExpr/Unify.h" // for typesCompatible 33 #include "ResolvExpr/typeops.h" // for typesCompatible 35 34 #include "SynTree/LinkageSpec.h" // for isMangled, isOverridable, Spec 36 35 #include "SynTree/Constant.h" // for Constant -
src/SymTab/Validate.cc
r2ed94a9 r997185e 63 63 #include "InitTweak/GenInit.h" // for fixReturnStatements 64 64 #include "InitTweak/InitTweak.h" // for isCtorDtorAssign 65 #include "ResolvExpr/typeops.h" // for extractResultType 66 #include "ResolvExpr/Unify.h" // for typesCompatible 65 #include "ResolvExpr/typeops.h" // for typesCompatible 67 66 #include "ResolvExpr/Resolver.h" // for findSingleExpression 68 67 #include "ResolvExpr/ResolveTypeof.h" // for resolveTypeof … … 863 862 864 863 void ReplaceTypedef::premutate( TypeDecl * typeDecl ) { 865 typedefNames.erase( typeDecl->name ); 864 TypedefMap::iterator i = typedefNames.find( typeDecl->name ); 865 if ( i != typedefNames.end() ) { 866 typedefNames.erase( i ) ; 867 } // if 868 866 869 typedeclNames.insert( typeDecl->name, typeDecl ); 867 870 } -
src/SynTree/ApplicationExpr.cc
r2ed94a9 r997185e 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ApplicationExpr.cc --7 // ApplicationExpr.cc.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 26 26 #include "Expression.h" // for ParamEntry, ApplicationExpr, Expression 27 27 #include "InitTweak/InitTweak.h" // for getFunction 28 #include "ResolvExpr/ Unify.h"// for extractResultType28 #include "ResolvExpr/typeops.h" // for extractResultType 29 29 #include "Type.h" // for Type, PointerType, FunctionType 30 30 -
src/Validate/FixReturnTypes.cpp
r2ed94a9 r997185e 20 20 #include "AST/Type.hpp" 21 21 #include "CodeGen/CodeGenerator.h" 22 #include "ResolvExpr/ Unify.h"22 #include "ResolvExpr/typeops.h" 23 23 24 24 namespace ast { -
src/Validate/ReplaceTypedef.cpp
r2ed94a9 r997185e 20 20 #include "Common/UniqueName.h" 21 21 #include "Common/utility.h" 22 #include "ResolvExpr/ Unify.h"22 #include "ResolvExpr/typeops.h" 23 23 24 24 namespace Validate { … … 186 186 187 187 void ReplaceTypedefCore::previsit( ast::TypeDecl const * decl ) { 188 typedefNames.erase( decl->name ); 188 TypedefMap::iterator iter = typedefNames.find( decl->name ); 189 if ( iter != typedefNames.end() ) { 190 typedefNames.erase( iter ); 191 } 189 192 typedeclNames.insert( decl->name, decl ); 190 193 } -
src/main.cc
r2ed94a9 r997185e 46 46 #include "Common/UnimplementedError.h" // for UnimplementedError 47 47 #include "Common/utility.h" // for deleteAll, filter, printAll 48 #include "Concurrency/Actors.hpp" // for implementActors49 48 #include "Concurrency/Keywords.h" // for implementMutex, implement... 50 49 #include "Concurrency/Waitfor.h" // for generateWaitfor … … 342 341 PASS( "Generate Autogen Routines", Validate::autogenerateRoutines( transUnit ) ); 343 342 344 PASS( "Implement Actors", Concurrency::implementActors( transUnit ) );345 346 343 PASS( "Implement Mutex", Concurrency::implementMutex( transUnit ) ); 347 344 PASS( "Implement Thread Start", Concurrency::implementThreadStarter( transUnit ) ); -
tests/.expect/forall.txt
r2ed94a9 r997185e 1 1 2 f 3 97 4 f 5 g 6 f 7 f 8 g 9 fT 10 fT 11 fT 12 fTU 13 fTU 14 fTU 15 1 2 16 2 1 17 1, 2 18 @ 0 2 0 4 6.4 6.4 6.4 6.4+3.i 4 19 3. 3. 20 45 21 12 3 1 forall.cfa:244:25: warning: Compiled -
tests/Makefile.am
r2ed94a9 r997185e 11 11 ## Created On : Sun May 31 09:08:15 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Fri Feb 3 23:06:44 202314 ## Update Count : 9 413 ## Last Modified On : Sat Jun 5 14:49:25 2021 14 ## Update Count : 92 15 15 ############################################################################### 16 16 … … 89 89 meta/fork+exec.hfa \ 90 90 concurrent/unified_locking/mutex_test.hfa \ 91 concurrent/channels/parallel_harness.hfa91 concurrent/channels/parallel_harness.hfa 92 92 93 93 dist-hook: … … 183 183 CFACOMPILE_SYNTAX = $(CFACOMPILETEST) -Wno-unused-variable -Wno-unused-label -c -fsyntax-only -o $(abspath ${@}) 184 184 185 SYNTAX_ONLY_CODE = expression typedefRedef variableDeclarator switch numericConstants identFuncDeclarator \185 SYNTAX_ONLY_CODE = expression typedefRedef variableDeclarator switch numericConstants identFuncDeclarator forall \ 186 186 init1 limits nested-types cast labelledExit array quasiKeyword include/stdincludes include/includes builtins/sync warnings/self-assignment 187 187 $(SYNTAX_ONLY_CODE): % : %.cfa $(CFACCBIN) -
tests/concurrent/channels/parallel_harness.hfa
r2ed94a9 r997185e 2 2 #include <fstream.hfa> 3 3 #include <stdio.h> 4 #include <string.h> 4 5 #include <channel.hfa> 5 6 #include <thread.hfa> 6 7 #include <time.hfa> 8 #include <stats.hfa> 7 9 8 10 // user defines this … … 128 130 } 129 131 130 sleep(1 0`s);132 sleep(1`s); 131 133 prod_done = true; 132 134 -
tests/forall.cfa
r2ed94a9 r997185e 10 10 // Created On : Wed May 9 08:48:15 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 5 07:54:43 2023 13 // Update Count : 90 14 // 15 16 #include <fstream.hfa> 12 // Last Modified On : Sat Jun 5 10:06:08 2021 13 // Update Count : 36 14 // 17 15 18 16 void g1() { 19 forall( T ) T f( T p ) { sout | 'f'; return p; }; 20 void f( int p ) { sout | p; }; 21 void g( void ) { sout | 'g'; }; 22 void h( void (*p)(void) ) { p(); }; 23 24 int x = 1; 25 void (*y)(void) = g; 26 char z = 'a'; 27 float w = 3.5; 17 forall( T ) T f( T ) {}; 18 void f( int ) {}; 19 void h( void (*p)(void) ) {}; 20 21 int x; 22 void (*y)(void); 23 char z; 24 float w; 28 25 29 26 f( x ); … … 31 28 f( z ); 32 29 f( w ); 33 h( y );34 f( y );35 30 h( f( y ) ); 36 31 } 37 32 38 33 void g2() { 39 forall( T ) void f( T, T ) { sout | "fT";}40 forall( T, U ) void f( T, U ) { sout | "fTU";}34 forall( T ) void f( T, T ) {} 35 forall( T, U ) void f( T, U ) {} 41 36 42 37 int x; 43 38 float y; 44 int * z; 45 float * w; 46 47 f( x, x ); 48 f( y, y ); 49 f( w, w ); 39 int *z; 40 float *w; 41 50 42 f( x, y ); 51 43 f( z, w ); … … 58 50 59 51 forall( T ) 60 void swap( T & left, T & right ) { // by reference 61 T temp = left; 62 left = right; 63 right = temp; 64 } 65 66 forall( T ) 67 [ T, T ] swap( T i, T j ) { // by value 68 return [ j, i ]; 69 } 70 71 forall( T ) trait sumable { 52 void swap( T left, T right ) { 53 T temp = left; 54 left = right; 55 right = temp; 56 } 57 58 trait sumable( T ) { 72 59 void ?{}( T &, zero_t ); // 0 literal constructor 73 60 T ?+?( T, T ); // assortment of additions … … 77 64 }; // sumable 78 65 79 forall( T | sumable( T ) ) // use trait66 forall( T | sumable( T ) ) // use trait 80 67 T sum( size_t size, T a[] ) { 81 68 T total = 0; // initialize by 0 constructor … … 85 72 } // sum 86 73 87 forall( T | { T ?+?( T, T ); T ?++( T & ); [T] ?+=?( T &, T ); } )74 forall( T | { T ?+?( T, T ); T ?++( T & ); [T] ?+=?( T &,T ); } ) 88 75 T twice( T t ) { 89 76 return t + t; … … 95 82 } 96 83 97 voidfred() {98 int x = 1, y = 2, a[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };84 int fred() { 85 int x = 1, y = 2, a[10]; 99 86 float f; 100 87 101 sout | x | y;102 88 swap( x, y ); 103 sout | x | y | nl | swap( x, y ); 104 // [ x, y ] = swap( y, x ); 105 sout | twice( ' ' ) | ' ' | twice( 0hh ) | twice( 1h ) | twice( 0n ) | twice( 2 ) 106 | twice( 3.2f ) | twice( 3.2 ) | twice( 3.2d ) | twice( 3.2+1.5i ) | twice( x ); 89 twice( x ); 107 90 f = min( 4.0, 3.0 ); 108 sout | f | min( 4.0, 3.0 ); 109 sout | sum( 10, a ); 91 sum( 10, a ); 110 92 } 111 93 … … 204 186 205 187 forall( T ) { 206 //extern "C" {188 extern "C" { 207 189 struct SS { T t; }; 208 T foo( T p ) { return p;}209 //}190 T foo( T ) {} 191 } 210 192 } 211 193 … … 213 195 W(int,int) w; 214 196 215 voidjane() {197 int jane() { 216 198 // int j = bar( 3, 4 ); 217 199 int k = baz( 3, 4, 5 ); 218 200 int i = foo( 3 ); 219 sout | k | i;220 201 } 221 202 … … 230 211 T t; 231 212 T t2 = t; 232 sout | &tr | tp;233 213 } 234 214 … … 262 242 263 243 int main( void ) { 264 g1(); 265 g2(); 266 fred(); 267 jane(); 244 #pragma GCC warning "Compiled" // force non-empty .expect file, NO TABS!!! 268 245 } 269 246
Note:
See TracChangeset
for help on using the changeset viewer.