Changes in / [eaace25:3873b5a1]


Ignore:
Location:
src
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/LinkageSpec.cc

    reaace25 r3873b5a1  
    1010// Created On       : Sat May 16 13:22:09 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Fri Jul  7 11:11:00 2017
    13 // Update Count     : 25
     12// Last Modified On : Wed Jun 28 11:51:00 2017
     13// Update Count     : 24
    1414//
    1515
     
    2222#include "Common/SemanticError.h"
    2323
    24 namespace LinkageSpec {
    25 
    26 Spec linkageCheck( const string * spec ) {
    27         assert( spec );
     24LinkageSpec::Spec LinkageSpec::linkageCheck( const string * spec ) {
    2825        unique_ptr<const string> guard( spec ); // allocated by lexer
    2926        if ( *spec == "\"Cforall\"" ) {
     
    3835}
    3936
    40 Spec 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
     37string 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];
    5243}
    5344
    54 std::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     }
     45bool 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];
    7354}
    7455
    75 } // LinkageSpec
     56bool 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
     67bool 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
     78bool 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}
    7688
    7789// Local Variables: //
  • src/Parser/LinkageSpec.h

    reaace25 r3873b5a1  
    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 : Fri Jul  7 11:03:00 2017
    13 // Update Count     : 13
     12// Last Modified On : Wed Jun 28 11:50:00 2017
     13// Update Count     : 12
    1414//
    1515
     
    1919#include <string>
    2020
    21 namespace 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,
     21struct 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
    3031        };
    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 };
     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 );
    7840};
    7941
  • src/libcfa/concurrency/CtxSwitch-i386.S

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

    reaace25 r3873b5a1  
    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
     101CtxGet:
     102        movq %rsp,SP_OFFSET(%rdi)
     103        movq %rbp,FP_OFFSET(%rdi)
     104
     105        ret
    97106
    98107// Local Variables: //
  • src/libcfa/concurrency/invoke.h

    reaace25 r3873b5a1  
    112112      extern void CtxInvokeStub( void );
    113113      void CtxSwitch( void * from, void * to ) asm ("CtxSwitch");
    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
     114      void CtxGet( void * this ) asm ("CtxGet");
    126115
    127116#endif //_INVOKE_PRIVATE_H_
  • src/libcfa/concurrency/kernel.c

    reaace25 r3873b5a1  
    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

    reaace25 r3873b5a1  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 08:32:38 2017
    13 // Update Count     : 117
     12// Last Modified On : Sat Jul  1 16:37:53 2017
     13// Update Count     : 112
    1414//
    1515
    16 #pragma once
     16#ifndef __FSTREAM_H__
     17#define __FSTREAM_H__
    1718
    1819#include "iostream"
    1920
    20 enum { sepSize = 16 };
     21enum { separateSize = 16 };
    2122struct ofstream {
    2223        void * file;
    2324        _Bool sepDefault;
    2425        _Bool sepOnOff;
    25         _Bool sawNL;
     26        _Bool lastSepOn;
    2627        const char * sepCur;
    27         char separator[sepSize];
    28         char tupleSeparator[sepSize];
     28        char separator[separateSize];
     29        char tupleSeparator[separateSize];
    2930}; // ofstream
    3031
     
    3536const char * sepGetCur( ofstream * );
    3637void sepSetCur( ofstream *, const char * );
    37 _Bool getNL( ofstream * );
    38 void setNL( ofstream *, _Bool );
     38_Bool lastSepOn( ofstream * );
    3939
    4040// public
     
    7575extern ifstream * sin;
    7676
     77#endif // __FSTREAM_H__
     78
    7779// Local Variables: //
    7880// mode: c //
  • src/libcfa/fstream.c

    reaace25 r3873b5a1  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul  6 18:38:25 2017
    13 // Update Count     : 251
     12// Last Modified On : Sat Jul  1 16:37:54 2017
     13// Update Count     : 242
    1414//
    1515
     
    3333        this->sepDefault = sepDefault;
    3434        this->sepOnOff = sepOnOff;
     35        this->lastSepOn = false;
    3536        sepSet( this, separator );
    3637        sepSetCur( this, sepGet( this ) );
     
    3940
    4041// private
    41 _Bool sepPrt( ofstream * os ) { setNL( os, false ); return os->sepOnOff; }
     42_Bool lastSepOn( ofstream * os ) { return os->lastSepOn; }
     43_Bool sepPrt( ofstream * os ) { os->lastSepOn = false; return os->sepOnOff; }
    4244void sepReset( ofstream * os ) { os->sepOnOff = os->sepDefault; }
    4345void sepReset( ofstream * os, _Bool reset ) { os->sepDefault = reset; os->sepOnOff = os->sepDefault; }
    4446const char * sepGetCur( ofstream * os ) { return os->sepCur; }
    4547void sepSetCur( ofstream * os, const char * sepCur ) { os->sepCur = sepCur; }
    46 _Bool getNL( ofstream * os ) { return os->sawNL; }
    47 void setNL( ofstream * os, _Bool state ) { os->sawNL = state; }
    4848
    4949// public
    50 void sepOn( ofstream * os ) { os->sepOnOff = ! getNL( os ); }
    51 void sepOff( ofstream * os ) { os->sepOnOff = false; }
     50void sepOn( ofstream * os ) { os->lastSepOn = true; os->sepOnOff = true; }
     51void sepOff( ofstream * os ) { os->lastSepOn = false; os->sepOnOff = 0; }
    5252
    5353_Bool sepDisable( ofstream *os ) {
    5454        _Bool temp = os->sepDefault;
    5555        os->sepDefault = false;
     56        os->lastSepOn = false;
    5657        sepReset( os );
    5758        return temp;
     
    6869void sepSet( ofstream * os, const char * s ) {
    6970        assert( s );
    70         strncpy( os->separator, s, sepSize - 1 );
    71         os->separator[sepSize - 1] = '\0';
     71        strncpy( os->separator, s, separateSize - 1 );
     72        os->separator[separateSize - 1] = '\0';
    7273} // sepSet
    7374
     
    7576void sepSetTuple( ofstream * os, const char * s ) {
    7677        assert( s );
    77         strncpy( os->tupleSeparator, s, sepSize - 1 );
    78         os->tupleSeparator[sepSize - 1] = '\0';
     78        strncpy( os->tupleSeparator, s, separateSize - 1 );
     79        os->tupleSeparator[separateSize - 1] = '\0';
    7980} // sepSet
    8081
     
    152153
    153154void open( ifstream * is, const char * name, const char * mode ) {
    154         FILE *file = fopen( name, mode );
    155         if ( file == 0 ) {                                                                      // do not change unless successful
     155        FILE *t = fopen( name, mode );
     156        if ( t == 0 ) {                                                                         // do not change unless successful
    156157                fprintf( stderr, IO_MSG "open input file \"%s\", ", name );
    157158                perror( 0 );
    158159                exit( EXIT_FAILURE );
    159160        } // if
    160         is->file = file;
     161        is->file = t;
    161162} // open
    162163
  • src/libcfa/gmp

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

    reaace25 r3873b5a1  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 08:35:59 2017
    13 // Update Count     : 118
     12// Last Modified On : Sun Jul  2 08:42:56 2017
     13// Update Count     : 110
    1414//
    1515
    16 #pragma once
     16#ifndef __IOSTREAM_H__
     17#define __IOSTREAM_H__
    1718
    1819#include "iterator"
     
    2526        const char * sepGetCur( ostype * );                                     // get current separator string
    2627        void sepSetCur( ostype *, const char * );                       // set current separator string
    27         _Bool getNL( ostype * );                                                        // check newline
    28         void setNL( ostype *, _Bool );                                          // saw newline
     28        _Bool lastSepOn( ostype * );                                            // last manipulator is setOn (context sensitive)
    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 * );
    84 forall( dtype ostype | ostream( ostype ) ) ostype * sep( ostype * );
    85 forall( dtype ostype | ostream( ostype ) ) ostype * sepTuple( ostype * );
    8684forall( dtype ostype | ostream( ostype ) ) ostype * sepOn( ostype * );
    8785forall( dtype ostype | ostream( ostype ) ) ostype * sepOff( ostype * );
     
    139137forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, _Istream_cstrC );
    140138
     139#endif // __IOSTREAM_H
     140
    141141// Local Variables: //
    142142// mode: c //
  • src/libcfa/iostream.c

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

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

    reaace25 r3873b5a1  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 08:38:23 2017
    13 // Update Count     : 28
     12// Last Modified On : Wed Mar  2 18:08:11 2016
     13// Update Count     : 27
    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         } // for
    23 } // for_each
     22        }
     23}
    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         } // for
    31 } // for_each_reverse
     30        }
     31}
    3232
    3333// Local Variables: //
  • src/libcfa/limits

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

    reaace25 r3873b5a1  
    1010// Created On       : Mon Apr 18 23:37:04 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 09:34:15 2017
    13 // Update Count     : 61
    14 //
    15 
    16 #pragma once
     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
    1718
    1819extern "C" {
     
    344345long double scalbln( long double, long int );
    345346
     347#endif // MATH_H
     348
    346349// Local Variables: //
    347350// mode: c //
  • src/libcfa/rational

    reaace25 r3873b5a1  
    1212// Created On       : Wed Apr  6 17:56:25 2016
    1313// Last Modified By : Peter A. Buhr
    14 // Last Modified On : Fri Jul  7 09:34:33 2017
    15 // Update Count     : 93
     14// Last Modified On : Mon May 15 21:30:12 2017
     15// Update Count     : 90
    1616//
    1717
    18 #pragma once
     18#ifndef RATIONAL_H
     19#define RATIONAL_H
    1920
    2021#include "iostream"
     
    4647// implementation
    4748
    48 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     49forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    4950struct Rational {
    5051        RationalImpl numerator, denominator;                            // invariant: denominator > 0
     
    5354// constructors
    5455
    55 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     56forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    5657void ?{}( Rational(RationalImpl) * r );
    5758
    58 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     59forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    5960void ?{}( Rational(RationalImpl) * r, RationalImpl n );
    6061
    61 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     62forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    6263void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d );
    6364
    64 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     65forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    6566void ?{}( Rational(RationalImpl) * r, zero_t );
    6667
    67 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     68forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    6869void ?{}( Rational(RationalImpl) * r, one_t );
    6970
    70 // numerator/denominator getter
     71// getter for numerator/denominator
    7172
    72 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     73forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    7374RationalImpl numerator( Rational(RationalImpl) r );
    7475
    75 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     76forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    7677RationalImpl denominator( Rational(RationalImpl) r );
    77 
    78 forall( otype RationalImpl | arithmetic( RationalImpl ) )
     78forall ( otype RationalImpl | arithmetic( RationalImpl ) )
    7979[ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src );
    8080
    81 // numerator/denominator setter
     81// setter for numerator/denominator
    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
    143145
    144146// Local Variables: //
  • src/libcfa/rational.c

    reaace25 r3873b5a1  
    1010// Created On       : Wed Apr  6 17:54:28 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 16 18:35:36 2017
    13 // Update Count     : 150
     12// Last Modified On : Mon May 15 21:29:23 2017
     13// Update Count     : 149
    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

    reaace25 r3873b5a1  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul  7 09:34:49 2017
    13 // Update Count     : 219
    14 //
    15 
    16 #pragma once
     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
    1718
    1819//---------------------------------------
     
    231232void swap( T * t1, T * t2 );
    232233
     234#endif // STDLIB_H
     235
    233236// Local Variables: //
    234237// mode: c //
  • src/main.cc

    reaace25 r3873b5a1  
    1010// Author           : Richard C. Bilson
    1111// Created On       : Fri May 15 23:12:02 2015
    12 // Last Modified By : Andrew Beach
    13 // Last Modified On : Fri Jul  7 11:13:00 2017
    14 // Update Count     : 442
     12// Last Modified By : Peter A. Buhr
     13// Last Modified On : Thu Jun 29 12:46:50 2017
     14// Update Count     : 441
    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::BuiltinCFA );
     208                                parse( builtins, LinkageSpec::Builtin );
    209209                        } // if
    210210                } // if
  • src/tests/.expect/32/math.txt

    reaace25 r3873b5a1  
    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.666239+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i
     24asin:1.5708 1.5707963267949 1.57079632679489662 0.66624+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

    reaace25 r3873b5a1  
    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 4, 5, 6
     34tuples 
     351, 2, 3 3, 4, 5
    3636
    37 toggle separator
     37toggle separator 
    38381.11.21.3
    39391.1+2.3i1.1-2.3i1.1-2.3i
    40 1.1+2.3i 1.1-2.3i1.1-2.3i
    41 1.1+2.3i 1.1-2.3i 1.1-2.3i
    42 1.1+2.3i1.1-2.3i 1.1-2.3i
    43 abcxyz
    44 abcxyz
     40 abcxyz
     41abcxyz
    4542
    46 change separator
    47 from " " to ", $"
     43change separator 
     44from "  "to " , $"
    48451.1, $1.2, $1.3
    49461.1+2.3i, $1.1-2.3i, $1.1-2.3i
    50 abc, $xyz
    51 1, 2, 3, $4, 5, 6
     47abc, $xyz, $
     481, 2, 3, $3, 4, 5
    5249
    53 from ", $" to " "
     50from ", $"to " "
    54511.1 1.2 1.3
    55521.1+2.3i 1.1-2.3i 1.1-2.3i
    56 abc xyz
    57 1, 2, 3 4, 5, 6
     53abc xyz 
     541, 2, 3 3, 4, 5
    5855
    59 check sepOn/sepOff
     56 1 2 3
     5712 3
     58 1 2 3
    60591 2 3
    61 12 3
    62 1 2 3
    63 1 2 3
     60 1 2 3
    6461
    65 1 2 3
    66 
    67 check enable/disable
    6862123
    69631 23
     
    7165123
    72661 2 3
    73 123
     67123 
    74681 2 3
    7569
    76 1 2 3 4 5 6 " "
    77 1, 2, 3 4, 5, 6 " "
    78 1, 2, 3 4, 5, 6
     701 2 3 3 4 5 " "
     711, 2, 3 3, 4, 5 ", "
     721, 2, 3 3, 4, 5
    7973
    80743, 4, a, 7.2
    81753, 4, a, 7.2
    82763 4 a 7.2
    83 3 4 a 7.234a7.23 4 a 7.2
     77 3 4 a 7.234a7.23 4 a 7.2
    84783-4-a-7.2^3^4^3-4-a-7.2
  • src/tests/Makefile.am

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

    reaace25 r3873b5a1  
    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}
    9794EXTRA_PROGRAMS = fstream_test$(EXEEXT) vector_test$(EXEEXT) \
    9895        avl_test$(EXEEXT)
     
    323320
    324321# applies to both programs
    325 DEBUG_FLAGS =
    326 BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ \
    327         $(am__append_2) $(am__append_3) $(am__append_4)
     322EXTRA_FLAGS =
     323BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ ${EXTRA_FLAGS}
    328324TEST_FLAGS = $(if $(test), 2> .err/${@}.log, )
    329325AM_CFLAGS = ${TEST_FLAGS} ${BUILD_FLAGS}
  • src/tests/io.c

    reaace25 r3873b5a1  
    1010// Created On       : Wed Mar  2 16:56:02 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jul  6 23:26:12 2017
    13 // Update Count     : 78
     12// Last Modified On : Sun Jul  2 09:40:58 2017
     13// Update Count     : 68
    1414//
    1515
     
    104104
    105105        sout | "tuples" | endl;
    106         [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ];
     106        [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 3, [ 4, 5 ] ];
    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 | 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
     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
    118115        sout | endl;
    119116
    120117        sout | "change separator" | endl;
    121         sout | "from \"" | sep | "\"";
     118        sout | "from \" " | sepGet( sout ) | "\"";
    122119        sepSet( sout, ", $" );                                                          // change separator, maximum of 15 characters
    123         sout | " to \"" | sep | "\"" | endl;
     120        sout | "to \" " | sepGet( sout ) | "\"" | endl;
    124121        sout | f | d | ld | endl
    125122                | fc | dc | ldc | endl
     
    127124                | t1 | t2 | endl;                                                               // print tuple
    128125        sout | endl;
    129         sout | "from \"" | sep | "\" ";
     126        sout | "from \"" | sepGet( sout ) | "\"";
    130127        sepSet( sout, " " );                                                            // restore separator
    131         sout | "to \"" | sep | "\"" | endl;
     128        sout | "to \"" | sepGet( sout ) | "\"" | endl;
    132129        sout | f | d | ld | endl
    133130                | fc | dc | ldc | endl
     
    136133        sout | endl;
    137134
    138         sout | "check sepOn/sepOff" | endl;
    139         sout | sepOn | 1 | 2 | 3 | sepOn | endl;                        // no separator at start/end of line
     135        sout | sepOn | 1 | 2 | 3 | sepOn | endl;                        // separator at start/end of line
    140136        sout | 1 | sepOff | 2 | 3 | endl;                                       // locally turn off implicit separator
    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
     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
    143139        sout | 1 | 2 | 3 | endl;
    144140        sout | endl;
    145141
    146         sout | "check enable/disable" | endl;
    147142        sout | sepDisable | 1 | 2 | 3 | endl;                           // globally turn off implicit separation
    148143        sout | 1 | sepOn | 2 | 3 | endl;                                        // locally turn on implicit separator
     
    154149        sout | endl;
    155150
    156 //      sout | fmt( d, "%8.3f" ) || endl;
    157 //      sout | endl;
    158 
    159151        sepSetTuple( sout, " " );                                                       // set tuple separator from ", " to " "
    160         sout | t1 | t2 | " \"" | sep | "\"" | endl;
     152        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
    161153        sepSetTuple( sout, ", " );                                                      // reset tuple separator to ", "
    162         sout | t1 | t2 | " \"" | sep | "\"" | endl;
     154        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
    163155        sout | t1 | t2 | endl;                                                          // print tuple
    164156        sout | endl;
  • src/tests/test.py

    reaace25 r3873b5a1  
    166166
    167167        # build, skipping to next test on error
    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)
     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)
    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.