Changeset eaace25


Ignore:
Timestamp:
Jul 7, 2017, 12:26:31 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
67f2170
Parents:
3873b5a1 (diff), 7c03d6d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/LinkageSpec.cc

    r3873b5a1 reaace25  
    1010// Created On       : Sat May 16 13:22:09 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jun 28 11:51:00 2017
    13 // Update Count     : 24
     12// Last Modified On : Fri Jul  7 11:11:00 2017
     13// Update Count     : 25
    1414//
    1515
     
    2222#include "Common/SemanticError.h"
    2323
    24 LinkageSpec::Spec LinkageSpec::linkageCheck( const string * spec ) {
     24namespace LinkageSpec {
     25
     26Spec linkageCheck( const string * spec ) {
     27        assert( spec );
    2528        unique_ptr<const string> guard( spec ); // allocated by lexer
    2629        if ( *spec == "\"Cforall\"" ) {
     
    3538}
    3639
    37 string LinkageSpec::linkageName( LinkageSpec::Spec linkage ) {
    38         assert( 0 <= linkage && linkage < LinkageSpec::NoOfSpecs );
    39         static const char *linkageKinds[LinkageSpec::NoOfSpecs] = {
    40                 "intrinsic", "Cforall", "C", "automatically generated", "compiler built-in", "cfa built-in", "c built-in",
    41         };
    42         return linkageKinds[linkage];
     40Spec linkageUpdate( Spec old_spec, const string * cmd ) {
     41        assert( cmd );
     42        unique_ptr<const string> guard( cmd ); // allocated by lexer
     43        if ( *cmd == "\"Cforall\"" ) {
     44                old_spec.is_mangled = true;
     45                return old_spec;
     46        } else if ( *cmd == "\"C\"" ) {
     47                old_spec.is_mangled = false;
     48                return old_spec;
     49        } else {
     50                throw SemanticError( "Invalid linkage specifier " + *cmd );
     51        } // if
    4352}
    4453
    45 bool LinkageSpec::isMangled( Spec spec ) {
    46         assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
    47         static bool decoratable[LinkageSpec::NoOfSpecs] = {
    48                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler,
    49                         true,           true,           false,  true,           false,
    50                 //      Builtin,        BuiltinC,
    51                         true,           false,
    52         };
    53         return decoratable[spec];
     54std::string linkageName( Spec linkage ) {
     55    switch ( linkage ) {
     56    case Intrinsic:
     57        return "intrinsic";
     58    case C:
     59        return "C";
     60    case Cforall:
     61        return "Cforall";
     62    case AutoGen:
     63        return "autogenerated cfa";
     64    case Compiler:
     65        return "compiler built-in";
     66    case BuiltinCFA:
     67        return "cfa built-in";
     68    case BuiltinC:
     69        return "c built-in";
     70    default:
     71        return "<unnamed linkage spec>";
     72    }
    5473}
    5574
    56 bool LinkageSpec::isGeneratable( Spec spec ) {
    57         assert( 0 <= spec && spec < LinkageSpec::NoOfSpecs );
    58         static bool generatable[LinkageSpec::NoOfSpecs] = {
    59                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler,
    60                         true,           true,           true,   true,           false,
    61                 //      Builtin,        BuiltinC,
    62                         true,           true,
    63         };
    64         return generatable[spec];
    65 }
    66 
    67 bool LinkageSpec::isOverridable( Spec spec ) {
    68         assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
    69         static bool overridable[LinkageSpec::NoOfSpecs] = {
    70                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler,
    71                         true,           false,          false,  true,           false,
    72                 //      Builtin,        BuiltinC,
    73                         false,          false,
    74         };
    75         return overridable[spec];
    76 }
    77 
    78 bool LinkageSpec::isBuiltin( Spec spec ) {
    79         assert( spec >= 0 && spec < LinkageSpec::NoOfSpecs );
    80         static bool builtin[LinkageSpec::NoOfSpecs] = {
    81                 //      Intrinsic,      Cforall,        C,              AutoGen,        Compiler,
    82                         true,           false,          false,  false,          true,
    83                 //      Builtin,        BuiltinC,
    84                         true,           true,
    85         };
    86         return builtin[spec];
    87 }
     75} // LinkageSpec
    8876
    8977// Local Variables: //
  • src/Parser/LinkageSpec.h

    r3873b5a1 reaace25  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // LinkageSpec.h -- 
     7// LinkageSpec.h --
    88//
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:24:28 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jun 28 11:50:00 2017
    13 // Update Count     : 12
     12// Last Modified On : Fri Jul  7 11:03:00 2017
     13// Update Count     : 13
    1414//
    1515
     
    1919#include <string>
    2020
    21 struct LinkageSpec {
    22         enum Spec {
    23                 Intrinsic,                                                                              // C built-in defined in prelude
    24                 Cforall,                                                                                // ordinary
    25                 C,                                                                                              // not overloadable, not mangled
    26                 AutoGen,                                                                                // built by translator (struct assignment)
    27                 Compiler,                                                                               // gcc internal
    28                 Builtin,                                                                                // mangled builtins
    29                 BuiltinC,                                                                               // non-mangled builtins
    30                 NoOfSpecs
     21namespace LinkageSpec {
     22        // All linkage specs are some combination of these flags:
     23        enum {
     24                Mangle = 1 << 0,
     25                Generate = 1 << 1,
     26                Overrideable = 1 << 2,
     27                Builtin = 1 << 3,
     28
     29                NoOfSpecs = 1 << 4,
    3130        };
    32  
    33         static Spec linkageCheck( const std::string * );
    34         static std::string linkageName( Spec );
    35  
    36         static bool isMangled( Spec );
    37         static bool isGeneratable( Spec );
    38         static bool isOverridable( Spec );
    39         static bool isBuiltin( Spec );
     31
     32        union Spec {
     33                unsigned int val;
     34                struct {
     35                        bool is_mangled : 1;
     36                        bool is_generatable : 1;
     37                        bool is_overridable : 1;
     38                        bool is_builtin : 1;
     39                };
     40                constexpr Spec( unsigned int val ) : val( val ) {}
     41                constexpr Spec( Spec const &other ) : val( other.val ) {}
     42                // Operators may go here.
     43                // Supports == and !=
     44                constexpr operator unsigned int () const { return val; }
     45        };
     46
     47
     48        Spec linkageCheck( const std::string * );
     49        // Returns the Spec with the given name (limited to C, Cforall & BuiltinC)
     50        Spec linkageUpdate( Spec old_spec, const std::string * cmd );
     51        /* If cmd = "C" returns a Spec that is old_spec with is_mangled = false
     52         * If cmd = "Cforall" returns old_spec Spec with is_mangled = true
     53         */
     54
     55        std::string linkageName( Spec );
     56
     57        // To Update: LinkageSpec::isXyz( cur_spec ) -> cur_spec.is_xyz
     58        inline bool isMangled( Spec spec ) { return spec.is_mangled; }
     59        inline bool isGeneratable( Spec spec ) { return spec.is_generatable; }
     60        inline bool isOverridable( Spec spec ) { return spec.is_overridable; }
     61        inline bool isBuiltin( Spec spec ) { return spec.is_builtin; }
     62
     63        // Pre-defined flag combinations:
     64        // C built-in defined in prelude
     65        constexpr Spec const Intrinsic = { Mangle | Generate | Overrideable | Builtin };
     66        // ordinary
     67        constexpr Spec const Cforall = { Mangle | Generate };
     68        // not overloadable, not mangled
     69        constexpr Spec const C = { Generate };
     70        // built by translator (struct assignment)
     71        constexpr Spec const AutoGen = { Mangle | Generate | Overrideable };
     72        // gcc internal
     73        constexpr Spec const Compiler = { Builtin };
     74        // mangled builtins
     75        constexpr Spec const BuiltinCFA = { Mangle | Generate | Builtin };
     76        // non-mangled builtins
     77        constexpr Spec const BuiltinC = { Generate | Builtin };
    4078};
    4179
  • src/libcfa/concurrency/CtxSwitch-i386.S

    r3873b5a1 reaace25  
    9898        ret
    9999
    100 .text
    101         .align 2
    102 .globl  CtxGet
    103 CtxGet:
    104         movl %esp,SP_OFFSET(%eax)
    105         movl %ebp,FP_OFFSET(%eax)
    106 
    107         ret
    108 
    109100// Local Variables: //
    110101// compile-command: "make install" //
  • src/libcfa/concurrency/CtxSwitch-x86_64.S

    r3873b5a1 reaace25  
    1 //                               -*- Mode: Asm -*- 
     1//                               -*- Mode: Asm -*-
    22//
    33// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
     
    1818// Free Software  Foundation; either  version 2.1 of  the License, or  (at your
    1919// option) any later version.
    20 // 
     20//
    2121// This library is distributed in the  hope that it will be useful, but WITHOUT
    2222// ANY  WARRANTY;  without even  the  implied  warranty  of MERCHANTABILITY  or
    2323// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
    2424// for more details.
    25 // 
     25//
    2626// You should  have received a  copy of the  GNU Lesser General  Public License
    2727// along  with this library.
    28 // 
     28//
    2929
    3030// This context switch routine depends on the fact that the stack of a new
     
    9393.globl  CtxInvokeStub
    9494CtxInvokeStub:
    95         movq %rbx, %rdi 
     95        movq %rbx, %rdi
    9696        jmp *%r12
    97 
    98 .text
    99         .align 2
    100 .globl  CtxGet
    101 CtxGet:
    102         movq %rsp,SP_OFFSET(%rdi)
    103         movq %rbp,FP_OFFSET(%rdi)
    104 
    105         ret
    10697
    10798// Local Variables: //
  • src/libcfa/concurrency/invoke.h

    r3873b5a1 reaace25  
    112112      extern void CtxInvokeStub( void );
    113113      void CtxSwitch( void * from, void * to ) asm ("CtxSwitch");
    114       void CtxGet( void * this ) asm ("CtxGet");
     114
     115      #if   defined( __x86_64__ )
     116      #define CtxGet( ctx ) __asm__ ( \
     117                  "movq %%rsp,%0\n"   \
     118                  "movq %%rbp,%1\n"   \
     119            : "=rm" (ctx.SP), "=rm" (ctx.FP) )
     120      #elif defined( __i386__ )
     121      #define CtxGet( ctx ) __asm__ ( \
     122                  "movl %%esp,%0\n"   \
     123                  "movl %%ebp,%1\n"   \
     124            : "=rm" (ctx.SP), "=rm" (ctx.FP) )
     125      #endif
    115126
    116127#endif //_INVOKE_PRIVATE_H_
  • src/libcfa/concurrency/kernel.c

    r3873b5a1 reaace25  
    7575
    7676void ?{}( current_stack_info_t * this ) {
    77         CtxGet( &this->ctx );
     77        CtxGet( this->ctx );
    7878        this->base = this->ctx.FP;
    7979        this->storage = this->ctx.SP;
  • src/libcfa/fstream

    r3873b5a1 reaace25  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul  1 16:37:53 2017
    13 // Update Count     : 112
     12// Last Modified On : Fri Jul  7 08:32:38 2017
     13// Update Count     : 117
    1414//
    1515
    16 #ifndef __FSTREAM_H__
    17 #define __FSTREAM_H__
     16#pragma once
    1817
    1918#include "iostream"
    2019
    21 enum { separateSize = 16 };
     20enum { sepSize = 16 };
    2221struct ofstream {
    2322        void * file;
    2423        _Bool sepDefault;
    2524        _Bool sepOnOff;
    26         _Bool lastSepOn;
     25        _Bool sawNL;
    2726        const char * sepCur;
    28         char separator[separateSize];
    29         char tupleSeparator[separateSize];
     27        char separator[sepSize];
     28        char tupleSeparator[sepSize];
    3029}; // ofstream
    3130
     
    3635const char * sepGetCur( ofstream * );
    3736void sepSetCur( ofstream *, const char * );
    38 _Bool lastSepOn( ofstream * );
     37_Bool getNL( ofstream * );
     38void setNL( ofstream *, _Bool );
    3939
    4040// public
     
    7575extern ifstream * sin;
    7676
    77 #endif // __FSTREAM_H__
    78 
    7977// Local Variables: //
    8078// mode: c //
  • src/libcfa/fstream.c

    r3873b5a1 reaace25  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul  1 16:37:54 2017
    13 // Update Count     : 242
     12// Last Modified On : Thu Jul  6 18:38:25 2017
     13// Update Count     : 251
    1414//
    1515
     
    3333        this->sepDefault = sepDefault;
    3434        this->sepOnOff = sepOnOff;
    35         this->lastSepOn = false;
    3635        sepSet( this, separator );
    3736        sepSetCur( this, sepGet( this ) );
     
    4039
    4140// private
    42 _Bool lastSepOn( ofstream * os ) { return os->lastSepOn; }
    43 _Bool sepPrt( ofstream * os ) { os->lastSepOn = false; return os->sepOnOff; }
     41_Bool sepPrt( ofstream * os ) { setNL( os, false ); return os->sepOnOff; }
    4442void sepReset( ofstream * os ) { os->sepOnOff = os->sepDefault; }
    4543void sepReset( ofstream * os, _Bool reset ) { os->sepDefault = reset; os->sepOnOff = os->sepDefault; }
    4644const char * sepGetCur( ofstream * os ) { return os->sepCur; }
    4745void sepSetCur( ofstream * os, const char * sepCur ) { os->sepCur = sepCur; }
     46_Bool getNL( ofstream * os ) { return os->sawNL; }
     47void setNL( ofstream * os, _Bool state ) { os->sawNL = state; }
    4848
    4949// public
    50 void sepOn( ofstream * os ) { os->lastSepOn = true; os->sepOnOff = true; }
    51 void sepOff( ofstream * os ) { os->lastSepOn = false; os->sepOnOff = 0; }
     50void sepOn( ofstream * os ) { os->sepOnOff = ! getNL( os ); }
     51void sepOff( ofstream * os ) { os->sepOnOff = false; }
    5252
    5353_Bool sepDisable( ofstream *os ) {
    5454        _Bool temp = os->sepDefault;
    5555        os->sepDefault = false;
    56         os->lastSepOn = false;
    5756        sepReset( os );
    5857        return temp;
     
    6968void sepSet( ofstream * os, const char * s ) {
    7069        assert( s );
    71         strncpy( os->separator, s, separateSize - 1 );
    72         os->separator[separateSize - 1] = '\0';
     70        strncpy( os->separator, s, sepSize - 1 );
     71        os->separator[sepSize - 1] = '\0';
    7372} // sepSet
    7473
     
    7675void sepSetTuple( ofstream * os, const char * s ) {
    7776        assert( s );
    78         strncpy( os->tupleSeparator, s, separateSize - 1 );
    79         os->tupleSeparator[separateSize - 1] = '\0';
     77        strncpy( os->tupleSeparator, s, sepSize - 1 );
     78        os->tupleSeparator[sepSize - 1] = '\0';
    8079} // sepSet
    8180
     
    153152
    154153void open( ifstream * is, const char * name, const char * mode ) {
    155         FILE *t = fopen( name, mode );
    156         if ( t == 0 ) {                                                                         // do not change unless successful
     154        FILE *file = fopen( name, mode );
     155        if ( file == 0 ) {                                                                      // do not change unless successful
    157156                fprintf( stderr, IO_MSG "open input file \"%s\", ", name );
    158157                perror( 0 );
    159158                exit( EXIT_FAILURE );
    160159        } // if
    161         is->file = t;
     160        is->file = file;
    162161} // open
    163162
  • src/libcfa/gmp

    r3873b5a1 reaace25  
    1010// Created On       : Tue Apr 19 08:43:43 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat May 27 09:55:51 2017
    13 // Update Count     : 14
     12// Last Modified On : Fri Jul  7 09:33:20 2017
     13// Update Count     : 15
    1414//
    1515
    1616// https://gmplib.org/gmp-man-6.1.1.pdf
     17
     18#pragma once
    1719
    1820#include <gmp.h>                                                                                // GNU multi-precise integers
  • src/libcfa/iostream

    r3873b5a1 reaace25  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul  2 08:42:56 2017
    13 // Update Count     : 110
     12// Last Modified On : Fri Jul  7 08:35:59 2017
     13// Update Count     : 118
    1414//
    1515
    16 #ifndef __IOSTREAM_H__
    17 #define __IOSTREAM_H__
     16#pragma once
    1817
    1918#include "iterator"
     
    2625        const char * sepGetCur( ostype * );                                     // get current separator string
    2726        void sepSetCur( ostype *, const char * );                       // set current separator string
    28         _Bool lastSepOn( ostype * );                                            // last manipulator is setOn (context sensitive)
     27        _Bool getNL( ostype * );                                                        // check newline
     28        void setNL( ostype *, _Bool );                                          // saw newline
    2929        // public
    3030        void sepOn( ostype * );                                                         // turn separator state on
     
    8282forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, ostype * (*)( ostype * ) );
    8383forall( dtype ostype | ostream( ostype ) ) ostype * endl( ostype * );
     84forall( dtype ostype | ostream( ostype ) ) ostype * sep( ostype * );
     85forall( dtype ostype | ostream( ostype ) ) ostype * sepTuple( ostype * );
    8486forall( dtype ostype | ostream( ostype ) ) ostype * sepOn( ostype * );
    8587forall( dtype ostype | ostream( ostype ) ) ostype * sepOff( ostype * );
     
    137139forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, _Istream_cstrC );
    138140
    139 #endif // __IOSTREAM_H
    140 
    141141// Local Variables: //
    142142// mode: c //
  • src/libcfa/iostream.c

    r3873b5a1 reaace25  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul  2 08:54:02 2017
    13 // Update Count     : 375
     12// Last Modified On : Thu Jul  6 18:14:17 2017
     13// Update Count     : 396
    1414//
    1515
     
    1818extern "C" {
    1919#include <stdio.h>
     20#include <stdbool.h>                                                                    // true/false
    2021#include <string.h>                                                                             // strlen
    2122#include <float.h>                                                                              // DBL_DIG, LDBL_DIG
     
    2425
    2526forall( dtype ostype | ostream( ostype ) )
    26 ostype * ?|?( ostype * os, char c ) {
    27         fmt( os, "%c", c );
     27ostype * ?|?( ostype * os, char ch ) {
     28        fmt( os, "%c", ch );
     29        if ( ch == '\n' ) setNL( os, true );
    2830        sepOff( os );
    2931        return os;
     
    180182
    181183        // last character IS spacing or opening punctuation => turn off separator for next item
    182         unsigned int len = strlen( cp ), posn = len - 1;
    183         ch = cp[posn];                                                                          // must make unsigned
     184        size_t len = strlen( cp );
     185        ch = cp[len - 1];                                                                       // must make unsigned
    184186        if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) {
    185187                sepOn( os );
     
    187189                sepOff( os );
    188190        } // if
     191        if ( ch == '\n' ) setNL( os, true );                            // check *AFTER* sepPrt call above as it resets NL flag
    189192        return write( os, cp, len );
    190193} // ?|?
     
    216219
    217220forall( dtype ostype | ostream( ostype ) )
     221ostype * sep( ostype * os ) {
     222        os | sepGet( os );
     223        return os;
     224} // sep
     225
     226forall( dtype ostype | ostream( ostype ) )
     227ostype * sepTuple( ostype * os ) {
     228        os | sepGetTuple( os );
     229        return os;
     230} // sepTuple
     231
     232forall( dtype ostype | ostream( ostype ) )
    218233ostype * endl( ostype * os ) {
    219         if ( lastSepOn( os ) ) fmt( os, "%s", sepGetCur( os ) );
    220234        os | '\n';
     235        setNL( os, true );
    221236        flush( os );
    222237        sepOff( os );                                                                           // prepare for next line
  • src/libcfa/iterator

    r3873b5a1 reaace25  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 18:06:05 2016
    13 // Update Count     : 9
     12// Last Modified On : Fri Jul  7 08:37:25 2017
     13// Update Count     : 10
    1414//
    1515
    16 #ifndef ITERATOR_H
    17 #define ITERATOR_H
     16#pragma once
    1817
    1918// An iterator can be used to traverse a data structure.
     
    3938
    4039forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
    41 void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) );
     40void for_each( iterator_type begin, iterator_type end, void (* func)( elt_type ) );
    4241
    4342forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
    44 void for_each_reverse( iterator_type begin, iterator_type end, void (*func)( elt_type ) );
    45 
    46 #endif // ITERATOR_H
     43void for_each_reverse( iterator_type begin, iterator_type end, void (* func)( elt_type ) );
    4744
    4845// Local Variables: //
  • src/libcfa/iterator.c

    r3873b5a1 reaace25  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  2 18:08:11 2016
    13 // Update Count     : 27
     12// Last Modified On : Fri Jul  7 08:38:23 2017
     13// Update Count     : 28
    1414//
    1515
     
    1717
    1818forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
    19 void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) {
     19void for_each( iterator_type begin, iterator_type end, void (* func)( elt_type ) ) {
    2020        for ( iterator_type i = begin; i != end; ++i ) {
    2121                func( *i );
    22         }
    23 }
     22        } // for
     23} // for_each
    2424
    2525forall( otype iterator_type, otype elt_type | iterator( iterator_type, elt_type ) )
    26 void for_each_reverse( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) {
     26void for_each_reverse( iterator_type begin, iterator_type end, void (* func)( elt_type ) ) {
    2727        for ( iterator_type i = end; i != begin; ) {
    2828                --i;
    2929                func( *i );
    30         }
    31 }
     30        } // for
     31} // for_each_reverse
    3232
    3333// Local Variables: //
  • src/libcfa/limits

    r3873b5a1 reaace25  
    1010// Created On       : Wed Apr  6 18:06:52 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Apr  6 21:08:16 2016
    13 // Update Count     : 6
     12// Last Modified On : Fri Jul  7 09:33:57 2017
     13// Update Count     : 7
    1414//
    1515
    16 #ifndef LIMITS_H
    17 #define LIMITS_H
     16#pragma once
    1817
    1918// Integral Constants
     
    110109extern const long _Complex _1_SQRT_2;                                   // 1 / sqrt(2)
    111110
    112 #endif // LIMITS_H
    113 
    114111// Local Variables: //
    115112// mode: c //
  • src/libcfa/math

    r3873b5a1 reaace25  
    1010// Created On       : Mon Apr 18 23:37:04 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed May 24 17:40:39 2017
    13 // Update Count     : 60
    14 //
    15 
    16 #ifndef MATH_H
    17 #define MATH_H
     12// Last Modified On : Fri Jul  7 09:34:15 2017
     13// Update Count     : 61
     14//
     15
     16#pragma once
    1817
    1918extern "C" {
     
    345344long double scalbln( long double, long int );
    346345
    347 #endif // MATH_H
    348 
    349346// Local Variables: //
    350347// mode: c //
  • src/libcfa/rational

    r3873b5a1 reaace25  
    1212// Created On       : Wed Apr  6 17:56:25 2016
    1313// Last Modified By : Peter A. Buhr
    14 // Last Modified On : Mon May 15 21:30:12 2017
    15 // Update Count     : 90
     14// Last Modified On : Fri Jul  7 09:34:33 2017
     15// Update Count     : 93
    1616//
    1717
    18 #ifndef RATIONAL_H
    19 #define RATIONAL_H
     18#pragma once
    2019
    2120#include "iostream"
     
    4746// implementation
    4847
    49 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     48forall( otype RationalImpl | arithmetic( RationalImpl ) )
    5049struct Rational {
    5150        RationalImpl numerator, denominator;                            // invariant: denominator > 0
     
    5453// constructors
    5554
    56 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     55forall( otype RationalImpl | arithmetic( RationalImpl ) )
    5756void ?{}( Rational(RationalImpl) * r );
    5857
    59 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     58forall( otype RationalImpl | arithmetic( RationalImpl ) )
    6059void ?{}( Rational(RationalImpl) * r, RationalImpl n );
    6160
    62 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     61forall( otype RationalImpl | arithmetic( RationalImpl ) )
    6362void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d );
    6463
    65 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     64forall( otype RationalImpl | arithmetic( RationalImpl ) )
    6665void ?{}( Rational(RationalImpl) * r, zero_t );
    6766
    68 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     67forall( otype RationalImpl | arithmetic( RationalImpl ) )
    6968void ?{}( Rational(RationalImpl) * r, one_t );
    7069
    71 // getter for numerator/denominator
     70// numerator/denominator getter
    7271
    73 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     72forall( otype RationalImpl | arithmetic( RationalImpl ) )
    7473RationalImpl numerator( Rational(RationalImpl) r );
    7574
    76 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     75forall( otype RationalImpl | arithmetic( RationalImpl ) )
    7776RationalImpl denominator( Rational(RationalImpl) r );
    78 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     77
     78forall( otype RationalImpl | arithmetic( RationalImpl ) )
    7979[ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src );
    8080
    81 // setter for numerator/denominator
     81// numerator/denominator setter
    8282
    83 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     83forall( otype RationalImpl | arithmetic( RationalImpl ) )
    8484RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n );
    8585
    86 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     86forall( otype RationalImpl | arithmetic( RationalImpl ) )
    8787RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d );
    8888
    8989// comparison
    9090
    91 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     91forall( otype RationalImpl | arithmetic( RationalImpl ) )
    9292int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    9393
    94 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     94forall( otype RationalImpl | arithmetic( RationalImpl ) )
    9595int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    9696
    97 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     97forall( otype RationalImpl | arithmetic( RationalImpl ) )
    9898int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    9999
    100 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     100forall( otype RationalImpl | arithmetic( RationalImpl ) )
    101101int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    102102
    103 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     103forall( otype RationalImpl | arithmetic( RationalImpl ) )
    104104int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    105105
    106 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     106forall( otype RationalImpl | arithmetic( RationalImpl ) )
    107107int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    108108
    109109// arithmetic
    110110
    111 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     111forall( otype RationalImpl | arithmetic( RationalImpl ) )
    112112Rational(RationalImpl) +?( Rational(RationalImpl) r );
    113113
    114 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     114forall( otype RationalImpl | arithmetic( RationalImpl ) )
    115115Rational(RationalImpl) -?( Rational(RationalImpl) r );
    116116
    117 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     117forall( otype RationalImpl | arithmetic( RationalImpl ) )
    118118Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    119119
    120 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     120forall( otype RationalImpl | arithmetic( RationalImpl ) )
    121121Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    122122
    123 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     123forall( otype RationalImpl | arithmetic( RationalImpl ) )
    124124Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    125125
    126 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     126forall( otype RationalImpl | arithmetic( RationalImpl ) )
    127127Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r );
    128128
    129129// conversion
    130 forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
     130forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
    131131double widen( Rational(RationalImpl) r );
    132 forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl );  RationalImpl convert( double );} )
     132forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl );  RationalImpl convert( double );} )
    133133Rational(RationalImpl) narrow( double f, RationalImpl md );
    134134
    135135// I/O
    136 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     136forall( otype RationalImpl | arithmetic( RationalImpl ) )
    137137forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } )
    138138istype * ?|?( istype *, Rational(RationalImpl) * );
    139139
    140 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     140forall( otype RationalImpl | arithmetic( RationalImpl ) )
    141141forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )
    142142ostype * ?|?( ostype *, Rational(RationalImpl ) );
    143 
    144 #endif // RATIONAL_H
    145143
    146144// Local Variables: //
  • src/libcfa/rational.c

    r3873b5a1 reaace25  
    1010// Created On       : Wed Apr  6 17:54:28 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon May 15 21:29:23 2017
    13 // Update Count     : 149
     12// Last Modified On : Tue May 16 18:35:36 2017
     13// Update Count     : 150
    1414//
    1515
     
    2222// Calculate greatest common denominator of two numbers, the first of which may be negative. Used to reduce rationals.
    2323// alternative: https://en.wikipedia.org/wiki/Binary_GCD_algorithm
    24 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     24forall( otype RationalImpl | arithmetic( RationalImpl ) )
    2525static RationalImpl gcd( RationalImpl a, RationalImpl b ) {
    2626        for ( ;; ) {                                                                            // Euclid's algorithm
     
    3333} // gcd
    3434
    35 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     35forall( otype RationalImpl | arithmetic( RationalImpl ) )
    3636static RationalImpl simplify( RationalImpl * n, RationalImpl * d ) {
    3737        if ( *d == (RationalImpl){0} ) {
     
    4646// constructors
    4747
    48 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     48forall( otype RationalImpl | arithmetic( RationalImpl ) )
    4949void ?{}( Rational(RationalImpl) * r ) {
    5050        r{ (RationalImpl){0}, (RationalImpl){1} };
    5151} // rational
    5252
    53 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     53forall( otype RationalImpl | arithmetic( RationalImpl ) )
    5454void ?{}( Rational(RationalImpl) * r, RationalImpl n ) {
    5555        r{ n, (RationalImpl){1} };
    5656} // rational
    5757
    58 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     58forall( otype RationalImpl | arithmetic( RationalImpl ) )
    5959void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d ) {
    6060        RationalImpl t = simplify( &n, &d );                            // simplify
     
    6666// getter for numerator/denominator
    6767
    68 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     68forall( otype RationalImpl | arithmetic( RationalImpl ) )
    6969RationalImpl numerator( Rational(RationalImpl) r ) {
    7070        return r.numerator;
    7171} // numerator
    7272
    73 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     73forall( otype RationalImpl | arithmetic( RationalImpl ) )
    7474RationalImpl denominator( Rational(RationalImpl) r ) {
    7575        return r.denominator;
    7676} // denominator
    7777
    78 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     78forall( otype RationalImpl | arithmetic( RationalImpl ) )
    7979[ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ) {
    8080        return *dest = src.[ numerator, denominator ];
     
    8383// setter for numerator/denominator
    8484
    85 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     85forall( otype RationalImpl | arithmetic( RationalImpl ) )
    8686RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n ) {
    8787        RationalImpl prev = r.numerator;
     
    9292} // numerator
    9393
    94 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     94forall( otype RationalImpl | arithmetic( RationalImpl ) )
    9595RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d ) {
    9696        RationalImpl prev = r.denominator;
     
    104104// comparison
    105105
    106 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     106forall( otype RationalImpl | arithmetic( RationalImpl ) )
    107107int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    108108        return l.numerator * r.denominator == l.denominator * r.numerator;
    109109} // ?==?
    110110
    111 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     111forall( otype RationalImpl | arithmetic( RationalImpl ) )
    112112int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    113113        return ! ( l == r );
    114114} // ?!=?
    115115
    116 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     116forall( otype RationalImpl | arithmetic( RationalImpl ) )
    117117int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    118118        return l.numerator * r.denominator < l.denominator * r.numerator;
    119119} // ?<?
    120120
    121 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     121forall( otype RationalImpl | arithmetic( RationalImpl ) )
    122122int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    123123        return l.numerator * r.denominator <= l.denominator * r.numerator;
    124124} // ?<=?
    125125
    126 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     126forall( otype RationalImpl | arithmetic( RationalImpl ) )
    127127int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    128128        return ! ( l <= r );
    129129} // ?>?
    130130
    131 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     131forall( otype RationalImpl | arithmetic( RationalImpl ) )
    132132int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    133133        return ! ( l < r );
     
    137137// arithmetic
    138138
    139 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     139forall( otype RationalImpl | arithmetic( RationalImpl ) )
    140140Rational(RationalImpl) +?( Rational(RationalImpl) r ) {
    141141        Rational(RationalImpl) t = { r.numerator, r.denominator };
     
    143143} // +?
    144144
    145 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     145forall( otype RationalImpl | arithmetic( RationalImpl ) )
    146146Rational(RationalImpl) -?( Rational(RationalImpl) r ) {
    147147        Rational(RationalImpl) t = { -r.numerator, r.denominator };
     
    149149} // -?
    150150
    151 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     151forall( otype RationalImpl | arithmetic( RationalImpl ) )
    152152Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    153153        if ( l.denominator == r.denominator ) {                         // special case
     
    160160} // ?+?
    161161
    162 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     162forall( otype RationalImpl | arithmetic( RationalImpl ) )
    163163Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    164164        if ( l.denominator == r.denominator ) {                         // special case
     
    171171} // ?-?
    172172
    173 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     173forall( otype RationalImpl | arithmetic( RationalImpl ) )
    174174Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    175175        Rational(RationalImpl) t = { l.numerator * r.numerator, l.denominator * r.denominator };
     
    177177} // ?*?
    178178
    179 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     179forall( otype RationalImpl | arithmetic( RationalImpl ) )
    180180Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r ) {
    181181        if ( r.numerator < (RationalImpl){0} ) {
     
    190190// conversion
    191191
    192 forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
     192forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )
    193193double widen( Rational(RationalImpl) r ) {
    194194        return convert( r.numerator ) / convert( r.denominator );
     
    196196
    197197// http://www.ics.uci.edu/~eppstein/numth/frap.c
    198 forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double ); } )
     198forall( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double ); } )
    199199Rational(RationalImpl) narrow( double f, RationalImpl md ) {
    200200        if ( md <= (RationalImpl){1} ) {                                        // maximum fractional digits too small?
     
    227227// I/O
    228228
    229 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     229forall( otype RationalImpl | arithmetic( RationalImpl ) )
    230230forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } )
    231231istype * ?|?( istype * is, Rational(RationalImpl) * r ) {
     
    238238} // ?|?
    239239
    240 forall ( otype RationalImpl | arithmetic( RationalImpl ) )
     240forall( otype RationalImpl | arithmetic( RationalImpl ) )
    241241forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } )
    242242ostype * ?|?( ostype * os, Rational(RationalImpl ) r ) {
  • src/libcfa/stdlib

    r3873b5a1 reaace25  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun  2 15:51:03 2017
    13 // Update Count     : 218
    14 //
    15 
    16 #ifndef STDLIB_H
    17 #define STDLIB_H
     12// Last Modified On : Fri Jul  7 09:34:49 2017
     13// Update Count     : 219
     14//
     15
     16#pragma once
    1817
    1918//---------------------------------------
     
    232231void swap( T * t1, T * t2 );
    233232
    234 #endif // STDLIB_H
    235 
    236233// Local Variables: //
    237234// mode: c //
  • src/main.cc

    r3873b5a1 reaace25  
    1010// Author           : Richard C. Bilson
    1111// Created On       : Fri May 15 23:12:02 2015
    12 // Last Modified By : Peter A. Buhr
    13 // Last Modified On : Thu Jun 29 12:46:50 2017
    14 // Update Count     : 441
     12// Last Modified By : Andrew Beach
     13// Last Modified On : Fri Jul  7 11:13:00 2017
     14// Update Count     : 442
    1515//
    1616
     
    206206                                FILE * builtins = fopen( libcfap | treep ? "../prelude/builtins.cf" : CFA_LIBDIR "/builtins.cf", "r" );
    207207                                assertf( builtins, "cannot open builtins.cf\n" );
    208                                 parse( builtins, LinkageSpec::Builtin );
     208                                parse( builtins, LinkageSpec::BuiltinCFA );
    209209                        } // if
    210210                } // if
  • src/tests/.expect/32/math.txt

    r3873b5a1 reaace25  
    2222cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i
    2323tan:1.55741 1.5574077246549 1.55740772465490223 0.271753+1.08392i 0.271752585319512+1.08392332733869i 0.271752585319511717+1.08392332733869454i
    24 asin:1.5708 1.5707963267949 1.57079632679489662 0.66624+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i
     24asin:1.5708 1.5707963267949 1.57079632679489662 0.666239+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i
    2525acos:0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i
    2626atan:0.785398 0.785398163397448 0.78539816339744831 1.01722+0.402359i 1.01722196789785+0.402359478108525i 1.01722196789785137+0.402359478108525094i
  • src/tests/.expect/io.txt

    r3873b5a1 reaace25  
    44123
    55
    6 opening delimiters 
     6opening delimiters
    77x (1 x [2 x {3 x =4 x $5 x £6 x ¥7 x ¡8 x ¿9 x «10
    88
    9 closing delimiters 
    10 1, x 2. x 3; x 4! x 5? x 6% x 7¢ x 8» x 9) x 10] x 11} x 
     9closing delimiters
     101, x 2. x 3; x 4! x 5? x 6% x 7¢ x 8» x 9) x 10] x 11} x
    1111
    12 opening/closing delimiters 
     12opening/closing delimiters
    1313x`1`x'2'x"3"x:4:x 5 x   6       x
    14147
     
    1919x
    202010
    21 x 
     21x
    2222
    23 override opening/closing delimiters 
     23override opening/closing delimiters
    2424x ( 1 ) x 2 , x 3 :x: 4
    2525
    26 input bacis types 
     26input bacis types
    2727
    28 output basic types 
     28output basic types
    2929A
    30301 2 3 4 5 6 7 8
     
    32321.1+2.3i 1.1-2.3i 1.1-2.3i
    3333
    34 tuples 
    35 1, 2, 3 3, 4, 5
     34tuples
     351, 2, 3 4, 5, 6
    3636
    37 toggle separator 
     37toggle separator
    38381.11.21.3
    39391.1+2.3i1.1-2.3i1.1-2.3i
    40  abcxyz
    41 abcxyz
     401.1+2.3i 1.1-2.3i1.1-2.3i
     411.1+2.3i 1.1-2.3i 1.1-2.3i
     421.1+2.3i1.1-2.3i 1.1-2.3i
     43abcxyz
     44abcxyz
    4245
    43 change separator 
    44 from "  "to " , $"
     46change separator
     47from " " to ", $"
    45481.1, $1.2, $1.3
    46491.1+2.3i, $1.1-2.3i, $1.1-2.3i
    47 abc, $xyz, $
    48 1, 2, 3, $3, 4, 5
     50abc, $xyz
     511, 2, 3, $4, 5, 6
    4952
    50 from ", $"to " "
     53from ", $" to " "
    51541.1 1.2 1.3
    52551.1+2.3i 1.1-2.3i 1.1-2.3i
    53 abc xyz 
    54 1, 2, 3 3, 4, 5
     56abc xyz
     571, 2, 3 4, 5, 6
    5558
    56  1 2 3
     59check sepOn/sepOff
     601 2 3
    576112 3
    58  1 2 3
    59621 2 3
    60  1 2 3
     631 2 3
    6164
     651 2 3
     66
     67check enable/disable
    6268123
    63691 23
     
    6571123
    66721 2 3
    67 123 
     73123
    68741 2 3
    6975
    70 1 2 3 3 4 5 " "
    71 1, 2, 3 3, 4, 5 ", "
    72 1, 2, 3 3, 4, 5
     761 2 3 4 5 6 " "
     771, 2, 3 4, 5, 6 " "
     781, 2, 3 4, 5, 6
    7379
    74803, 4, a, 7.2
    75813, 4, a, 7.2
    76823 4 a 7.2
    77  3 4 a 7.234a7.23 4 a 7.2
     833 4 a 7.234a7.23 4 a 7.2
    78843-4-a-7.2^3^4^3-4-a-7.2
  • src/tests/Makefile.am

    r3873b5a1 reaace25  
    2929
    3030# applies to both programs
    31 EXTRA_FLAGS =
    32 BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ ${EXTRA_FLAGS}
     31DEBUG_FLAGS =
     32
     33BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@
     34if !BUILD_DEBUG
     35BUILD_FLAGS += -nodebug
     36else
     37if !BUILD_RELEASE
     38BUILD_FLAGS += -debug
     39else
     40BUILD_FLAGS += ${DEBUG_FLAGS}
     41endif
     42endif
     43
    3344TEST_FLAGS = $(if $(test), 2> .err/${@}.log, )
    3445AM_CFLAGS = ${TEST_FLAGS} ${BUILD_FLAGS}
  • src/tests/Makefile.in

    r3873b5a1 reaace25  
    9292host_triplet = @host@
    9393@BUILD_CONCURRENCY_TRUE@am__append_1 = coroutine thread monitor
     94@BUILD_DEBUG_FALSE@am__append_2 = -nodebug
     95@BUILD_DEBUG_TRUE@@BUILD_RELEASE_FALSE@am__append_3 = -debug
     96@BUILD_DEBUG_TRUE@@BUILD_RELEASE_TRUE@am__append_4 = ${DEBUG_FLAGS}
    9497EXTRA_PROGRAMS = fstream_test$(EXEEXT) vector_test$(EXEEXT) \
    9598        avl_test$(EXEEXT)
     
    320323
    321324# applies to both programs
    322 EXTRA_FLAGS =
    323 BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ ${EXTRA_FLAGS}
     325DEBUG_FLAGS =
     326BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ \
     327        $(am__append_2) $(am__append_3) $(am__append_4)
    324328TEST_FLAGS = $(if $(test), 2> .err/${@}.log, )
    325329AM_CFLAGS = ${TEST_FLAGS} ${BUILD_FLAGS}
  • src/tests/io.c

    r3873b5a1 reaace25  
    1010// Created On       : Wed Mar  2 16:56:02 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jul  2 09:40:58 2017
    13 // Update Count     : 68
     12// Last Modified On : Thu Jul  6 23:26:12 2017
     13// Update Count     : 78
    1414//
    1515
     
    104104
    105105        sout | "tuples" | endl;
    106         [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 3, [ 4, 5 ] ];
     106        [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ];
    107107        sout | t1 | t2 | endl;                                                          // print tuple
    108108        sout | endl;
     
    110110        sout | "toggle separator" | endl;
    111111        sout | f | "" | d | "" | ld | endl                                      // floating point without separator
    112                 | sepDisable | fc | dc | ldc | sepEnable | endl // complex without separator
    113                 | sepOn | s1 | sepOff | s2 | endl                               // local separator removal
    114                 | s1 | "" | s2 | endl;                                                  // C string without separator
     112                | sepDisable | fc | dc | ldc | endl                             // complex without separator
     113                | fc | sepOn | dc | ldc | endl                                  // local separator add
     114                | sepEnable | fc | dc | ldc | endl                              // complex with separator
     115                | fc | sepOff | dc | ldc | endl                                 // local separator removal
     116                | s1 | sepOff | s2 | endl                                               // local separator removal
     117                | s1 | "" | s2 | endl;                                                  // local separator removal
    115118        sout | endl;
    116119
    117120        sout | "change separator" | endl;
    118         sout | "from \" " | sepGet( sout ) | "\"";
     121        sout | "from \"" | sep | "\"";
    119122        sepSet( sout, ", $" );                                                          // change separator, maximum of 15 characters
    120         sout | "to \" " | sepGet( sout ) | "\"" | endl;
     123        sout | " to \"" | sep | "\"" | endl;
    121124        sout | f | d | ld | endl
    122125                | fc | dc | ldc | endl
     
    124127                | t1 | t2 | endl;                                                               // print tuple
    125128        sout | endl;
    126         sout | "from \"" | sepGet( sout ) | "\"";
     129        sout | "from \"" | sep | "\" ";
    127130        sepSet( sout, " " );                                                            // restore separator
    128         sout | "to \"" | sepGet( sout ) | "\"" | endl;
     131        sout | "to \"" | sep | "\"" | endl;
    129132        sout | f | d | ld | endl
    130133                | fc | dc | ldc | endl
     
    133136        sout | endl;
    134137
    135         sout | sepOn | 1 | 2 | 3 | sepOn | endl;                        // separator at start/end of line
     138        sout | "check sepOn/sepOff" | endl;
     139        sout | sepOn | 1 | 2 | 3 | sepOn | endl;                        // no separator at start/end of line
    136140        sout | 1 | sepOff | 2 | 3 | endl;                                       // locally turn off implicit separator
    137         sout | sepOn | 1 | 2 | 3 | sepOn | sepOff | endl;       // separator at start of line
    138         sout | 1 | 2 | 3 | endl | sepOn;                                        // separator at start of next line
     141        sout | sepOn | sepOn | 1 | 2 | 3 | sepOn | sepOff | sepOn | '\n'; // no separator at start/end of line
     142        sout | 1 | 2 | 3 | "\n\n" | sepOn;                                      // no separator at start of next line
    139143        sout | 1 | 2 | 3 | endl;
    140144        sout | endl;
    141145
     146        sout | "check enable/disable" | endl;
    142147        sout | sepDisable | 1 | 2 | 3 | endl;                           // globally turn off implicit separation
    143148        sout | 1 | sepOn | 2 | 3 | endl;                                        // locally turn on implicit separator
     
    149154        sout | endl;
    150155
     156//      sout | fmt( d, "%8.3f" ) || endl;
     157//      sout | endl;
     158
    151159        sepSetTuple( sout, " " );                                                       // set tuple separator from ", " to " "
    152         sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
     160        sout | t1 | t2 | " \"" | sep | "\"" | endl;
    153161        sepSetTuple( sout, ", " );                                                      // reset tuple separator to ", "
    154         sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
     162        sout | t1 | t2 | " \"" | sep | "\"" | endl;
    155163        sout | t1 | t2 | endl;                                                          // print tuple
    156164        sout | endl;
  • src/tests/test.py

    r3873b5a1 reaace25  
    166166
    167167        # build, skipping to next test on error
    168         make_ret, _ = sh("""%s test=yes EXTRA_FLAGS="%s" %s 2> %s 1> /dev/null""" % (make_cmd, options, test.name, out_file), dry_run)
     168        make_ret, _ = sh("""%s test=yes DEBUG_FLAGS="%s" %s 2> %s 1> /dev/null""" % (make_cmd, options, test.name, out_file), dry_run)
    169169
    170170        retcode = 0
     
    202202                        error = myfile.read()
    203203
    204                
     204
    205205        # clean the executable
    206206        sh("rm -f %s > /dev/null 2>&1" % test.name, dry_run)
Note: See TracChangeset for help on using the changeset viewer.