Changes in / [5217569:dbae916]
- Files:
-
- 1 added
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/LaTeXmacros/common.tex
r5217569 rdbae916 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Fri Feb 1 0 11:48:00202314 %% Update Count : 56 413 %% Last Modified On : Fri Feb 17 08:32:47 2023 14 %% Update Count : 565 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 269 269 \newcommand{\LstCommentStyle}[1]{{\lst@basicstyle{\lst@commentstyle{#1}}}} 270 270 \newcommand{\LstStringStyle}[1]{{\lst@basicstyle{\lst@stringstyle{#1}}}} 271 \newcommand{\LstNumberStyle}[1]{{\lst@basicstyle{\lst@numberstyle{#1}}}} 271 272 272 273 \newlength{\gcolumnposn} % temporary hack because lstlisting does not handle tabs correctly -
doc/bibliography/pl.bib
r5217569 rdbae916 799 799 800 800 @article{Joung00, 801 keywords = {group mutual exclusion, congenial talking philosophers, resource allocation, shared-memory algorithms}, 801 802 author = {Joung, Yuh-Jzer}, 802 803 title = {Asynchronous group mutual exclusion}, … … 1115 1116 } 1116 1117 1118 @inproceedings{CAF, 1119 keywords = {performance measurement, actor model, c++, message-oriented middleware, distributed debugging}, 1120 author = {Charousset, Dominik and Hiesgen, Raphael and Schmidt, Thomas C.}, 1121 title = {{CAF} - the {C}++ Actor Framework for Scalable and Resource-Efficient Applications}, 1122 publisher = {ACM}, 1123 address = {New York, NY, USA}, 1124 organization= {Proceedings of the 4th International Workshop on Programming Based on Actors Agents \& Decentralized Control}, 1125 pages = {15-28}, 1126 numpages = {14}, 1127 location = {Portland, Oregon, USA}, 1128 series = {AGERE'14}, 1129 year = {2014}, 1130 } 1131 1117 1132 @techreport{cfa-cc, 1118 1133 keywords = {Cforall, cfa-cc, transpiler}, … … 1297 1312 @techreport{Prokopec11, 1298 1313 keywords = {ctrie, concurrent map}, 1299 contributer 1314 contributer = {a3moss@uwaterloo.ca}, 1300 1315 title = {Cache-aware lock-free concurrent hash tries}, 1301 1316 author = {Prokopec, Aleksandar and Bagwell, Phil and Odersky, Martin}, … … 1621 1636 author = {Emery D. Berger and Benjamin G. Zorn and Kathryn S. McKinley}, 1622 1637 title = {Composing High-Performance Memory Allocators}, 1623 booktitle= {{SIGPLAN} Conference on Programming Language Design and Implementation},1638 organization= {{SIGPLAN} Conference on Programming Language Design and Implementation}, 1624 1639 pages = {114-124}, 1625 1640 year = 2001, … … 2121 2136 address = {Eindhoven, Neth.}, 2122 2137 year = 1965, 2123 note = {Reprinted in \cite{Genuys68} pp. 43--112.} 2138 optnote = {Reprinted in \cite{Genuys68} pp. 43--112.} 2139 note = {\url{https://pure.tue.nl/ws/files/4279816/344354178746665.pdf}}, 2124 2140 } 2125 2141 … … 6226 6242 organization= {USENIX Association}, 6227 6243 year = 1988, 6228 pages = {1-18} 6244 pages = {1-18}, 6229 6245 } 6230 6246 … … 7513 7529 } 7514 7530 7531 @article{Nickolls08, 7532 author = {Nickolls, John and Buck, Ian and Garland, Michael and Skadron, Kevin}, 7533 title = {Scalable Parallel Programming with CUDA}, 7534 journal = {Queue}, 7535 volume = {6}, 7536 number = {2}, 7537 month = mar, 7538 year = 2008, 7539 pages = {40-53}, 7540 publisher = {ACM}, 7541 address = {New York, NY, USA}, 7542 } 7543 7544 @inproceedings{Leissa14, 7545 title = {{S}ierra: a {SIMD} extension for {C}++}, 7546 author = {Lei{\ss}a, Roland and Haffner, Immanuel and Hack, Sebastian}, 7547 booktitle = {Proceedings of the 2014 Workshop on Workshop on programming models for SIMD/Vector processing}, 7548 pages = {17-24}, 7549 year = {2014}, 7550 organization= {ACM} 7551 } 7552 7515 7553 @inproceedings{Howard76b, 7516 7554 keywords = {monitors}, … … 8483 8521 author = {Paul R. Wilson}, 8484 8522 title = {Uniprocessor Garbage Collection Techniques}, 8485 booktitle= {Proceedings of the International Workshop on Memory Management},8523 organization= {Proceedings of the International Workshop on Memory Management}, 8486 8524 location = {St. Malo, France}, 8487 8525 publisher = {Springer}, -
doc/theses/colby_parsons_MMAth/benchmarks/actors/plotData.py
r5217569 rdbae916 53 53 Static = 7 54 54 Dynamic = 8 55 Mem = 9 55 56 56 57 nameSet = False … … 90 91 name = "Dynamic" 91 92 currBench = Bench.Dynamic 93 elif line == "mem": 94 name = "ExecutorMemory" 95 currBench = Bench.Mem 92 96 else: 93 97 print("Expected benchmark name") … … 98 102 continue 99 103 100 if currBench == Bench.Static or currBench == Bench.Dynamic :104 if currBench == Bench.Static or currBench == Bench.Dynamic or currBench == Bench.Mem: 101 105 if not nameSet: 102 106 nameSet = True … … 116 120 if currBench == Bench.Static: 117 121 fileName += "SendStatic" 122 elif currBench == Bench.Dynamic: 123 fileName += "SendDynamic" 118 124 else: 119 fileName += " SendDynamic"125 fileName += "ExecutorMem" 120 126 f = open(fileName, 'w') 121 f.write(" & ".join(map(lambda a: str(int(a)) + 'ns', sendData))) 127 if currBench == Bench.Mem: 128 f.write(" & ".join(map(lambda a: str(int(a/1000)) + 'MB', sendData))) 129 else: 130 f.write(" & ".join(map(lambda a: str(int(a)) + 'ns', sendData))) 122 131 123 132 # reset … … 162 171 plt.xticks(procs) 163 172 ax.legend(names) 164 # fig.savefig("plots/" + name + ".png")173 # fig.savefig("plots/" + machineName + name + ".png") 165 174 plt.savefig("plots/" + machineName + name + ".pgf") 166 175 fig.clf() -
libcfa/src/algorithms/range_iterator.hfa
r5217569 rdbae916 9 9 // Author : Thierry Delisle 10 10 // Created On : Tue Nov 30 13:06:22 2021 11 // Last Modified By : 12 // Last Modified On : 13 // Update Count : 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 13 23:10:35 2023 13 // Update Count : 1 14 14 // 15 16 #pragma once 15 17 16 18 generator RangeIter { -
libcfa/src/concurrency/channel.hfa
r5217569 rdbae916 1 #pragma once 2 1 3 #include <locks.hfa> 2 4 -
libcfa/src/concurrency/clib/cfathread.cfa
r5217569 rdbae916 17 17 18 18 #include <string.h> 19 #include <errno.h>20 #include <unistd.h>21 #include <sys/socket.h>22 19 23 20 #include "fstream.hfa" -
libcfa/src/concurrency/clib/cfathread.h
r5217569 rdbae916 10 10 // Created On : Tue Sep 22 15:31:20 2020 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 25 17:39:20 202313 // Update Count : 612 // Last Modified On : Mon Mar 13 23:48:40 2023 13 // Update Count : 7 14 14 // 15 16 #pragma once 15 17 16 18 #if defined(__cforall) || defined(__cplusplus) -
libcfa/src/concurrency/future.hfa
r5217569 rdbae916 14 14 // 15 15 16 //#pragma once16 #pragma once 17 17 18 18 #include "bits/locks.hfa" -
libcfa/src/concurrency/invoke.h
r5217569 rdbae916 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Nov 29 20:42:21 2022 13 // Update Count : 56 14 // 12 // Last Modified On : Tue Mar 14 13:39:31 2023 13 // Update Count : 59 14 // 15 16 // No not use #pragma once was this file is included twice in some places. It has its own guard system. 15 17 16 18 #include "bits/containers.hfa" -
libcfa/src/concurrency/iofwd.hfa
r5217569 rdbae916 9 9 // Author : Thierry Delisle 10 10 // Created On : Thu Apr 23 17:31:00 2020 11 // Last Modified By : 12 // Last Modified On : 13 // Update Count : 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 13 23:54:57 2023 13 // Update Count : 1 14 14 // 15 15 … … 50 50 typedef __off64_t off64_t; 51 51 52 struct cluster;53 struct io_context$;54 55 struct iovec;56 struct msghdr;57 struct statx;58 52 struct epoll_event; 59 60 struct io_uring_sqe;61 53 62 54 //----------------------------------------------------------------------- … … 89 81 // synchronous calls 90 82 #if defined(CFA_HAVE_PREADV2) 91 extern ssize_t cfa_preadv2(int fd, const struct iovec * iov, int iovcnt, off_t offset, int flags, __u64 submit_flags);83 extern ssize_t cfa_preadv2(int fd, const struct iovec * iov, int iovcnt, off_t offset, int flags, __u64 submit_flags); 92 84 #endif 93 85 #if defined(CFA_HAVE_PWRITEV2) 94 extern ssize_t cfa_pwritev2(int fd, const struct iovec * iov, int iovcnt, off_t offset, int flags, __u64 submit_flags);86 extern ssize_t cfa_pwritev2(int fd, const struct iovec * iov, int iovcnt, off_t offset, int flags, __u64 submit_flags); 95 87 #endif 96 88 extern int cfa_fsync(int fd, __u64 submit_flags); 97 extern int cfa_epoll_ctl(int epfd, int op, int fd, struct epoll_event * event, __u64 submit_flags);89 extern int cfa_epoll_ctl(int epfd, int op, int fd, struct epoll_event * event, __u64 submit_flags); 98 90 extern int cfa_sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags, __u64 submit_flags); 99 extern ssize_t cfa_sendmsg(int sockfd, const struct msghdr * msg, int flags, __u64 submit_flags);100 extern ssize_t cfa_recvmsg(int sockfd, struct msghdr * msg, int flags, __u64 submit_flags);101 extern ssize_t cfa_send(int sockfd, const void * buf, size_t len, int flags, __u64 submit_flags);102 extern ssize_t cfa_recv(int sockfd, void * buf, size_t len, int flags, __u64 submit_flags);91 extern ssize_t cfa_sendmsg(int sockfd, const struct msghdr * msg, int flags, __u64 submit_flags); 92 extern ssize_t cfa_recvmsg(int sockfd, struct msghdr * msg, int flags, __u64 submit_flags); 93 extern ssize_t cfa_send(int sockfd, const void * buf, size_t len, int flags, __u64 submit_flags); 94 extern ssize_t cfa_recv(int sockfd, void * buf, size_t len, int flags, __u64 submit_flags); 103 95 extern int cfa_accept4(int sockfd, __SOCKADDR_ARG addr, socklen_t * restrict addrlen, int flags, __u64 submit_flags); 104 96 extern int cfa_connect(int sockfd, __CONST_SOCKADDR_ARG addr, socklen_t addrlen, __u64 submit_flags); 105 97 extern int cfa_fallocate(int fd, int mode, off_t offset, off_t len, __u64 submit_flags); 106 98 extern int cfa_posix_fadvise(int fd, off_t offset, off_t len, int advice, __u64 submit_flags); 107 extern int cfa_madvise(void * addr, size_t length, int advice, __u64 submit_flags);108 extern int cfa_openat(int dirfd, const char * pathname, int flags, mode_t mode, __u64 submit_flags);99 extern int cfa_madvise(void * addr, size_t length, int advice, __u64 submit_flags); 100 extern int cfa_openat(int dirfd, const char * pathname, int flags, mode_t mode, __u64 submit_flags); 109 101 #if defined(CFA_HAVE_OPENAT2) 110 extern int cfa_openat2(int dirfd, const char * pathname, struct open_how * how, size_t size, __u64 submit_flags);102 extern int cfa_openat2(int dirfd, const char * pathname, struct open_how * how, size_t size, __u64 submit_flags); 111 103 #endif 112 104 extern int cfa_close(int fd, __u64 submit_flags); 113 105 #if defined(CFA_HAVE_STATX) 114 extern int cfa_statx(int dirfd, const char * pathname, int flags, unsigned int mask, struct statx *statxbuf, __u64 submit_flags);106 extern int cfa_statx(int dirfd, const char * pathname, int flags, unsigned int mask, struct statx * statxbuf, __u64 submit_flags); 115 107 #endif 116 108 extern ssize_t cfa_read(int fd, void * buf, size_t count, __u64 submit_flags); 117 109 extern ssize_t cfa_write(int fd, void * buf, size_t count, __u64 submit_flags); 118 extern ssize_t cfa_splice(int fd_in, __off64_t * off_in, int fd_out, __off64_t *off_out, size_t len, unsigned int flags, __u64 submit_flags);110 extern ssize_t cfa_splice(int fd_in, __off64_t * off_in, int fd_out, __off64_t * off_out, size_t len, unsigned int flags, __u64 submit_flags); 119 111 extern ssize_t cfa_tee(int fd_in, int fd_out, size_t len, unsigned int flags, __u64 submit_flags); 120 112 … … 122 114 // asynchronous calls 123 115 #if defined(CFA_HAVE_PREADV2) 124 extern void async_preadv2(io_future_t & future, int fd, const struct iovec * iov, int iovcnt, off_t offset, int flags, __u64 submit_flags);116 extern void async_preadv2(io_future_t & future, int fd, const struct iovec * iov, int iovcnt, off_t offset, int flags, __u64 submit_flags); 125 117 #endif 126 118 #if defined(CFA_HAVE_PWRITEV2) 127 extern void async_pwritev2(io_future_t & future, int fd, const struct iovec * iov, int iovcnt, off_t offset, int flags, __u64 submit_flags);119 extern void async_pwritev2(io_future_t & future, int fd, const struct iovec * iov, int iovcnt, off_t offset, int flags, __u64 submit_flags); 128 120 #endif 129 121 extern void async_fsync(io_future_t & future, int fd, __u64 submit_flags); 130 extern void async_epoll_ctl(io_future_t & future, int epfd, int op, int fd, struct epoll_event * event, __u64 submit_flags);122 extern void async_epoll_ctl(io_future_t & future, int epfd, int op, int fd, struct epoll_event * event, __u64 submit_flags); 131 123 extern void async_sync_file_range(io_future_t & future, int fd, off64_t offset, off64_t nbytes, unsigned int flags, __u64 submit_flags); 132 extern void async_sendmsg(io_future_t & future, int sockfd, const struct msghdr * msg, int flags, __u64 submit_flags);133 extern void async_recvmsg(io_future_t & future, int sockfd, struct msghdr * msg, int flags, __u64 submit_flags);134 extern void async_send(io_future_t & future, int sockfd, const void * buf, size_t len, int flags, __u64 submit_flags);135 extern void async_recv(io_future_t & future, int sockfd, void * buf, size_t len, int flags, __u64 submit_flags);124 extern void async_sendmsg(io_future_t & future, int sockfd, const struct msghdr * msg, int flags, __u64 submit_flags); 125 extern void async_recvmsg(io_future_t & future, int sockfd, struct msghdr * msg, int flags, __u64 submit_flags); 126 extern void async_send(io_future_t & future, int sockfd, const void * buf, size_t len, int flags, __u64 submit_flags); 127 extern void async_recv(io_future_t & future, int sockfd, void * buf, size_t len, int flags, __u64 submit_flags); 136 128 extern void async_accept4(io_future_t & future, int sockfd, __SOCKADDR_ARG addr, socklen_t * restrict addrlen, int flags, __u64 submit_flags); 137 129 extern void async_connect(io_future_t & future, int sockfd, __CONST_SOCKADDR_ARG addr, socklen_t addrlen, __u64 submit_flags); 138 130 extern void async_fallocate(io_future_t & future, int fd, int mode, off_t offset, off_t len, __u64 submit_flags); 139 131 extern void async_posix_fadvise(io_future_t & future, int fd, off_t offset, off_t len, int advice, __u64 submit_flags); 140 extern void async_madvise(io_future_t & future, void * addr, size_t length, int advice, __u64 submit_flags);141 extern void async_openat(io_future_t & future, int dirfd, const char * pathname, int flags, mode_t mode, __u64 submit_flags);132 extern void async_madvise(io_future_t & future, void * addr, size_t length, int advice, __u64 submit_flags); 133 extern void async_openat(io_future_t & future, int dirfd, const char * pathname, int flags, mode_t mode, __u64 submit_flags); 142 134 #if defined(CFA_HAVE_OPENAT2) 143 extern void async_openat2(io_future_t & future, int dirfd, const char * pathname, struct open_how * how, size_t size, __u64 submit_flags);135 extern void async_openat2(io_future_t & future, int dirfd, const char * pathname, struct open_how * how, size_t size, __u64 submit_flags); 144 136 #endif 145 137 extern void async_close(io_future_t & future, int fd, __u64 submit_flags); 146 138 #if defined(CFA_HAVE_STATX) 147 extern void async_statx(io_future_t & future, int dirfd, const char * pathname, int flags, unsigned int mask, struct statx *statxbuf, __u64 submit_flags);139 extern void async_statx(io_future_t & future, int dirfd, const char * pathname, int flags, unsigned int mask, struct statx * statxbuf, __u64 submit_flags); 148 140 #endif 149 141 void async_read(io_future_t & future, int fd, void * buf, size_t count, __u64 submit_flags); 150 142 extern void async_write(io_future_t & future, int fd, void * buf, size_t count, __u64 submit_flags); 151 extern void async_splice(io_future_t & future, int fd_in, __off64_t * off_in, int fd_out, __off64_t *off_out, size_t len, unsigned int flags, __u64 submit_flags);143 extern void async_splice(io_future_t & future, int fd_in, __off64_t * off_in, int fd_out, __off64_t * off_out, size_t len, unsigned int flags, __u64 submit_flags); 152 144 extern void async_tee(io_future_t & future, int fd_in, int fd_out, size_t len, unsigned int flags, __u64 submit_flags); 153 145 -
libcfa/src/concurrency/kernel/startup.cfa
r5217569 rdbae916 33 33 #include "kernel/private.hfa" 34 34 #include "iofwd.hfa" 35 #include "startup.hfa" // STARTUP_PRIORITY_XXX35 #include "startup.hfa" // STARTUP_PRIORITY_XXX 36 36 #include "limits.hfa" 37 37 #include "math.hfa" -
libcfa/src/concurrency/mutex_stmt.hfa
r5217569 rdbae916 1 #pragma once 2 1 3 #include "bits/algorithm.hfa" 2 4 #include "bits/defs.hfa" -
libcfa/src/concurrency/pthread.cfa
r5217569 rdbae916 598 598 if (t->pthreadData == NULL) return NULL; 599 599 lock(key_lock); 600 pthread_values & entry = ((pthread_values *)t->pthreadData)[key];600 pthread_values & entry = ((pthread_values *)t->pthreadData)[key]; 601 601 if ( ! entry.in_use ) { 602 602 unlock( key_lock ); -
libcfa/src/concurrency/select.hfa
r5217569 rdbae916 1 #pragma once 2 1 3 #include "containers/list.hfa" 2 4 #include <stdint.h> -
libcfa/src/containers/vector2.hfa
r5217569 rdbae916 9 9 // Author : Michael Brooks 10 10 // Created On : Thu Jun 23 22:00:00 2021 11 // Last Modified By : Michael Brooks 12 // Last Modified On : Thu Jun 23 22:00:00 2021 13 // Update Count : 1 14 // 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 14 08:40:53 2023 13 // Update Count : 2 14 // 15 16 #pragma once 15 17 16 18 #include <stdlib.hfa> -
libcfa/src/interpose.cfa
r5217569 rdbae916 10 10 // Created On : Wed Mar 29 16:10:31 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 2 13:56:26 2023 13 // Update Count : 191 14 // 15 16 #include <stdarg.h> // va_start, va_end 12 // Last Modified On : Mon Mar 13 22:39:12 2023 13 // Update Count : 193 14 // 15 17 16 #include <stdio.h> 18 #include <string.h> // strlen19 17 #include <unistd.h> // _exit, getpid 20 #include <signal.h>21 18 extern "C" { 22 19 #include <dlfcn.h> // dlopen, dlsym … … 24 21 } 25 22 26 #include "bits/debug.hfa"27 23 #include "bits/defs.hfa" 28 24 #include "bits/signal.hfa" // sigHandler_? … … 40 36 41 37 typedef void (* generic_fptr_t)(void); 38 42 39 static generic_fptr_t do_interpose_symbol( void * library, const char symbol[], const char version[] ) { 43 const char * error;44 45 40 union { generic_fptr_t fptr; void * ptr; } originalFunc; 46 41 47 42 originalFunc.ptr = dlsym( library, symbol ); 48 error = dlerror();49 if ( error ) abort( "interpose_symbol : internal error, %s\n", error);50 43 if ( ! originalFunc.ptr ) { // == nullptr 44 abort( "interpose_symbol : internal error, %s\n", dlerror() ); 45 } // if 51 46 return originalFunc.fptr; 52 47 } … … 57 52 library = RTLD_NEXT; 58 53 #else 54 // missing RTLD_NEXT => must hard-code library name, assuming libstdc++ 59 55 library = dlopen( "libc.so.6", RTLD_LAZY ); 60 if ( ! library ) { 61 const char * error = dlerror(); 62 if ( error ) { 63 abort( "interpose_symbol : failed to open libc, %s\n", error ); 64 } // if 56 if ( ! library ) { // == nullptr 57 abort( "interpose_symbol : failed to open libc, %s\n", dlerror() ); 65 58 } // if 66 #endif 67 68 return do_interpose_symbol( library, symbol, version);59 #endif // RTLD_NEXT 60 61 return do_interpose_symbol( library, symbol, version ); 69 62 } 70 63 -
libcfa/src/interpose_thread.cfa
r5217569 rdbae916 14 14 // 15 15 16 #include <stdarg.h> // va_start, va_end 17 #include <stdio.h> 18 #include <string.h> // strlen 16 #ifdef __i386__ // 32-bit architecture 17 #undef _GNU_SOURCE 18 #endif // __i386__ 19 19 20 #include <signal.h> 20 21 #include <pthread.h> 22 #include <signal.h> 21 23 extern "C" { 22 24 #include <dlfcn.h> // dlopen, dlsym 23 #include <execinfo.h> // backtrace, messages24 25 } 25 26 26 #include "bits/debug.hfa"27 27 #include "bits/defs.hfa" 28 #include <assert.h>29 28 30 29 //============================================================================================= … … 40 39 ) libcfa_public { 41 40 void * library; 41 42 42 #if defined( RTLD_NEXT ) 43 43 library = RTLD_NEXT; 44 44 #else 45 45 // missing RTLD_NEXT => must hard-code library name, assuming libstdc++ 46 library = dlopen( "libthread_db.so", RTLD_LAZY ); 47 if ( ! library ) { 48 const char * error = dlerror(); 49 if ( error ) { 50 abort( "interpose_symbol : failed to open libpthread, %s\n", error ); 51 } 46 library = dlopen( "libpthread.so", RTLD_LAZY ); 47 if ( ! library ) { // == nullptr 48 abort( "interpose_symbol : failed to open libpthread, %s\n", dlerror() ); 52 49 } // if 53 50 #endif // RTLD_NEXT 54 51 55 return do_interpose_symbol( library, symbol, version);52 return do_interpose_symbol( library, symbol, version ); 56 53 } 57 54 … … 81 78 #pragma GCC diagnostic push 82 79 #pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" 83 INTERPOSE( pthread_create 84 INTERPOSE( pthread_join 85 INTERPOSE( pthread_self 86 INTERPOSE( pthread_attr_init 87 INTERPOSE( pthread_attr_destroy 88 INTERPOSE( pthread_attr_setstack 89 INTERPOSE( pthread_attr_getstacksize 90 INTERPOSE( pthread_sigmask 91 INTERPOSE( pthread_sigqueue 92 INTERPOSE( pthread_once 80 INTERPOSE( pthread_create, version ); 81 INTERPOSE( pthread_join, version ); 82 INTERPOSE( pthread_self, version ); 83 INTERPOSE( pthread_attr_init, version ); 84 INTERPOSE( pthread_attr_destroy, version ); 85 INTERPOSE( pthread_attr_setstack, version ); 86 INTERPOSE( pthread_attr_getstacksize, version ); 87 INTERPOSE( pthread_sigmask, version ); 88 INTERPOSE( pthread_sigqueue, version ); 89 INTERPOSE( pthread_once, version ); 93 90 #pragma GCC diagnostic pop 94 91 } -
src/AST/TranslationUnit.hpp
r5217569 rdbae916 10 10 // Created On : Tue Jun 11 15:30:00 2019 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : T ue Mar 11 11:19:00 202213 // Update Count : 112 // Last Modified On : Thr Mar 9 16:41:00 2023 13 // Update Count : 2 14 14 // 15 15 … … 17 17 18 18 #include <map> 19 #include < vector>19 #include <list> 20 20 21 21 #include "Fwd.hpp" … … 28 28 29 29 ptr<Type> sizeType; 30 const FunctionDecl * dereference ;31 const StructDecl * dtorStruct ;32 const FunctionDecl * dtorDestroy ;30 const FunctionDecl * dereference = nullptr; 31 const StructDecl * dtorStruct = nullptr; 32 const FunctionDecl * dtorDestroy = nullptr; 33 33 }; 34 34 -
src/Parser/DeclarationNode.cc
r5217569 rdbae916 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 12:34:05 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Feb 25 12:15:40 202313 // Update Count : 140 411 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Mar 14 11:56:00 2023 13 // Update Count : 1406 14 14 // 15 15 … … 41 41 42 42 // These must harmonize with the corresponding DeclarationNode enumerations. 43 const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "int128", 44 "float", "double", "long double", "float80", "float128", 45 "_float16", "_float32", "_float32x", "_float64", "_float64x", "_float128", "_float128x", "NoBasicTypeNames" }; 46 const char * DeclarationNode::complexTypeNames[] = { "_Complex", "NoComplexTypeNames", "_Imaginary" }; // Imaginary unsupported => parse, but make invisible and print error message 47 const char * DeclarationNode::signednessNames[] = { "signed", "unsigned", "NoSignednessNames" }; 48 const char * DeclarationNode::lengthNames[] = { "short", "long", "long long", "NoLengthNames" }; 49 const char * DeclarationNode::builtinTypeNames[] = { "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" }; 43 const char * DeclarationNode::basicTypeNames[] = { 44 "void", "_Bool", "char", "int", "int128", 45 "float", "double", "long double", "float80", "float128", 46 "_float16", "_float32", "_float32x", "_float64", "_float64x", "_float128", "_float128x", "NoBasicTypeNames" 47 }; 48 const char * DeclarationNode::complexTypeNames[] = { 49 "_Complex", "NoComplexTypeNames", "_Imaginary" 50 }; // Imaginary unsupported => parse, but make invisible and print error message 51 const char * DeclarationNode::signednessNames[] = { 52 "signed", "unsigned", "NoSignednessNames" 53 }; 54 const char * DeclarationNode::lengthNames[] = { 55 "short", "long", "long long", "NoLengthNames" 56 }; 57 const char * DeclarationNode::builtinTypeNames[] = { 58 "__builtin_va_list", "__auto_type", "zero_t", "one_t", "NoBuiltinTypeNames" 59 }; 50 60 51 61 UniqueName DeclarationNode::anonymous( "__anonymous" ); … … 70 80 delete variable.initializer; 71 81 72 // 82 // delete type; 73 83 delete bitfieldWidth; 74 84 … … 504 514 // src is the new item being added and has a single bit 505 515 } else if ( ! src->storageClasses.is_threadlocal_any() ) { // conflict ? 506 appendError( error, string( "conflicting " ) + Type::StorageClassesNames[storageClasses.ffs()] + 507 " & " + Type::StorageClassesNames[src->storageClasses.ffs()] ); 516 appendError( error, string( "conflicting " ) 517 + Type::StorageClassesNames[storageClasses.ffs()] 518 + " & " + Type::StorageClassesNames[src->storageClasses.ffs()] ); 508 519 src->storageClasses.reset(); // FIX to preserve invariant of one basic storage specifier 509 520 } // if … … 589 600 } else { 590 601 switch ( dst->kind ) { 591 602 case TypeData::Unknown: 592 603 src->qualifiers |= dst->qualifiers; 593 604 dst = src; 594 605 src = nullptr; 595 606 break; 596 607 case TypeData::Basic: 597 608 dst->qualifiers |= src->qualifiers; 598 609 if ( src->kind != TypeData::Unknown ) { … … 622 633 } // if 623 634 break; 624 635 default: 625 636 switch ( src->kind ) { 626 627 637 case TypeData::Aggregate: 638 case TypeData::Enum: 628 639 dst->base = new TypeData( TypeData::AggregateInst ); 629 640 dst->base->aggInst.aggregate = src; … … 634 645 src = nullptr; 635 646 break; 636 647 default: 637 648 if ( dst->forall ) { 638 649 dst->forall->appendList( src->forall ); … … 706 717 DeclarationNode * DeclarationNode::addAssertions( DeclarationNode * assertions ) { 707 718 if ( variable.tyClass != TypeDecl::NUMBER_OF_KINDS ) { 708 709 710 711 712 713 719 if ( variable.assertions ) { 720 variable.assertions->appendList( assertions ); 721 } else { 722 variable.assertions = assertions; 723 } // if 724 return this; 714 725 } // if 715 726 716 727 assert( type ); 717 728 switch ( type->kind ) { 718 729 case TypeData::Symbolic: 719 730 if ( type->symbolic.assertions ) { 720 731 type->symbolic.assertions->appendList( assertions ); … … 723 734 } // if 724 735 break; 725 736 default: 726 737 assert( false ); 727 738 } // switch … … 822 833 if ( type ) { 823 834 switch ( type->kind ) { 824 825 835 case TypeData::Aggregate: 836 case TypeData::Enum: 826 837 p->type->base = new TypeData( TypeData::AggregateInst ); 827 838 p->type->base->aggInst.aggregate = type; … … 832 843 break; 833 844 834 845 default: 835 846 p->type->base = type; 836 847 } // switch … … 854 865 855 866 DeclarationNode * DeclarationNode::addNewArray( DeclarationNode * a ) { 856 867 if ( ! a ) return this; 857 868 assert( a->type->kind == TypeData::Array ); 858 869 TypeData * lastArray = findLast( a->type ); 859 870 if ( type ) { 860 871 switch ( type->kind ) { 861 862 872 case TypeData::Aggregate: 873 case TypeData::Enum: 863 874 lastArray->base = new TypeData( TypeData::AggregateInst ); 864 875 lastArray->base->aggInst.aggregate = type; … … 868 879 lastArray->base->qualifiers |= type->qualifiers; 869 880 break; 870 881 default: 871 882 lastArray->base = type; 872 883 } // switch … … 1204 1215 } // if 1205 1216 bool isDelete = initializer && initializer->get_isDelete(); 1206 Declaration * decl = buildDecl( type, name ? *name : string( "" ), storageClasses, maybeBuild < Expression >( bitfieldWidth ), funcSpecs, linkage, asmName, isDelete ? nullptr : maybeBuild< Initializer >(initializer), attributes )->set_extension( extension );1217 Declaration * decl = buildDecl( type, name ? *name : string( "" ), storageClasses, maybeBuild( bitfieldWidth ), funcSpecs, linkage, asmName, isDelete ? nullptr : maybeBuild(initializer), attributes )->set_extension( extension ); 1207 1218 if ( isDelete ) { 1208 1219 DeclarationWithType * dwt = strict_dynamic_cast<DeclarationWithType *>( decl ); … … 1213 1224 1214 1225 if ( assert.condition ) { 1215 return new StaticAssertDecl( maybeBuild < Expression >( assert.condition ), strict_dynamic_cast< ConstantExpr * >( maybeClone( assert.message ) ) );1226 return new StaticAssertDecl( maybeBuild( assert.condition ), strict_dynamic_cast< ConstantExpr * >( maybeClone( assert.message ) ) ); 1216 1227 } 1217 1228 … … 1227 1238 } // if 1228 1239 assertf( name, "ObjectDecl must a have name\n" ); 1229 return (new ObjectDecl( *name, storageClasses, linkage, maybeBuild < Expression >( bitfieldWidth ), nullptr, maybeBuild< Initializer >( initializer ) ))->set_asmName( asmName )->set_extension( extension );1240 return (new ObjectDecl( *name, storageClasses, linkage, maybeBuild( bitfieldWidth ), nullptr, maybeBuild( initializer ) ))->set_asmName( asmName )->set_extension( extension ); 1230 1241 } 1231 1242 … … 1234 1245 1235 1246 switch ( type->kind ) { 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1247 case TypeData::Enum: 1248 case TypeData::Aggregate: { 1249 ReferenceToType * ret = buildComAggInst( type, attributes, linkage ); 1250 buildList( type->aggregate.actuals, ret->get_parameters() ); 1251 return ret; 1252 } 1253 case TypeData::Symbolic: { 1254 TypeInstType * ret = new TypeInstType( buildQualifiers( type ), *type->symbolic.name, false, attributes ); 1255 buildList( type->symbolic.actuals, ret->get_parameters() ); 1256 return ret; 1257 } 1258 default: 1248 1259 Type * simpletypes = typebuild( type ); 1249 1260 simpletypes->get_attributes() = attributes; // copy because member is const -
src/Parser/ExpressionNode.cc
r5217569 rdbae916 9 9 // Author : Peter A. Buhr 10 10 // Created On : Sat May 16 13:17:07 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Sat Feb 11 14:49:00 202313 // Update Count : 10 7911 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Mar 14 12:00:00 2023 13 // Update Count : 1082 14 14 // 15 15 … … 71 71 size_t end = str.length() - 1; 72 72 if ( posn == end ) { type = 3; return; } // no length after 'l' => long 73 73 74 74 string::size_type next = posn + 1; // advance to length 75 75 if ( str[next] == '3' ) { // 32 … … 122 122 if ( str[i] == '1' ) v |= 1; 123 123 i += 1; 124 124 if ( i == last - 1 || (str[i] != '0' && str[i] != '1') ) break; 125 125 v <<= 1; 126 126 } // for … … 157 157 } // if 158 158 159 string::size_type posn;160 161 159 // 'u' can appear before or after length suffix 162 160 if ( str.find_last_of( "uU" ) != string::npos ) Unsigned = true; … … 166 164 } else { 167 165 // At least one digit in integer constant, so safe to backup while looking for suffix. 168 169 posn = str.find_last_of( "pP" ); // pointer value 170 if ( posn != string::npos ) { ltype = 5; str.erase( posn, 1 ); goto FINI; } 171 172 posn = str.find_last_of( "zZ" ); // size_t 173 if ( posn != string::npos ) { Unsigned = true; type = 2; ltype = 4; str.erase( posn, 1 ); goto FINI; } 174 175 posn = str.rfind( "hh" ); // signed char 176 if ( posn != string::npos ) { type = 1; str.erase( posn, 2 ); goto FINI; } 177 178 posn = str.rfind( "HH" ); // signed char 179 if ( posn != string::npos ) { type = 1; str.erase( posn, 2 ); goto FINI; } 180 181 posn = str.find_last_of( "hH" ); // short 182 if ( posn != string::npos ) { type = 0; str.erase( posn, 1 ); goto FINI; } 183 184 posn = str.find_last_of( "nN" ); // int (natural number) 185 if ( posn != string::npos ) { type = 2; str.erase( posn, 1 ); goto FINI; } 186 187 if ( str.rfind( "ll" ) != string::npos || str.rfind( "LL" ) != string::npos ) { type = 4; goto FINI; } 188 189 lnthSuffix( str, type, ltype ); // must be after check for "ll" 190 FINI: ; 166 string::size_type posn; 167 // pointer value 168 if ( posn = str.find_last_of( "pP" ); posn != string::npos ) { 169 ltype = 5; str.erase( posn, 1 ); 170 // size_t 171 } else if ( posn = str.find_last_of( "zZ" ); posn != string::npos ) { 172 Unsigned = true; type = 2; ltype = 4; str.erase( posn, 1 ); 173 // signed char 174 } else if ( posn = str.rfind( "hh" ); posn != string::npos ) { 175 type = 1; str.erase( posn, 2 ); 176 // signed char 177 } else if ( posn = str.rfind( "HH" ); posn != string::npos ) { 178 type = 1; str.erase( posn, 2 ); 179 // short 180 } else if ( posn = str.find_last_of( "hH" ); posn != string::npos ) { 181 type = 0; str.erase( posn, 1 ); 182 // int (natural number) 183 } else if ( posn = str.find_last_of( "nN" ); posn != string::npos ) { 184 type = 2; str.erase( posn, 1 ); 185 } else if ( str.rfind( "ll" ) != string::npos || str.rfind( "LL" ) != string::npos ) { 186 type = 4; 187 } else { 188 lnthSuffix( str, type, ltype ); 189 } // if 191 190 } // if 192 191 … … 196 195 if ( type == 5 ) SemanticError( yylloc, "int128 constant is not supported on this target " + str ); 197 196 #endif // ! __SIZEOF_INT128__ 198 197 199 198 if ( str[0] == '0' ) { // radix character ? 200 199 dec = false; … … 206 205 unsigned int len = str.length(); 207 206 if ( len > (2 + 16 + 16) ) SemanticError( yylloc, "128-bit hexadecimal constant to large " + str ); 208 if ( len <= (2 + 16) ) goto FHEX1; // hex digits < 2^64 209 str2 = "0x" + str.substr( len - 16 ); 210 sscanf( (char *)str2.c_str(), "%llx", &v2 ); 211 str = str.substr( 0, len - 16 ); 212 FHEX1: ; 207 // hex digits < 2^64 208 if ( len > (2 + 16) ) { 209 str2 = "0x" + str.substr( len - 16 ); 210 sscanf( (char *)str2.c_str(), "%llx", &v2 ); 211 str = str.substr( 0, len - 16 ); 212 } // if 213 213 sscanf( (char *)str.c_str(), "%llx", &v ); 214 214 #endif // __SIZEOF_INT128__ … … 309 309 // ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][type] ), false ); 310 310 ret2 = new ConstantExpr( Constant( new BasicType( noQualifiers, BasicType::LongLongSignedInt ), str2, v2 ) ); 311 ret = build_compoundLiteral( DeclarationNode::newBasicType( DeclarationNode::Int128 )->addType( DeclarationNode::newSignedNess( DeclarationNode::Unsigned ) ), 312 new InitializerNode( (InitializerNode *)(new InitializerNode( new ExpressionNode( v2 == 0 ? ret2 : ret ) ))->set_last( new InitializerNode( new ExpressionNode( v2 == 0 ? ret : ret2 ) ) ), true ) ); 311 ret = build_compoundLiteral( 312 DeclarationNode::newBasicType( DeclarationNode::Int128 )->addType( DeclarationNode::newSignedNess( DeclarationNode::Unsigned ) ), 313 new InitializerNode( (InitializerNode *)(new InitializerNode( new ExpressionNode( v2 == 0 ? ret2 : ret ) ))->set_last( new InitializerNode( new ExpressionNode( v2 == 0 ? ret : ret2 ) ) ), true ) ); 313 314 } else { // explicit length, (length_type)constant 314 315 ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][ltype], false ), false ); … … 435 436 Type * strtype; 436 437 switch ( str[0] ) { // str has >= 2 characters, i.e, null string "" => safe to look at subscripts 0/1 437 438 case 'u': 438 439 if ( str[1] == '8' ) goto Default; // utf-8 characters => array of char 439 440 // lookup type of associated typedef 440 441 strtype = new TypeInstType( Type::Qualifiers( ), "char16_t", false ); 441 442 break; 442 443 case 'U': 443 444 strtype = new TypeInstType( Type::Qualifiers( ), "char32_t", false ); 444 445 break; 445 446 case 'L': 446 447 strtype = new TypeInstType( Type::Qualifiers( ), "wchar_t", false ); 447 448 break; 448 449 449 Default: // char default string type 450 default: 450 451 strtype = new BasicType( Type::Qualifiers( ), BasicType::Char ); 451 452 } // switch … … 500 501 501 502 Expression * build_field_name_fraction_constants( Expression * fieldName, ExpressionNode * fracts ) { 502 return make_field_name_fraction_constants( fieldName, maybeMoveBuild < Expression >( fracts ) );503 return make_field_name_fraction_constants( fieldName, maybeMoveBuild( fracts ) ); 503 504 } // build_field_name_fraction_constants 504 505 … … 510 511 511 512 QualifiedNameExpr * build_qualified_expr( const DeclarationNode * decl_node, const NameExpr * name ) { 512 Declaration * newDecl = maybeBuild < Declaration >(decl_node);513 Declaration * newDecl = maybeBuild(decl_node); 513 514 if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { 514 515 const Type * t = newDeclWithType->get_type(); … … 548 549 if ( dynamic_cast< VoidType * >( targetType ) ) { 549 550 delete targetType; 550 return new CastExpr( maybeMoveBuild < Expression >(expr_node), false );551 return new CastExpr( maybeMoveBuild( expr_node ), false ); 551 552 } else { 552 return new CastExpr( maybeMoveBuild < Expression >(expr_node), targetType, false );553 return new CastExpr( maybeMoveBuild( expr_node ), targetType, false ); 553 554 } // if 554 555 } // build_cast 555 556 556 557 Expression * build_keyword_cast( AggregateDecl::Aggregate target, ExpressionNode * expr_node ) { 557 return new KeywordCastExpr( maybeMoveBuild < Expression >(expr_node), target );558 return new KeywordCastExpr( maybeMoveBuild( expr_node ), target ); 558 559 } 559 560 560 561 Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) { 561 return new VirtualCastExpr( maybeMoveBuild < Expression >( expr_node ), maybeMoveBuildType( decl_node ) );562 return new VirtualCastExpr( maybeMoveBuild( expr_node ), maybeMoveBuildType( decl_node ) ); 562 563 } // build_virtual_cast 563 564 564 565 Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ) { 565 return new UntypedMemberExpr( member, maybeMoveBuild < Expression >(expr_node) );566 return new UntypedMemberExpr( member, maybeMoveBuild( expr_node ) ); 566 567 } // build_fieldSel 567 568 … … 569 570 UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) ); 570 571 deref->location = expr_node->location; 571 deref->get_args().push_back( maybeMoveBuild < Expression >(expr_node) );572 deref->get_args().push_back( maybeMoveBuild( expr_node ) ); 572 573 UntypedMemberExpr * ret = new UntypedMemberExpr( member, deref ); 573 574 return ret; … … 581 582 582 583 Expression * build_and_or( ExpressionNode * expr_node1, ExpressionNode * expr_node2, bool kind ) { 583 return new LogicalExpr( notZeroExpr( maybeMoveBuild < Expression >(expr_node1) ), notZeroExpr( maybeMoveBuild< Expression >(expr_node2) ), kind );584 return new LogicalExpr( notZeroExpr( maybeMoveBuild( expr_node1 ) ), notZeroExpr( maybeMoveBuild( expr_node2 ) ), kind ); 584 585 } // build_and_or 585 586 586 587 Expression * build_unary_val( OperKinds op, ExpressionNode * expr_node ) { 587 588 list< Expression * > args; 588 args.push_back( maybeMoveBuild < Expression >(expr_node) );589 args.push_back( maybeMoveBuild( expr_node ) ); 589 590 return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args ); 590 591 } // build_unary_val 591 592 592 Expression * build_unary_ptr( OperKinds op, ExpressionNode * expr_node ) {593 list< Expression * > args;594 args.push_back( maybeMoveBuild< Expression >(expr_node) ); // xxx -- this is exactly the same as the val case now, refactor this code.595 return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );596 } // build_unary_ptr597 598 593 Expression * build_binary_val( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) { 599 594 list< Expression * > args; 600 args.push_back( maybeMoveBuild < Expression >(expr_node1) );601 args.push_back( maybeMoveBuild < Expression >(expr_node2) );595 args.push_back( maybeMoveBuild( expr_node1 ) ); 596 args.push_back( maybeMoveBuild( expr_node2 ) ); 602 597 return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args ); 603 598 } // build_binary_val … … 605 600 Expression * build_binary_ptr( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) { 606 601 list< Expression * > args; 607 args.push_back( maybeMoveBuild < Expression >(expr_node1) );608 args.push_back( maybeMoveBuild < Expression >(expr_node2) );602 args.push_back( maybeMoveBuild( expr_node1 ) ); 603 args.push_back( maybeMoveBuild( expr_node2 ) ); 609 604 return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args ); 610 605 } // build_binary_ptr 611 606 612 607 Expression * build_cond( ExpressionNode * expr_node1, ExpressionNode * expr_node2, ExpressionNode * expr_node3 ) { 613 return new ConditionalExpr( notZeroExpr( maybeMoveBuild < Expression >(expr_node1) ), maybeMoveBuild< Expression >(expr_node2), maybeMoveBuild< Expression >(expr_node3) );608 return new ConditionalExpr( notZeroExpr( maybeMoveBuild( expr_node1 ) ), maybeMoveBuild( expr_node2 ), maybeMoveBuild( expr_node3 ) ); 614 609 } // build_cond 615 610 … … 623 618 list< Expression * > args; 624 619 buildMoveList( expr_node, args ); 625 return new UntypedExpr( maybeMoveBuild < Expression >(function), args );620 return new UntypedExpr( maybeMoveBuild( function ), args ); 626 621 } // build_func 627 622 628 623 Expression * build_compoundLiteral( DeclarationNode * decl_node, InitializerNode * kids ) { 629 Declaration * newDecl = maybeBuild < Declaration >(decl_node); // compound literal type624 Declaration * newDecl = maybeBuild( decl_node ); // compound literal type 630 625 if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type 631 return new CompoundLiteralExpr( newDeclWithType->get_type(), maybeMoveBuild < Initializer >(kids) );626 return new CompoundLiteralExpr( newDeclWithType->get_type(), maybeMoveBuild( kids ) ); 632 627 // these types do not have associated type information 633 628 } else if ( StructDecl * newDeclStructDecl = dynamic_cast< StructDecl * >( newDecl ) ) { 634 629 if ( newDeclStructDecl->has_body() ) { 635 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl ), maybeMoveBuild < Initializer >(kids) );630 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl ), maybeMoveBuild( kids ) ); 636 631 } else { 637 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeMoveBuild < Initializer >(kids) );632 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeMoveBuild( kids ) ); 638 633 } // if 639 634 } else if ( UnionDecl * newDeclUnionDecl = dynamic_cast< UnionDecl * >( newDecl ) ) { 640 635 if ( newDeclUnionDecl->has_body() ) { 641 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl ), maybeMoveBuild < Initializer >(kids) );636 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl ), maybeMoveBuild( kids ) ); 642 637 } else { 643 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeMoveBuild < Initializer >(kids) );638 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeMoveBuild( kids ) ); 644 639 } // if 645 640 } else if ( EnumDecl * newDeclEnumDecl = dynamic_cast< EnumDecl * >( newDecl ) ) { 646 641 if ( newDeclEnumDecl->has_body() ) { 647 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl ), maybeMoveBuild < Initializer >(kids) );642 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl ), maybeMoveBuild( kids ) ); 648 643 } else { 649 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeMoveBuild < Initializer >(kids) );644 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeMoveBuild( kids ) ); 650 645 } // if 651 646 } else { … … 656 651 // Local Variables: // 657 652 // tab-width: 4 // 658 // mode: c++ //659 // compile-command: "make install" //660 653 // End: // -
src/Parser/InitializerNode.cc
r5217569 rdbae916 102 102 if ( get_expression() ) { 103 103 assertf( get_expression()->expr, "The expression of initializer must have value" ); 104 return new SingleInit( maybeBuild < Expression >( get_expression() ), maybeConstructed );104 return new SingleInit( maybeBuild( get_expression() ), maybeConstructed ); 105 105 } // if 106 106 } // if -
src/Parser/ParseNode.h
r5217569 rdbae916 137 137 bool isExpressionType() const { return nullptr != dynamic_cast<T>(expr.get()); } 138 138 139 Expression * build() const { return const_cast<ExpressionNode *>(this)->expr.release(); } 139 Expression * build() const { 140 Expression * node = const_cast<ExpressionNode *>(this)->expr.release(); 141 node->set_extension( this->get_extension() ); 142 node->location = this->location; 143 return node; 144 } 140 145 141 146 std::unique_ptr<Expression> expr; // public because of lifetime implications … … 143 148 bool extension = false; 144 149 }; // ExpressionNode 145 146 template< typename T >147 struct maybeBuild_t< Expression, T > {148 static inline Expression * doit( const T * orig ) {149 if ( orig ) {150 Expression * p = orig->build();151 p->set_extension( orig->get_extension() );152 p->location = orig->location;153 return p;154 } else {155 return nullptr;156 } // if157 }158 };159 150 160 151 // Must harmonize with OperName. … … 199 190 Expression * build_and_or( ExpressionNode * expr_node1, ExpressionNode * expr_node2, bool kind ); 200 191 Expression * build_unary_val( OperKinds op, ExpressionNode * expr_node ); 201 Expression * build_unary_ptr( OperKinds op, ExpressionNode * expr_node );202 192 Expression * build_binary_val( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ); 203 193 Expression * build_binary_ptr( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ); … … 213 203 struct DeclarationNode : public ParseNode { 214 204 // These enumerations must harmonize with their names in DeclarationNode.cc. 215 enum BasicType { Void, Bool, Char, Int, Int128, 216 Float, Double, LongDouble, uuFloat80, uuFloat128, 217 uFloat16, uFloat32, uFloat32x, uFloat64, uFloat64x, uFloat128, uFloat128x, NoBasicType }; 205 enum BasicType { 206 Void, Bool, Char, Int, Int128, 207 Float, Double, LongDouble, uuFloat80, uuFloat128, 208 uFloat16, uFloat32, uFloat32x, uFloat64, uFloat64x, uFloat128, uFloat128x, 209 NoBasicType 210 }; 218 211 static const char * basicTypeNames[]; 219 212 enum ComplexType { Complex, NoComplexType, Imaginary }; // Imaginary unsupported => parse, but make invisible and print error message … … 401 394 402 395 struct ForCtrl { 403 ForCtrl( ExpressionNode * expr, ExpressionNode * condition, ExpressionNode * change ) : 404 init( new StatementNode( build_expr( expr ) ) ), condition( condition ), change( change ) {} 405 ForCtrl( DeclarationNode * decl, ExpressionNode * condition, ExpressionNode * change ) : 406 init( new StatementNode( decl ) ), condition( condition ), change( change ) {} 396 ForCtrl( StatementNode * stmt, ExpressionNode * condition, ExpressionNode * change ) : 397 init( stmt ), condition( condition ), change( change ) {} 407 398 408 399 StatementNode * init; … … 451 442 while ( cur ) { 452 443 try { 453 SynTreeType * result = dynamic_cast< SynTreeType * >( maybeBuild < typename std::pointer_traits< decltype(cur->build())>::element_type >( cur ) );444 SynTreeType * result = dynamic_cast< SynTreeType * >( maybeBuild( cur ) ); 454 445 if ( result ) { 455 446 result->location = cur->location; -
src/Parser/StatementNode.cc
r5217569 rdbae916 38 38 DeclarationNode * agg = decl->extractAggregate(); 39 39 if ( agg ) { 40 StatementNode * nextStmt = new StatementNode( new DeclStmt( maybeBuild < Declaration >( decl ) ) );40 StatementNode * nextStmt = new StatementNode( new DeclStmt( maybeBuild( decl ) ) ); 41 41 set_next( nextStmt ); 42 42 if ( decl->get_next() ) { … … 51 51 agg = decl; 52 52 } // if 53 stmt.reset( new DeclStmt( maybeMoveBuild < Declaration >(agg) ) );53 stmt.reset( new DeclStmt( maybeMoveBuild( agg ) ) ); 54 54 } // StatementNode::StatementNode 55 55 … … 73 73 74 74 Statement * build_expr( ExpressionNode * ctl ) { 75 Expression * e = maybeMoveBuild < Expression >( ctl );75 Expression * e = maybeMoveBuild( ctl ); 76 76 77 77 if ( e ) return new ExprStmt( e ); … … 87 87 if ( ctl->condition ) { 88 88 // compare the provided condition against 0 89 cond = notZeroExpr( maybeMoveBuild < Expression >(ctl->condition) );89 cond = notZeroExpr( maybeMoveBuild( ctl->condition ) ); 90 90 } else { 91 91 for ( Statement * stmt : init ) { … … 134 134 } // if 135 135 // aststmt.size() == 0 for switch (...) {}, i.e., no declaration or statements 136 return new SwitchStmt( maybeMoveBuild < Expression >(ctl), aststmt );136 return new SwitchStmt( maybeMoveBuild( ctl ), aststmt ); 137 137 } // build_switch 138 138 139 139 Statement * build_case( ExpressionNode * ctl ) { 140 return new CaseStmt( maybeMoveBuild < Expression >(ctl), {} ); // stmt starts empty and then added to140 return new CaseStmt( maybeMoveBuild( ctl ), {} ); // stmt starts empty and then added to 141 141 } // build_case 142 142 … … 168 168 169 169 // do-while cannot have declarations in the contitional, so init is always empty 170 return new WhileDoStmt( notZeroExpr( maybeMoveBuild < Expression >(ctl) ), aststmt.front(), astelse.front(), {}, true );170 return new WhileDoStmt( notZeroExpr( maybeMoveBuild( ctl ) ), aststmt.front(), astelse.front(), {}, true ); 171 171 } // build_do_while 172 172 … … 176 176 177 177 Expression * astcond = nullptr; // maybe empty 178 astcond = notZeroExpr( maybeMoveBuild < Expression >(forctl->condition) );178 astcond = notZeroExpr( maybeMoveBuild( forctl->condition ) ); 179 179 180 180 Expression * astincr = nullptr; // maybe empty 181 astincr = maybeMoveBuild < Expression >(forctl->change);181 astincr = maybeMoveBuild( forctl->change ); 182 182 delete forctl; 183 183 … … 199 199 Statement * build_branch( string * identifier, BranchStmt::Type kind ) { 200 200 Statement * ret = new BranchStmt( * identifier, kind ); 201 delete identifier; 201 delete identifier; // allocated by lexer 202 202 return ret; 203 203 } // build_branch 204 204 205 205 Statement * build_computedgoto( ExpressionNode * ctl ) { 206 return new BranchStmt( maybeMoveBuild < Expression >(ctl), BranchStmt::Goto );206 return new BranchStmt( maybeMoveBuild( ctl ), BranchStmt::Goto ); 207 207 } // build_computedgoto 208 208 … … 236 236 list< CatchStmt * > aststmt; 237 237 buildMoveList< CatchStmt, StatementNode >( catch_, aststmt ); 238 CompoundStmt * tryBlock = strict_dynamic_cast< CompoundStmt * >( maybeMoveBuild< Statement >(try_));239 FinallyStmt * finallyBlock = dynamic_cast< FinallyStmt * >( maybeMoveBuild< Statement >(finally_) );238 CompoundStmt * tryBlock = strict_dynamic_cast< CompoundStmt * >( maybeMoveBuild( try_ ) ); 239 FinallyStmt * finallyBlock = dynamic_cast< FinallyStmt * >( maybeMoveBuild( finally_ ) ); 240 240 return new TryStmt( tryBlock, aststmt, finallyBlock ); 241 241 } // build_try … … 245 245 buildMoveList< Statement, StatementNode >( body, aststmt ); 246 246 assert( aststmt.size() == 1 ); 247 return new CatchStmt( kind, maybeMoveBuild < Declaration >(decl), maybeMoveBuild< Expression >(cond), aststmt.front() );247 return new CatchStmt( kind, maybeMoveBuild( decl ), maybeMoveBuild( cond ), aststmt.front() ); 248 248 } // build_catch 249 249 … … 274 274 275 275 WaitForStmt::Target target; 276 target.function = maybeBuild <Expression>( targetExpr );276 target.function = maybeBuild( targetExpr ); 277 277 278 278 ExpressionNode * next = dynamic_cast<ExpressionNode *>( targetExpr->get_next() ); … … 284 284 node->clauses.push_back( WaitForStmt::Clause{ 285 285 target, 286 maybeMoveBuild <Statement >( stmt ),287 notZeroExpr( maybeMoveBuild <Expression>( when ) )286 maybeMoveBuild( stmt ), 287 notZeroExpr( maybeMoveBuild( when ) ) 288 288 }); 289 289 … … 293 293 WaitForStmt * build_waitfor( ExpressionNode * targetExpr, StatementNode * stmt, ExpressionNode * when, WaitForStmt * node ) { 294 294 WaitForStmt::Target target; 295 target.function = maybeBuild <Expression>( targetExpr );295 target.function = maybeBuild( targetExpr ); 296 296 297 297 ExpressionNode * next = dynamic_cast<ExpressionNode *>( targetExpr->get_next() ); … … 303 303 node->clauses.insert( node->clauses.begin(), WaitForStmt::Clause{ 304 304 std::move( target ), 305 maybeMoveBuild <Statement >( stmt ),306 notZeroExpr( maybeMoveBuild <Expression>( when ) )305 maybeMoveBuild( stmt ), 306 notZeroExpr( maybeMoveBuild( when ) ) 307 307 }); 308 308 … … 314 314 315 315 if( timeout ) { 316 node->timeout.time = maybeMoveBuild <Expression>( timeout );317 node->timeout.statement = maybeMoveBuild <Statement >( stmt );318 node->timeout.condition = notZeroExpr( maybeMoveBuild <Expression>( when ) );316 node->timeout.time = maybeMoveBuild( timeout ); 317 node->timeout.statement = maybeMoveBuild( stmt ); 318 node->timeout.condition = notZeroExpr( maybeMoveBuild( when ) ); 319 319 } else { 320 node->orelse.statement = maybeMoveBuild <Statement >( stmt );321 node->orelse.condition = notZeroExpr( maybeMoveBuild <Expression>( when ) );320 node->orelse.statement = maybeMoveBuild( stmt ); 321 node->orelse.condition = notZeroExpr( maybeMoveBuild( when ) ); 322 322 } // if 323 323 … … 328 328 auto node = new WaitForStmt(); 329 329 330 node->timeout.time = maybeMoveBuild <Expression>( timeout );331 node->timeout.statement = maybeMoveBuild <Statement >( stmt );332 node->timeout.condition = notZeroExpr( maybeMoveBuild <Expression>( when ) );333 334 node->orelse.statement = maybeMoveBuild <Statement >( else_ );335 node->orelse.condition = notZeroExpr( maybeMoveBuild <Expression>( else_when ) );330 node->timeout.time = maybeMoveBuild( timeout ); 331 node->timeout.statement = maybeMoveBuild( stmt ); 332 node->timeout.condition = notZeroExpr( maybeMoveBuild( when ) ); 333 334 node->orelse.statement = maybeMoveBuild( else_ ); 335 node->orelse.condition = notZeroExpr( maybeMoveBuild( else_when ) ); 336 336 337 337 return node; … … 341 341 list< Expression * > e; 342 342 buildMoveList( exprs, e ); 343 Statement * s = maybeMoveBuild <Statement>( stmt );343 Statement * s = maybeMoveBuild( stmt ); 344 344 return new DeclStmt( new WithStmt( e, s ) ); 345 345 } // build_with … … 384 384 list< Expression * > expList; 385 385 buildMoveList( exprs, expList ); 386 Statement * body = maybeMoveBuild <Statement>( stmt );386 Statement * body = maybeMoveBuild( stmt ); 387 387 return new MutexStmt( body, expList ); 388 388 } // build_mutex -
src/Parser/TypeData.cc
r5217569 rdbae916 33 33 TypeData::TypeData( Kind k ) : location( yylloc ), kind( k ), base( nullptr ), forall( nullptr ) /*, PTR1( (void*)(0xdeadbeefdeadbeef)), PTR2( (void*)(0xdeadbeefdeadbeef) ) */ { 34 34 switch ( kind ) { 35 case Unknown: 36 case Pointer: 37 case Reference: 38 case EnumConstant: 39 case GlobalScope: 40 // nothing else to initialize 41 break; 42 case Basic: 43 // basic = new Basic_t; 44 break; 45 case Array: 46 // array = new Array_t; 35 case Unknown: 36 case Pointer: 37 case Reference: 38 case EnumConstant: 39 case GlobalScope: 40 case Basic: 41 // No unique data to initialize. 42 break; 43 case Array: 47 44 array.dimension = nullptr; 48 45 array.isVarLen = false; 49 46 array.isStatic = false; 50 47 break; 51 case Function: 52 // function = new Function_t; 48 case Function: 53 49 function.params = nullptr; 54 50 function.idList = nullptr; … … 57 53 function.withExprs = nullptr; 58 54 break; 59 // Enum is an Aggregate, so both structures are initialized together. 60 case Enum: 61 // enumeration = new Enumeration_t; 55 case Enum: 62 56 enumeration.name = nullptr; 63 57 enumeration.constants = nullptr; … … 65 59 enumeration.anon = false; 66 60 break; 67 case Aggregate: 68 // aggregate = new Aggregate_t; 61 case Aggregate: 69 62 aggregate.kind = AggregateDecl::NoAggregate; 70 63 aggregate.name = nullptr; … … 77 70 aggregate.anon = false; 78 71 break; 79 case AggregateInst: 80 // aggInst = new AggInst_t; 72 case AggregateInst: 81 73 aggInst.aggregate = nullptr; 82 74 aggInst.params = nullptr; 83 75 aggInst.hoistType = false; 84 76 break; 85 case Symbolic: 86 case SymbolicInst: 87 // symbolic = new Symbolic_t; 77 case Symbolic: 78 case SymbolicInst: 88 79 symbolic.name = nullptr; 89 80 symbolic.params = nullptr; … … 91 82 symbolic.assertions = nullptr; 92 83 break; 93 case Tuple: 94 // tuple = new Tuple_t; 84 case Tuple: 95 85 tuple = nullptr; 96 86 break; 97 case Typeof: 98 case Basetypeof: 99 // typeexpr = new Typeof_t; 87 case Typeof: 88 case Basetypeof: 100 89 typeexpr = nullptr; 101 90 break; 102 case Vtable:103 break;104 case Builtin:105 // builtin = new Builtin_t;106 91 case Builtin: 92 case Vtable: 93 // No unique data to initialize. 94 break; 95 case Qualified: 107 96 qualified.parent = nullptr; 108 97 qualified.child = nullptr; … … 117 106 118 107 switch ( kind ) { 119 case Unknown: 120 case Pointer: 121 case Reference: 122 case EnumConstant: 123 case GlobalScope: 124 // nothing to destroy 125 break; 126 case Basic: 127 // delete basic; 128 break; 129 case Array: 108 case Unknown: 109 case Pointer: 110 case Reference: 111 case EnumConstant: 112 case GlobalScope: 113 // No unique data to deconstruct. 114 break; 115 case Basic: 116 break; 117 case Array: 130 118 delete array.dimension; 131 // delete array; 132 break; 133 case Function: 119 break; 120 case Function: 134 121 delete function.params; 135 122 delete function.idList; … … 137 124 delete function.body; 138 125 delete function.withExprs; 139 // delete function; 140 break; 141 case Aggregate: 126 break; 127 case Aggregate: 142 128 delete aggregate.name; 143 129 delete aggregate.params; 144 130 delete aggregate.actuals; 145 131 delete aggregate.fields; 146 // delete aggregate; 147 break; 148 case AggregateInst: 132 break; 133 case AggregateInst: 149 134 delete aggInst.aggregate; 150 135 delete aggInst.params; 151 // delete aggInst; 152 break; 153 case Enum: 136 break; 137 case Enum: 154 138 delete enumeration.name; 155 139 delete enumeration.constants; 156 // delete enumeration; 157 break; 158 case Symbolic: 159 case SymbolicInst: 140 break; 141 case Symbolic: 142 case SymbolicInst: 160 143 delete symbolic.name; 161 144 delete symbolic.params; 162 145 delete symbolic.actuals; 163 146 delete symbolic.assertions; 164 // delete symbolic; 165 break; 166 case Tuple: 167 // delete tuple->members; 147 break; 148 case Tuple: 168 149 delete tuple; 169 150 break; 170 case Typeof: 171 case Basetypeof: 172 // delete typeexpr->expr; 151 case Typeof: 152 case Basetypeof: 173 153 delete typeexpr; 174 154 break; 175 case Vtable: 176 break; 177 case Builtin: 178 // delete builtin; 179 break; 180 case Qualified: 155 case Vtable: 156 case Builtin: 157 // No unique data to deconstruct. 158 break; 159 case Qualified: 181 160 delete qualified.parent; 182 161 delete qualified.child; 162 break; 183 163 } // switch 184 164 } // TypeData::~TypeData … … 192 172 193 173 switch ( kind ) { 194 195 196 197 198 174 case Unknown: 175 case EnumConstant: 176 case Pointer: 177 case Reference: 178 case GlobalScope: 199 179 // nothing else to copy 200 180 break; 201 181 case Basic: 202 182 newtype->basictype = basictype; 203 183 newtype->complextype = complextype; … … 205 185 newtype->length = length; 206 186 break; 207 187 case Array: 208 188 newtype->array.dimension = maybeClone( array.dimension ); 209 189 newtype->array.isVarLen = array.isVarLen; 210 190 newtype->array.isStatic = array.isStatic; 211 191 break; 212 192 case Function: 213 193 newtype->function.params = maybeClone( function.params ); 214 194 newtype->function.idList = maybeClone( function.idList ); … … 217 197 newtype->function.withExprs = maybeClone( function.withExprs ); 218 198 break; 219 199 case Aggregate: 220 200 newtype->aggregate.kind = aggregate.kind; 221 201 newtype->aggregate.name = aggregate.name ? new string( *aggregate.name ) : nullptr; … … 228 208 newtype->aggregate.parent = aggregate.parent ? new string( *aggregate.parent ) : nullptr; 229 209 break; 230 210 case AggregateInst: 231 211 newtype->aggInst.aggregate = maybeClone( aggInst.aggregate ); 232 212 newtype->aggInst.params = maybeClone( aggInst.params ); 233 213 newtype->aggInst.hoistType = aggInst.hoistType; 234 214 break; 235 215 case Enum: 236 216 newtype->enumeration.name = enumeration.name ? new string( *enumeration.name ) : nullptr; 237 217 newtype->enumeration.constants = maybeClone( enumeration.constants ); … … 239 219 newtype->enumeration.anon = enumeration.anon; 240 220 break; 241 242 221 case Symbolic: 222 case SymbolicInst: 243 223 newtype->symbolic.name = symbolic.name ? new string( *symbolic.name ) : nullptr; 244 224 newtype->symbolic.params = maybeClone( symbolic.params ); … … 247 227 newtype->symbolic.isTypedef = symbolic.isTypedef; 248 228 break; 249 229 case Tuple: 250 230 newtype->tuple = maybeClone( tuple ); 251 231 break; 252 253 232 case Typeof: 233 case Basetypeof: 254 234 newtype->typeexpr = maybeClone( typeexpr ); 255 235 break; 256 257 break; 258 236 case Vtable: 237 break; 238 case Builtin: 259 239 assert( builtintype == DeclarationNode::Zero || builtintype == DeclarationNode::One ); 260 240 newtype->builtintype = builtintype; 261 241 break; 262 242 case Qualified: 263 243 newtype->qualified.parent = maybeClone( qualified.parent ); 264 244 newtype->qualified.child = maybeClone( qualified.child ); … … 280 260 281 261 switch ( kind ) { 282 262 case Basic: 283 263 if ( signedness != DeclarationNode::NoSignedness ) os << DeclarationNode::signednessNames[ signedness ] << " "; 284 264 if ( length != DeclarationNode::NoLength ) os << DeclarationNode::lengthNames[ length ] << " "; … … 286 266 if ( basictype != DeclarationNode::NoBasicType ) os << DeclarationNode::basicTypeNames[ basictype ] << " "; 287 267 break; 288 268 case Pointer: 289 269 os << "pointer "; 290 270 if ( base ) { … … 293 273 } // if 294 274 break; 295 275 case Reference: 296 276 os << "reference "; 297 277 if ( base ) { … … 300 280 } // if 301 281 break; 302 282 case Array: 303 283 if ( array.isStatic ) { 304 284 os << "static "; … … 316 296 } // if 317 297 break; 318 298 case Function: 319 299 os << "function" << endl; 320 300 if ( function.params ) { … … 344 324 } // if 345 325 break; 346 326 case Aggregate: 347 327 os << AggregateDecl::aggrString( aggregate.kind ) << ' ' << *aggregate.name << endl; 348 328 if ( aggregate.params ) { … … 362 342 } // if 363 343 break; 364 344 case AggregateInst: 365 345 if ( aggInst.aggregate ) { 366 346 os << "instance of " ; … … 374 354 } // if 375 355 break; 376 356 case Enum: 377 357 os << "enumeration " << *enumeration.name << endl;; 378 358 if ( enumeration.constants ) { … … 388 368 } // if 389 369 break; 390 370 case EnumConstant: 391 371 os << "enumeration constant "; 392 372 break; 393 373 case Symbolic: 394 374 if ( symbolic.isTypedef ) { 395 375 os << "typedef definition "; … … 411 391 } // if 412 392 break; 413 393 case SymbolicInst: 414 394 os << *symbolic.name; 415 395 if ( symbolic.actuals ) { … … 419 399 } // if 420 400 break; 421 401 case Tuple: 422 402 os << "tuple "; 423 403 if ( tuple ) { … … 426 406 } // if 427 407 break; 428 408 case Basetypeof: 429 409 os << "base-"; 430 410 #if defined(__GNUC__) && __GNUC__ >= 7 … … 432 412 #endif 433 413 // FALL THROUGH 434 414 case Typeof: 435 415 os << "type-of expression "; 436 416 if ( typeexpr ) { … … 438 418 } // if 439 419 break; 440 420 case Vtable: 441 421 os << "vtable"; 442 422 break; 443 423 case Builtin: 444 424 os << DeclarationNode::builtinTypeNames[builtintype]; 445 425 break; 446 447 break; 448 426 case GlobalScope: 427 break; 428 case Qualified: 449 429 qualified.parent->print( os ); 450 430 os << "."; 451 431 qualified.child->print( os ); 452 432 break; 453 433 case Unknown: 454 434 os << "entity of unknown type "; 455 435 break; 456 436 default: 457 437 os << "internal error: TypeData::print " << kind << endl; 458 438 assert( false ); … … 462 442 const std::string * TypeData::leafName() const { 463 443 switch ( kind ) { 464 465 466 467 468 469 470 471 472 473 474 475 476 477 444 case Unknown: 445 case Pointer: 446 case Reference: 447 case EnumConstant: 448 case GlobalScope: 449 case Array: 450 case Basic: 451 case Function: 452 case AggregateInst: 453 case Tuple: 454 case Typeof: 455 case Basetypeof: 456 case Builtin: 457 case Vtable: 478 458 assertf(false, "Tried to get leaf name from kind without a name: %d", kind); 479 459 break; 480 460 case Aggregate: 481 461 return aggregate.name; 482 462 case Enum: 483 463 return enumeration.name; 484 485 464 case Symbolic: 465 case SymbolicInst: 486 466 return symbolic.name; 487 467 case Qualified: 488 468 return qualified.child->leafName(); 489 469 } // switch … … 530 510 assert( td ); 531 511 switch ( td->kind ) { 532 512 case TypeData::Unknown: 533 513 // fill in implicit int 534 514 return new BasicType( buildQualifiers( td ), BasicType::SignedInt ); 535 515 case TypeData::Basic: 536 516 return buildBasicType( td ); 537 517 case TypeData::Pointer: 538 518 return buildPointer( td ); 539 519 case TypeData::Array: 540 520 return buildArray( td ); 541 521 case TypeData::Reference: 542 522 return buildReference( td ); 543 523 case TypeData::Function: 544 524 return buildFunction( td ); 545 525 case TypeData::AggregateInst: 546 526 return buildAggInst( td ); 547 527 case TypeData::EnumConstant: 548 528 return new EnumInstType( buildQualifiers( td ), "" ); 549 529 case TypeData::SymbolicInst: 550 530 return buildSymbolicInst( td ); 551 531 case TypeData::Tuple: 552 532 return buildTuple( td ); 553 554 533 case TypeData::Typeof: 534 case TypeData::Basetypeof: 555 535 return buildTypeof( td ); 556 536 case TypeData::Vtable: 557 537 return buildVtable( td ); 558 538 case TypeData::Builtin: 559 539 switch ( td->builtintype ) { 560 540 case DeclarationNode::Zero: 561 541 return new ZeroType( noQualifiers ); 562 542 case DeclarationNode::One: 563 543 return new OneType( noQualifiers ); 564 544 default: 565 545 return new VarArgsType( buildQualifiers( td ) ); 566 546 } // switch 567 547 case TypeData::GlobalScope: 568 548 return new GlobalScopeType(); 569 549 case TypeData::Qualified: 570 550 return new QualifiedType( buildQualifiers( td ), typebuild( td->qualified.parent ), typebuild( td->qualified.child ) ); 571 572 573 551 case TypeData::Symbolic: 552 case TypeData::Enum: 553 case TypeData::Aggregate: 574 554 assert( false ); 575 555 } // switch … … 583 563 584 564 switch ( td->kind ) { 585 565 case TypeData::Aggregate: 586 566 if ( ! toplevel && td->aggregate.body ) { 587 567 ret = td->clone(); 588 568 } // if 589 569 break; 590 570 case TypeData::Enum: 591 571 if ( ! toplevel && td->enumeration.body ) { 592 572 ret = td->clone(); 593 573 } // if 594 574 break; 595 575 case TypeData::AggregateInst: 596 576 if ( td->aggInst.aggregate ) { 597 577 ret = typeextractAggregate( td->aggInst.aggregate, false ); 598 578 } // if 599 579 break; 600 580 default: 601 581 if ( td->base ) { 602 582 ret = typeextractAggregate( td->base, false ); … … 620 600 621 601 switch ( td->basictype ) { 622 602 case DeclarationNode::Void: 623 603 if ( td->signedness != DeclarationNode::NoSignedness ) { 624 604 genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype ); … … 630 610 break; 631 611 632 612 case DeclarationNode::Bool: 633 613 if ( td->signedness != DeclarationNode::NoSignedness ) { 634 614 genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype ); … … 641 621 break; 642 622 643 623 case DeclarationNode::Char: 644 624 // C11 Standard 6.2.5.15: The three types char, signed char, and unsigned char are collectively called the 645 625 // character types. The implementation shall define char to have the same range, representation, and behavior as … … 654 634 break; 655 635 656 636 case DeclarationNode::Int: 657 637 static BasicType::Kind inttype[2][4] = { 658 638 { BasicType::ShortSignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt, BasicType::SignedInt }, … … 660 640 }; 661 641 662 642 Integral: ; 663 643 if ( td->signedness == DeclarationNode::NoSignedness ) { 664 644 const_cast<TypeData *>(td)->signedness = DeclarationNode::Signed; … … 667 647 break; 668 648 669 649 case DeclarationNode::Int128: 670 650 ret = td->signedness == DeclarationNode::Unsigned ? BasicType::UnsignedInt128 : BasicType::SignedInt128; 671 651 if ( td->length != DeclarationNode::NoLength ) { … … 674 654 break; 675 655 676 677 678 679 680 681 682 683 684 685 686 687 656 case DeclarationNode::Float: 657 case DeclarationNode::Double: 658 case DeclarationNode::LongDouble: // not set until below 659 case DeclarationNode::uuFloat80: 660 case DeclarationNode::uuFloat128: 661 case DeclarationNode::uFloat16: 662 case DeclarationNode::uFloat32: 663 case DeclarationNode::uFloat32x: 664 case DeclarationNode::uFloat64: 665 case DeclarationNode::uFloat64x: 666 case DeclarationNode::uFloat128: 667 case DeclarationNode::uFloat128x: 688 668 static BasicType::Kind floattype[2][12] = { 689 669 { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex, (BasicType::Kind)-1, (BasicType::Kind)-1, BasicType::uFloat16Complex, BasicType::uFloat32Complex, BasicType::uFloat32xComplex, BasicType::uFloat64Complex, BasicType::uFloat64xComplex, BasicType::uFloat128Complex, BasicType::uFloat128xComplex, }, … … 691 671 }; 692 672 693 673 FloatingPoint: ; 694 674 if ( td->signedness != DeclarationNode::NoSignedness ) { 695 675 genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype ); … … 715 695 break; 716 696 717 697 case DeclarationNode::NoBasicType: 718 698 // No basic type in declaration => default double for Complex/Imaginary and int type for integral types 719 699 if ( td->complextype == DeclarationNode::Complex || td->complextype == DeclarationNode::Imaginary ) { … … 724 704 const_cast<TypeData *>(td)->basictype = DeclarationNode::Int; 725 705 goto Integral; 726 727 706 default: 707 assertf( false, "unknown basic type" ); 728 708 return nullptr; 729 709 } // switch … … 750 730 ArrayType * at; 751 731 if ( td->base ) { 752 at = new ArrayType( buildQualifiers( td ), typebuild( td->base ), maybeBuild < Expression >( td->array.dimension ),732 at = new ArrayType( buildQualifiers( td ), typebuild( td->base ), maybeBuild( td->array.dimension ), 753 733 td->array.isVarLen, td->array.isStatic ); 754 734 } else { 755 735 at = new ArrayType( buildQualifiers( td ), new BasicType( Type::Qualifiers(), BasicType::SignedInt ), 756 maybeBuild < Expression >( td->array.dimension ), td->array.isVarLen, td->array.isStatic );736 maybeBuild( td->array.dimension ), td->array.isVarLen, td->array.isStatic ); 757 737 } // if 758 738 buildForall( td->forall, at->get_forall() ); … … 777 757 AggregateDecl * at; 778 758 switch ( td->aggregate.kind ) { 779 780 781 782 783 784 759 case AggregateDecl::Struct: 760 case AggregateDecl::Coroutine: 761 case AggregateDecl::Exception: 762 case AggregateDecl::Generator: 763 case AggregateDecl::Monitor: 764 case AggregateDecl::Thread: 785 765 at = new StructDecl( *td->aggregate.name, td->aggregate.kind, attributes, linkage ); 786 766 buildForall( td->aggregate.params, at->get_parameters() ); 787 767 break; 788 768 case AggregateDecl::Union: 789 769 at = new UnionDecl( *td->aggregate.name, attributes, linkage ); 790 770 buildForall( td->aggregate.params, at->get_parameters() ); 791 771 break; 792 772 case AggregateDecl::Trait: 793 773 at = new TraitDecl( *td->aggregate.name, attributes, linkage ); 794 774 buildList( td->aggregate.params, at->get_parameters() ); 795 775 break; 796 776 default: 797 777 assert( false ); 798 778 } // switch … … 807 787 ReferenceToType * buildComAggInst( const TypeData * type, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) { 808 788 switch ( type->kind ) { 809 case TypeData::Enum: { 810 if ( type->enumeration.body ) { 811 EnumDecl * typedecl = buildEnum( type, attributes, linkage ); 812 return new EnumInstType( buildQualifiers( type ), typedecl ); 813 } else { 814 return new EnumInstType( buildQualifiers( type ), *type->enumeration.name ); 815 } // if 816 } 817 case TypeData::Aggregate: { 818 ReferenceToType * ret; 819 if ( type->aggregate.body ) { 820 AggregateDecl * typedecl = buildAggregate( type, attributes, linkage ); 821 switch ( type->aggregate.kind ) { 822 case AggregateDecl::Struct: 823 case AggregateDecl::Coroutine: 824 case AggregateDecl::Monitor: 825 case AggregateDecl::Thread: 826 ret = new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl ); 827 break; 828 case AggregateDecl::Union: 829 ret = new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl ); 830 break; 831 case AggregateDecl::Trait: 832 assert( false ); 833 //ret = new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl ); 834 break; 835 default: 836 assert( false ); 837 } // switch 838 } else { 839 switch ( type->aggregate.kind ) { 840 case AggregateDecl::Struct: 841 case AggregateDecl::Coroutine: 842 case AggregateDecl::Monitor: 843 case AggregateDecl::Thread: 844 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 845 break; 846 case AggregateDecl::Union: 847 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 848 break; 849 case AggregateDecl::Trait: 850 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 851 break; 852 default: 853 assert( false ); 854 } // switch 855 } // if 856 return ret; 857 } 858 default: 789 case TypeData::Enum: 790 if ( type->enumeration.body ) { 791 EnumDecl * typedecl = buildEnum( type, attributes, linkage ); 792 return new EnumInstType( buildQualifiers( type ), typedecl ); 793 } else { 794 return new EnumInstType( buildQualifiers( type ), *type->enumeration.name ); 795 } // if 796 case TypeData::Aggregate: 797 if ( type->aggregate.body ) { 798 AggregateDecl * typedecl = buildAggregate( type, attributes, linkage ); 799 switch ( type->aggregate.kind ) { 800 case AggregateDecl::Struct: 801 case AggregateDecl::Coroutine: 802 case AggregateDecl::Monitor: 803 case AggregateDecl::Thread: 804 return new StructInstType( buildQualifiers( type ), (StructDecl *)typedecl ); 805 case AggregateDecl::Union: 806 return new UnionInstType( buildQualifiers( type ), (UnionDecl *)typedecl ); 807 case AggregateDecl::Trait: 808 assert( false ); 809 //return new TraitInstType( buildQualifiers( type ), (TraitDecl *)typedecl ); 810 break; 811 default: 812 assert( false ); 813 } // switch 814 } else { 815 switch ( type->aggregate.kind ) { 816 case AggregateDecl::Struct: 817 case AggregateDecl::Coroutine: 818 case AggregateDecl::Monitor: 819 case AggregateDecl::Thread: 820 return new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 821 case AggregateDecl::Union: 822 return new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 823 case AggregateDecl::Trait: 824 return new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 825 default: 826 assert( false ); 827 } // switch 828 } // if 829 return nullptr; 830 default: 859 831 assert( false ); 860 832 } // switch … … 869 841 TypeData * type = td->aggInst.aggregate; 870 842 switch ( type->kind ) { 871 case TypeData::Enum: { 872 return new EnumInstType( buildQualifiers( type ), *type->enumeration.name ); 873 } 874 case TypeData::Aggregate: { 875 switch ( type->aggregate.kind ) { 876 case AggregateDecl::Struct: 877 case AggregateDecl::Coroutine: 878 case AggregateDecl::Monitor: 879 case AggregateDecl::Thread: 880 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 881 break; 882 case AggregateDecl::Union: 883 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 884 break; 885 case AggregateDecl::Trait: 886 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 887 break; 888 default: 889 assert( false ); 890 } // switch 891 } 892 break; 893 default: 843 case TypeData::Enum: 844 return new EnumInstType( buildQualifiers( type ), *type->enumeration.name ); 845 case TypeData::Aggregate: 846 switch ( type->aggregate.kind ) { 847 case AggregateDecl::Struct: 848 case AggregateDecl::Coroutine: 849 case AggregateDecl::Monitor: 850 case AggregateDecl::Thread: 851 ret = new StructInstType( buildQualifiers( type ), *type->aggregate.name ); 852 break; 853 case AggregateDecl::Union: 854 ret = new UnionInstType( buildQualifiers( type ), *type->aggregate.name ); 855 break; 856 case AggregateDecl::Trait: 857 ret = new TraitInstType( buildQualifiers( type ), *type->aggregate.name ); 858 break; 859 default: 860 assert( false ); 861 } // switch 862 break; 863 default: 894 864 assert( false ); 895 865 } // switch … … 931 901 } else if ( cur->has_enumeratorValue() ) { 932 902 ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members); 933 member->set_init( new SingleInit( maybeMoveBuild < Expression >( cur->consume_enumeratorValue() ) ) );903 member->set_init( new SingleInit( maybeMoveBuild( cur->consume_enumeratorValue() ) ) ); 934 904 } else if ( !cur->initializer ) { 935 905 if ( baseType && (!dynamic_cast<BasicType *>(baseType) || !dynamic_cast<BasicType *>(baseType)->isInteger())) { … … 985 955 986 956 FunctionDecl * decl; 987 Statement * stmt = maybeBuild <Statement>( td->function.body );957 Statement * stmt = maybeBuild( td->function.body ); 988 958 CompoundStmt * body = dynamic_cast< CompoundStmt * >( stmt ); 989 959 decl = new FunctionDecl( name, scs, linkage, buildFunction( td ), body, attributes, funcSpec ); … … 1010 980 if ( td->base ) { 1011 981 switch ( td->base->kind ) { 1012 982 case TypeData::Tuple: 1013 983 buildList( td->base->tuple, ft->returnVals ); 1014 984 break; 1015 985 default: 1016 986 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", Type::StorageClasses(), nullptr, Type::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) ); 1017 987 } // switch -
src/Parser/TypeData.h
r5217569 rdbae916 130 130 TypeofType * buildTypeof( const TypeData * ); 131 131 VTableType * buildVtable( const TypeData * ); 132 Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, Expression * asmName, 133 Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); 132 Declaration * buildDecl( 133 const TypeData *, const std::string &, Type::StorageClasses, Expression *, 134 Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, Expression * asmName, 135 Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); 134 136 FunctionType * buildFunction( const TypeData * ); 135 137 Declaration * addEnumBase( Declaration *, const TypeData * ); -
src/Parser/TypedefTable.cc
r5217569 rdbae916 31 31 static const char *kindName( int kind ) { 32 32 switch ( kind ) { 33 34 35 36 37 33 case IDENTIFIER: return "identifier"; 34 case TYPEDIMname: return "typedim"; 35 case TYPEDEFname: return "typedef"; 36 case TYPEGENname: return "typegen"; 37 default: 38 38 cerr << "Error: cfa-cpp internal error, invalid kind of identifier" << endl; 39 39 abort(); -
src/Parser/parser.yy
r5217569 rdbae916 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 25 13:23:16202313 // Update Count : 59 8912 // Last Modified On : Tue Mar 14 09:37:58 2023 13 // Update Count : 5990 14 14 // 15 15 … … 206 206 #define MISSING_HIGH "Missing high value for down-to range so index is uninitialized." 207 207 208 static ForCtrl * makeForCtrl( 209 DeclarationNode * init, 210 enum OperKinds compop, 211 ExpressionNode * comp, 212 ExpressionNode * inc ) { 213 // Wrap both comp/inc if they are non-null. 214 if ( comp ) comp = new ExpressionNode( build_binary_val( 215 compop, 216 new ExpressionNode( build_varref( new string( *init->name ) ) ), 217 comp ) ); 218 if ( inc ) inc = new ExpressionNode( build_binary_val( 219 // choose += or -= for upto/downto 220 compop == OperKinds::LThan || compop == OperKinds::LEThan ? OperKinds::PlusAssn : OperKinds::MinusAssn, 221 new ExpressionNode( build_varref( new string( *init->name ) ) ), 222 inc ) ); 223 // The StatementNode call frees init->name, it must happen later. 224 return new ForCtrl( new StatementNode( init ), comp, inc ); 225 } 226 208 227 ForCtrl * forCtrl( DeclarationNode * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) { 209 228 if ( index->initializer ) { … … 213 232 SemanticError( yylloc, "Multiple loop indexes disallowed in for-loop declaration." ); 214 233 } // if 215 return new ForCtrl( index->addInitializer( new InitializerNode( start ) ), 216 // NULL comp/inc => leave blank 217 comp ? new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index->name ) ) ), comp ) ) : nullptr, 218 inc ? new ExpressionNode( build_binary_val( compop == OperKinds::LThan || compop == OperKinds::LEThan ? // choose += or -= for upto/downto 219 OperKinds::PlusAssn : OperKinds::MinusAssn, new ExpressionNode( build_varref( new string( *index->name ) ) ), inc ) ) : nullptr ); 234 DeclarationNode * initDecl = index->addInitializer( new InitializerNode( start ) ); 235 return makeForCtrl( initDecl, compop, comp, inc ); 220 236 } // forCtrl 221 237 … … 223 239 ConstantExpr * constant = dynamic_cast<ConstantExpr *>(type->expr.get()); 224 240 if ( constant && (constant->get_constant()->get_value() == "0" || constant->get_constant()->get_value() == "1") ) { 225 type = new ExpressionNode( new CastExpr( maybeMoveBuild <Expression>(type), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) );241 type = new ExpressionNode( new CastExpr( maybeMoveBuild( type ), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) ); 226 242 } // if 227 // type = new ExpressionNode( build_func( new ExpressionNode( build_varref( new string( "__for_control_index_constraints__" ) ) ), type ) ); 228 return new ForCtrl( 229 distAttr( DeclarationNode::newTypeof( type, true ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ), 230 // NULL comp/inc => leave blank 231 comp ? new ExpressionNode( build_binary_val( compop, new ExpressionNode( build_varref( new string( *index ) ) ), comp ) ) : nullptr, 232 inc ? new ExpressionNode( build_binary_val( compop == OperKinds::LThan || compop == OperKinds::LEThan ? // choose += or -= for upto/downto 233 OperKinds::PlusAssn : OperKinds::MinusAssn, new ExpressionNode( build_varref( new string( *index ) ) ), inc ) ) : nullptr ); 243 DeclarationNode * initDecl = distAttr( 244 DeclarationNode::newTypeof( type, true ), 245 DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) 246 ); 247 return makeForCtrl( initDecl, compop, comp, inc ); 234 248 } // forCtrl 235 249 … … 649 663 { $$ = $2; } 650 664 | '(' compound_statement ')' // GCC, lambda expression 651 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast<CompoundStmt *>(maybeMoveBuild <Statement>($2) ) ) ); }665 { $$ = new ExpressionNode( new StmtExpr( dynamic_cast<CompoundStmt *>(maybeMoveBuild( $2 ) ) ) ); } 652 666 | type_name '.' identifier // CFA, nested type 653 667 { $$ = new ExpressionNode( build_qualified_expr( $1, build_varref( $3 ) ) ); } … … 657 671 { 658 672 // add the missing control expression to the GenericExpr and return it 659 $5->control = maybeMoveBuild <Expression>( $3 );673 $5->control = maybeMoveBuild( $3 ); 660 674 $$ = new ExpressionNode( $5 ); 661 675 } … … 693 707 { 694 708 // create a GenericExpr wrapper with one association pair 695 $$ = new GenericExpr( nullptr, { { maybeMoveBuildType($1), maybeMoveBuild <Expression>( $3 ) } } );709 $$ = new GenericExpr( nullptr, { { maybeMoveBuildType($1), maybeMoveBuild( $3 ) } } ); 696 710 } 697 711 | DEFAULT ':' assignment_expression 698 { $$ = new GenericExpr( nullptr, { { maybeMoveBuild <Expression>( $3 ) } } ); }712 { $$ = new GenericExpr( nullptr, { { maybeMoveBuild( $3 ) } } ); } 699 713 ; 700 714 … … 751 765 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $4 ) ) ); } 752 766 | postfix_expression ICR 753 { $$ = new ExpressionNode( build_unary_ ptr( OperKinds::IncrPost, $1 ) ); }767 { $$ = new ExpressionNode( build_unary_val( OperKinds::IncrPost, $1 ) ); } 754 768 | postfix_expression DECR 755 { $$ = new ExpressionNode( build_unary_ ptr( OperKinds::DecrPost, $1 ) ); }769 { $$ = new ExpressionNode( build_unary_val( OperKinds::DecrPost, $1 ) ); } 756 770 | '(' type_no_function ')' '{' initializer_list_opt comma_opt '}' // C99, compound-literal 757 771 { $$ = new ExpressionNode( build_compoundLiteral( $2, new InitializerNode( $5, true ) ) ); } … … 793 807 field_name 794 808 | FLOATING_DECIMALconstant field 795 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), maybeMoveBuild <Expression>( $2 ) ) ); }809 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), maybeMoveBuild( $2 ) ) ); } 796 810 | FLOATING_DECIMALconstant '[' field_name_list ']' 797 811 { $$ = new ExpressionNode( build_fieldSel( new ExpressionNode( build_field_name_FLOATING_DECIMALconstant( *$1 ) ), build_tuple( $3 ) ) ); } 798 812 | field_name '.' field 799 { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild <Expression>( $3 ) ) ); }813 { $$ = new ExpressionNode( build_fieldSel( $1, maybeMoveBuild( $3 ) ) ); } 800 814 | field_name '.' '[' field_name_list ']' 801 815 { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); } 802 816 | field_name ARROW field 803 { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild <Expression>( $3 ) ) ); }817 { $$ = new ExpressionNode( build_pfieldSel( $1, maybeMoveBuild( $3 ) ) ); } 804 818 | field_name ARROW '[' field_name_list ']' 805 819 { $$ = new ExpressionNode( build_pfieldSel( $1, build_tuple( $4 ) ) ); } … … 843 857 switch ( $1 ) { 844 858 case OperKinds::AddressOf: 845 $$ = new ExpressionNode( new AddressExpr( maybeMoveBuild <Expression>( $2 ) ) );859 $$ = new ExpressionNode( new AddressExpr( maybeMoveBuild( $2 ) ) ); 846 860 break; 847 861 case OperKinds::PointTo: … … 849 863 break; 850 864 case OperKinds::And: 851 $$ = new ExpressionNode( new AddressExpr( new AddressExpr( maybeMoveBuild <Expression>( $2 ) ) ) );865 $$ = new ExpressionNode( new AddressExpr( new AddressExpr( maybeMoveBuild( $2 ) ) ) ); 852 866 break; 853 867 default: … … 858 872 { $$ = new ExpressionNode( build_unary_val( $1, $2 ) ); } 859 873 | ICR unary_expression 860 { $$ = new ExpressionNode( build_unary_ ptr( OperKinds::Incr, $2 ) ); }874 { $$ = new ExpressionNode( build_unary_val( OperKinds::Incr, $2 ) ); } 861 875 | DECR unary_expression 862 { $$ = new ExpressionNode( build_unary_ ptr( OperKinds::Decr, $2 ) ); }876 { $$ = new ExpressionNode( build_unary_val( OperKinds::Decr, $2 ) ); } 863 877 | SIZEOF unary_expression 864 { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuild <Expression>( $2 ) ) ); }878 { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuild( $2 ) ) ); } 865 879 | SIZEOF '(' type_no_function ')' 866 880 { $$ = new ExpressionNode( new SizeofExpr( maybeMoveBuildType( $3 ) ) ); } 867 881 | ALIGNOF unary_expression // GCC, variable alignment 868 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuild <Expression>( $2 ) ) ); }882 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuild( $2 ) ) ); } 869 883 | ALIGNOF '(' type_no_function ')' // GCC, type alignment 870 884 { $$ = new ExpressionNode( new AlignofExpr( maybeMoveBuildType( $3 ) ) ); } … … 901 915 { $$ = new ExpressionNode( build_keyword_cast( $2, $5 ) ); } 902 916 | '(' VIRTUAL ')' cast_expression // CFA 903 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild <Expression>( $4 ), maybeMoveBuildType( nullptr ) ) ); }917 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild( $4 ), maybeMoveBuildType( nullptr ) ) ); } 904 918 | '(' VIRTUAL type_no_function ')' cast_expression // CFA 905 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild <Expression>( $5 ), maybeMoveBuildType( $3 ) ) ); }919 { $$ = new ExpressionNode( new VirtualCastExpr( maybeMoveBuild( $5 ), maybeMoveBuildType( $3 ) ) ); } 906 920 | '(' RETURN type_no_function ')' cast_expression // CFA 907 921 { SemanticError( yylloc, "Return cast is currently unimplemented." ); $$ = nullptr; } … … 1092 1106 assignment_expression 1093 1107 | comma_expression ',' assignment_expression 1094 { $$ = new ExpressionNode( new CommaExpr( maybeMoveBuild <Expression>( $1 ), maybeMoveBuild<Expression>( $3 ) ) ); }1108 { $$ = new ExpressionNode( new CommaExpr( maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); } 1095 1109 ; 1096 1110 … … 1230 1244 constant_expression { $$ = $1; } 1231 1245 | constant_expression ELLIPSIS constant_expression // GCC, subrange 1232 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild <Expression>( $1 ), maybeMoveBuild<Expression>( $3 ) ) ); }1246 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); } 1233 1247 | subrange // CFA, subrange 1234 1248 ; … … 1298 1312 { $$ = new StatementNode( build_do_while( $5, maybe_build_compound( $2 ), $8 ) ); } 1299 1313 | FOR '(' ')' statement %prec THEN // CFA => for ( ;; ) 1300 { $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) ); }1314 { $$ = new StatementNode( build_for( new ForCtrl( nullptr, nullptr, nullptr ), maybe_build_compound( $4 ) ) ); } 1301 1315 | FOR '(' ')' statement ELSE statement // CFA 1302 1316 { 1303 $$ = new StatementNode( build_for( new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ), maybe_build_compound( $4 ) ) );1317 $$ = new StatementNode( build_for( new ForCtrl( nullptr, nullptr, nullptr ), maybe_build_compound( $4 ) ) ); 1304 1318 SemanticWarning( yylloc, Warning::SuperfluousElse ); 1305 1319 } … … 1335 1349 for_control_expression: 1336 1350 ';' comma_expression_opt ';' comma_expression_opt 1337 { $$ = new ForCtrl( (ExpressionNode * )nullptr, $2, $4 ); }1351 { $$ = new ForCtrl( nullptr, $2, $4 ); } 1338 1352 | comma_expression ';' comma_expression_opt ';' comma_expression_opt 1339 { $$ = new ForCtrl( $1, $3, $5 ); } 1353 { 1354 StatementNode * init = $1 ? new StatementNode( new ExprStmt( maybeMoveBuild( $1 ) ) ) : nullptr; 1355 $$ = new ForCtrl( init, $3, $5 ); 1356 } 1340 1357 | declaration comma_expression_opt ';' comma_expression_opt // C99, declaration has ';' 1341 { $$ = new ForCtrl( $1, $2, $4 ); }1358 { $$ = new ForCtrl( new StatementNode( $1 ), $2, $4 ); } 1342 1359 1343 1360 | '@' ';' comma_expression // CFA, empty loop-index 1344 { $$ = new ForCtrl( (ExpressionNode *)nullptr, $3, nullptr ); }1361 { $$ = new ForCtrl( nullptr, $3, nullptr ); } 1345 1362 | '@' ';' comma_expression ';' comma_expression // CFA, empty loop-index 1346 { $$ = new ForCtrl( (ExpressionNode *)nullptr, $3, $5 ); }1363 { $$ = new ForCtrl( nullptr, $3, $5 ); } 1347 1364 1348 1365 | comma_expression // CFA, anonymous loop-index … … 1732 1749 asm_operand: // GCC 1733 1750 string_literal '(' constant_expression ')' 1734 { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild <Expression>( $3 ) ) ); }1751 { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild( $3 ) ) ); } 1735 1752 | '[' IDENTIFIER ']' string_literal '(' constant_expression ')' 1736 { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild <Expression>( $6 ) ) ); }1753 { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild( $6 ) ) ); } 1737 1754 ; 1738 1755 … … 2038 2055 basic_type_specifier 2039 2056 | sue_type_specifier 2040 {2041 // printf( "sue_type_specifier2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );2042 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {2043 // printf( "\tattr %s\n", attr->name.c_str() );2044 // } // for2045 }2046 2057 | type_type_specifier 2047 2058 ; … … 2383 2394 '{' field_declaration_list_opt '}' type_parameters_opt 2384 2395 { 2385 // printf( "aggregate_type1 %s\n", $3.str->c_str() );2386 // if ( $2 )2387 // for ( Attribute * attr: reverseIterate( $2->attributes ) ) {2388 // printf( "copySpecifiers12 %s\n", attr->name.c_str() );2389 // } // for2390 2396 $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); 2391 // printf( "aggregate_type2 %p %s\n", $$, $$->type->aggregate.name ? $$->type->aggregate.name->c_str() : "(nil)" );2392 // for ( Attribute * attr: reverseIterate( $$->attributes ) ) {2393 // printf( "aggregate_type3 %s\n", attr->name.c_str() );2394 // } // for2395 2397 } 2396 2398 | aggregate_key attribute_list_opt TYPEDEFname // unqualified type name … … 2401 2403 '{' field_declaration_list_opt '}' type_parameters_opt 2402 2404 { 2403 // printf( "AGG3\n" );2404 2405 DeclarationNode::newFromTypedef( $3 ); 2405 2406 $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); … … 2412 2413 '{' field_declaration_list_opt '}' type_parameters_opt 2413 2414 { 2414 // printf( "AGG4\n" );2415 2415 DeclarationNode::newFromTypeGen( $3, nullptr ); 2416 2416 $$ = DeclarationNode::newAggregate( $1, $3, $8, $6, true )->addQualifiers( $2 ); … … 2439 2439 // switched to a TYPEGENname. Link any generic arguments from typegen_name to new generic declaration and 2440 2440 // delete newFromTypeGen. 2441 $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $3->type->symbolic.actuals, nullptr, false )->addQualifiers( $2 ); 2442 $3->type->symbolic.name = nullptr; 2443 $3->type->symbolic.actuals = nullptr; 2444 delete $3; 2441 if ( $3->type->kind == TypeData::SymbolicInst && ! $3->type->symbolic.isTypedef ) { 2442 $$ = $3->addQualifiers( $2 ); 2443 } else { 2444 $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $3->type->symbolic.actuals, nullptr, false )->addQualifiers( $2 ); 2445 $3->type->symbolic.name = nullptr; // copied to $$ 2446 $3->type->symbolic.actuals = nullptr; 2447 delete $3; 2448 } 2445 2449 } 2446 2450 ; … … 2779 2783 type_no_function: // sizeof, alignof, cast (constructor) 2780 2784 cfa_abstract_declarator_tuple // CFA 2781 | type_specifier 2785 | type_specifier // cannot be type_specifier_nobody, e.g., (struct S {}){} is a thing 2782 2786 | type_specifier abstract_declarator 2783 2787 { $$ = $2->addType( $1 ); } … … 2843 2847 { $$ = $3; } 2844 2848 | '[' push constant_expression ELLIPSIS constant_expression pop ']' // GCC, multiple array elements 2845 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild <Expression>( $3 ), maybeMoveBuild<Expression>( $5 ) ) ); }2849 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild( $3 ), maybeMoveBuild( $5 ) ) ); } 2846 2850 | '.' '[' push field_name_list pop ']' // CFA, tuple field selector 2847 2851 { $$ = $4; } … … 3231 3235 subrange: 3232 3236 constant_expression '~' constant_expression // CFA, integer subrange 3233 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild <Expression>( $1 ), maybeMoveBuild<Expression>( $3 ) ) ); }3237 { $$ = new ExpressionNode( new RangeExpr( maybeMoveBuild( $1 ), maybeMoveBuild( $3 ) ) ); } 3234 3238 ; 3235 3239 -
src/Parser/parserutility.h
r5217569 rdbae916 10 10 // Created On : Sat May 16 15:31:46 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Feb 16 12:34:00 202313 // Update Count : 512 // Last Modified On : Thr Mar 9 12:16:00 2023 13 // Update Count : 6 14 14 // 15 15 … … 20 20 Expression *notZeroExpr( Expression *orig ); 21 21 22 template< typename T, typename U > 23 struct maybeBuild_t { 24 static T * doit( const U *orig ) { 25 if ( orig ) { 26 return orig->build(); 27 } else { 28 return 0; 29 } 30 } 31 }; 32 33 template< typename T, typename U > 34 static inline T * maybeBuild( const U *orig ) { 35 return maybeBuild_t<T,U>::doit(orig); 22 template< typename T > 23 static inline auto maybeBuild( const T *orig ) -> decltype(orig->build()) { 24 return (orig) ? orig->build() : nullptr; 36 25 } 37 26 38 template< typename T , typename U>39 static inline T * maybeMoveBuild( const U *orig) {40 T*ret = maybeBuild<T>(orig);27 template< typename T > 28 static inline auto maybeMoveBuild( const T *orig ) -> decltype(orig->build()) { 29 auto ret = maybeBuild<T>(orig); 41 30 delete orig; 42 31 return ret; -
tests/io/comp_fair.cfa
r5217569 rdbae916 29 29 barrier & bar; 30 30 int pipe[2]; 31 32 31 } globals; 33 32 -
tests/linking/mangling/header.hfa
r5217569 rdbae916 8 8 extern name_but_a_typedefed_t a_typedefed_global; 9 9 10 extern struct /* anonymous */ { 11 int some_int; 12 int some_other_int; 13 } a_global_with_no_type; 10 // Must be extern C to prevent name mangling. 11 extern "C" { 12 extern struct /* anonymous */ { 13 int some_int; 14 int some_other_int; 15 } a_global_with_no_type; 16 } -
tests/linking/mangling/lib.cfa
r5217569 rdbae916 3 3 name_but_a_typedefed_t a_typedefed_global; 4 4 5 struct { 6 int some_int; 7 int some_other_int; 8 } a_global_with_no_type; 5 // Must be extern C to prevent name mangling. 6 extern "C" { 7 // This declaration is necessary to create an instance of a_global_with_no_type. 8 // typeof is a trick to get a_global_with_no_type's type because its type is anonymous. 9 // Otherwise C generates conflicting types for a_global_with_no_type in .h and .c 10 // because C uses name equivalence and the two anonymous types cannot have the same name. 11 typeof(a_global_with_no_type) a_global_with_no_type; 12 } -
tests/linking/mangling/main.cfa
r5217569 rdbae916 1 1 #include <fstream.hfa> 2 2 3 st ruct { int a; } test; //purposefully before the include3 static struct { int a; } test; // purposefully before the include to force anonymous name numbering 4 4 5 5 #include "header.hfa" … … 13 13 14 14 sout | "Done!"; 15 16 return 0;17 15 }
Note: See TracChangeset
for help on using the changeset viewer.