diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b71a001..faed8ae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,14 +43,14 @@ jobs: exit 1; fi ${GITHUB_WORKSPACE}/ci/fail-on-warning.sh build.log - - name: Test + - name: Run integration tests shell: bash working-directory: ${{runner.workspace}}/build run: | git clone --single-branch https://github.com/SacBase/sac-examples.git cd sac-examples make all - ./test.sh + MT=4 ./test.sh build-macos-x86: runs-on: macos-13 @@ -92,14 +92,14 @@ jobs: exit 1; fi ${GITHUB_WORKSPACE}/ci/fail-on-warning.sh build.log - - name: Test + - name: Run integration tests shell: bash working-directory: ${{runner.workspace}}/build run: | git clone --single-branch https://github.com/SacBase/sac-examples.git cd sac-examples make all - ./test.sh + MT=3 ./test.sh build-macos-arm: runs-on: macos-15 @@ -141,11 +141,11 @@ jobs: exit 1; fi ${GITHUB_WORKSPACE}/ci/fail-on-warning.sh build.log - - name: Test + - name: Run integration tests shell: bash working-directory: ${{runner.workspace}}/build run: | git clone --single-branch https://github.com/SacBase/sac-examples.git cd sac-examples make all - ./test.sh + MT=3 ./test.sh diff --git a/src/stdio/ArrayIO.xsac b/src/stdio/ArrayIO.xsac index b1c9ad3..55affc9 100644 --- a/src/stdio/ArrayIO.xsac +++ b/src/stdio/ArrayIO.xsac @@ -64,32 +64,32 @@ external void showarray(TermFile &stream, int d, int[.] s, char[*] a); /******************************************************************************/ #define PRINT(typ, _postfix, _fmt, _zero, _one) \ -inline void fprint(TermFile &stream, string fmt, typ[d:shp] arr) \ +void fprint(TermFile &stream, string fmt, typ[d:shp] arr) \ { \ printarray(stream, fmt, d, shp, arr); \ } \ \ -inline void fprint(TermFile &stream, typ[d:shp] arr) \ +void fprint(TermFile &stream, typ[d:shp] arr) \ { \ printarray(stream, d, shp, arr); \ } \ \ -inline void fprint(File &stream, string fmt, typ[d:shp] arr) \ +void fprint(File &stream, string fmt, typ[d:shp] arr) \ { \ printarray(stream, fmt, d, shp, arr); \ } \ \ -inline void fprint(File &stream, typ[d:shp] arr) \ +void fprint(File &stream, typ[d:shp] arr) \ { \ printarray(stream, d, shp, arr); \ } \ \ -inline void print(string fmt, typ[d:shp] arr) \ +void print(string fmt, typ[d:shp] arr) \ { \ printarray(stdout, fmt, d, shp, arr); \ } \ \ -inline void print(typ[d:shp] arr) \ +void print(typ[d:shp] arr) \ { \ printarray(stdout, d, shp, arr); \ } @@ -99,7 +99,7 @@ BUILT_IN(PRINT) /******************************************************************************/ #define SHOW(typ) \ -inline void show(typ[+] arr) \ +void show(typ[+] arr) \ { \ carr = format(arr); \ showarray(stdout, dim(carr), shape(carr), carr); \ diff --git a/src/stdio/ComplexIO.sac b/src/stdio/ComplexIO.sac index 9811771..e7dd5b2 100644 --- a/src/stdio/ComplexIO.sac +++ b/src/stdio/ComplexIO.sac @@ -44,7 +44,7 @@ external void printarray( TermFile &stream, string format, int d, int[.] s, com /*****************************************************************/ -inline void fprint(File &stream, complex c) +void fprint(File &stream, complex c) { File::fprintf(stream, "(%g,%g)", real(c), imag(c)); } @@ -52,7 +52,7 @@ inline void fprint(File &stream, complex c) /*****************************************************************/ -inline void fprint(File &stream, complex c, int mode) +void fprint(File &stream, complex c, int mode) { if (mode==2) { @@ -74,7 +74,7 @@ inline void fprint(File &stream, complex c, int mode) /*****************************************************************/ -inline void fprint(File &stream, complex c, int mode, int prec) +void fprint(File &stream, complex c, int mode, int prec) { if (mode==2) { @@ -98,7 +98,7 @@ inline void fprint(File &stream, complex c, int mode, int prec) /*****************************************************************/ -inline void fprint(TermFile &stream, complex c) +void fprint(TermFile &stream, complex c) { TermFile::fprintf(stream, "(%g,%g)", real(c), imag(c)); } @@ -106,7 +106,7 @@ inline void fprint(TermFile &stream, complex c) /*****************************************************************/ -inline void fprint(TermFile &stream, complex c, int mode) +void fprint(TermFile &stream, complex c, int mode) { if (mode==2) { @@ -128,7 +128,7 @@ inline void fprint(TermFile &stream, complex c, int mode) /*****************************************************************/ -inline void fprint(TermFile &stream, complex c, int mode, int prec) +void fprint(TermFile &stream, complex c, int mode, int prec) { if (mode==2) { @@ -151,7 +151,7 @@ inline void fprint(TermFile &stream, complex c, int mode, int prec) /*****************************************************************/ /*****************************************************************/ -inline void print(complex c) +void print(complex c) { fprint(TermFile::stdout, c); } @@ -159,7 +159,7 @@ inline void print(complex c) /*****************************************************************/ -inline void print(complex c, int mode) +void print(complex c, int mode) { fprint(TermFile::stdout, c, mode); } @@ -167,21 +167,21 @@ inline void print(complex c, int mode) /*****************************************************************/ -inline void print(complex c, int mode, int prec) +void print(complex c, int mode, int prec) { fprint(TermFile::stdout, c, mode, prec); } /*****************************************************************/ -inline void print(complex[+] arr) +void print(complex[+] arr) { printarray(TermFile::stdout, dim( arr), shape( arr), arr); } /*****************************************************************/ -inline void print(complex[+] arr, int mode) +void print(complex[+] arr, int mode) { string format; if (mode==2) @@ -204,7 +204,7 @@ inline void print(complex[+] arr, int mode) /*****************************************************************/ -inline void print(complex[+] arr, int mode, int prec) +void print(complex[+] arr, int mode, int prec) { string format; if (mode==2) @@ -228,7 +228,7 @@ inline void print(complex[+] arr, int mode, int prec) /*****************************************************************/ /*****************************************************************/ -inline bool, complex fscancomplex(File &stream) +bool, complex fscancomplex(File &stream) { double re; double im; @@ -245,7 +245,7 @@ inline bool, complex fscancomplex(File &stream) /*****************************************************************/ -inline bool, complex fscancomplex(File &stream, int mode) +bool, complex fscancomplex(File &stream, int mode) { double re; double im; @@ -278,7 +278,7 @@ inline bool, complex fscancomplex(File &stream, int mode) /*****************************************************************/ -inline bool, complex fscancomplex(TermFile &stream) +bool, complex fscancomplex(TermFile &stream) { double re; double im; @@ -295,7 +295,7 @@ inline bool, complex fscancomplex(TermFile &stream) /*****************************************************************/ -inline bool, complex fscancomplex(TermFile &stream, int mode) +bool, complex fscancomplex(TermFile &stream, int mode) { double re; double im; @@ -328,7 +328,7 @@ inline bool, complex fscancomplex(TermFile &stream, int mode) /*****************************************************************/ -inline bool, complex scancomplex() +bool, complex scancomplex() { double re; double im; @@ -345,7 +345,7 @@ inline bool, complex scancomplex() /*****************************************************************/ -inline bool, complex scancomplex(int mode) +bool, complex scancomplex(int mode) { double re; double im; diff --git a/src/stdio/FibreIO.sac b/src/stdio/FibreIO.sac index 1ede60b..3161d42 100644 --- a/src/stdio/FibreIO.sac +++ b/src/stdio/FibreIO.sac @@ -184,116 +184,116 @@ stringArray FibreScanStringArray() /******************************************************************************/ -inline void FibrePrint(File &stream, int[d:shp] arr) +void FibrePrint(File &stream, int[d:shp] arr) { FibrePrint(stream, d, shp, arr); } -inline void FibrePrint(File &stream, int arr) +void FibrePrint(File &stream, int arr) { File::fprintf(stream, "%d\n", arr); } -inline void FibrePrint(File &stream, float[d:shp] arr) +void FibrePrint(File &stream, float[d:shp] arr) { FibrePrint(stream, d, shp, arr); } -inline void FibrePrint(File &stream, float arr) +void FibrePrint(File &stream, float arr) { File::fprintf(stream, "%.16f\n", tod(arr)); } -inline void FibrePrint(File &stream, double[d:shp] arr) +void FibrePrint(File &stream, double[d:shp] arr) { FibrePrint(stream, d, shp, arr); } -inline void FibrePrint(File &stream, double arr) +void FibrePrint(File &stream, double arr) { File::fprintf(stream, "%.16f\n", arr); } -inline void FibrePrint(File &stream, stringArray arr) +void FibrePrint(File &stream, stringArray arr) { FibrePrint(stream, StringArray::dim(arr), StringArray::shape(arr), arr); } /******************************************************************************/ -inline void FibrePrint(TermFile &stream, int[d:shp] arr) +void FibrePrint(TermFile &stream, int[d:shp] arr) { FibrePrint(stream, d, shp, arr); } -inline void FibrePrint(TermFile &stream, int arr) +void FibrePrint(TermFile &stream, int arr) { TermFile::fprintf(stream, "%d\n", arr); } -inline void FibrePrint(TermFile &stream, float[d:shp] arr) +void FibrePrint(TermFile &stream, float[d:shp] arr) { FibrePrint(stream, d, shp, arr); } -inline void FibrePrint(TermFile &stream, float arr) +void FibrePrint(TermFile &stream, float arr) { TermFile::fprintf(stream, "%.16f\n", tod(arr)); } -inline void FibrePrint(TermFile &stream, double[d:shp] arr) +void FibrePrint(TermFile &stream, double[d:shp] arr) { FibrePrint(stream, d, shp, arr); } -inline void FibrePrint(TermFile &stream, double arr) +void FibrePrint(TermFile &stream, double arr) { TermFile::fprintf(stream, "%.16f\n", arr); } -inline void FibrePrint(TermFile &stream, stringArray arr) +void FibrePrint(TermFile &stream, stringArray arr) { FibrePrint(stream, StringArray::dim(arr), StringArray::shape(arr), arr); } /******************************************************************************/ -inline void FibrePrint(int[d:shp] arr) +void FibrePrint(int[d:shp] arr) { FibrePrint(stdout, d, shp, arr); } -inline void FibrePrint(int arr) +void FibrePrint(int arr) { TermFile::fprintf(stdout, "%d\n", arr); } -inline void FibrePrint(float[d:shp] arr) +void FibrePrint(float[d:shp] arr) { FibrePrint(stdout, d, shp, arr); } -inline void FibrePrint(float arr) +void FibrePrint(float arr) { TermFile::fprintf(stdout, "%.16f\n", tod(arr)); } -inline void FibrePrint(double[d:shp] arr) +void FibrePrint(double[d:shp] arr) { FibrePrint(stdout, d, shp, arr); } -inline void FibrePrint(double arr) +void FibrePrint(double arr) { TermFile::fprintf(stdout, "%.16f\n", arr); } -inline void FibrePrint(StringArray::stringArray arr) +void FibrePrint(StringArray::stringArray arr) { FibrePrint(stdout, StringArray::dim(arr), StringArray::shape(arr), arr); } -inline void FibrePrint(string scaler) +void FibrePrint(string scaler) { TermFile::printf("%s", scaler); } @@ -344,32 +344,32 @@ type[*] FibreScan##alias##Array() \ } #define FIBREPRINT(type,formatting) \ -inline void FibrePrint(File &stream, type[d:shp] arr) \ +void FibrePrint(File &stream, type[d:shp] arr) \ { \ FibrePrint(stream, d, shp, arr); \ } \ \ -inline void FibrePrint(File &stream, type arr) \ +void FibrePrint(File &stream, type arr) \ { \ File::fprintf(stream, SETFORMAT(formatting), arr); \ } \ \ -inline void FibrePrint(TermFile &stream, type[d:shp] arr) \ +void FibrePrint(TermFile &stream, type[d:shp] arr) \ { \ FibrePrint(stream, d, shp, arr); \ } \ \ -inline void FibrePrint(TermFile &stream, type arr) \ +void FibrePrint(TermFile &stream, type arr) \ { \ TermFile::fprintf(stream, SETFORMAT(formatting), arr); \ } \ \ -inline void FibrePrint(type[d:shp] arr) \ +void FibrePrint(type[d:shp] arr) \ { \ FibrePrint(stdout, d, shp, arr); \ } \ \ -inline void FibrePrint(type arr) \ +void FibrePrint(type arr) \ { \ TermFile::fprintf(stdout, SETFORMAT(formatting), arr); \ } diff --git a/src/stdio/ScalarIO.xsac b/src/stdio/ScalarIO.xsac index 0063e07..af24e3f 100644 --- a/src/stdio/ScalarIO.xsac +++ b/src/stdio/ScalarIO.xsac @@ -13,7 +13,7 @@ export all except { bool2str }; #define QUOTE(s) #s -inline string bool2str(bool val, int mode) +string bool2str(bool val, int mode) { if (mode == 2) { @@ -40,7 +40,7 @@ inline string bool2str(bool val, int mode) ******************************************************************************/ #define FPRINT_FILE_S(typ, _postfix, fmt, _zval, _oval) \ -inline void fprint(File &stream, typ val) \ +void fprint(File &stream, typ val) \ { \ File::fprintf(stream, QUOTE(%fmt), val); \ } @@ -48,32 +48,32 @@ inline void fprint(File &stream, typ val) \ INT_NUM(FPRINT_FILE_S) CHAR(FPRINT_FILE_S) -inline void fprint(File &stream, float val) +void fprint(File &stream, float val) { File::fprintf(stream, "%g", tod(val)); } -inline void fprint(File &stream, float val, int prec) +void fprint(File &stream, float val, int prec) { File::fprintf(stream, "%.*g", prec, tod(val)); } -inline void fprint(File &stream, double val) +void fprint(File &stream, double val) { File::fprintf(stream, "%g", val); } -inline void fprint(File &stream, double val, int prec) +void fprint(File &stream, double val, int prec) { File::fprintf(stream, "%.*g", prec, val); } -inline void fprint(File &stream, bool val) +void fprint(File &stream, bool val) { File::fprintf(stream, bool2str(val, 0)); } -inline void fprint(File &stream, bool val, int mode) +void fprint(File &stream, bool val, int mode) { File::fprintf(stream, bool2str(val, mode)); } @@ -87,7 +87,7 @@ inline void fprint(File &stream, bool val, int mode) ******************************************************************************/ #define FPRINT_TERMFILE_S(typ, _postfix, fmt, _zval, _oval) \ -inline void fprint(TermFile &stream, typ val) \ +void fprint(TermFile &stream, typ val) \ { \ TermFile::fprintf(stream, QUOTE(%fmt), val); \ } @@ -95,32 +95,32 @@ inline void fprint(TermFile &stream, typ val) \ INT_NUM(FPRINT_TERMFILE_S) CHAR(FPRINT_TERMFILE_S) -inline void fprint(TermFile &stream, float val) +void fprint(TermFile &stream, float val) { TermFile::fprintf(stream, "%g", tod(val)); } -inline void fprint(TermFile &stream, float val, int prec) +void fprint(TermFile &stream, float val, int prec) { TermFile::fprintf(stream, "%.*g", prec, tod(val)); } -inline void fprint(TermFile &stream, double val) +void fprint(TermFile &stream, double val) { TermFile::fprintf(stream, "%g", val); } -inline void fprint(TermFile &stream, double val, int prec) +void fprint(TermFile &stream, double val, int prec) { TermFile::fprintf(stream, "%.*g", prec, val); } -inline void fprint(TermFile &stream, bool val) +void fprint(TermFile &stream, bool val) { TermFile::fprintf(stream, bool2str(val, 0)); } -inline void fprint(TermFile &stream, bool val, int mode) +void fprint(TermFile &stream, bool val, int mode) { TermFile::fprintf(stream, bool2str(val, mode)); } @@ -135,7 +135,7 @@ inline void fprint(TermFile &stream, bool val, int mode) ******************************************************************************/ #define SHOW_TERMFILE_S(typ, _postfix, fmt, _zval, _oval) \ -inline void show(typ val) \ +void show(typ val) \ { \ TermFile::printf(QUOTE(%fmt\n), val); \ } @@ -144,12 +144,12 @@ INT_NUM(SHOW_TERMFILE_S) CHAR(SHOW_TERMFILE_S) BOOL(SHOW_TERMFILE_S) -inline void show(float val) +void show(float val) { TermFile::printf("%g\n", tod(val)); } -inline void show(double val) +void show(double val) { TermFile::printf("%g\n", val); } @@ -163,7 +163,7 @@ inline void show(double val) ******************************************************************************/ #define PRINT_TERMFILE_S(typ, _postfix, fmt, _zval, _oval) \ -inline void print(typ val) \ +void print(typ val) \ { \ TermFile::printf("Dimension: 0\nShape : < >\n"); \ TermFile::printf(" " QUOTE(%fmt\n), val); \ @@ -171,37 +171,37 @@ inline void print(typ val) \ INT_NUM(PRINT_TERMFILE_S) -inline void print(float val) +void print(float val) { TermFile::printf("Dimension: 0\nShape : < >\n"); TermFile::printf(" %g\n", tod(val)); } -inline void print(float val, int prec) +void print(float val, int prec) { TermFile::printf("Dimension: 0\nShape : < >\n"); TermFile::printf(" %.*g\n", prec, tod(val)); } -inline void print(double val) +void print(double val) { TermFile::printf("Dimension: 0\nShape : < >\n"); TermFile::printf(" %g\n", val); } -inline void print(double val, int prec) +void print(double val, int prec) { TermFile::printf("Dimension: 0\nShape : < >\n"); TermFile::printf(" %.*g\n", prec, val); } -inline void print(bool val) +void print(bool val) { TermFile::printf("Dimension: 0\nShape : < >\n"); TermFile::printf(" %s\n", bool2str(val, 2)); } -inline void print(bool val, int mode) +void print(bool val, int mode) { TermFile::printf("Dimension: 0\nShape : < >\n"); TermFile::printf(" %s\n", bool2str(val, mode)); @@ -223,7 +223,7 @@ void print(char val) ******************************************************************************/ #define FSCAN_FILE_S(typ, _postfix, fmt, _zval, _oval) \ -inline bool, typ fscan##typ(File &stream) \ +bool, typ fscan##typ(File &stream) \ { \ typ res; \ success, res = File::fscanf(stream, QUOTE(%fmt)); \ @@ -233,7 +233,7 @@ inline bool, typ fscan##typ(File &stream) \ NUM(FSCAN_FILE_S) CHAR(FSCAN_FILE_S) -inline bool, bool fscanbool(File &stream) +bool, bool fscanbool(File &stream) { char c; success, c = File::fscanf(stream, "%c"); @@ -241,7 +241,7 @@ inline bool, bool fscanbool(File &stream) return (success == 1, res); } -inline bool, string fscanstring(File &stream, int length) +bool, string fscanstring(File &stream, int length) { string res; res = File::fscans(stream, length); @@ -258,7 +258,7 @@ inline bool, string fscanstring(File &stream, int length) ******************************************************************************/ #define FSCAN_TERMFILE_S(typ, _postfix, fmt, _zval, _oval) \ -inline bool, typ fscan##typ(TermFile &stream) \ +bool, typ fscan##typ(TermFile &stream) \ { \ typ res; \ success, res = TermFile::fscanf(stream, QUOTE(%fmt)); \ @@ -268,7 +268,7 @@ inline bool, typ fscan##typ(TermFile &stream) \ NUM(FSCAN_TERMFILE_S) CHAR(FSCAN_TERMFILE_S) -inline bool, bool fscanbool(TermFile &stream) +bool, bool fscanbool(TermFile &stream) { char c; success, c = TermFile::fscanf(stream, "%c"); @@ -276,7 +276,7 @@ inline bool, bool fscanbool(TermFile &stream) return (success == 1, res); } -inline bool, string fscanstring(TermFile &stream, int length) +bool, string fscanstring(TermFile &stream, int length) { string res; res = TermFile::fscans(stream, length); @@ -293,7 +293,7 @@ inline bool, string fscanstring(TermFile &stream, int length) ******************************************************************************/ #define SCAN_S(typ, _postfix, fmt, _zval, _oval) \ -inline bool, typ scan##typ() \ +bool, typ scan##typ() \ { \ typ res; \ success, res = TermFile::scanf(QUOTE(%format)); \ @@ -303,7 +303,7 @@ inline bool, typ scan##typ() \ NUM(SCAN_S) CHAR(SCAN_S) -inline bool, bool scanbool() +bool, bool scanbool() { char c; success, c = TermFile::scanf("%c"); @@ -311,7 +311,7 @@ inline bool, bool scanbool() return (success == 1, res); } -inline bool, string scanstring(int length) +bool, string scanstring(int length) { string res; res = TermFile::scans(length); diff --git a/src/stdio/TermFile.sac b/src/stdio/TermFile.sac index 03c1e81..d2b6345 100644 --- a/src/stdio/TermFile.sac +++ b/src/stdio/TermFile.sac @@ -4,7 +4,6 @@ class TermFile; external classtype; use String: { string }; -use Terminal: { TheTerminal }; export all except { createStdIn, createStdOut, createStdErr }; @@ -16,32 +15,30 @@ objdef TermFile stderr = createStdErr(); /****************************************************************************** * - * Initialiser Functions creating standard I/O TermFiles. + * Initialiser functions for creating standard I/O TermFiles. * ******************************************************************************/ external TermFile createStdIn(); - #pragma effect TheTerminal - #pragma linkname "SAC_create_stdin" + #pragma effect Terminal::TheTerminal #pragma linkobj "src/TermFile/stdstreams.o" + #pragma linkname "SAC_create_stdin" #pragma linksign [0] external TermFile createStdOut(); - #pragma effect TheTerminal - #pragma linkname "SAC_create_stdout" + #pragma effect Terminal::TheTerminal #pragma linkobj "src/TermFile/stdstreams.o" + #pragma linkname "SAC_create_stdout" #pragma linksign [0] external TermFile createStdErr(); - #pragma effect TheTerminal - #pragma linkname "SAC_create_stderr" + #pragma effect Terminal::TheTerminal #pragma linkobj "src/TermFile/stdstreams.o" + #pragma linkname "SAC_create_stderr" #pragma linksign [0] - /* - * Each function of class TermFile exists in two versions. One expects + /* Each function of class TermFile exists in two versions. One expects * an I/O stream as an explicit argument, the other writes implicitly - * to stdout or reads implicitly from stdin, respectively. - */ + * to stdout or reads implicitly from stdin, respectively. */ /****************************************************************************** * @@ -50,55 +47,46 @@ external TermFile createStdErr(); ******************************************************************************/ external void fputc(char C, TermFile &STREAM); - #pragma effect TheTerminal - #pragma linkname "SACfputc_TF" + #pragma effect Terminal::TheTerminal #pragma linkobj "src/TermFile/fputc.o" + #pragma linkname "SACfputc_TF" -inline void putc(char C) { fputc(C, stdout); } - /* - * Put the character C to the output stream STREAM which must be - * either stdout or stderr. - */ +void putc(char C) { fputc(C, stdout); } + /* Put the character C to the output stream STREAM which must be + * either stdout or stderr. */ external char fgetc(TermFile &STREAM); - #pragma effect TheTerminal - #pragma linkname "SACfgetc_TF" + #pragma effect Terminal::TheTerminal #pragma linkobj "src/TermFile/fgetc.o" + #pragma linkname "SACfgetc_TF" #pragma linksign [0,1] -inline char getc() { return fgetc(stdin); } - /* - * Get the next character from the input stream STREAM which must be stdin. - */ +char getc() { return fgetc(stdin); } + /* Get the next character from the input stream STREAM which must + * be stdin. */ external void fputs(string S, TermFile &STREAM); - #pragma effect TheTerminal - #pragma linkname "SACfputs_TF" + #pragma effect Terminal::TheTerminal #pragma linkobj "src/TermFile/fputs.o" - /* - * Write string S to stream. - */ + #pragma linkname "SACfputs_TF" + /* Write string S to stream. */ external void puts(string S); - #pragma effect TheTerminal - #pragma linkname "SACputs_TF" + #pragma effect Terminal::TheTerminal #pragma linkobj "src/TermFile/puts.o" - /* - * Write string S and a newline to stdout. - */ + #pragma linkname "SACputs_TF" + /* Write string S and a newline to stdout. */ external void ungetc(char C, TermFile &STREAM); - #pragma effect TheTerminal - #pragma linkname "SACungetc_TF" + #pragma effect Terminal::TheTerminal #pragma linkobj "src/TermFile/ungetc.o" + #pragma linkname "SACungetc_TF" -inline void ungetc(char C) { ungetc(C, stdin); } - /* - * Put the character C back to the input stream STREAM which must be - * stdin for further read operations. Only one character may be put back - * between two consecutive read operations, otherwise the character put - * back first is overwritten. - */ +void ungetc(char C) { ungetc(C, stdin); } + /* Put the character C back to the input stream STREAM which must be stdin + * for further read operations. Only one character may be put back between + * two consecutive read operations, otherwise the character put back first + * is overwritten. */ /****************************************************************************** * @@ -107,67 +95,58 @@ inline void ungetc(char C) { ungetc(C, stdin); } ******************************************************************************/ external void fprintf(TermFile &STREAM, string FORMAT, ...); - #pragma effect TheTerminal - #pragma linkname "SACfprintf_TF" + #pragma effect Terminal::TheTerminal #pragma linkobj "src/TermFile/fprintf.o" + #pragma linkname "SACfprintf_TF" external void printf(string FORMAT, ...); - #pragma effect TheTerminal, stdout - #pragma linkname "SACprintf_TF" + #pragma effect Terminal::TheTerminal, stdout #pragma linkobj "src/TermFile/printf.o" - /* - * Print formatted output to STREAM which must be open for writing. + #pragma linkname "SACprintf_TF" + /* Print formatted output to STREAM which must be open for writing. * The syntax of format strings is identical to that known from C. * This function may be used to print values of types - * char, string, int, float, and double. - */ + * char, string, int, float, and double. */ external int, ... fscanf(TermFile &STREAM, string FORMAT); - #pragma effect TheTerminal - #pragma linkname "SACfscanf_TF" + #pragma effect Terminal::TheTerminal #pragma linkobj "src/TermFile/fscanf.o" + #pragma linkname "SACfscanf_TF" #pragma linksign [0,1,2] external int, ... scanf(string FORMAT); - #pragma effect TheTerminal, stdin - #pragma linkname "SACscanf_TF" + #pragma effect Terminal::TheTerminal, stdin #pragma linkobj "src/TermFile/scanf.o" + #pragma linkname "SACscanf_TF" #pragma linksign [0,1] - /* - * Scan the given stream STREAM concerning the format string FORMAT. The + /* Scan the given stream STREAM concerning the format string FORMAT. The * syntax of format strings is identical to C except that the string * conversion specifier %s is not supported. This function may be used * to scan values of types char, int, float, and double. To scan strings * use either fscans or fscanl, respectively. The int result gives the - * number of successfully performed conversions. - */ + * number of successfully performed conversions. */ external string fscans(TermFile &STREAM, int MAX); - #pragma effect TheTerminal - #pragma linkname "term_fscans" + #pragma effect Terminal::TheTerminal #pragma linkobj "src/TermFile/fscans.o" + #pragma linkname "term_fscans" #pragma linksign [0,1,2] -inline string scans(int MAX) { return fscans(stdin, MAX); } - /* - * Read the next character string from the input stream STREAM. Strings +string scans(int MAX) { return fscans(stdin, MAX); } + /* Read the next character string from the input stream STREAM. Strings * are delimited by any whitespace character including the end-of-file - * symbol. Always read at most MAX characters. - * Upon failure an empty string is returned. - */ + * symbol. Always read at most MAX characters. Upon failure an empty + * string is returned. */ external string fscanl(TermFile &STREAM, int MAX); - #pragma effect TheTerminal + #pragma effect Terminal::TheTerminal #pragma linkname "term_fscanl" - #pragma linkobj "src/TermFile/fscanl.o" #pragma linksign [0,1,2] -inline string scanl(int MAX) { return fscanl(stdin, MAX); } - /* - * Read the next line from the input stream STREAM. Lines are character - * strings delimited by any new-line or end-of-file symbol. Always read - * at most MAX characters. Upon failure an empty string is returned. - */ +string scanl(int MAX) { return fscanl(stdin, MAX); } + /* Read the next line from the input stream STREAM. Lines are character + * strings delimited by any new-line or end-of-file symbol. Always read + * at most MAX characters. Upon failure an empty string is returned. */ /****************************************************************************** * @@ -176,25 +155,21 @@ inline string scanl(int MAX) { return fscanl(stdin, MAX); } ******************************************************************************/ external void fflush(TermFile &STREAM); - #pragma effect TheTerminal - #pragma linkname "SACfflush_TF" + #pragma effect Terminal::TheTerminal #pragma linkobj "src/TermFile/fflush.o" + #pragma linkname "SACfflush_TF" -inline void flush() { fflush(stdout); } - /* - * Write the buffer of a buffered output stream STREAM which must be - * either stdout or stderr to the respective file or terminal device. - */ +void flush() { fflush(stdout); } + /* Write the buffer of a buffered output stream STREAM which must be + * either stdout or stderr to the respective file or terminal device. */ external bool feof(TermFile &STREAM); - #pragma effect TheTerminal - #pragma linkname "SACfeof_TF" + #pragma effect Terminal::TheTerminal #pragma linkobj "src/TermFile/feof.o" + #pragma linkname "SACfeof_TF" #pragma linksign [0,1] -inline bool eof() { return feof(stdin); } - /* - * Test the stream STREAM for having reached the end of the respective +bool eof() { return feof(stdin); } + /* Test the stream STREAM for having reached the end of the respective * file. This function is useful if standard I/O streams are redirected - * to or from files. - */ + * to or from files. */ diff --git a/src/structures/ArrayFormat.sac b/src/structures/ArrayFormat.sac index 8621b3e..c4a0ff0 100644 --- a/src/structures/ArrayFormat.sac +++ b/src/structures/ArrayFormat.sac @@ -30,7 +30,6 @@ export { format }; * @brief Default format for any character array. * ******************************************************************************/ -inline char[d:shp] format(char[d:shp] arr) { return arr; @@ -43,7 +42,6 @@ char[d:shp] format(char[d:shp] arr) * @brief Default format for boolean scalar. * ******************************************************************************/ -inline char[1] format(bool arr) { return [arr ? '1' : '0']; @@ -56,7 +54,6 @@ char[1] format(bool arr) * Default format for boolean non-scalars. * ******************************************************************************/ -inline char[d:shp,m] format(bool[d:shp,n] arr) | _eq_SxS_(m, max(2 * n - 1, 0)) { @@ -78,7 +75,6 @@ char[d:shp,m] format(bool[d:shp,n] arr) * @param w[1] The number of significant digits to be printed. * ******************************************************************************/ -inline char[.] format(bool arr, int[2] w) { return format(tod(arr), w); @@ -91,7 +87,6 @@ char[.] format(bool arr, int[2] w) * @brief Defined-width format on boolean non-scalar. * ******************************************************************************/ -inline char[d:shp,m] format(bool[d:shp,n] arr, int[2] w) | _eq_SxS_(m, max(2 * n - 1, 0)) { @@ -105,7 +100,6 @@ char[d:shp,m] format(bool[d:shp,n] arr, int[2] w) * @brief Default format on integer scalar. * ******************************************************************************/ -inline char[.] format(int arr) { return tochar(sprintf("%d", arr)); @@ -118,7 +112,6 @@ char[.] format(int arr) * @brief Default format on long scalar. * ******************************************************************************/ -inline char[.] format(long arr) { return tochar(sprintf("%ld", arr)); @@ -133,7 +126,6 @@ char[.] format(long arr) * Refer to UTThorn.dws for APL model of this. * ******************************************************************************/ -inline char[+] format(int[d:shp,n] arr) { shpp = prod(shp); @@ -164,7 +156,6 @@ char[+] format(int[d:shp,n] arr) * @brief Defined-precision format on integer scalar. * ******************************************************************************/ -inline char[.] format(int arr, int precision) { return format(tod(arr), precision); @@ -177,7 +168,6 @@ char[.] format(int arr, int precision) * @brief Precision-significant digit format on integer non-scalar. * ******************************************************************************/ -inline char[+] format(int[+] arr, int precision) { return format(tod(arr), precision); @@ -194,7 +184,6 @@ char[+] format(int[+] arr, int precision) * @param w[1] The number of significant digits to be printed. * ******************************************************************************/ -inline char[.] format(int arr, int[2] w) { res = tochar(sprintf("%*.*d", w[0], w[1], arr)); @@ -209,7 +198,6 @@ char[.] format(int arr, int[2] w) * @brief Default format on float scalar. * ******************************************************************************/ -inline char[.] format(float arr) { return format(tod(arr), 15); @@ -222,7 +210,6 @@ char[.] format(float arr) * @brief Default format on float non-scalar. * ******************************************************************************/ -inline char[+] format(float[+] arr) { return format(tod(arr), 15); @@ -235,7 +222,6 @@ char[+] format(float[+] arr) * @brief Defined-precision format on floating scalar. * ******************************************************************************/ -inline char[.] format(float arr, int precision) { return format(tod(arr), precision); @@ -248,7 +234,6 @@ char[.] format(float arr, int precision) * @brief Precision-significant digit format on floating non-scalar. * ******************************************************************************/ -inline char[+] format(float[+] arr, int precision) { return format(tod(arr), precision); @@ -265,7 +250,6 @@ char[+] format(float[+] arr, int precision) * @param w[1] The number of significant digits to be printed. * ******************************************************************************/ -inline char[.] format(float arr, int[2] w) { return format(tod(arr), w); @@ -282,7 +266,6 @@ char[.] format(float arr, int[2] w) * @param w[1] The number of significant digits to be printed. * ******************************************************************************/ -inline char[+] format(float[+] arr, int[2] w) { return format(tod(arr), w); @@ -295,7 +278,6 @@ char[+] format(float[+] arr, int[2] w) * @brief Default format on double scalar. * ******************************************************************************/ -inline char[.] format(double arr) { return format(arr, 15); @@ -310,7 +292,6 @@ char[.] format(double arr) * Refer to UTThorn.dws for APL model of this. * ******************************************************************************/ -inline char[+] format(double[+] arr) { return format(arr, 15); @@ -323,7 +304,6 @@ char[+] format(double[+] arr) * @brief Formatting for a double scalar. * ******************************************************************************/ -inline char[.] format(double arr, int precision) { res = scalarFormatter(arr, precision); @@ -340,7 +320,6 @@ char[.] format(double arr, int precision) * @note Refer to UTThorn.dws for APL model of this. * ******************************************************************************/ -inline char[+] format(double[d:shp,n] arr, int precision) { shpp = prod(shp); @@ -388,7 +367,6 @@ char[+] format(double[d:shp,n] arr, int precision) * @param w[1] The number of significant digits to be printed. * ******************************************************************************/ -inline char[.] format(double arr, int[2] w) { res = tochar(sprintf("%*.*g", w[0], w[1], arr)); @@ -407,7 +385,6 @@ char[.] format(double arr, int[2] w) * @param w[1] The number of significant digits to be printed. * ******************************************************************************/ -inline char[+] format(double[d:shp] arr, int[2] w) { res = { iv -> format(arr[iv], w) | iv < shp }; @@ -431,7 +408,6 @@ char[+] format(double[d:shp] arr, int[2] w) * @brief Utility function for formatting an int vector to widths wid. * ******************************************************************************/ -inline char[olen] formatrow(int[vlen] wid, int[vlen] arr) { olen = sum(wid + 1) - 1; @@ -475,7 +451,6 @@ int[d:shp] log10(int[d:shp] arr) * @brief First-axis max-reduce rank-2 matrix. * ******************************************************************************/ -inline int[m] maxsl1(int[n,m] arr) { return { [i] -> with { @@ -491,7 +466,6 @@ int[m] maxsl1(int[n,m] arr) * @brief First-axis min-reduce rank-2 matrix. * ******************************************************************************/ -inline int[m] minsl1(int[n,m] arr) { return { [i] -> with { @@ -534,7 +508,6 @@ char[zcols] alignrow(char[.,.] fry, int i, int[cols] widths, * @brief SAC does not have overtake, so this does the job. * ******************************************************************************/ -inline char[wid] padWithBlanks(int wid, char[n] arr) { maxidx = max(wid, n); @@ -551,7 +524,6 @@ char[wid] padWithBlanks(int wid, char[n] arr) * I.e., (fry member ch) iota 1. * ******************************************************************************/ -inline int thCharsTo(char ch0, char ch1, char[lim] fry) { res = lim; @@ -572,7 +544,6 @@ int thCharsTo(char ch0, char ch1, char[lim] fry) * @brief Indexed assign array into vec for next result element. * ******************************************************************************/ -inline char[d], int thrnAppend(char[d] vec, int sink, char[n] arr) { res = vec; @@ -608,7 +579,6 @@ char[.] scalarFormatter(double arr, int precision) * This is "(arr != '+') compress arr", the hard way * ******************************************************************************/ -inline char[.] killPlusSign(char[n] arr) { res = arr; @@ -629,7 +599,6 @@ char[.] killPlusSign(char[n] arr) * @brief Check for txt overflowing wid. * ******************************************************************************/ -inline char[.] overflowCheck(char[n] arr, int wid) { return wid < n ? genarray([wid], '*') : arr;