Changes in / [e7d6968:37b7d95]


Ignore:
Files:
3 added
6 deleted
53 edited

Legend:

Unmodified
Added
Removed
  • Jenkins/FullBuild

    re7d6968 r37b7d95  
    1717
    1818                                parallel (
    19                                         gcc_8_x86: { trigger_build( 'gcc-8',   'x86' ) },
    20                                         gcc_7_x86: { trigger_build( 'gcc-7',   'x86' ) },
     19                                        clang_x86: { trigger_build( 'gcc-8',   'x86' ) },
     20                                        gcc_5_x86: { trigger_build( 'gcc-7',   'x86' ) },
    2121                                        gcc_6_x86: { trigger_build( 'gcc-6',   'x86' ) },
    2222                                        gcc_9_x64: { trigger_build( 'gcc-9',   'x64' ) },
  • Jenkinsfile

    re7d6968 r37b7d95  
    127127                        }
    128128
    129                         ast = Settings.NewAST ? "--enable-new-ast" : "--disable-new-ast"
    130 
    131                         sh "${SrcDir}/configure CXX=${Settings.Compiler.CXX} CC=${Settings.Compiler.CC} ${Settings.Architecture.flags} AR=gcc-ar RANLIB=gcc-ranlib ${targets} ${ast} --quiet --prefix=${BuildDir}"
     129                        sh "${SrcDir}/configure CXX=${Settings.Compiler.CXX} CC=${Settings.Compiler.CC} ${Settings.Architecture.flags} AR=gcc-ar RANLIB=gcc-ranlib ${targets} --quiet --prefix=${BuildDir}"
    132130
    133131                        // Configure libcfa
     
    361359        public final CC_Desc Compiler
    362360        public final Arch_Desc Architecture
    363         public final Boolean NewAST
    364361        public final Boolean RunAllTests
    365362        public final Boolean RunBenchmark
     
    395392                        break
    396393                        case 'clang':
    397                                 this.Compiler = new CC_Desc('clang', 'clang++-10', 'gcc-9', '-flto=thin -flto-jobs=0')
     394                                this.Compiler = new CC_Desc('clang', 'clang++-6.0', 'gcc-6', '-flto=thin -flto-jobs=0')
    398395                        break
    399396                        default :
     
    413410
    414411                this.IsSandbox          = (branch == "jenkins-sandbox")
    415                 this.NewAST             = param.NewAST
    416412                this.RunAllTests        = param.RunAllTests
    417413                this.RunBenchmark       = param.RunBenchmark
     
    474470                                ],                                                                                              \
    475471                                [$class: 'BooleanParameterDefinition',                                                  \
    476                                         description: 'If true, build compiler using new AST',           \
    477                                         name: 'NewAST',                                                                         \
    478                                         defaultValue: false,                                                            \
    479                                 ],                                                                                              \
    480                                 [$class: 'BooleanParameterDefinition',                                                  \
    481472                                        description: 'If false, only the quick test suite is ran',              \
    482473                                        name: 'RunAllTests',                                                            \
    483474                                        defaultValue: false,                                                            \
    484                                 ],
     475                                ],                                                                                              \
    485476                                [$class: 'BooleanParameterDefinition',                                                  \
    486477                                        description: 'If true, jenkins also runs benchmarks',           \
  • libcfa/prelude/builtins.c

    re7d6968 r37b7d95  
    1010// Created On       : Fri Jul 21 16:21:03 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Oct  9 18:26:19 2020
    13 // Update Count     : 110
     12// Last Modified On : Mon Jul 13 21:10:02 2020
     13// Update Count     : 109
    1414//
    1515
     
    9494// universal typed pointer constant
    9595static inline forall( dtype DT ) DT * intptr( uintptr_t addr ) { return (DT *)addr; }
    96 static inline forall( ftype FT ) FT * intptr( uintptr_t addr ) { return (FT *)addr; }
    9796
    9897#if defined(__SIZEOF_INT128__)
  • libcfa/src/concurrency/coroutine.cfa

    re7d6968 r37b7d95  
    4747
    4848//-----------------------------------------------------------------------------
    49 FORALL_DATA_INSTANCE(CoroutineCancelled, (dtype coroutine_t), (coroutine_t))
     49FORALL_DATA_INSTANCE(CoroutineCancelled,
     50                (dtype coroutine_t | sized(coroutine_t)), (coroutine_t))
    5051
    5152struct __cfaehm_node {
     
    5859void mark_exception(CoroutineCancelled(T) *) {}
    5960
    60 forall(dtype T)
     61forall(dtype T | sized(T))
    6162void copy(CoroutineCancelled(T) * dst, CoroutineCancelled(T) * src) {
    6263        dst->the_coroutine = src->the_coroutine;
     
    7677        exception_t * except = (exception_t *)(1 + (__cfaehm_node *)desc->cancellation);
    7778
    78         // TODO: Remove explitate vtable set once trac#186 is fixed.
    7979        CoroutineCancelled(T) except;
    80         except.virtual_table = &get_exception_vtable(&except);
    8180        except.the_coroutine = &cor;
    8281        except.the_exception = except;
     
    9291
    9392// minimum feasible stack size in bytes
    94 static const size_t MinStackSize = 1000;
     93#define MinStackSize 1000
    9594extern size_t __page_size;                              // architecture pagesize HACK, should go in proper runtime singleton
    9695
  • libcfa/src/concurrency/coroutine.hfa

    re7d6968 r37b7d95  
    2222//-----------------------------------------------------------------------------
    2323// Exception thrown from resume when a coroutine stack is cancelled.
    24 FORALL_DATA_EXCEPTION(CoroutineCancelled, (dtype coroutine_t), (coroutine_t)) (
     24// Should not have to be be sized (see trac #196).
     25FORALL_DATA_EXCEPTION(CoroutineCancelled,
     26                (dtype coroutine_t | sized(coroutine_t)), (coroutine_t)) (
    2527        coroutine_t * the_coroutine;
    2628        exception_t * the_exception;
     
    2830
    2931forall(dtype T)
     32void mark_exception(CoroutineCancelled(T) *);
     33
     34forall(dtype T | sized(T))
    3035void copy(CoroutineCancelled(T) * dst, CoroutineCancelled(T) * src);
    3136
     
    3742// Anything that implements this trait can be resumed.
    3843// Anything that is resumed is a coroutine.
    39 trait is_coroutine(dtype T | IS_RESUMPTION_EXCEPTION(CoroutineCancelled, (T))) {
     44trait is_coroutine(dtype T | sized(T)
     45                | is_resumption_exception(CoroutineCancelled(T))
     46                | VTABLE_ASSERTION(CoroutineCancelled, (T))) {
    4047        void main(T & this);
    4148        $coroutine * get_coroutine(T & this);
  • libcfa/src/concurrency/io.cfa

    re7d6968 r37b7d95  
    134134                int ret = 0;
    135135                if( need_sys_to_submit || need_sys_to_complete ) {
    136                         ret = syscall( __NR_io_uring_enter, ring.fd, to_submit, 0, flags, (sigset_t *)0p, _NSIG / 8);
     136                        ret = syscall( __NR_io_uring_enter, ring.fd, to_submit, 0, flags, 0p, _NSIG / 8);
    137137                        if( ret < 0 ) {
    138138                                switch((int)errno) {
  • libcfa/src/concurrency/io/call.cfa.in

    re7d6968 r37b7d95  
    4747        #include "kernel/fwd.hfa"
    4848
    49         static const __u8 REGULAR_FLAGS = 0
    50                 #if defined(CFA_HAVE_IOSQE_FIXED_FILE)
    51                         | IOSQE_FIXED_FILE
    52                 #endif
    53                 #if defined(CFA_HAVE_IOSQE_IO_DRAIN)
    54                         | IOSQE_IO_DRAIN
    55                 #endif
    56                 #if defined(CFA_HAVE_IOSQE_ASYNC)
    57                         | IOSQE_ASYNC
    58                 #endif
    59         ;
    60 
    61         static const __u32 LINK_FLAGS = 0
    62                 #if defined(CFA_HAVE_IOSQE_IO_LINK)
    63                         | IOSQE_IO_LINK
    64                 #endif
    65                 #if defined(CFA_HAVE_IOSQE_IO_HARDLINK)
    66                         | IOSQE_IO_HARDLINK
    67                 #endif
    68         ;
    69 
    70         static const __u32 SPLICE_FLAGS = 0
    71                 #if defined(CFA_HAVE_SPLICE_F_FD_IN_FIXED)
    72                         | SPLICE_F_FD_IN_FIXED
    73                 #endif
    74         ;
     49        #if defined(CFA_HAVE_IOSQE_FIXED_FILE) && defined(CFA_HAVE_IOSQE_IO_DRAIN) && defined(CFA_HAVE_IOSQE_ASYNC)
     50                #define REGULAR_FLAGS (IOSQE_FIXED_FILE | IOSQE_IO_DRAIN | IOSQE_ASYNC)
     51        #elif defined(CFA_HAVE_IOSQE_FIXED_FILE) && defined(CFA_HAVE_IOSQE_ASYNC)
     52                #define REGULAR_FLAGS (IOSQE_FIXED_FILE | IOSQE_ASYNC)
     53        #elif defined(CFA_HAVE_IOSQE_FIXED_FILE) && defined(CFA_HAVE_IOSQE_IO_DRAIN)
     54                #define REGULAR_FLAGS (IOSQE_FIXED_FILE | IOSQE_IO_DRAIN)
     55        #elif defined(CFA_HAVE_IOSQE_IO_DRAIN) && defined(CFA_HAVE_IOSQE_ASYNC)
     56                #define REGULAR_FLAGS (IOSQE_IO_DRAIN | IOSQE_ASYNC)
     57        #elif defined(CFA_HAVE_IOSQE_FIXED_FILE)
     58                #define REGULAR_FLAGS (IOSQE_FIXED_FILE)
     59        #elif defined(CFA_HAVE_IOSQE_IO_DRAIN)
     60                #define REGULAR_FLAGS (IOSQE_IO_DRAIN)
     61        #elif defined(CFA_HAVE_IOSQE_ASYNC)
     62                #define REGULAR_FLAGS (IOSQE_ASYNC)
     63        #else
     64                #define REGULAR_FLAGS (0)
     65        #endif
     66
     67        #if defined(CFA_HAVE_IOSQE_IO_LINK) && defined(CFA_HAVE_IOSQE_IO_HARDLINK)
     68                #define LINK_FLAGS (IOSQE_IO_LINK | IOSQE_IO_HARDLINK)
     69        #elif defined(CFA_HAVE_IOSQE_IO_LINK)
     70                #define LINK_FLAGS (IOSQE_IO_LINK)
     71        #elif defined(CFA_HAVE_IOSQE_IO_HARDLINK)
     72                #define LINK_FLAGS (IOSQE_IO_HARDLINK)
     73        #else
     74                #define LINK_FLAGS (0)
     75        #endif
     76
     77        #if defined(CFA_HAVE_SPLICE_F_FD_IN_FIXED)
     78                #define SPLICE_FLAGS (SPLICE_F_FD_IN_FIXED)
     79        #else
     80                #define SPLICE_FLAGS (0)
     81        #endif
    7582
    7683        extern [* struct io_uring_sqe, __u32] __submit_alloc( struct __io_data & ring, __u64 data );
  • libcfa/src/concurrency/kernel.cfa

    re7d6968 r37b7d95  
    252252                /* paranoid */ verify( kernelTLS.this_thread == thrd_dst );
    253253                /* paranoid */ verify( thrd_dst->context.SP );
    254                 /* paranoid */ verify( thrd_dst->state != Halted );
    255254                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) < ((uintptr_t)__get_stack(thrd_dst->curr_cor)->base ) || thrd_dst->curr_cor == proc_cor, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too small.\n", thrd_dst ); // add escape condition if we are setting up the processor
    256255                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) > ((uintptr_t)__get_stack(thrd_dst->curr_cor)->limit) || thrd_dst->curr_cor == proc_cor, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too large.\n", thrd_dst ); // add escape condition if we are setting up the processor
     
    288287                if(unlikely(thrd_dst->state == Halted)) {
    289288                        // The thread has halted, it should never be scheduled/run again
    290                         // finish the thread
    291                         __thread_finish( thrd_dst );
     289                        // We may need to wake someone up here since
     290                        unpark( this->destroyer );
     291                        this->destroyer = 0p;
    292292                        break RUNNING;
    293293                }
     
    448448}
    449449
    450 extern "C" {
    451         // Leave the thread monitor
    452         // last routine called by a thread.
    453         // Should never return
    454         void __cfactx_thrd_leave() {
    455                 $thread * thrd = TL_GET( this_thread );
    456                 $monitor * this = &thrd->self_mon;
    457 
    458                 // Lock the monitor now
    459                 lock( this->lock __cfaabi_dbg_ctx2 );
    460 
    461                 disable_interrupts();
    462 
    463                 thrd->state = Halted;
    464 
    465                 if( thrd != this->owner || this->recursion != 1) { abort( "Thread internal monitor has unbalanced recursion" ); }
    466 
    467                 // Leave the thread
    468                 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    469                 returnToKernel();
    470                 abort();
    471 
    472                 // Control flow should never reach here!
    473         }
     450// KERNEL ONLY
     451void __leave_thread() {
     452        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
     453        returnToKernel();
     454        abort();
    474455}
    475456
  • libcfa/src/concurrency/kernel.hfa

    re7d6968 r37b7d95  
    7979        // Handle to pthreads
    8080        pthread_t kernel_thread;
     81
     82        // RunThread data
     83        // Action to do after a thread is ran
     84        $thread * destroyer;
    8185
    8286        // Preemption data
  • libcfa/src/concurrency/kernel/startup.cfa

    re7d6968 r37b7d95  
    474474        this.cltr = &_cltr;
    475475        full_proc = true;
     476        destroyer = 0p;
    476477        do_terminate = false;
    477478        preemption_alarm = 0p;
  • libcfa/src/concurrency/kernel_private.hfa

    re7d6968 r37b7d95  
    3939;
    4040
    41 //release/wake-up the following resources
    42 void __thread_finish( $thread * thrd );
     41//Block current thread and release/wake-up the following resources
     42void __leave_thread() __attribute__((noreturn));
    4343
    4444//-----------------------------------------------------------------------------
  • libcfa/src/concurrency/monitor.cfa

    re7d6968 r37b7d95  
    281281}
    282282
    283 void __thread_finish( $thread * thrd ) {
    284         $monitor * this = &thrd->self_mon;
    285 
    286         // Lock the monitor now
    287         /* paranoid */ verify( this->lock.lock );
    288         /* paranoid */ verifyf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", thrd, this->owner, this->recursion, this );
    289         /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    290         /* paranoid */ verify( thrd->state == Halted );
    291         /* paranoid */ verify( this->recursion == 1 );
    292 
    293         // Leaving a recursion level, decrement the counter
    294         this->recursion -= 1;
    295         this->owner = 0p;
    296 
    297         // Fetch the next thread, can be null
    298         $thread * new_owner = next_thread( this );
    299 
    300         // Release the monitor lock
    301         unlock( this->lock );
    302 
    303         // Unpark the next owner if needed
    304         /* paranoid */ verifyf( !new_owner || new_owner == this->owner, "Expected owner to be %p, got %p (m: %p)", new_owner, this->owner, this );
    305         /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    306         /* paranoid */ verify( thrd->state == Halted );
    307         unpark( new_owner );
     283extern "C" {
     284        // Leave the thread monitor
     285        // last routine called by a thread.
     286        // Should never return
     287        void __cfactx_thrd_leave() {
     288                $thread * thrd = TL_GET( this_thread );
     289                $monitor * this = &thrd->self_mon;
     290
     291                // Lock the monitor now
     292                lock( this->lock __cfaabi_dbg_ctx2 );
     293
     294                disable_interrupts();
     295
     296                thrd->state = Halted;
     297
     298                /* paranoid */ verifyf( thrd == this->owner, "Expected owner to be %p, got %p (r: %i, m: %p)", thrd, this->owner, this->recursion, this );
     299
     300                // Leaving a recursion level, decrement the counter
     301                this->recursion -= 1;
     302
     303                // If we haven't left the last level of recursion
     304                // it must mean there is an error
     305                if( this->recursion != 0) { abort( "Thread internal monitor has unbalanced recursion" ); }
     306
     307                // Fetch the next thread, can be null
     308                $thread * new_owner = next_thread( this );
     309
     310                // Release the monitor lock
     311                unlock( this->lock );
     312
     313                // Unpark the next owner if needed
     314                /* paranoid */ verifyf( !new_owner || new_owner == this->owner, "Expected owner to be %p, got %p (m: %p)", new_owner, this->owner, this );
     315                /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
     316                /* paranoid */ verify( ! kernelTLS.this_processor->destroyer );
     317                /* paranoid */ verify( thrd->state == Halted );
     318
     319                kernelTLS.this_processor->destroyer = new_owner;
     320
     321                // Leave the thread
     322                __leave_thread();
     323
     324                // Control flow should never reach here!
     325        }
    308326}
    309327
  • libcfa/src/concurrency/snzi.hfa

    re7d6968 r37b7d95  
    3636static inline void depart( __snzi_node_t & );
    3737
    38 static const int __snzi_half = -1;
     38#define __snzi_half -1
    3939
    4040//--------------------------------------------------
  • libcfa/src/exception.h

    re7d6968 r37b7d95  
    7676// implemented in the .c file either so they all have to be inline.
    7777
    78 trait is_exception(dtype exceptT, dtype virtualT) {
     78trait is_exception(dtype exceptT) {
    7979        /* The first field must be a pointer to a virtual table.
    80          * That virtual table must be a decendent of the base exception virtual table.
     80         * That virtual table must be a decendent of the base exception virtual tab$
    8181         */
    82         virtualT const & get_exception_vtable(exceptT *);
    83         // Always returns the virtual table for this type (associated types hack).
     82        void mark_exception(exceptT *);
     83        // This is never used and should be a no-op.
    8484};
    8585
    86 trait is_termination_exception(dtype exceptT, dtype virtualT | is_exception(exceptT, virtualT)) {
     86trait is_termination_exception(dtype exceptT | is_exception(exceptT)) {
    8787        void defaultTerminationHandler(exceptT &);
    8888};
    8989
    90 trait is_resumption_exception(dtype exceptT, dtype virtualT | is_exception(exceptT, virtualT)) {
     90trait is_resumption_exception(dtype exceptT | is_exception(exceptT)) {
    9191        void defaultResumptionHandler(exceptT &);
    9292};
    9393
    94 forall(dtype exceptT, dtype virtualT | is_termination_exception(exceptT, virtualT))
     94forall(dtype exceptT | is_termination_exception(exceptT))
    9595static inline void $throw(exceptT & except) {
    9696        __cfaehm_throw_terminate(
     
    100100}
    101101
    102 forall(dtype exceptT, dtype virtualT | is_resumption_exception(exceptT, virtualT))
     102forall(dtype exceptT | is_resumption_exception(exceptT))
    103103static inline void $throwResume(exceptT & except) {
    104104        __cfaehm_throw_resume(
     
    108108}
    109109
    110 forall(dtype exceptT, dtype virtualT | is_exception(exceptT, virtualT))
     110forall(dtype exceptT | is_exception(exceptT))
    111111static inline void cancel_stack(exceptT & except) __attribute__((noreturn)) {
    112112        __cfaehm_cancel_stack( (exception_t *)&except );
    113113}
    114114
    115 forall(dtype exceptT, dtype virtualT | is_exception(exceptT, virtualT))
     115forall(dtype exceptT | is_exception(exceptT))
    116116static inline void defaultTerminationHandler(exceptT & except) {
    117117        return cancel_stack( except );
    118118}
    119119
    120 forall(dtype exceptT, dtype virtualT | is_exception(exceptT, virtualT))
     120forall(dtype exceptT | is_exception(exceptT))
    121121static inline void defaultResumptionHandler(exceptT & except) {
    122122        throw except;
  • libcfa/src/exception.hfa

    re7d6968 r37b7d95  
    9595// visible anywhere you use the instantiation of the exception is used.
    9696#define POLY_VTABLE_DECLARATION(exception_name, ...) \
    97         VTABLE_TYPE(exception_name)(__VA_ARGS__) const & get_exception_vtable(exception_name(__VA_ARGS__) *); \
     97        void mark_exception(exception_name(__VA_ARGS__) *); \
    9898        extern VTABLE_TYPE(exception_name)(__VA_ARGS__) VTABLE_NAME(exception_name)
    9999
     
    125125#define VTABLE_ASSERTION(exception_name, parameters) \
    126126        { VTABLE_TYPE(exception_name) parameters VTABLE_NAME(exception_name); }
    127 
    128 // IS_EXCEPTION(exception_name [, (...parameters)])
    129 // IS_RESUMPTION_EXCEPTION(exception_name [, (parameters...)])
    130 // IS_TERMINATION_EXCEPTION(exception_name [, (parameters...)])
    131 // Create an assertion that exception_name, possibly with the qualifing parameters, is the given
    132 // kind of exception with the standard vtable with the same parameters if applicable.
    133 #define IS_EXCEPTION(...) _IS_EXCEPTION(is_exception, __VA_ARGS__, , ~)
    134 #define IS_RESUMPTION_EXCEPTION(...) _IS_EXCEPTION(is_resumption_exception, __VA_ARGS__, , ~)
    135 #define IS_TERMINATION_EXCEPTION(...) _IS_EXCEPTION(is_termination_exception, __VA_ARGS__, , ~)
    136127
    137128// All internal helper macros begin with an underscore.
     
    169160
    170161#define _FORALL_CTOR0_DECLARATION(exception_name, assertions, parameters) \
    171         forall(_UNPACK assertions | \
    172                 is_exception(exception_name parameters, VTABLE_TYPE(exception_name) parameters)) \
     162        forall(_UNPACK assertions | VTABLE_ASSERTION(exception_name, parameters) ) \
    173163        void ?{}(exception_name parameters & this)
    174164
    175165#define _FORALL_CTOR0_INSTANCE(exception_name, assertions, parameters) \
    176166        _FORALL_CTOR0_DECLARATION(exception_name, assertions, parameters) { \
    177                 (this).virtual_table = &get_exception_vtable(&this); \
     167                VTABLE_INIT(this, exception_name); \
    178168        }
    179169
     
    195185#define _VTABLE_DECLARATION(exception_name, parent_name, ...) \
    196186        struct exception_name; \
     187        void mark_exception(exception_name *); \
    197188        VTABLE_TYPE(exception_name); \
    198         VTABLE_TYPE(exception_name) const & get_exception_vtable(exception_name *); \
    199189        extern VTABLE_TYPE(exception_name) VTABLE_NAME(exception_name); \
    200190        VTABLE_TYPE(exception_name) { \
     
    207197
    208198#define _VTABLE_INSTANCE(exception_name, parent_name, ...) \
    209         VTABLE_TYPE(exception_name) const & get_exception_vtable(exception_name *) { \
    210                 return VTABLE_NAME(exception_name); \
    211         } \
     199        void mark_exception(exception_name *) {} \
    212200        void _GLUE2(exception_name,_copy)(exception_name * this, exception_name * other) { \
    213201                *this = *other; \
     
    230218
    231219#define _POLY_VTABLE_INSTANCE(exception_name, parent_name, ...) \
    232         extern VTABLE_TYPE(exception_name)(__VA_ARGS__) VTABLE_NAME(exception_name); \
    233         VTABLE_TYPE(exception_name)(__VA_ARGS__) const & get_exception_vtable( \
    234                         exception_name(__VA_ARGS__) *) { \
    235                 return VTABLE_NAME(exception_name); \
    236         } \
     220        void mark_exception(exception_name(__VA_ARGS__) *) {} \
    237221        void _GLUE2(exception_name,_copy)( \
    238222                        exception_name(__VA_ARGS__) * this, exception_name(__VA_ARGS__) * other) { \
     
    243227                _GLUE2(exception_name,_copy), ^?{}, \
    244228                _CLOSE
    245 
    246 #define _IS_EXCEPTION(kind, exception_name, parameters, ...) \
    247         kind(exception_name parameters, VTABLE_TYPE(exception_name) parameters)
  • libcfa/src/limits.cfa

    re7d6968 r37b7d95  
    1010// Created On       : Wed Apr  6 18:06:52 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  1 16:22:51 2018
    13 // Update Count     : 74
     12// Last Modified On : Wed Sep 30 22:56:32 2020
     13// Update Count     : 76
    1414//
    1515
     
    2323// Integral Constants
    2424
    25 const signed char MIN = SCHAR_MIN;
    26 const unsigned char MIN = 0;
    27 const short int MIN = SHRT_MIN;
    28 const unsigned short int MIN = 0;
    29 const int MIN = INT_MIN;
    30 const unsigned int MIN = 0;
    31 const long int MIN = LONG_MIN;
    32 const unsigned long int MIN = 0;
    33 const long long int MIN = LLONG_MIN;
    34 const unsigned long long int MIN = 0;
     25signed char MIN = SCHAR_MIN;
     26unsigned char MIN = 0;
     27short int MIN = SHRT_MIN;
     28unsigned short int MIN = 0;
     29int MIN = INT_MIN;
     30unsigned int MIN = 0;
     31long int MIN = LONG_MIN;
     32unsigned long int MIN = 0;
     33long long int MIN = LLONG_MIN;
     34unsigned long long int MIN = 0;
    3535
    36 const signed char MAX = SCHAR_MAX;
    37 const unsigned char MAX = UCHAR_MAX;
    38 const short int MAX = SHRT_MAX;
    39 const unsigned short int MAX = USHRT_MAX;
    40 const int MAX = INT_MAX;
    41 const unsigned int MAX = UINT_MAX;
    42 const long int MAX = LONG_MAX;
    43 const unsigned long int MAX = ULONG_MAX;
    44 const long long int MAX = LLONG_MAX;
    45 const unsigned long long int MAX = ULLONG_MAX;
     36signed char MAX = SCHAR_MAX;
     37unsigned char MAX = UCHAR_MAX;
     38short int MAX = SHRT_MAX;
     39unsigned short int MAX = USHRT_MAX;
     40int MAX = INT_MAX;
     41unsigned int MAX = UINT_MAX;
     42long int MAX = LONG_MAX;
     43unsigned long int MAX = ULONG_MAX;
     44long long int MAX = LLONG_MAX;
     45unsigned long long int MAX = ULLONG_MAX;
    4646
    4747// Floating-Point Constants
    4848
    49 const float MIN = FLT_MIN;
    50 const double MIN = DBL_MIN;
    51 const long double MIN = LDBL_MIN;
    52 const float _Complex MIN = __FLT_MIN__ + __FLT_MIN__ * I;
    53 const double _Complex MIN = DBL_MIN +  DBL_MIN * I;
    54 const long double _Complex MIN = LDBL_MIN + LDBL_MIN * I;
     49float MIN = FLT_MIN;
     50double MIN = DBL_MIN;
     51long double MIN = LDBL_MIN;
     52float _Complex MIN = __FLT_MIN__ + __FLT_MIN__ * I;
     53double _Complex MIN = DBL_MIN +  DBL_MIN * I;
     54long double _Complex MIN = LDBL_MIN + LDBL_MIN * I;
    5555
    56 const float MAX = FLT_MAX;
    57 const double MAX = DBL_MAX;
    58 const long double MAX = LDBL_MAX;
    59 const float _Complex MAX = FLT_MAX + FLT_MAX * I;
    60 const double _Complex MAX = DBL_MAX + DBL_MAX * I;
    61 const long double _Complex MAX = LDBL_MAX + LDBL_MAX * I;
     56float MAX = FLT_MAX;
     57double MAX = DBL_MAX;
     58long double MAX = LDBL_MAX;
     59float _Complex MAX = FLT_MAX + FLT_MAX * I;
     60double _Complex MAX = DBL_MAX + DBL_MAX * I;
     61long double _Complex MAX = LDBL_MAX + LDBL_MAX * I;
    6262
    63 const float PI = (float)M_PI;                                                   // pi
    64 const float PI_2 = (float)M_PI_2;                                               // pi / 2
    65 const float PI_4 = (float)M_PI_4;                                               // pi / 4
    66 const float _1_PI = (float)M_1_PI;                                              // 1 / pi
    67 const float _2_PI = (float)M_2_PI;                                              // 2 / pi
    68 const float _2_SQRT_PI = (float)M_2_SQRTPI;                             // 2 / sqrt(pi)
     63float PI = (float)M_PI;                                                                 // pi
     64float PI_2 = (float)M_PI_2;                                                             // pi / 2
     65float PI_4 = (float)M_PI_4;                                                             // pi / 4
     66float _1_PI = (float)M_1_PI;                                                    // 1 / pi
     67float _2_PI = (float)M_2_PI;                                                    // 2 / pi
     68float _2_SQRT_PI = (float)M_2_SQRTPI;                                   // 2 / sqrt(pi)
    6969
    70 const double PI = M_PI;                                                                 // pi
    71 const double PI_2 = M_PI_2;                                                             // pi / 2
    72 const double PI_4 = M_PI_4;                                                             // pi / 4
    73 const double _1_PI = M_1_PI;                                                    // 1 / pi
    74 const double _2_PI = M_2_PI;                                                    // 2 / pi
    75 const double _2_SQRT_PI = M_2_SQRTPI;                                   // 2 / sqrt(pi)
     70double PI = M_PI;                                                                               // pi
     71double PI_2 = M_PI_2;                                                                   // pi / 2
     72double PI_4 = M_PI_4;                                                                   // pi / 4
     73double _1_PI = M_1_PI;                                                                  // 1 / pi
     74double _2_PI = M_2_PI;                                                                  // 2 / pi
     75double _2_SQRT_PI = M_2_SQRTPI;                                                 // 2 / sqrt(pi)
    7676
    77 const long double PI = M_PIl;                                                   // pi
    78 const long double PI_2 = M_PI_2l;                                               // pi / 2
    79 const long double PI_4 = M_PI_4l;                                               // pi / 4
    80 const long double _1_PI = M_1_PIl;                                              // 1 / pi
    81 const long double _2_PI = M_2_PIl;                                              // 2 / pi
    82 const long double _2_SQRT_PI = M_2_SQRTPIl;                             // 2 / sqrt(pi)
     77long double PI = M_PIl;                                                                 // pi
     78long double PI_2 = M_PI_2l;                                                             // pi / 2
     79long double PI_4 = M_PI_4l;                                                             // pi / 4
     80long double _1_PI = M_1_PIl;                                                    // 1 / pi
     81long double _2_PI = M_2_PIl;                                                    // 2 / pi
     82long double _2_SQRT_PI = M_2_SQRTPIl;                                   // 2 / sqrt(pi)
    8383
    84 const float _Complex PI = (float)M_PI + 0.0_iF;                 // pi
    85 const float _Complex PI_2 = (float)M_PI_2 + 0.0_iF;             // pi / 2
    86 const float _Complex PI_4 = (float)M_PI_4 + 0.0_iF;             // pi / 4
    87 const float _Complex _1_PI = (float)M_1_PI + 0.0_iF;    // 1 / pi
    88 const float _Complex _2_PI = (float)M_2_PI + 0.0_iF;    // 2 / pi
    89 const float _Complex _2_SQRT_PI = (float)M_2_SQRTPI + 0.0_iF; // 2 / sqrt(pi)
     84float _Complex PI = (float)M_PI + 0.0_iF;                               // pi
     85float _Complex PI_2 = (float)M_PI_2 + 0.0_iF;                   // pi / 2
     86float _Complex PI_4 = (float)M_PI_4 + 0.0_iF;                   // pi / 4
     87float _Complex _1_PI = (float)M_1_PI + 0.0_iF;                  // 1 / pi
     88float _Complex _2_PI = (float)M_2_PI + 0.0_iF;                  // 2 / pi
     89float _Complex _2_SQRT_PI = (float)M_2_SQRTPI + 0.0_iF; // 2 / sqrt(pi)
    9090
    91 const double _Complex PI = M_PI + 0.0_iD;                               // pi
    92 const double _Complex PI_2 = M_PI_2 + 0.0_iD;                   // pi / 2
    93 const double _Complex PI_4 = M_PI_4 + 0.0_iD;                   // pi / 4
    94 const double _Complex _1_PI = M_1_PI + 0.0_iD;                  // 1 / pi
    95 const double _Complex _2_PI = M_2_PI + 0.0_iD;                  // 2 / pi
    96 const double _Complex _2_SQRT_PI = M_2_SQRTPI + 0.0_iD; // 2 / sqrt(pi)
     91double _Complex PI = M_PI + 0.0_iD;                                             // pi
     92double _Complex PI_2 = M_PI_2 + 0.0_iD;                                 // pi / 2
     93double _Complex PI_4 = M_PI_4 + 0.0_iD;                                 // pi / 4
     94double _Complex _1_PI = M_1_PI + 0.0_iD;                                // 1 / pi
     95double _Complex _2_PI = M_2_PI + 0.0_iD;                                // 2 / pi
     96double _Complex _2_SQRT_PI = M_2_SQRTPI + 0.0_iD;               // 2 / sqrt(pi)
    9797
    98 const long double _Complex PI = M_PIl + 0.0_iL;                 // pi
    99 const long double _Complex PI_2 = M_PI_2l + 0.0_iL;             // pi / 2
    100 const long double _Complex PI_4 = M_PI_4l + 0.0_iL;             // pi / 4
    101 const long double _Complex _1_PI = M_1_PIl + 0.0_iL;    // 1 / pi
    102 const long double _Complex _2_PI = M_2_PIl + 0.0_iL;    // 2 / pi
    103 const long double _Complex _2_SQRT_PI = M_2_SQRTPIl + 0.0_iL; // 2 / sqrt(pi)
     98long double _Complex PI = M_PIl + 0.0_iL;                               // pi
     99long double _Complex PI_2 = M_PI_2l + 0.0_iL;                   // pi / 2
     100long double _Complex PI_4 = M_PI_4l + 0.0_iL;                   // pi / 4
     101long double _Complex _1_PI = M_1_PIl + 0.0_iL;                  // 1 / pi
     102long double _Complex _2_PI = M_2_PIl + 0.0_iL;                  // 2 / pi
     103long double _Complex _2_SQRT_PI = M_2_SQRTPIl + 0.0_iL; // 2 / sqrt(pi)
    104104
    105 const float E = (float)M_E;                                                             // e
    106 const float LOG2_E = (float)M_LOG2E;                                    // log_2(e)
    107 const float LOG10_E = (float)M_LOG10E;                                  // log_10(e)
    108 const float LN_2 = (float)M_LN2;                                                // log_e(2)
    109 const float LN_10 = (float)M_LN10;                                              // log_e(10)
    110 const float SQRT_2 = (float)M_SQRT2;                                    // sqrt(2)
    111 const float _1_SQRT_2 = (float)M_SQRT1_2;                               // 1 / sqrt(2)
     105float E = (float)M_E;                                                                   // e
     106float LOG2_E = (float)M_LOG2E;                                                  // log_2(e)
     107float LOG10_E = (float)M_LOG10E;                                                // log_10(e)
     108float LN_2 = (float)M_LN2;                                                              // log_e(2)
     109float LN_10 = (float)M_LN10;                                                    // log_e(10)
     110float SQRT_2 = (float)M_SQRT2;                                                  // sqrt(2)
     111float _1_SQRT_2 = (float)M_SQRT1_2;                                             // 1 / sqrt(2)
    112112
    113 const double E = M_E;                                                                   // e
    114 const double LOG2_E = M_LOG2E;                                                  // log_2(e)
    115 const double LOG10_E = M_LOG10E;                                                // log_10(e)
    116 const double LN_2 = M_LN2;                                                              // log_e(2)
    117 const double LN_10 = M_LN10;                                                    // log_e(10)
    118 const double SQRT_2 = M_SQRT2;                                                  // sqrt(2)
    119 const double _1_SQRT_2 = M_SQRT1_2;                                             // 1 / sqrt(2)
     113double E = M_E;                                                                                 // e
     114double LOG2_E = M_LOG2E;                                                                // log_2(e)
     115double LOG10_E = M_LOG10E;                                                              // log_10(e)
     116double LN_2 = M_LN2;                                                                    // log_e(2)
     117double LN_10 = M_LN10;                                                                  // log_e(10)
     118double SQRT_2 = M_SQRT2;                                                                // sqrt(2)
     119double _1_SQRT_2 = M_SQRT1_2;                                                   // 1 / sqrt(2)
    120120
    121 const long double E = M_El;                                                             // e
    122 const long double LOG2_E = M_LOG2El;                                    // log_2(e)
    123 const long double LOG10_E = M_LOG10El;                                  // log_10(e)
    124 const long double LN_2 = M_LN2l;                                                // log_e(2)
    125 const long double LN_10 = M_LN10l;                                              // log_e(10)
    126 const long double SQRT_2 = M_SQRT2l;                                    // sqrt(2)
    127 const long double _1_SQRT_2 = M_SQRT1_2l;                               // 1 / sqrt(2)
     121long double E = M_El;                                                                   // e
     122long double LOG2_E = M_LOG2El;                                                  // log_2(e)
     123long double LOG10_E = M_LOG10El;                                                // log_10(e)
     124long double LN_2 = M_LN2l;                                                              // log_e(2)
     125long double LN_10 = M_LN10l;                                                    // log_e(10)
     126long double SQRT_2 = M_SQRT2l;                                                  // sqrt(2)
     127long double _1_SQRT_2 = M_SQRT1_2l;                                             // 1 / sqrt(2)
    128128
    129 const float _Complex E = M_E + 0.0_iF;                                  // e
    130 const float _Complex LOG2_E = M_LOG2E + 0.0_iF;                 // log_2(e)
    131 const float _Complex LOG10_E = M_LOG10E + 0.0_iF;               // log_10(e)
    132 const float _Complex LN_2 = M_LN2 + 0.0_iF;                             // log_e(2)
    133 const float _Complex LN_10 = M_LN10 + 0.0_iF;                   // log_e(10)
    134 const float _Complex SQRT_2 = M_SQRT2 + 0.0_iF;                 // sqrt(2)
    135 const float _Complex _1_SQRT_2 = M_SQRT1_2 + 0.0_iF;    // 1 / sqrt(2)
     129float _Complex E = M_E + 0.0_iF;                                                // e
     130float _Complex LOG2_E = M_LOG2E + 0.0_iF;                               // log_2(e)
     131float _Complex LOG10_E = M_LOG10E + 0.0_iF;                             // log_10(e)
     132float _Complex LN_2 = M_LN2 + 0.0_iF;                                   // log_e(2)
     133float _Complex LN_10 = M_LN10 + 0.0_iF;                                 // log_e(10)
     134float _Complex SQRT_2 = M_SQRT2 + 0.0_iF;                               // sqrt(2)
     135float _Complex _1_SQRT_2 = M_SQRT1_2 + 0.0_iF;                  // 1 / sqrt(2)
    136136
    137 const double _Complex E = M_E + 0.0_iD;                                 // e
    138 const double _Complex LOG2_E = M_LOG2E + 0.0_iD;                // log_2(e)
    139 const double _Complex LOG10_E = M_LOG10E + 0.0_iD;              // log_10(e)
    140 const double _Complex LN_2 = M_LN2 + 0.0_iD;                    // log_e(2)
    141 const double _Complex LN_10 = M_LN10 + 0.0_iD;                  // log_e(10)
    142 const double _Complex SQRT_2 = M_SQRT2 + 0.0_iD;                // sqrt(2)
    143 const double _Complex _1_SQRT_2 = M_SQRT1_2 + 0.0_iD;   // 1 / sqrt(2)
     137double _Complex E = M_E + 0.0_iD;                                               // e
     138double _Complex LOG2_E = M_LOG2E + 0.0_iD;                              // log_2(e)
     139double _Complex LOG10_E = M_LOG10E + 0.0_iD;                    // log_10(e)
     140double _Complex LN_2 = M_LN2 + 0.0_iD;                                  // log_e(2)
     141double _Complex LN_10 = M_LN10 + 0.0_iD;                                // log_e(10)
     142double _Complex SQRT_2 = M_SQRT2 + 0.0_iD;                              // sqrt(2)
     143double _Complex _1_SQRT_2 = M_SQRT1_2 + 0.0_iD;                 // 1 / sqrt(2)
    144144
    145 const long double _Complex E = M_El + 0.0_iL;                   // e
    146 const long double _Complex LOG2_E = M_LOG2El + 0.0_iL;  // log_2(e)
    147 const long double _Complex LOG10_E = M_LOG10El + 0.0_iL; // log_10(e)
    148 const long double _Complex LN_2 = M_LN2l + 0.0_iL;              // log_e(2)
    149 const long double _Complex LN_10 = M_LN10l + 0.0_iL;    // log_e(10)
    150 const long double _Complex SQRT_2 = M_SQRT2l + 0.0_iL;  // sqrt(2)
    151 const long double _Complex _1_SQRT_2 = M_SQRT1_2l + 0.0_iL; // 1 / sqrt(2)
     145long double _Complex E = M_El + 0.0_iL;                                 // e
     146long double _Complex LOG2_E = M_LOG2El + 0.0_iL;                // log_2(e)
     147long double _Complex LOG10_E = M_LOG10El + 0.0_iL;              // log_10(e)
     148long double _Complex LN_2 = M_LN2l + 0.0_iL;                    // log_e(2)
     149long double _Complex LN_10 = M_LN10l + 0.0_iL;                  // log_e(10)
     150long double _Complex SQRT_2 = M_SQRT2l + 0.0_iL;                // sqrt(2)
     151long double _Complex _1_SQRT_2 = M_SQRT1_2l + 0.0_iL;   // 1 / sqrt(2)
    152152
    153153// Local Variables: //
  • libcfa/src/limits.hfa

    re7d6968 r37b7d95  
    1010// Created On       : Wed Apr  6 18:06:52 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar  1 16:20:54 2018
    13 // Update Count     : 13
     12// Last Modified On : Wed Sep 30 22:56:35 2020
     13// Update Count     : 15
    1414//
    1515
     
    1818// Integral Constants
    1919
    20 extern const signed char MIN;
    21 extern const unsigned char MIN;
    22 extern const short int MIN;
    23 extern const unsigned short int MIN;
    24 extern const int MIN;
    25 extern const unsigned int MIN;
    26 extern const long int MIN;
    27 extern const unsigned long int MIN;
    28 extern const long long int MIN;
    29 extern const unsigned long long int MIN;
     20extern signed char MIN;
     21extern unsigned char MIN;
     22extern short int MIN;
     23extern unsigned short int MIN;
     24extern int MIN;
     25extern unsigned int MIN;
     26extern long int MIN;
     27extern unsigned long int MIN;
     28extern long long int MIN;
     29extern unsigned long long int MIN;
    3030
    31 extern const signed char MAX;
    32 extern const unsigned char MAX;
    33 extern const short int MAX;
    34 extern const unsigned short int MAX;
    35 extern const int MAX;
    36 extern const unsigned int MAX;
    37 extern const long int MAX;
    38 extern const unsigned long int MAX;
    39 extern const long long int MAX;
    40 extern const unsigned long long int MAX;
     31extern signed char MAX;
     32extern unsigned char MAX;
     33extern short int MAX;
     34extern unsigned short int MAX;
     35extern int MAX;
     36extern unsigned int MAX;
     37extern long int MAX;
     38extern unsigned long int MAX;
     39extern long long int MAX;
     40extern unsigned long long int MAX;
    4141
    4242// Floating-Point Constants
    4343
    44 extern const float MIN;
    45 extern const double MIN;
    46 extern const long double MIN;
    47 extern const float _Complex MIN;
    48 extern const double _Complex MIN;
    49 extern const long double _Complex MIN;
     44extern float MIN;
     45extern double MIN;
     46extern long double MIN;
     47extern float _Complex MIN;
     48extern double _Complex MIN;
     49extern long double _Complex MIN;
    5050
    51 extern const float MAX;
    52 extern const double MAX;
    53 extern const long double MAX;
    54 extern const float _Complex MAX;
    55 extern const double _Complex MAX;
    56 extern const long double _Complex MAX;
     51extern float MAX;
     52extern double MAX;
     53extern long double MAX;
     54extern float _Complex MAX;
     55extern double _Complex MAX;
     56extern long double _Complex MAX;
    5757
    58 extern const float PI;                                                                  // pi
    59 extern const float PI_2;                                                                // pi / 2
    60 extern const float PI_4;                                                                // pi / 4
    61 extern const float _1_PI;                                                               // 1 / pi
    62 extern const float _2_PI;                                                               // 2 / pi
    63 extern const float _2_SQRT_PI;                                                  // 2 / sqrt(pi)
     58extern float PI;                                                                                // pi
     59extern float PI_2;                                                                              // pi / 2
     60extern float PI_4;                                                                              // pi / 4
     61extern float _1_PI;                                                                             // 1 / pi
     62extern float _2_PI;                                                                             // 2 / pi
     63extern float _2_SQRT_PI;                                                                // 2 / sqrt(pi)
    6464
    65 extern const double PI;                                                                 // pi
    66 extern const double PI_2;                                                               // pi / 2
    67 extern const double PI_4;                                                               // pi / 4
    68 extern const double _1_PI;                                                              // 1 / pi
    69 extern const double _2_PI;                                                              // 2 / pi
    70 extern const double _2_SQRT_PI;                                                 // 2 / sqrt(pi)
     65extern double PI;                                                                               // pi
     66extern double PI_2;                                                                             // pi / 2
     67extern double PI_4;                                                                             // pi / 4
     68extern double _1_PI;                                                                    // 1 / pi
     69extern double _2_PI;                                                                    // 2 / pi
     70extern double _2_SQRT_PI;                                                               // 2 / sqrt(pi)
    7171
    72 extern const long double PI;                                                    // pi
    73 extern const long double PI_2;                                                  // pi / 2
    74 extern const long double PI_4;                                                  // pi / 4
    75 extern const long double _1_PI;                                                 // 1 / pi
    76 extern const long double _2_PI;                                                 // 2 / pi
    77 extern const long double _2_SQRT_PI;                                    // 2 / sqrt(pi)
     72extern long double PI;                                                                  // pi
     73extern long double PI_2;                                                                // pi / 2
     74extern long double PI_4;                                                                // pi / 4
     75extern long double _1_PI;                                                               // 1 / pi
     76extern long double _2_PI;                                                               // 2 / pi
     77extern long double _2_SQRT_PI;                                                  // 2 / sqrt(pi)
    7878
    79 extern const float _Complex PI;                                                 // pi
    80 extern const float _Complex PI_2;                                               // pi / 2
    81 extern const float _Complex PI_4;                                               // pi / 4
    82 extern const float _Complex _1_PI;                                              // 1 / pi
    83 extern const float _Complex _2_PI;                                              // 2 / pi
    84 extern const float _Complex _2_SQRT_PI;                                 // 2 / sqrt(pi)
     79extern float _Complex PI;                                                               // pi
     80extern float _Complex PI_2;                                                             // pi / 2
     81extern float _Complex PI_4;                                                             // pi / 4
     82extern float _Complex _1_PI;                                                    // 1 / pi
     83extern float _Complex _2_PI;                                                    // 2 / pi
     84extern float _Complex _2_SQRT_PI;                                               // 2 / sqrt(pi)
    8585
    86 extern const double _Complex PI;                                                // pi
    87 extern const double _Complex PI_2;                                              // pi / 2
    88 extern const double _Complex PI_4;                                              // pi / 4
    89 extern const double _Complex _1_PI;                                             // 1 / pi
    90 extern const double _Complex _2_PI;                                             // 2 / pi
    91 extern const double _Complex _2_SQRT_PI;                                // 2 / sqrt(pi)
     86extern double _Complex PI;                                                              // pi
     87extern double _Complex PI_2;                                                    // pi / 2
     88extern double _Complex PI_4;                                                    // pi / 4
     89extern double _Complex _1_PI;                                                   // 1 / pi
     90extern double _Complex _2_PI;                                                   // 2 / pi
     91extern double _Complex _2_SQRT_PI;                                              // 2 / sqrt(pi)
    9292
    93 extern const long double _Complex PI;                                   // pi
    94 extern const long double _Complex PI_2;                                 // pi / 2
    95 extern const long double _Complex PI_4;                                 // pi / 4
    96 extern const long double _Complex _1_PI;                                // 1 / pi
    97 extern const long double _Complex _2_PI;                                // 2 / pi
    98 extern const long double _Complex _2_SQRT_PI;                   // 2 / sqrt(pi)
     93extern long double _Complex PI;                                                 // pi
     94extern long double _Complex PI_2;                                               // pi / 2
     95extern long double _Complex PI_4;                                               // pi / 4
     96extern long double _Complex _1_PI;                                              // 1 / pi
     97extern long double _Complex _2_PI;                                              // 2 / pi
     98extern long double _Complex _2_SQRT_PI;                                 // 2 / sqrt(pi)
    9999
    100 extern const float E;                                                                   // e
    101 extern const float LOG2_E;                                                              // log_2(e)
    102 extern const float LOG10_E;                                                             // log_10(e)
    103 extern const float LN_2;                                                                // log_e(2)
    104 extern const float LN_10;                                                               // log_e(10)
    105 extern const float SQRT_2;                                                              // sqrt(2)
    106 extern const float _1_SQRT_2;                                                   // 1 / sqrt(2)
     100extern float E;                                                                                 // e
     101extern float LOG2_E;                                                                    // log_2(e)
     102extern float LOG10_E;                                                                   // log_10(e)
     103extern float LN_2;                                                                              // log_e(2)
     104extern float LN_10;                                                                             // log_e(10)
     105extern float SQRT_2;                                                                    // sqrt(2)
     106extern float _1_SQRT_2;                                                                 // 1 / sqrt(2)
    107107
    108 extern const double E;                                                                  // e
    109 extern const double LOG2_E;                                                             // log_2(e)
    110 extern const double LOG10_E;                                                    // log_10(e)
    111 extern const double LN_2;                                                               // log_e(2)
    112 extern const double LN_10;                                                              // log_e(10)
    113 extern const double SQRT_2;                                                             // sqrt(2)
    114 extern const double _1_SQRT_2;                                                  // 1 / sqrt(2)
     108extern double E;                                                                                // e
     109extern double LOG2_E;                                                                   // log_2(e)
     110extern double LOG10_E;                                                                  // log_10(e)
     111extern double LN_2;                                                                             // log_e(2)
     112extern double LN_10;                                                                    // log_e(10)
     113extern double SQRT_2;                                                                   // sqrt(2)
     114extern double _1_SQRT_2;                                                                // 1 / sqrt(2)
    115115
    116 extern const long double E;                                                             // e
    117 extern const long double LOG2_E;                                                // log_2(e)
    118 extern const long double LOG10_E;                                               // log_10(e)
    119 extern const long double LN_2;                                                  // log_e(2)
    120 extern const long double LN_10;                                                 // log_e(10)
    121 extern const long double SQRT_2;                                                // sqrt(2)
    122 extern const long double _1_SQRT_2;                                             // 1/sqrt(2)
     116extern long double E;                                                                   // e
     117extern long double LOG2_E;                                                              // log_2(e)
     118extern long double LOG10_E;                                                             // log_10(e)
     119extern long double LN_2;                                                                // log_e(2)
     120extern long double LN_10;                                                               // log_e(10)
     121extern long double SQRT_2;                                                              // sqrt(2)
     122extern long double _1_SQRT_2;                                                   // 1/sqrt(2)
    123123
    124 extern const float _Complex E;                                                  // e
    125 extern const float _Complex LOG2_E;                                             // log_2(e)
    126 extern const float _Complex LOG10_E;                                    // log_10(e)
    127 extern const float _Complex LN_2;                                               // log_e(2)
    128 extern const float _Complex LN_10;                                              // log_e(10)
    129 extern const float _Complex SQRT_2;                                             // sqrt(2)
    130 extern const float _Complex _1_SQRT_2;                                  // 1 / sqrt(2)
     124extern float _Complex E;                                                                // e
     125extern float _Complex LOG2_E;                                                   // log_2(e)
     126extern float _Complex LOG10_E;                                                  // log_10(e)
     127extern float _Complex LN_2;                                                             // log_e(2)
     128extern float _Complex LN_10;                                                    // log_e(10)
     129extern float _Complex SQRT_2;                                                   // sqrt(2)
     130extern float _Complex _1_SQRT_2;                                                // 1 / sqrt(2)
    131131
    132 extern const double _Complex E;                                                 // e
    133 extern const double _Complex LOG2_E;                                    // log_2(e)
    134 extern const double _Complex LOG10_E;                                   // log_10(e)
    135 extern const double _Complex LN_2;                                              // log_e(2)
    136 extern const double _Complex LN_10;                                             // log_e(10)
    137 extern const double _Complex SQRT_2;                                    // sqrt(2)
    138 extern const double _Complex _1_SQRT_2;                                 // 1 / sqrt(2)
     132extern double _Complex E;                                                               // e
     133extern double _Complex LOG2_E;                                                  // log_2(e)
     134extern double _Complex LOG10_E;                                                 // log_10(e)
     135extern double _Complex LN_2;                                                    // log_e(2)
     136extern double _Complex LN_10;                                                   // log_e(10)
     137extern double _Complex SQRT_2;                                                  // sqrt(2)
     138extern double _Complex _1_SQRT_2;                                               // 1 / sqrt(2)
    139139
    140 extern const long double _Complex E;                                    // e
    141 extern const long double _Complex LOG2_E;                               // log_2(e)
    142 extern const long double _Complex LOG10_E;                              // log_10(e)
    143 extern const long double _Complex LN_2;                                 // log_e(2)
    144 extern const long double _Complex LN_10;                                // log_e(10)
    145 extern const long double _Complex SQRT_2;                               // sqrt(2)
    146 extern const long double _Complex _1_SQRT_2;                    // 1 / sqrt(2)
     140extern long double _Complex E;                                                  // e
     141extern long double _Complex LOG2_E;                                             // log_2(e)
     142extern long double _Complex LOG10_E;                                    // log_10(e)
     143extern long double _Complex LN_2;                                               // log_e(2)
     144extern long double _Complex LN_10;                                              // log_e(10)
     145extern long double _Complex SQRT_2;                                             // sqrt(2)
     146extern long double _Complex _1_SQRT_2;                                  // 1 / sqrt(2)
    147147
    148148// Local Variables: //
  • src/AST/Expr.cpp

    re7d6968 r37b7d95  
    102102        }
    103103        return ret;
    104 }
    105 
    106 // --- VariableExpr
    107 
    108 VariableExpr::VariableExpr( const CodeLocation & loc )
    109 : Expr( loc ), var( nullptr ) {}
    110 
    111 VariableExpr::VariableExpr( const CodeLocation & loc, const DeclWithType * v )
    112 : Expr( loc ), var( v ) {
    113         assert( var );
    114         assert( var->get_type() );
    115         result = shallowCopy( var->get_type() );
    116 }
    117 
    118 bool VariableExpr::get_lvalue() const {
    119         // It isn't always an lvalue, but it is never an rvalue.
    120         return true;
    121 }
    122 
    123 VariableExpr * VariableExpr::functionPointer(
    124                 const CodeLocation & loc, const FunctionDecl * decl ) {
    125         // wrap usually-determined result type in a pointer
    126         VariableExpr * funcExpr = new VariableExpr{ loc, decl };
    127         funcExpr->result = new PointerType{ funcExpr->result };
    128         return funcExpr;
    129104}
    130105
     
    263238}
    264239
     240// --- VariableExpr
     241
     242VariableExpr::VariableExpr( const CodeLocation & loc )
     243: Expr( loc ), var( nullptr ) {}
     244
     245VariableExpr::VariableExpr( const CodeLocation & loc, const DeclWithType * v )
     246: Expr( loc ), var( v ) {
     247        assert( var );
     248        assert( var->get_type() );
     249        result = shallowCopy( var->get_type() );
     250}
     251
     252bool VariableExpr::get_lvalue() const {
     253        // It isn't always an lvalue, but it is never an rvalue.
     254        return true;
     255}
     256
     257VariableExpr * VariableExpr::functionPointer(
     258                const CodeLocation & loc, const FunctionDecl * decl ) {
     259        // wrap usually-determined result type in a pointer
     260        VariableExpr * funcExpr = new VariableExpr{ loc, decl };
     261        funcExpr->result = new PointerType{ funcExpr->result };
     262        return funcExpr;
     263}
     264
    265265// --- ConstantExpr
    266266
  • src/AST/Expr.hpp

    re7d6968 r37b7d95  
    250250};
    251251
    252 /// A reference to a named variable.
    253 class VariableExpr final : public Expr {
    254 public:
    255         readonly<DeclWithType> var;
    256 
    257         VariableExpr( const CodeLocation & loc );
    258         VariableExpr( const CodeLocation & loc, const DeclWithType * v );
    259 
    260         bool get_lvalue() const final;
    261 
    262         /// generates a function pointer for a given function
    263         static VariableExpr * functionPointer( const CodeLocation & loc, const FunctionDecl * decl );
    264 
    265         const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
    266 private:
    267         VariableExpr * clone() const override { return new VariableExpr{ *this }; }
    268         MUTATE_FRIEND
    269 };
    270 
    271252/// Address-of expression `&e`
    272253class AddressExpr final : public Expr {
     
    409390        friend class ::ConverterOldToNew;
    410391        friend class ::ConverterNewToOld;
     392};
     393
     394/// A reference to a named variable.
     395class VariableExpr final : public Expr {
     396public:
     397        readonly<DeclWithType> var;
     398
     399        VariableExpr( const CodeLocation & loc );
     400        VariableExpr( const CodeLocation & loc, const DeclWithType * v );
     401
     402        bool get_lvalue() const final;
     403
     404        /// generates a function pointer for a given function
     405        static VariableExpr * functionPointer( const CodeLocation & loc, const FunctionDecl * decl );
     406
     407        const Expr * accept( Visitor & v ) const override { return v.visit( this ); }
     408private:
     409        VariableExpr * clone() const override { return new VariableExpr{ *this }; }
     410        MUTATE_FRIEND
    411411};
    412412
  • src/AST/Type.cpp

    re7d6968 r37b7d95  
    157157
    158158template<typename decl_t>
    159 SueInstType<decl_t>::SueInstType(
    160         const base_type * b, std::vector<ptr<Expr>> && params,
    161         CV::Qualifiers q, std::vector<ptr<Attribute>> && as )
    162 : BaseInstType( b->name, std::move(params), q, std::move(as) ), base( b ) {}
    163 
    164 template<typename decl_t>
    165159bool SueInstType<decl_t>::isComplete() const {
    166160        return base ? base->body : false;
  • src/AST/Type.hpp

    re7d6968 r37b7d95  
    302302class FunctionType final : public ParameterizedType {
    303303public:
     304//      std::vector<ptr<DeclWithType>> returns;
     305//      std::vector<ptr<DeclWithType>> params;
     306
    304307        std::vector<ptr<Type>> returns;
    305308        std::vector<ptr<Type>> params;
     
    342345        : ParameterizedType(q, std::move(as)), params(), name(n) {}
    343346
    344         BaseInstType(
    345                 const std::string& n, std::vector<ptr<Expr>> && params,
    346                 CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} )
    347         : ParameterizedType(q, std::move(as)), params(std::move(params)), name(n) {}
    348 
    349347        BaseInstType( const BaseInstType & o );
    350348
     
    371369
    372370        SueInstType(
    373                 const base_type * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} );
    374 
    375         SueInstType(
    376                 const base_type * b, std::vector<ptr<Expr>> && params,
    377                 CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} );
     371                const decl_t * b, CV::Qualifiers q = {}, std::vector<ptr<Attribute>> && as = {} );
    378372
    379373        bool isComplete() const override;
  • src/AST/porting.md

    re7d6968 r37b7d95  
    3030  * Base nodes now override `const Node * accept( Visitor & v ) const = 0` with, e.g. `const Stmt * accept( Visitor & v ) const override = 0`
    3131* `PassVisitor` is replaced with `ast::Pass`
    32   * Most one shot uses can use `ast::Pass::run` and `ast::Pass::read`.
    33 
    34 `WithConstTypeSubstitution`
    35 * `env` => `typeSubs`
    3632
    3733## Structural Changes ##
     
    150146  * allows `newObject` as just default settings
    151147
    152 `FunctionDecl`
    153 * `params` and `returns` added.
    154   * Contain the declarations of the parameters and return variables.
    155   * Types should match (even be shared with) the fields of `type`.
    156 
    157148`NamedTypeDecl`
    158149* `parameters` => `params`
     
    163154`AggregateDecl`
    164155* `parameters` => `params`
    165 
    166 `StructDecl`
    167 * `makeInst` replaced by better constructor on `StructInstType`.
    168156
    169157`Expr`
     
    257245* **TODO** move `kind`, `typeNames` into code generator
    258246
    259 `ReferenceToType` => `BaseInstType`
     247`ReferenceToType`
    260248* deleted `get_baseParameters()` from children
    261249  * replace with `aggr() ? aggr()->params : nullptr`
     
    273261* `returnVals` => `returns`
    274262* `parameters` => `params`
    275   * Both now just point at types.
    276263* `bool isVarArgs;` => `enum ArgumentFlag { FixedArgs, VariableArgs }; ArgumentFlag isVarArgs;`
    277 
    278 `SueInstType`
    279 * Template class, with specializations and using to implement some other types:
    280   * `StructInstType`, `UnionInstType` & `EnumInstType`
    281264
    282265`TypeInstType`
  • src/Concurrency/Keywords.cc

    re7d6968 r37b7d95  
    6666                        bool needs_main, AggregateDecl::Aggregate cast_target ) :
    6767                  type_name( type_name ), field_name( field_name ), getter_name( getter_name ),
    68                   context_error( context_error ), exception_name( exception_name ),
    69                   vtable_name( getVTableName( exception_name ) ),
     68                  context_error( context_error ), vtable_name( getVTableName( exception_name ) ),
    7069                  needs_main( needs_main ), cast_target( cast_target ) {}
    7170
     
    9089                const std::string getter_name;
    9190                const std::string context_error;
    92                 const std::string exception_name;
    9391                const std::string vtable_name;
    9492                bool needs_main;
     
    9795                StructDecl   * type_decl = nullptr;
    9896                FunctionDecl * dtor_decl = nullptr;
    99                 StructDecl * except_decl = nullptr;
    10097                StructDecl * vtable_decl = nullptr;
    10198        };
     
    379376                else if ( is_target(decl) ) {
    380377                        handle( decl );
    381                 }
    382                 else if ( !except_decl && exception_name == decl->name && decl->body ) {
    383                         except_decl = decl;
    384378                }
    385379                else if ( !vtable_decl && vtable_name == decl->name && decl->body ) {
     
    404398                        assert( struct_type );
    405399
    406                         std::list< Expression * > poly_args = { new TypeExpr( struct_type->clone() ) };
    407                         ObjectDecl * vtable_object = Virtual::makeVtableInstance(
    408                                 vtable_decl->makeInst( poly_args ), struct_type, nullptr );
    409                         declsToAddAfter.push_back( vtable_object );
    410                         declsToAddAfter.push_back( Virtual::makeGetExceptionFunction(
    411                                 vtable_object, except_decl->makeInst( std::move( poly_args ) )
    412                         ) );
     400                        declsToAddAfter.push_back( Virtual::makeVtableInstance( vtable_decl, {
     401                                new TypeExpr( struct_type->clone() ),
     402                        }, struct_type, nullptr ) );
    413403                }
    414404
     
    444434        void ConcurrentSueKeyword::addVtableForward( StructDecl * decl ) {
    445435                if ( vtable_decl ) {
    446                         std::list< Expression * > poly_args = {
     436                        declsToAddBefore.push_back( Virtual::makeVtableForward( vtable_decl, {
    447437                                new TypeExpr( new StructInstType( noQualifiers, decl ) ),
    448                         };
    449                         declsToAddBefore.push_back( Virtual::makeGetExceptionForward(
    450                                 vtable_decl->makeInst( poly_args ),
    451                                 except_decl->makeInst( poly_args )
    452                         ) );
    453                         declsToAddBefore.push_back( Virtual::makeVtableForward(
    454                                 vtable_decl->makeInst( move( poly_args ) ) ) );
     438                        } ) );
    455439                // Its only an error if we want a vtable and don't have one.
    456440                } else if ( ! vtable_name.empty() ) {
  • src/InitTweak/FixGlobalInit.cc

    re7d6968 r37b7d95  
    153153                        } // if
    154154                        if ( Statement * ctor = ctorInit->ctor ) {
    155                                 addDataSectonAttribute( objDecl );
    156155                                initStatements.push_back( ctor );
    157156                                objDecl->init = nullptr;
  • src/InitTweak/FixInit.cc

    re7d6968 r37b7d95  
    802802                                if ( Statement * ctor = ctorInit->get_ctor() ) {
    803803                                        if ( objDecl->get_storageClasses().is_static ) {
    804 
    805                                                 // The ojbect needs to go in the data section, regardless of dtor complexity below.
    806                                                 // The attribute works, and is meant to apply, both for leaving the static local alone,
    807                                                 // and for hoisting it out as a static global.
    808                                                 addDataSectonAttribute( objDecl );
    809 
    810804                                                // originally wanted to take advantage of gcc nested functions, but
    811805                                                // we get memory errors with this approach. To remedy this, the static
  • src/InitTweak/InitTweak.cc

    re7d6968 r37b7d95  
    11031103                return isCopyFunction( decl, "?{}" );
    11041104        }
    1105 
    1106         void addDataSectonAttribute( ObjectDecl * objDecl ) {
    1107                 Type *strLitT = new PointerType( Type::Qualifiers( ),
    1108                         new BasicType( Type::Qualifiers( ), BasicType::Char ) );
    1109                 std::list< Expression * > attr_params;
    1110                 attr_params.push_back(
    1111                         new ConstantExpr( Constant( strLitT, "\".data#\"", std::nullopt ) ) );
    1112                 objDecl->attributes.push_back(new Attribute("section", attr_params));
    1113         }
    1114 
    11151105}
  • src/InitTweak/InitTweak.h

    re7d6968 r37b7d95  
    108108        bool isConstExpr( Initializer * init );
    109109
    110         /// Modifies objDecl to have:
    111         ///    __attribute__((section (".data#")))
    112         /// which makes gcc put the declared variable in the data section,
    113         /// which is helpful for global constants on newer gcc versions,
    114         /// so that CFA's generated initialization won't segfault when writing it via a const cast.
    115         /// The trailing # is an injected assembly comment, to suppress the "a" in
    116         ///    .section .data,"a"
    117         ///    .section .data#,"a"
    118         /// to avoid assembler warning "ignoring changed section attributes for .data"
    119         void addDataSectonAttribute( ObjectDecl * objDecl );
    120 
    121110        class InitExpander_old {
    122111        public:
  • src/Parser/DeclarationNode.cc

    re7d6968 r37b7d95  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Oct  8 08:03:38 2020
    13 // Update Count     : 1135
     12// Last Modified On : Tue Jun  9 20:26:55 2020
     13// Update Count     : 1134
    1414//
    1515
     
    10161016                        if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) {
    10171017                                dwt->location = cur->location;
    1018                                 *out++ = dwt;
     1018                                * out++ = dwt;
    10191019                        } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) {
    10201020                                // e.g., int foo(struct S) {}
     
    10221022                                auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
    10231023                                obj->location = cur->location;
    1024                                 *out++ = obj;
     1024                                * out++ = obj;
    10251025                                delete agg;
    10261026                        } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {
     
    10291029                                auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
    10301030                                obj->location = cur->location;
    1031                                 *out++ = obj;
     1031                                * out++ = obj;
    10321032                        } else if ( EnumDecl * agg = dynamic_cast< EnumDecl * >( decl ) ) {
    10331033                                // e.g., int foo(enum E) {}
     
    10351035                                auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr );
    10361036                                obj->location = cur->location;
    1037                                 *out++ = obj;
     1037                                * out++ = obj;
    10381038                        } // if
    10391039                } catch( SemanticErrorException & e ) {
  • src/Parser/parser.yy

    re7d6968 r37b7d95  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Oct  9 18:09:09 2020
    13 // Update Count     : 4614
     12// Last Modified On : Tue Oct  6 18:24:18 2020
     13// Update Count     : 4610
    1414//
    1515
     
    204204                        return forCtrl( type, new string( identifier->name ), start, compop, comp, inc );
    205205                } else {
    206                         SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed." ); return nullptr;
     206                        SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr;
    207207                } // if
    208208        } else {
    209                 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed." ); return nullptr;
     209                SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); return nullptr;
    210210        } // if
    211211} // forCtrl
     
    24122412// Overloading: function, data, and operator identifiers may be overloaded.
    24132413//
    2414 // Type declarations: "otype" is used to generate new types for declaring objects. Similarly, "dtype" is used for object
     2414// Type declarations: "type" is used to generate new types for declaring objects. Similarly, "dtype" is used for object
    24152415//     and incomplete types, and "ftype" is used for function types. Type declarations with initializers provide
    24162416//     definitions of new types. Type declarations with storage class "extern" provide opaque types.
     
    24412441        type_class identifier_or_type_name
    24422442                { typedefTable.addToScope( *$2, TYPEDEFname, "9" ); }
    2443         type_initializer_opt assertion_list_opt
     2443          type_initializer_opt assertion_list_opt
    24442444                { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); }
    24452445        | type_specifier identifier_parameter_declarator
     
    24682468        assertion
    24692469        | assertion_list assertion
    2470                 { $$ = $1->appendList( $2 ); }
     2470                { $$ = $1 ? $1->appendList( $2 ) : $2; }
    24712471        ;
    24722472
  • src/SynTree/AggregateDecl.cc

    re7d6968 r37b7d95  
    2121#include "Common/utility.h"      // for printAll, cloneAll, deleteAll
    2222#include "Declaration.h"         // for AggregateDecl, TypeDecl, Declaration
    23 #include "Expression.h"
    2423#include "Initializer.h"
    2524#include "LinkageSpec.h"         // for Spec, linkageName, Cforall
     
    8988const char * StructDecl::typeString() const { return aggrString( kind ); }
    9089
    91 StructInstType * StructDecl::makeInst( std::list< Expression * > const & new_parameters ) {
    92         std::list< Expression * > copy_parameters;
    93         cloneAll( new_parameters, copy_parameters );
    94         return makeInst( move( copy( copy_parameters ) ) );
    95 }
    96 
    97 StructInstType * StructDecl::makeInst( std::list< Expression * > && new_parameters ) {
    98         assert( parameters.size() == new_parameters.size() );
    99         StructInstType * type = new StructInstType( noQualifiers, this );
    100         type->parameters = std::move( new_parameters );
    101         return type;
    102 }
    103 
    10490const char * UnionDecl::typeString() const { return aggrString( Union ); }
    10591
  • src/SynTree/Declaration.h

    re7d6968 r37b7d95  
    306306        bool is_thread   () { return kind == Thread   ; }
    307307
    308         // Make a type instance of this declaration.
    309         StructInstType * makeInst( std::list< Expression * > const & parameters );
    310         StructInstType * makeInst( std::list< Expression * > && parameters );
    311 
    312308        virtual StructDecl * clone() const override { return new StructDecl( *this ); }
    313309        virtual void accept( Visitor & v ) override { v.visit( this ); }
  • src/SynTree/Expression.h

    re7d6968 r37b7d95  
    163163};
    164164
    165 /// VariableExpr represents an expression that simply refers to the value of a named variable.
    166 /// Does not take ownership of var.
    167 class VariableExpr : public Expression {
    168   public:
    169         DeclarationWithType * var;
    170 
    171         VariableExpr();
    172         VariableExpr( DeclarationWithType * var );
    173         VariableExpr( const VariableExpr & other );
    174         virtual ~VariableExpr();
    175 
    176         bool get_lvalue() const final;
    177 
    178         DeclarationWithType * get_var() const { return var; }
    179         void set_var( DeclarationWithType * newValue ) { var = newValue; }
    180 
    181         static VariableExpr * functionPointer( FunctionDecl * decl );
    182 
    183         virtual VariableExpr * clone() const override { return new VariableExpr( * this ); }
    184         virtual void accept( Visitor & v ) override { v.visit( this ); }
    185         virtual void accept( Visitor & v ) const override { v.visit( this ); }
    186         virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); }
    187         virtual void print( std::ostream & os, Indenter indent = {} ) const override;
    188 };
    189 
    190165// The following classes are used to represent expression types that cannot be converted into
    191166// function-call format.
     
    354329};
    355330
     331/// VariableExpr represents an expression that simply refers to the value of a named variable.
     332/// Does not take ownership of var.
     333class VariableExpr : public Expression {
     334  public:
     335        DeclarationWithType * var;
     336
     337        VariableExpr();
     338        VariableExpr( DeclarationWithType * var );
     339        VariableExpr( const VariableExpr & other );
     340        virtual ~VariableExpr();
     341
     342        bool get_lvalue() const final;
     343
     344        DeclarationWithType * get_var() const { return var; }
     345        void set_var( DeclarationWithType * newValue ) { var = newValue; }
     346
     347        static VariableExpr * functionPointer( FunctionDecl * decl );
     348
     349        virtual VariableExpr * clone() const override { return new VariableExpr( * this ); }
     350        virtual void accept( Visitor & v ) override { v.visit( this ); }
     351        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     352        virtual Expression * acceptMutator( Mutator & m ) override { return m.mutate( this ); }
     353        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     354};
     355
    356356/// ConstantExpr represents an expression that simply refers to the value of a constant
    357357class ConstantExpr : public Expression {
  • src/SynTree/TypeDecl.cc

    re7d6968 r37b7d95  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Oct  8 18:18:55 2020
    13 // Update Count     : 22
     12// Last Modified On : Fri Dec 13 15:26:14 2019
     13// Update Count     : 21
    1414//
    1515
     
    2121#include "Type.h"            // for Type, Type::StorageClasses
    2222
    23 TypeDecl::TypeDecl( const std::string & name, Type::StorageClasses scs, Type * type, Kind kind, bool sized, Type * init ) :
    24         Parent( name, scs, type ), kind( kind ), sized( kind == Ttype || sized ), init( init ) {
     23TypeDecl::TypeDecl( const std::string & name, Type::StorageClasses scs, Type * type, Kind kind, bool sized, Type * init ) : Parent( name, scs, type ), kind( kind ), sized( kind == Ttype || sized ), init( init ) {
    2524}
    2625
  • src/Virtual/Tables.cc

    re7d6968 r37b7d95  
    1414//
    1515
    16 #include <SynTree/Attribute.h>
    1716#include <SynTree/Declaration.h>
    1817#include <SynTree/Expression.h>
    19 #include <SynTree/Statement.h>
    2018#include <SynTree/Type.h>
    2119
     
    4038}
    4139
     40// Fuse base polymorphic declaration and forall arguments into a new type.
     41static StructInstType * vtableInstType(
     42                StructDecl * polyDecl, std::list< Expression * > && parameters ) {
     43        assert( parameters.size() == polyDecl->parameters.size() );
     44        StructInstType * type = new StructInstType(
     45                        Type::Qualifiers( /* Type::Const */ ), polyDecl );
     46        type->parameters = std::move( parameters );
     47        return type;
     48}
     49
    4250static ObjectDecl * makeVtableDeclaration(
    4351                StructInstType * type, Initializer * init ) {
     
    5866
    5967ObjectDecl * makeVtableForward( StructInstType * type ) {
    60         assert( type );
    6168        return makeVtableDeclaration( type, nullptr );
    6269}
    6370
     71ObjectDecl * makeVtableForward(
     72                StructDecl * polyDecl, std::list< Expression * > && parameters ) {
     73        return makeVtableForward( vtableInstType( polyDecl, std::move( parameters ) ) );
     74}
     75
    6476ObjectDecl * makeVtableInstance(
    65                 StructInstType * vtableType, Type * objectType, Initializer * init ) {
    66         assert( vtableType );
    67         assert( objectType );
     77                StructInstType * vtableType, Type * vobject_type, Initializer * init ) {
    6878        StructDecl * vtableStruct = vtableType->baseStruct;
    6979        // Build the initialization
     
    8292                                                new SingleInit( new AddressExpr( new NameExpr( parentInstance ) ) ) );
    8393                        } else if ( std::string( "size" ) == field->name ) {
    84                                 inits.push_back( new SingleInit( new SizeofExpr( objectType->clone() ) ) );
     94                                inits.push_back( new SingleInit( new SizeofExpr( vobject_type->clone() ) ) );
    8595                        } else if ( std::string( "align" ) == field->name ) {
    86                                 inits.push_back( new SingleInit( new AlignofExpr( objectType->clone() ) ) );
     96                                inits.push_back( new SingleInit( new AlignofExpr( vobject_type->clone() ) ) );
    8797                        } else {
    8898                                inits.push_back( new SingleInit( new NameExpr( field->name ) ) );
     
    98108}
    99109
    100 namespace {
    101         std::string const functionName = "get_exception_vtable";
    102 }
    103 
    104 FunctionDecl * makeGetExceptionForward(
    105                 Type * vtableType, Type * exceptType ) {
    106         assert( vtableType );
    107         assert( exceptType );
    108         FunctionType * type = new FunctionType( noQualifiers, false );
    109         vtableType->tq.is_const = true;
    110         type->returnVals.push_back( new ObjectDecl(
    111                 "_retvalue",
    112                 noStorageClasses,
    113                 LinkageSpec::Cforall,
    114                 nullptr,
    115                 new ReferenceType( noQualifiers, vtableType ),
    116                 nullptr,
    117         { new Attribute("unused") }
    118         ) );
    119         type->parameters.push_back( new ObjectDecl(
    120                 "__unused",
    121                 noStorageClasses,
    122                 LinkageSpec::Cforall,
    123                 nullptr,
    124                 new PointerType( noQualifiers, exceptType ),
    125                 nullptr,
    126                 { new Attribute("unused") }
    127         ) );
    128         return new FunctionDecl(
    129                 functionName,
    130                 noStorageClasses,
    131                 LinkageSpec::Cforall,
    132                 type,
    133                 nullptr
    134         );
    135 }
    136 
    137 FunctionDecl * makeGetExceptionFunction(
    138                 ObjectDecl * vtableInstance, Type * exceptType ) {
    139         assert( vtableInstance );
    140         assert( exceptType );
    141         FunctionDecl * func = makeGetExceptionForward(
    142                 vtableInstance->type->clone(), exceptType );
    143         func->statements = new CompoundStmt( {
    144                 new ReturnStmt( new VariableExpr( vtableInstance ) ),
    145         } );
    146         return func;
     110ObjectDecl * makeVtableInstance(
     111                StructDecl * polyDecl, std::list< Expression * > && parameters,
     112                Type * vobject, Initializer * init ) {
     113        return makeVtableInstance(
     114                vtableInstType( polyDecl, std::move( parameters ) ), vobject, init );
    147115}
    148116
  • src/Virtual/Tables.h

    re7d6968 r37b7d95  
    2727bool isVTableInstanceName( std::string const & name );
    2828
    29 ObjectDecl * makeVtableForward( StructInstType * vtableType );
    30 /* Create a forward declaration of a vtable of the given type.
    31  * vtableType node is consumed.
     29/// Converts exceptions into regular structures.
     30//void ( std::list< Declaration * > & translationUnit );
     31
     32ObjectDecl * makeVtableForward( StructInstType * );
     33ObjectDecl * makeVtableForward( StructDecl *, std::list< Expression * > && );
     34/* Create a forward definition of a vtable of the given type.
     35 *
     36 * Instead of the virtual table type you may provide the declaration and all
     37 * the forall parameters.
    3238 */
    3339
    34 ObjectDecl * makeVtableInstance( StructInstType * vtableType, Type * objectType,
    35         Initializer * init = nullptr );
     40ObjectDecl * makeVtableInstance( StructInstType *, Type *, Initializer * );
     41ObjectDecl * makeVtableInstance(
     42        StructDecl *, std::list< Expression * > &&, Type *, Initializer * );
    3643/* Create an initialized definition of a vtable.
    37  * vtableType and init (if provided) nodes are consumed.
    38  */
    39 
    40 // Some special code for how exceptions interact with virtual tables.
    41 FunctionDecl * makeGetExceptionForward( Type * vtableType, Type * exceptType );
    42 /* Create a forward declaration of the exception virtual function
    43  * linking the vtableType to the exceptType. Both nodes are consumed.
    44  */
    45 
    46 FunctionDecl * makeGetExceptionFunction(
    47         ObjectDecl * vtableInstance, Type * exceptType );
    48 /* Create the definition of the exception virtual function.
    49  * exceptType node is consumed.
     44 *
     45 * The parameters are the virtual table type (or the base declaration and the
     46 * forall parameters), the object type and optionally an initializer.
     47 *
     48 * Instead of the virtual table type you may provide the declaration and all
     49 * the forall parameters.
    5050 */
    5151
  • src/main.cc

    re7d6968 r37b7d95  
    99// Author           : Peter Buhr and Rob Schluntz
    1010// Created On       : Fri May 15 23:12:02 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Oct  8 18:17:46 2020
    13 // Update Count     : 637
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tue May 19 12:03:00 2020
     13// Update Count     : 634
    1414//
    1515
     
    458458
    459459
    460 static const char optstring[] = ":c:ghlLmNnpdOAP:S:twW:D:";
     460static const char optstring[] = ":c:ghlLmNnpdP:S:twW:D:";
    461461
    462462enum { PreludeDir = 128 };
     
    485485
    486486static const char * description[] = {
    487         "diagnostic color: never, always, or auto.",            // -c
    488         "wait for gdb to attach",                                                       // -g
    489         "print help message",                                                           // -h
    490         "generate libcfa.c",                                                            // -l
    491         "generate line marks",                                                          // -L
    492         "do not replace main",                                                          // -m
    493         "do not generate line marks",                                           // -N
    494         "do not read prelude",                                                          // -n
     487        "diagnostic color: never, always, or auto.",          // -c
     488        "wait for gdb to attach",                             // -g
     489        "print help message",                                 // -h
     490        "generate libcfa.c",                                  // -l
     491        "generate line marks",                                // -L
     492        "do not replace main",                                // -m
     493        "do not generate line marks",                         // -N
     494        "do not read prelude",                                // -n
    495495        "generate prototypes for prelude functions",            // -p
    496         "only print deterministic output",                  // -d
    497         "Use the old-ast",                                                                      // -O
    498         "Use the new-ast",                                                                      // -A
    499         "print",                                                                                        // -P
     496        "don't print output that isn't deterministic",        // -d
     497        "Use the old-ast",                                    // -O
     498        "Use the new-ast",                                    // -A
     499        "print",                                              // -P
    500500        "<directory> prelude directory for debug/nodebug",      // no flag
    501501        "<option-list> enable profiling information:\n          counters,heap,time,all,none", // -S
    502         "building cfa standard lib",                                            // -t
    503         "",                                                                                                     // -w
    504         "",                                                                                                     // -W
    505         "",                                                                                                     // -D
     502        "building cfa standard lib",                          // -t
     503        "",                                                   // -w
     504        "",                                                   // -W
     505        "",                                                   // -D
    506506}; // description
    507507
  • tests/.expect/init1.txt

    re7d6968 r37b7d95  
    1 init1.cfa: In function '_X4mainFi___1':
    2 init1.cfa:136:9: note: #pragma message: Compiled
     1error: No reasonable alternatives for expression Untyped Init Expression
     2  Name: rx  InitAlternative: reference to signed int
     3error: No reasonable alternatives for expression Untyped Init Expression
     4  Name: px  InitAlternative: pointer to signed int
     5error: No reasonable alternatives for expression Untyped Init Expression
     6  Name: crx  InitAlternative: reference to float
     7error: No reasonable alternatives for expression Untyped Init Expression
     8  Name: cpx  InitAlternative: pointer to float
     9init1.cfa:94:1 error: No reasonable alternatives for expression Generated Cast of:
     10  Name: rx
     11... to:
     12  reference to signed int
     13init1.cfa:97:1 error: No reasonable alternatives for expression Applying untyped:
     14  Name: ?{}
     15...to:
     16  Generated Cast of:
     17    Variable Expression: _retval_f_py: pointer to signed int
     18  ... to:
     19    reference to pointer to signed int
     20  Name: px
     21
     22init1.cfa:104:1 error: No reasonable alternatives for expression Generated Cast of:
     23  Name: crx
     24... to:
     25  reference to float
     26init1.cfa:107:1 error: No reasonable alternatives for expression Applying untyped:
     27  Name: ?{}
     28...to:
     29  Generated Cast of:
     30    Variable Expression: _retval_f_py2: pointer to float
     31  ... to:
     32    reference to pointer to float
     33  Name: cpx
     34
     35init1.cfa:114:1 error: No reasonable alternatives for expression Generated Cast of:
     36  Name: s
     37... to:
     38  reference to instance of type T (not function type)
     39init1.cfa:118:1 error: No reasonable alternatives for expression Applying untyped:
     40  Name: ?{}
     41...to:
     42  Generated Cast of:
     43    Variable Expression: _retval_anycvt: pointer to instance of type T (not function type)
     44  ... to:
     45    reference to pointer to instance of type T (not function type)
     46  Name: s
     47
  • tests/.expect/limits.txt

    re7d6968 r37b7d95  
    11limits.cfa: In function '_X4mainFi_iPPKc__1':
    2 limits.cfa:154:9: note: #pragma message: Compiled
     2limits.cfa:151:9: note: #pragma message: Compiled
  • tests/Makefile.am

    re7d6968 r37b7d95  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Fri Oct  9 23:13:07 2020
    14 ## Update Count     : 86
     13## Last Modified On : Sun Sep 27 19:01:41 2020
     14## Update Count     : 84
    1515###############################################################################
    1616
     
    141141
    142142SYNTAX_ONLY_CODE = expression typedefRedef variableDeclarator switch numericConstants identFuncDeclarator forall \
    143         init1 limits nested-types stdincludes cast labelledExit array builtins/sync warnings/self-assignment
     143        limits nested-types stdincludes cast labelledExit array builtins/sync warnings/self-assignment
    144144$(SYNTAX_ONLY_CODE): % : %.cfa $(CFACCBIN)
    145145        $(CFACOMPILE_SYNTAX)
     
    149149# use custom target since they require a custom define *and* have a name that doesn't match the file
    150150alloc-ERROR : alloc.cfa $(CFACCBIN)
    151         $(CFACOMPILE_SYNTAX) -DERR1
    152         -cp $(test) $(abspath ${@})
    153 
    154 init1-ERROR : init1.cfa $(CFACCBIN)
    155151        $(CFACOMPILE_SYNTAX) -DERR1
    156152        -cp $(test) $(abspath ${@})
  • tests/alloc.cfa

    re7d6968 r37b7d95  
    1010// Created On       : Wed Feb  3 07:56:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Oct  9 23:03:11 2020
    13 // Update Count     : 431
     12// Last Modified On : Fri Aug 14 16:59:59 2020
     13// Update Count     : 430
    1414//
    1515
     
    362362        ip = memset( stp, 10 );
    363363        ip = memcpy( &st1, &st );
    364 #endif // ERR1
     364#endif
    365365} // main
    366366
  • tests/complex.cfa

    re7d6968 r37b7d95  
    1414//
    1515
     16#include <stdio.h>
    1617#include <complex.h>
    1718#ifdef __CFA__
  • tests/errors/.expect/completeType.x64.txt

    re7d6968 r37b7d95  
    132132?=?: pointer to function
    133133        ... with parameters
    134           reference to instance of type _110_0_T (not function type)
    135           instance of type _110_0_T (not function type)
     134          reference to instance of type _109_0_T (not function type)
     135          instance of type _109_0_T (not function type)
    136136        ... returning
    137           _retval__operator_assign: instance of type _110_0_T (not function type)
     137          _retval__operator_assign: instance of type _109_0_T (not function type)
    138138          ... with attributes:
    139139            Attribute with name: unused
  • tests/errors/.expect/completeType.x86.txt

    re7d6968 r37b7d95  
    132132?=?: pointer to function
    133133        ... with parameters
    134           reference to instance of type _109_0_T (not function type)
    135           instance of type _109_0_T (not function type)
     134          reference to instance of type _108_0_T (not function type)
     135          instance of type _108_0_T (not function type)
    136136        ... returning
    137           _retval__operator_assign: instance of type _109_0_T (not function type)
     137          _retval__operator_assign: instance of type _108_0_T (not function type)
    138138          ... with attributes:
    139139            Attribute with name: unused
  • tests/exceptions/cancel/coroutine.cfa

    re7d6968 r37b7d95  
    11// Try cancelling a coroutine.
    22
     3#include <stdio.h>
    34#include <coroutine.hfa>
    45#include <exception.hfa>
  • tests/exceptions/conditional.cfa

    re7d6968 r37b7d95  
    55
    66#include <exception.hfa>
     7#include <stdio.h>
    78
    89VTABLE_DECLARATION(num_error)(
  • tests/exceptions/defaults.cfa

    re7d6968 r37b7d95  
    5555
    5656void unhandled_test(void) {
    57         forall(dtype T, dtype V | is_exception(T, V))
     57        forall(dtype T | is_exception(T))
    5858        void defaultTerminationHandler(T &) {
    5959                throw (unhandled_exception){};
  • tests/exceptions/except-io.hfa

    re7d6968 r37b7d95  
    11// Common tools for the exception tests.
     2
     3#include <stdio.h>
    24
    35// Echo when a destructor is run and an area/block is left.
  • tests/exceptions/trash.cfa

    re7d6968 r37b7d95  
    22
    33#include <exception.hfa>
     4#include <stdio.h>
    45
    56TRIVIAL_EXCEPTION(yin);
  • tests/global-monomorph.cfa

    re7d6968 r37b7d95  
    1 // Create monomorphic instances of polymorphic types at global scope.
     1// Crea
     2
     3#include <stdlib.hfa>
     4#include <stdio.h>
    25
    36forall(dtype T)
  • tests/init1.cfa

    re7d6968 r37b7d95  
    99// Author           : Michael Brooks
    1010// Created On       : Thu Jul 16 22:00:00 2020
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Oct 11 10:26:50 2020
    13 // Update Count     : 8
     11// Last Modified By : Michael Brooks
     12// Last Modified On : Thu Jul 16 22:00:00 2020
     13// Update Count     : 1
    1414//
    1515
     
    4141    const float * cpx2 = cpx;
    4242
    43     // FIX ME: Code gen not producing correct cast.
    44 #pragma GCC diagnostic push
    45 #pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
    46     int (* fp)( int ) = 0p;
    47     fp = 0p;
    48 #pragma GCC diagnostic pop
    49 
    5043    //
    5144    // unsound initializations
    5245    //
    5346
    54     #ifdef ERR1
    5547    // mismatched referenced type
    5648    int & ry = rx;
     
    6052    float & ry2 = crx;
    6153    float * py2 = cpx;
    62     #endif // ERR1
    6354}
    6455
     
    9990//
    10091
    101 #ifdef ERR1
    10292int & f_ry() {
    10393    float & rx = *0p;
     
    129119    return s;               // mismatched referenced type
    130120}
    131 #endif // ERR1
    132 
    133 int main() {
    134     #pragma message( "Compiled" )                       // force non-empty .expect file
    135 }
  • tests/limits.cfa

    re7d6968 r37b7d95  
    1313// Update Count     : 10
    1414//
    15 
    16 // Note: For testing the ability to load the constants defined in libcfa/src/limits.cfa,
    17 // see discussion in test const-init.
    1815
    1916#include <limits.hfa>
  • tests/poly-d-cycle.cfa

    re7d6968 r37b7d95  
    11// Check that a cycle of polymorphic dtype structures can be instancated.
     2
     3#include <stdio.h>
    24
    35forall(dtype T)
  • tests/poly-o-cycle.cfa

    re7d6968 r37b7d95  
    11// Check that a cycle of polymorphic otype structures can be instancated.
     2
     3#include <stdio.h>
    24
    35forall(otype T)
Note: See TracChangeset for help on using the changeset viewer.