Changes in / [eaace25:3873b5a1]
- Location:
- src
- Files:
-
- 25 edited
-
Parser/LinkageSpec.cc (modified) (3 diffs)
-
Parser/LinkageSpec.h (modified) (2 diffs)
-
libcfa/concurrency/CtxSwitch-i386.S (modified) (1 diff)
-
libcfa/concurrency/CtxSwitch-x86_64.S (modified) (3 diffs)
-
libcfa/concurrency/invoke.h (modified) (1 diff)
-
libcfa/concurrency/kernel.c (modified) (1 diff)
-
libcfa/fstream (modified) (3 diffs)
-
libcfa/fstream.c (modified) (6 diffs)
-
libcfa/gmp (modified) (1 diff)
-
libcfa/iostream (modified) (4 diffs)
-
libcfa/iostream.c (modified) (6 diffs)
-
libcfa/iterator (modified) (2 diffs)
-
libcfa/iterator.c (modified) (2 diffs)
-
libcfa/limits (modified) (2 diffs)
-
libcfa/math (modified) (2 diffs)
-
libcfa/rational (modified) (3 diffs)
-
libcfa/rational.c (modified) (18 diffs)
-
libcfa/stdlib (modified) (2 diffs)
-
main.cc (modified) (2 diffs)
-
tests/.expect/32/math.txt (modified) (1 diff)
-
tests/.expect/io.txt (modified) (4 diffs)
-
tests/Makefile.am (modified) (1 diff)
-
tests/Makefile.in (modified) (2 diffs)
-
tests/io.c (modified) (6 diffs)
-
tests/test.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/LinkageSpec.cc
reaace25 r3873b5a1 10 10 // Created On : Sat May 16 13:22:09 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Jul 7 11:11:00 201713 // Update Count : 2 512 // Last Modified On : Wed Jun 28 11:51:00 2017 13 // Update Count : 24 14 14 // 15 15 … … 22 22 #include "Common/SemanticError.h" 23 23 24 namespace LinkageSpec { 25 26 Spec linkageCheck( const string * spec ) { 27 assert( spec ); 24 LinkageSpec::Spec LinkageSpec::linkageCheck( const string * spec ) { 28 25 unique_ptr<const string> guard( spec ); // allocated by lexer 29 26 if ( *spec == "\"Cforall\"" ) { … … 38 35 } 39 36 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 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]; 52 43 } 53 44 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 } 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]; 73 54 } 74 55 75 } // LinkageSpec 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 } 76 88 77 89 // Local Variables: // -
src/Parser/LinkageSpec.h
reaace25 r3873b5a1 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // LinkageSpec.h -- 7 // LinkageSpec.h -- 8 8 // 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:24:28 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Jul 7 11:03:00 201713 // Update Count : 1 312 // Last Modified On : Wed Jun 28 11:50:00 2017 13 // Update Count : 12 14 14 // 15 15 … … 19 19 #include <string> 20 20 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, 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 30 31 }; 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 ); 78 40 }; 79 41 -
src/libcfa/concurrency/CtxSwitch-i386.S
reaace25 r3873b5a1 98 98 ret 99 99 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 100 109 // Local Variables: // 101 110 // compile-command: "make install" // -
src/libcfa/concurrency/CtxSwitch-x86_64.S
reaace25 r3873b5a1 1 // -*- Mode: Asm -*- 1 // -*- Mode: Asm -*- 2 2 // 3 3 // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo … … 18 18 // Free Software Foundation; either version 2.1 of the License, or (at your 19 19 // option) any later version. 20 // 20 // 21 21 // This library is distributed in the hope that it will be useful, but WITHOUT 22 22 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 23 23 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 24 24 // for more details. 25 // 25 // 26 26 // You should have received a copy of the GNU Lesser General Public License 27 27 // along with this library. 28 // 28 // 29 29 30 30 // This context switch routine depends on the fact that the stack of a new … … 93 93 .globl CtxInvokeStub 94 94 CtxInvokeStub: 95 movq %rbx, %rdi 95 movq %rbx, %rdi 96 96 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 97 106 98 107 // Local Variables: // -
src/libcfa/concurrency/invoke.h
reaace25 r3873b5a1 112 112 extern void CtxInvokeStub( void ); 113 113 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"); 126 115 127 116 #endif //_INVOKE_PRIVATE_H_ -
src/libcfa/concurrency/kernel.c
reaace25 r3873b5a1 75 75 76 76 void ?{}( current_stack_info_t * this ) { 77 CtxGet( this->ctx );77 CtxGet( &this->ctx ); 78 78 this->base = this->ctx.FP; 79 79 this->storage = this->ctx.SP; -
src/libcfa/fstream
reaace25 r3873b5a1 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 7 08:32:38201713 // Update Count : 11 712 // Last Modified On : Sat Jul 1 16:37:53 2017 13 // Update Count : 112 14 14 // 15 15 16 #pragma once 16 #ifndef __FSTREAM_H__ 17 #define __FSTREAM_H__ 17 18 18 19 #include "iostream" 19 20 20 enum { sep Size = 16 };21 enum { separateSize = 16 }; 21 22 struct ofstream { 22 23 void * file; 23 24 _Bool sepDefault; 24 25 _Bool sepOnOff; 25 _Bool sawNL;26 _Bool lastSepOn; 26 27 const char * sepCur; 27 char separator[sep Size];28 char tupleSeparator[sep Size];28 char separator[separateSize]; 29 char tupleSeparator[separateSize]; 29 30 }; // ofstream 30 31 … … 35 36 const char * sepGetCur( ofstream * ); 36 37 void sepSetCur( ofstream *, const char * ); 37 _Bool getNL( ofstream * ); 38 void setNL( ofstream *, _Bool ); 38 _Bool lastSepOn( ofstream * ); 39 39 40 40 // public … … 75 75 extern ifstream * sin; 76 76 77 #endif // __FSTREAM_H__ 78 77 79 // Local Variables: // 78 80 // mode: c // -
src/libcfa/fstream.c
reaace25 r3873b5a1 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 6 18:38:25201713 // Update Count : 2 5112 // Last Modified On : Sat Jul 1 16:37:54 2017 13 // Update Count : 242 14 14 // 15 15 … … 33 33 this->sepDefault = sepDefault; 34 34 this->sepOnOff = sepOnOff; 35 this->lastSepOn = false; 35 36 sepSet( this, separator ); 36 37 sepSetCur( this, sepGet( this ) ); … … 39 40 40 41 // 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; } 42 44 void sepReset( ofstream * os ) { os->sepOnOff = os->sepDefault; } 43 45 void sepReset( ofstream * os, _Bool reset ) { os->sepDefault = reset; os->sepOnOff = os->sepDefault; } 44 46 const char * sepGetCur( ofstream * os ) { return os->sepCur; } 45 47 void 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; }48 48 49 49 // public 50 void sepOn( ofstream * os ) { os-> sepOnOff = ! getNL( os ); }51 void sepOff( ofstream * os ) { os-> sepOnOff = false; }50 void sepOn( ofstream * os ) { os->lastSepOn = true; os->sepOnOff = true; } 51 void sepOff( ofstream * os ) { os->lastSepOn = false; os->sepOnOff = 0; } 52 52 53 53 _Bool sepDisable( ofstream *os ) { 54 54 _Bool temp = os->sepDefault; 55 55 os->sepDefault = false; 56 os->lastSepOn = false; 56 57 sepReset( os ); 57 58 return temp; … … 68 69 void sepSet( ofstream * os, const char * s ) { 69 70 assert( s ); 70 strncpy( os->separator, s, sep Size - 1 );71 os->separator[sep Size - 1] = '\0';71 strncpy( os->separator, s, separateSize - 1 ); 72 os->separator[separateSize - 1] = '\0'; 72 73 } // sepSet 73 74 … … 75 76 void sepSetTuple( ofstream * os, const char * s ) { 76 77 assert( s ); 77 strncpy( os->tupleSeparator, s, sep Size - 1 );78 os->tupleSeparator[sep Size - 1] = '\0';78 strncpy( os->tupleSeparator, s, separateSize - 1 ); 79 os->tupleSeparator[separateSize - 1] = '\0'; 79 80 } // sepSet 80 81 … … 152 153 153 154 void open( ifstream * is, const char * name, const char * mode ) { 154 FILE * file= fopen( name, mode );155 if ( file == 0 ) {// do not change unless successful155 FILE *t = fopen( name, mode ); 156 if ( t == 0 ) { // do not change unless successful 156 157 fprintf( stderr, IO_MSG "open input file \"%s\", ", name ); 157 158 perror( 0 ); 158 159 exit( EXIT_FAILURE ); 159 160 } // if 160 is->file = file;161 is->file = t; 161 162 } // open 162 163 -
src/libcfa/gmp
reaace25 r3873b5a1 10 10 // Created On : Tue Apr 19 08:43:43 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 7 09:33:20201713 // Update Count : 1 512 // Last Modified On : Sat May 27 09:55:51 2017 13 // Update Count : 14 14 14 // 15 15 16 16 // https://gmplib.org/gmp-man-6.1.1.pdf 17 18 #pragma once19 17 20 18 #include <gmp.h> // GNU multi-precise integers -
src/libcfa/iostream
reaace25 r3873b5a1 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 7 08:35:59201713 // Update Count : 11 812 // Last Modified On : Sun Jul 2 08:42:56 2017 13 // Update Count : 110 14 14 // 15 15 16 #pragma once 16 #ifndef __IOSTREAM_H__ 17 #define __IOSTREAM_H__ 17 18 18 19 #include "iterator" … … 25 26 const char * sepGetCur( ostype * ); // get current separator string 26 27 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) 29 29 // public 30 30 void sepOn( ostype * ); // turn separator state on … … 82 82 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, ostype * (*)( ostype * ) ); 83 83 forall( 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 * );86 84 forall( dtype ostype | ostream( ostype ) ) ostype * sepOn( ostype * ); 87 85 forall( dtype ostype | ostream( ostype ) ) ostype * sepOff( ostype * ); … … 139 137 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, _Istream_cstrC ); 140 138 139 #endif // __IOSTREAM_H 140 141 141 // Local Variables: // 142 142 // mode: c // -
src/libcfa/iostream.c
reaace25 r3873b5a1 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 6 18:14:17201713 // Update Count : 3 9612 // Last Modified On : Sun Jul 2 08:54:02 2017 13 // Update Count : 375 14 14 // 15 15 … … 18 18 extern "C" { 19 19 #include <stdio.h> 20 #include <stdbool.h> // true/false21 20 #include <string.h> // strlen 22 21 #include <float.h> // DBL_DIG, LDBL_DIG … … 25 24 26 25 forall( dtype ostype | ostream( ostype ) ) 27 ostype * ?|?( ostype * os, char ch ) { 28 fmt( os, "%c", ch ); 29 if ( ch == '\n' ) setNL( os, true ); 26 ostype * ?|?( ostype * os, char c ) { 27 fmt( os, "%c", c ); 30 28 sepOff( os ); 31 29 return os; … … 182 180 183 181 // 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 unsigned182 unsigned int len = strlen( cp ), posn = len - 1; 183 ch = cp[posn]; // must make unsigned 186 184 if ( sepPrt( os ) && mask[ ch ] != Open && mask[ ch ] != OpenClose ) { 187 185 sepOn( os ); … … 189 187 sepOff( os ); 190 188 } // if 191 if ( ch == '\n' ) setNL( os, true ); // check *AFTER* sepPrt call above as it resets NL flag192 189 return write( os, cp, len ); 193 190 } // ?|? … … 219 216 220 217 forall( dtype ostype | ostream( ostype ) ) 221 ostype * sep( ostype * os ) {222 os | sepGet( os );223 return os;224 } // sep225 226 forall( dtype ostype | ostream( ostype ) )227 ostype * sepTuple( ostype * os ) {228 os | sepGetTuple( os );229 return os;230 } // sepTuple231 232 forall( dtype ostype | ostream( ostype ) )233 218 ostype * endl( ostype * os ) { 219 if ( lastSepOn( os ) ) fmt( os, "%s", sepGetCur( os ) ); 234 220 os | '\n'; 235 setNL( os, true );236 221 flush( os ); 237 222 sepOff( os ); // prepare for next line -
src/libcfa/iterator
reaace25 r3873b5a1 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 7 08:37:25 201713 // Update Count : 1012 // Last Modified On : Wed Mar 2 18:06:05 2016 13 // Update Count : 9 14 14 // 15 15 16 #pragma once 16 #ifndef ITERATOR_H 17 #define ITERATOR_H 17 18 18 19 // An iterator can be used to traverse a data structure. … … 38 39 39 40 forall( 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 ) );41 void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) ); 41 42 42 43 forall( 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 ) ); 44 void for_each_reverse( iterator_type begin, iterator_type end, void (*func)( elt_type ) ); 45 46 #endif // ITERATOR_H 44 47 45 48 // Local Variables: // -
src/libcfa/iterator.c
reaace25 r3873b5a1 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 7 08:38:23 201713 // Update Count : 2 812 // Last Modified On : Wed Mar 2 18:08:11 2016 13 // Update Count : 27 14 14 // 15 15 … … 17 17 18 18 forall( 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 ) ) {19 void for_each( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) { 20 20 for ( iterator_type i = begin; i != end; ++i ) { 21 21 func( *i ); 22 } // for23 } // for_each22 } 23 } 24 24 25 25 forall( 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 ) ) {26 void for_each_reverse( iterator_type begin, iterator_type end, void (*func)( elt_type ) ) { 27 27 for ( iterator_type i = end; i != begin; ) { 28 28 --i; 29 29 func( *i ); 30 } // for31 } // for_each_reverse30 } 31 } 32 32 33 33 // Local Variables: // -
src/libcfa/limits
reaace25 r3873b5a1 10 10 // Created On : Wed Apr 6 18:06:52 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 7 09:33:57 201713 // Update Count : 712 // Last Modified On : Wed Apr 6 21:08:16 2016 13 // Update Count : 6 14 14 // 15 15 16 #pragma once 16 #ifndef LIMITS_H 17 #define LIMITS_H 17 18 18 19 // Integral Constants … … 109 110 extern const long _Complex _1_SQRT_2; // 1 / sqrt(2) 110 111 112 #endif // LIMITS_H 113 111 114 // Local Variables: // 112 115 // mode: c // -
src/libcfa/math
reaace25 r3873b5a1 10 10 // Created On : Mon Apr 18 23:37:04 2016 11 11 // 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 17 18 18 19 extern "C" { … … 344 345 long double scalbln( long double, long int ); 345 346 347 #endif // MATH_H 348 346 349 // Local Variables: // 347 350 // mode: c // -
src/libcfa/rational
reaace25 r3873b5a1 12 12 // Created On : Wed Apr 6 17:56:25 2016 13 13 // Last Modified By : Peter A. Buhr 14 // Last Modified On : Fri Jul 7 09:34:33201715 // Update Count : 9 314 // Last Modified On : Mon May 15 21:30:12 2017 15 // Update Count : 90 16 16 // 17 17 18 #pragma once 18 #ifndef RATIONAL_H 19 #define RATIONAL_H 19 20 20 21 #include "iostream" … … 46 47 // implementation 47 48 48 forall ( otype RationalImpl | arithmetic( RationalImpl ) )49 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 49 50 struct Rational { 50 51 RationalImpl numerator, denominator; // invariant: denominator > 0 … … 53 54 // constructors 54 55 55 forall ( otype RationalImpl | arithmetic( RationalImpl ) )56 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 56 57 void ?{}( Rational(RationalImpl) * r ); 57 58 58 forall ( otype RationalImpl | arithmetic( RationalImpl ) )59 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 59 60 void ?{}( Rational(RationalImpl) * r, RationalImpl n ); 60 61 61 forall ( otype RationalImpl | arithmetic( RationalImpl ) )62 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 62 63 void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d ); 63 64 64 forall ( otype RationalImpl | arithmetic( RationalImpl ) )65 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 65 66 void ?{}( Rational(RationalImpl) * r, zero_t ); 66 67 67 forall ( otype RationalImpl | arithmetic( RationalImpl ) )68 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 68 69 void ?{}( Rational(RationalImpl) * r, one_t ); 69 70 70 // numerator/denominator getter71 // getter for numerator/denominator 71 72 72 forall ( otype RationalImpl | arithmetic( RationalImpl ) )73 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 73 74 RationalImpl numerator( Rational(RationalImpl) r ); 74 75 75 forall ( otype RationalImpl | arithmetic( RationalImpl ) )76 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 76 77 RationalImpl denominator( Rational(RationalImpl) r ); 77 78 forall( otype RationalImpl | arithmetic( RationalImpl ) ) 78 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 79 79 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ); 80 80 81 // numerator/denominator setter81 // setter for numerator/denominator 82 82 83 forall ( otype RationalImpl | arithmetic( RationalImpl ) )83 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 84 84 RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n ); 85 85 86 forall ( otype RationalImpl | arithmetic( RationalImpl ) )86 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 87 87 RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d ); 88 88 89 89 // comparison 90 90 91 forall ( otype RationalImpl | arithmetic( RationalImpl ) )91 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 92 92 int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r ); 93 93 94 forall ( otype RationalImpl | arithmetic( RationalImpl ) )94 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 95 95 int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r ); 96 96 97 forall ( otype RationalImpl | arithmetic( RationalImpl ) )97 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 98 98 int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r ); 99 99 100 forall ( otype RationalImpl | arithmetic( RationalImpl ) )100 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 101 101 int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r ); 102 102 103 forall ( otype RationalImpl | arithmetic( RationalImpl ) )103 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 104 104 int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r ); 105 105 106 forall ( otype RationalImpl | arithmetic( RationalImpl ) )106 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 107 107 int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r ); 108 108 109 109 // arithmetic 110 110 111 forall ( otype RationalImpl | arithmetic( RationalImpl ) )111 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 112 112 Rational(RationalImpl) +?( Rational(RationalImpl) r ); 113 113 114 forall ( otype RationalImpl | arithmetic( RationalImpl ) )114 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 115 115 Rational(RationalImpl) -?( Rational(RationalImpl) r ); 116 116 117 forall ( otype RationalImpl | arithmetic( RationalImpl ) )117 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 118 118 Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r ); 119 119 120 forall ( otype RationalImpl | arithmetic( RationalImpl ) )120 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 121 121 Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r ); 122 122 123 forall ( otype RationalImpl | arithmetic( RationalImpl ) )123 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 124 124 Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r ); 125 125 126 forall ( otype RationalImpl | arithmetic( RationalImpl ) )126 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 127 127 Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r ); 128 128 129 129 // conversion 130 forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )130 forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } ) 131 131 double widen( Rational(RationalImpl) r ); 132 forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double );} )132 forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double );} ) 133 133 Rational(RationalImpl) narrow( double f, RationalImpl md ); 134 134 135 135 // I/O 136 forall ( otype RationalImpl | arithmetic( RationalImpl ) )136 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 137 137 forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } ) 138 138 istype * ?|?( istype *, Rational(RationalImpl) * ); 139 139 140 forall ( otype RationalImpl | arithmetic( RationalImpl ) )140 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 141 141 forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } ) 142 142 ostype * ?|?( ostype *, Rational(RationalImpl ) ); 143 144 #endif // RATIONAL_H 143 145 144 146 // Local Variables: // -
src/libcfa/rational.c
reaace25 r3873b5a1 10 10 // Created On : Wed Apr 6 17:54:28 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 16 18:35:36201713 // Update Count : 1 5012 // Last Modified On : Mon May 15 21:29:23 2017 13 // Update Count : 149 14 14 // 15 15 … … 22 22 // Calculate greatest common denominator of two numbers, the first of which may be negative. Used to reduce rationals. 23 23 // alternative: https://en.wikipedia.org/wiki/Binary_GCD_algorithm 24 forall ( otype RationalImpl | arithmetic( RationalImpl ) )24 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 25 25 static RationalImpl gcd( RationalImpl a, RationalImpl b ) { 26 26 for ( ;; ) { // Euclid's algorithm … … 33 33 } // gcd 34 34 35 forall ( otype RationalImpl | arithmetic( RationalImpl ) )35 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 36 36 static RationalImpl simplify( RationalImpl * n, RationalImpl * d ) { 37 37 if ( *d == (RationalImpl){0} ) { … … 46 46 // constructors 47 47 48 forall ( otype RationalImpl | arithmetic( RationalImpl ) )48 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 49 49 void ?{}( Rational(RationalImpl) * r ) { 50 50 r{ (RationalImpl){0}, (RationalImpl){1} }; 51 51 } // rational 52 52 53 forall ( otype RationalImpl | arithmetic( RationalImpl ) )53 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 54 54 void ?{}( Rational(RationalImpl) * r, RationalImpl n ) { 55 55 r{ n, (RationalImpl){1} }; 56 56 } // rational 57 57 58 forall ( otype RationalImpl | arithmetic( RationalImpl ) )58 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 59 59 void ?{}( Rational(RationalImpl) * r, RationalImpl n, RationalImpl d ) { 60 60 RationalImpl t = simplify( &n, &d ); // simplify … … 66 66 // getter for numerator/denominator 67 67 68 forall ( otype RationalImpl | arithmetic( RationalImpl ) )68 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 69 69 RationalImpl numerator( Rational(RationalImpl) r ) { 70 70 return r.numerator; 71 71 } // numerator 72 72 73 forall ( otype RationalImpl | arithmetic( RationalImpl ) )73 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 74 74 RationalImpl denominator( Rational(RationalImpl) r ) { 75 75 return r.denominator; 76 76 } // denominator 77 77 78 forall ( otype RationalImpl | arithmetic( RationalImpl ) )78 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 79 79 [ RationalImpl, RationalImpl ] ?=?( * [ RationalImpl, RationalImpl ] dest, Rational(RationalImpl) src ) { 80 80 return *dest = src.[ numerator, denominator ]; … … 83 83 // setter for numerator/denominator 84 84 85 forall ( otype RationalImpl | arithmetic( RationalImpl ) )85 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 86 86 RationalImpl numerator( Rational(RationalImpl) r, RationalImpl n ) { 87 87 RationalImpl prev = r.numerator; … … 92 92 } // numerator 93 93 94 forall ( otype RationalImpl | arithmetic( RationalImpl ) )94 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 95 95 RationalImpl denominator( Rational(RationalImpl) r, RationalImpl d ) { 96 96 RationalImpl prev = r.denominator; … … 104 104 // comparison 105 105 106 forall ( otype RationalImpl | arithmetic( RationalImpl ) )106 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 107 107 int ?==?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 108 108 return l.numerator * r.denominator == l.denominator * r.numerator; 109 109 } // ?==? 110 110 111 forall ( otype RationalImpl | arithmetic( RationalImpl ) )111 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 112 112 int ?!=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 113 113 return ! ( l == r ); 114 114 } // ?!=? 115 115 116 forall ( otype RationalImpl | arithmetic( RationalImpl ) )116 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 117 117 int ?<?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 118 118 return l.numerator * r.denominator < l.denominator * r.numerator; 119 119 } // ?<? 120 120 121 forall ( otype RationalImpl | arithmetic( RationalImpl ) )121 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 122 122 int ?<=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 123 123 return l.numerator * r.denominator <= l.denominator * r.numerator; 124 124 } // ?<=? 125 125 126 forall ( otype RationalImpl | arithmetic( RationalImpl ) )126 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 127 127 int ?>?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 128 128 return ! ( l <= r ); 129 129 } // ?>? 130 130 131 forall ( otype RationalImpl | arithmetic( RationalImpl ) )131 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 132 132 int ?>=?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 133 133 return ! ( l < r ); … … 137 137 // arithmetic 138 138 139 forall ( otype RationalImpl | arithmetic( RationalImpl ) )139 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 140 140 Rational(RationalImpl) +?( Rational(RationalImpl) r ) { 141 141 Rational(RationalImpl) t = { r.numerator, r.denominator }; … … 143 143 } // +? 144 144 145 forall ( otype RationalImpl | arithmetic( RationalImpl ) )145 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 146 146 Rational(RationalImpl) -?( Rational(RationalImpl) r ) { 147 147 Rational(RationalImpl) t = { -r.numerator, r.denominator }; … … 149 149 } // -? 150 150 151 forall ( otype RationalImpl | arithmetic( RationalImpl ) )151 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 152 152 Rational(RationalImpl) ?+?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 153 153 if ( l.denominator == r.denominator ) { // special case … … 160 160 } // ?+? 161 161 162 forall ( otype RationalImpl | arithmetic( RationalImpl ) )162 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 163 163 Rational(RationalImpl) ?-?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 164 164 if ( l.denominator == r.denominator ) { // special case … … 171 171 } // ?-? 172 172 173 forall ( otype RationalImpl | arithmetic( RationalImpl ) )173 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 174 174 Rational(RationalImpl) ?*?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 175 175 Rational(RationalImpl) t = { l.numerator * r.numerator, l.denominator * r.denominator }; … … 177 177 } // ?*? 178 178 179 forall ( otype RationalImpl | arithmetic( RationalImpl ) )179 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 180 180 Rational(RationalImpl) ?/?( Rational(RationalImpl) l, Rational(RationalImpl) r ) { 181 181 if ( r.numerator < (RationalImpl){0} ) { … … 190 190 // conversion 191 191 192 forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } )192 forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); } ) 193 193 double widen( Rational(RationalImpl) r ) { 194 194 return convert( r.numerator ) / convert( r.denominator ); … … 196 196 197 197 // http://www.ics.uci.edu/~eppstein/numth/frap.c 198 forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double ); } )198 forall ( otype RationalImpl | arithmetic( RationalImpl ) | { double convert( RationalImpl ); RationalImpl convert( double ); } ) 199 199 Rational(RationalImpl) narrow( double f, RationalImpl md ) { 200 200 if ( md <= (RationalImpl){1} ) { // maximum fractional digits too small? … … 227 227 // I/O 228 228 229 forall ( otype RationalImpl | arithmetic( RationalImpl ) )229 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 230 230 forall( dtype istype | istream( istype ) | { istype * ?|?( istype *, RationalImpl * ); } ) 231 231 istype * ?|?( istype * is, Rational(RationalImpl) * r ) { … … 238 238 } // ?|? 239 239 240 forall ( otype RationalImpl | arithmetic( RationalImpl ) )240 forall ( otype RationalImpl | arithmetic( RationalImpl ) ) 241 241 forall( dtype ostype | ostream( ostype ) | { ostype * ?|?( ostype *, RationalImpl ); } ) 242 242 ostype * ?|?( ostype * os, Rational(RationalImpl ) r ) { -
src/libcfa/stdlib
reaace25 r3873b5a1 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // 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 17 18 18 19 //--------------------------------------- … … 231 232 void swap( T * t1, T * t2 ); 232 233 234 #endif // STDLIB_H 235 233 236 // Local Variables: // 234 237 // mode: c // -
src/main.cc
reaace25 r3873b5a1 10 10 // Author : Richard C. Bilson 11 11 // Created On : Fri May 15 23:12:02 2015 12 // Last Modified By : Andrew Beach13 // Last Modified On : Fri Jul 7 11:13:00 201714 // Update Count : 44 212 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Thu Jun 29 12:46:50 2017 14 // Update Count : 441 15 15 // 16 16 … … 206 206 FILE * builtins = fopen( libcfap | treep ? "../prelude/builtins.cf" : CFA_LIBDIR "/builtins.cf", "r" ); 207 207 assertf( builtins, "cannot open builtins.cf\n" ); 208 parse( builtins, LinkageSpec::Builtin CFA);208 parse( builtins, LinkageSpec::Builtin ); 209 209 } // if 210 210 } // if -
src/tests/.expect/32/math.txt
reaace25 r3873b5a1 22 22 cos:0.540302 0.54030230586814 0.540302305868139717 0.83373-0.988898i 0.833730025131149-0.988897705762865i 0.833730025131149049-0.988897705762865096i 23 23 tan: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.6662 39+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i24 asin:1.5708 1.5707963267949 1.57079632679489662 0.66624+1.06128i 0.666239432492515+1.06127506190504i 0.666239432492515255+1.06127506190503565i 25 25 acos:0 0 0 0.904557-1.06128i 0.904556894302381-1.06127506190504i 0.904556894302381364-1.06127506190503565i 26 26 atan: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 4 4 123 5 5 6 opening delimiters 6 opening delimiters 7 7 x (1 x [2 x {3 x =4 x $5 x £6 x ¥7 x ¡8 x ¿9 x «10 8 8 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 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 11 11 12 opening/closing delimiters 12 opening/closing delimiters 13 13 x`1`x'2'x"3"x:4:x 5 x 6 x 14 14 7 … … 19 19 x 20 20 10 21 x 21 x 22 22 23 override opening/closing delimiters 23 override opening/closing delimiters 24 24 x ( 1 ) x 2 , x 3 :x: 4 25 25 26 input bacis types 26 input bacis types 27 27 28 output basic types 28 output basic types 29 29 A 30 30 1 2 3 4 5 6 7 8 … … 32 32 1.1+2.3i 1.1-2.3i 1.1-2.3i 33 33 34 tuples 35 1, 2, 3 4, 5, 634 tuples 35 1, 2, 3 3, 4, 5 36 36 37 toggle separator 37 toggle separator 38 38 1.11.21.3 39 39 1.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 41 abcxyz 45 42 46 change separator 47 from " " to ", $"43 change separator 44 from " "to " , $" 48 45 1.1, $1.2, $1.3 49 46 1.1+2.3i, $1.1-2.3i, $1.1-2.3i 50 abc, $xyz 51 1, 2, 3, $ 4, 5, 647 abc, $xyz, $ 48 1, 2, 3, $3, 4, 5 52 49 53 from ", $" to " "50 from ", $"to " " 54 51 1.1 1.2 1.3 55 52 1.1+2.3i 1.1-2.3i 1.1-2.3i 56 abc xyz 57 1, 2, 3 4, 5, 653 abc xyz 54 1, 2, 3 3, 4, 5 58 55 59 check sepOn/sepOff 56 1 2 3 57 12 3 58 1 2 3 60 59 1 2 3 61 12 3 62 1 2 3 63 1 2 3 60 1 2 3 64 61 65 1 2 366 67 check enable/disable68 62 123 69 63 1 23 … … 71 65 123 72 66 1 2 3 73 123 67 123 74 68 1 2 3 75 69 76 1 2 3 4 5 6" "77 1, 2, 3 4, 5, 6 ""78 1, 2, 3 4, 5, 670 1 2 3 3 4 5 " " 71 1, 2, 3 3, 4, 5 ", " 72 1, 2, 3 3, 4, 5 79 73 80 74 3, 4, a, 7.2 81 75 3, 4, a, 7.2 82 76 3 4 a 7.2 83 3 4 a 7.234a7.23 4 a 7.277 3 4 a 7.234a7.23 4 a 7.2 84 78 3-4-a-7.2^3^4^3-4-a-7.2 -
src/tests/Makefile.am
reaace25 r3873b5a1 29 29 30 30 # 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 31 EXTRA_FLAGS = 32 BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ ${EXTRA_FLAGS} 44 33 TEST_FLAGS = $(if $(test), 2> .err/${@}.log, ) 45 34 AM_CFLAGS = ${TEST_FLAGS} ${BUILD_FLAGS} -
src/tests/Makefile.in
reaace25 r3873b5a1 92 92 host_triplet = @host@ 93 93 @BUILD_CONCURRENCY_TRUE@am__append_1 = coroutine thread monitor 94 @BUILD_DEBUG_FALSE@am__append_2 = -nodebug95 @BUILD_DEBUG_TRUE@@BUILD_RELEASE_FALSE@am__append_3 = -debug96 @BUILD_DEBUG_TRUE@@BUILD_RELEASE_TRUE@am__append_4 = ${DEBUG_FLAGS}97 94 EXTRA_PROGRAMS = fstream_test$(EXEEXT) vector_test$(EXEEXT) \ 98 95 avl_test$(EXEEXT) … … 323 320 324 321 # 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) 322 EXTRA_FLAGS = 323 BUILD_FLAGS = -g -Wall -Wno-unused-function -quiet @CFA_FLAGS@ ${EXTRA_FLAGS} 328 324 TEST_FLAGS = $(if $(test), 2> .err/${@}.log, ) 329 325 AM_CFLAGS = ${TEST_FLAGS} ${BUILD_FLAGS} -
src/tests/io.c
reaace25 r3873b5a1 10 10 // Created On : Wed Mar 2 16:56:02 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jul 6 23:26:12201713 // Update Count : 7812 // Last Modified On : Sun Jul 2 09:40:58 2017 13 // Update Count : 68 14 14 // 15 15 … … 104 104 105 105 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 ] ]; 107 107 sout | t1 | t2 | endl; // print tuple 108 108 sout | endl; … … 110 110 sout | "toggle separator" | endl; 111 111 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 118 115 sout | endl; 119 116 120 117 sout | "change separator" | endl; 121 sout | "from \" " | sep| "\"";118 sout | "from \" " | sepGet( sout ) | "\""; 122 119 sepSet( sout, ", $" ); // change separator, maximum of 15 characters 123 sout | " to \"" | sep| "\"" | endl;120 sout | "to \" " | sepGet( sout ) | "\"" | endl; 124 121 sout | f | d | ld | endl 125 122 | fc | dc | ldc | endl … … 127 124 | t1 | t2 | endl; // print tuple 128 125 sout | endl; 129 sout | "from \"" | sep | "\"";126 sout | "from \"" | sepGet( sout ) | "\""; 130 127 sepSet( sout, " " ); // restore separator 131 sout | "to \"" | sep | "\"" | endl;128 sout | "to \"" | sepGet( sout ) | "\"" | endl; 132 129 sout | f | d | ld | endl 133 130 | fc | dc | ldc | endl … … 136 133 sout | endl; 137 134 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 140 136 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/endof line142 sout | 1 | 2 | 3 | "\n\n" | sepOn; // noseparator at start of next line137 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 143 139 sout | 1 | 2 | 3 | endl; 144 140 sout | endl; 145 141 146 sout | "check enable/disable" | endl;147 142 sout | sepDisable | 1 | 2 | 3 | endl; // globally turn off implicit separation 148 143 sout | 1 | sepOn | 2 | 3 | endl; // locally turn on implicit separator … … 154 149 sout | endl; 155 150 156 // sout | fmt( d, "%8.3f" ) || endl;157 // sout | endl;158 159 151 sepSetTuple( sout, " " ); // set tuple separator from ", " to " " 160 sout | t1 | t2 | " \"" | sep | "\"" | endl;152 sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl; 161 153 sepSetTuple( sout, ", " ); // reset tuple separator to ", " 162 sout | t1 | t2 | " \"" | sep | "\"" | endl;154 sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl; 163 155 sout | t1 | t2 | endl; // print tuple 164 156 sout | endl; -
src/tests/test.py
reaace25 r3873b5a1 166 166 167 167 # 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) 169 169 170 170 retcode = 0 … … 202 202 error = myfile.read() 203 203 204 204 205 205 # clean the executable 206 206 sh("rm -f %s > /dev/null 2>&1" % test.name, dry_run)
Note:
See TracChangeset
for help on using the changeset viewer.