2016-10-22 18:07:12 +00:00
|
|
|
/* -*-comment-start: "//";comment-end:""-*-
|
2018-07-22 12:24:36 +00:00
|
|
|
* GNU Mes --- Maxwell Equations of Software
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
* Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
2021-04-20 13:24:27 +00:00
|
|
|
* Copyright © 2021 W. J. van der Laan <laanwj@protonmail.com>
|
2016-10-22 18:07:12 +00:00
|
|
|
*
|
2018-07-22 12:24:36 +00:00
|
|
|
* This file is part of GNU Mes.
|
2016-10-22 18:07:12 +00:00
|
|
|
*
|
2018-07-22 12:24:36 +00:00
|
|
|
* GNU Mes is free software; you can redistribute it and/or modify it
|
2016-10-22 18:07:12 +00:00
|
|
|
* under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
2018-07-22 12:24:36 +00:00
|
|
|
* GNU Mes is distributed in the hope that it will be useful, but
|
2016-10-22 18:07:12 +00:00
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-22 12:24:36 +00:00
|
|
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
2016-10-22 18:07:12 +00:00
|
|
|
*/
|
|
|
|
|
2019-06-08 13:36:22 +00:00
|
|
|
#include "mes/lib.h"
|
|
|
|
#include "mes/mes.h"
|
|
|
|
|
|
|
|
#include <ctype.h>
|
2017-05-02 21:30:46 +00:00
|
|
|
#include <limits.h>
|
2019-06-08 13:36:22 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2017-05-02 21:30:46 +00:00
|
|
|
|
2018-01-25 06:00:48 +00:00
|
|
|
void
|
2020-10-18 09:34:32 +00:00
|
|
|
assert_number (char const *name, struct scm *x)
|
2018-01-25 06:00:48 +00:00
|
|
|
{
|
2020-10-18 09:34:32 +00:00
|
|
|
if (x->type != TNUMBER)
|
2018-01-25 06:00:48 +00:00
|
|
|
{
|
|
|
|
eputs (name);
|
|
|
|
error (cell_symbol_not_a_number, x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-18 09:34:32 +00:00
|
|
|
struct scm *
|
|
|
|
greater_p (struct scm *x) /*:((name . ">") (arity . n)) */
|
mescc: Run module/base-0.mes.
* gc.c: New file.
* vector.c: New file.
* mes.c: Remove vector and gc functions, include vector.c, gc.c.
* GNUmakefile (mes.o): Add gc, vector dependencies.
* scaffold/mini-mes.c (eval_apply): Support primitive-load through
read_input_file.
(getenv_, open_input_file, current_input_port,
set_current_input_port force_output, exit_, values, arity_, xassq,
is_p, minus, plus, divide, modulo multiply, logior, ash): New function.
(mes_symbols): Add symbols %gnuc, %mesc.
* scaffold/mini-mes.c (): New functions.
* scaffold/b-0.mes: New file.
* scaffold/t-0.mes: New file.
2017-03-26 19:13:01 +00:00
|
|
|
{
|
2018-05-02 21:11:27 +00:00
|
|
|
if (x == cell_nil)
|
|
|
|
return cell_t;
|
2020-10-18 09:34:32 +00:00
|
|
|
assert_number ("greater_p", x->car);
|
|
|
|
long n = x->car->value;
|
|
|
|
x = x->cdr;
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
struct scm *i;
|
|
|
|
long v;
|
mescc: Run module/base-0.mes.
* gc.c: New file.
* vector.c: New file.
* mes.c: Remove vector and gc functions, include vector.c, gc.c.
* GNUmakefile (mes.o): Add gc, vector dependencies.
* scaffold/mini-mes.c (eval_apply): Support primitive-load through
read_input_file.
(getenv_, open_input_file, current_input_port,
set_current_input_port force_output, exit_, values, arity_, xassq,
is_p, minus, plus, divide, modulo multiply, logior, ash): New function.
(mes_symbols): Add symbols %gnuc, %mesc.
* scaffold/mini-mes.c (): New functions.
* scaffold/b-0.mes: New file.
* scaffold/t-0.mes: New file.
2017-03-26 19:13:01 +00:00
|
|
|
while (x != cell_nil)
|
|
|
|
{
|
2020-10-18 09:34:32 +00:00
|
|
|
assert_number ("greater_p", x->car);
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
i = car (x);
|
|
|
|
v = i->value;
|
2020-07-17 12:30:01 +00:00
|
|
|
if (v >= n)
|
2018-04-05 19:35:31 +00:00
|
|
|
return cell_f;
|
2020-07-17 12:30:01 +00:00
|
|
|
n = v;
|
mescc: Run module/base-0.mes.
* gc.c: New file.
* vector.c: New file.
* mes.c: Remove vector and gc functions, include vector.c, gc.c.
* GNUmakefile (mes.o): Add gc, vector dependencies.
* scaffold/mini-mes.c (eval_apply): Support primitive-load through
read_input_file.
(getenv_, open_input_file, current_input_port,
set_current_input_port force_output, exit_, values, arity_, xassq,
is_p, minus, plus, divide, modulo multiply, logior, ash): New function.
(mes_symbols): Add symbols %gnuc, %mesc.
* scaffold/mini-mes.c (): New functions.
* scaffold/b-0.mes: New file.
* scaffold/t-0.mes: New file.
2017-03-26 19:13:01 +00:00
|
|
|
x = cdr (x);
|
|
|
|
}
|
|
|
|
return cell_t;
|
|
|
|
}
|
2016-10-22 18:07:12 +00:00
|
|
|
|
2020-10-18 09:34:32 +00:00
|
|
|
struct scm *
|
|
|
|
less_p (struct scm *x) /*:((name . "<") (arity . n)) */
|
mescc: Run module/base-0.mes.
* gc.c: New file.
* vector.c: New file.
* mes.c: Remove vector and gc functions, include vector.c, gc.c.
* GNUmakefile (mes.o): Add gc, vector dependencies.
* scaffold/mini-mes.c (eval_apply): Support primitive-load through
read_input_file.
(getenv_, open_input_file, current_input_port,
set_current_input_port force_output, exit_, values, arity_, xassq,
is_p, minus, plus, divide, modulo multiply, logior, ash): New function.
(mes_symbols): Add symbols %gnuc, %mesc.
* scaffold/mini-mes.c (): New functions.
* scaffold/b-0.mes: New file.
* scaffold/t-0.mes: New file.
2017-03-26 19:13:01 +00:00
|
|
|
{
|
2018-05-02 21:11:27 +00:00
|
|
|
if (x == cell_nil)
|
|
|
|
return cell_t;
|
2020-10-18 09:34:32 +00:00
|
|
|
assert_number ("less_p", x->car);
|
|
|
|
long n = x->car->value;
|
|
|
|
x = x->cdr;
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
struct scm *i;
|
|
|
|
long v;
|
mescc: Run module/base-0.mes.
* gc.c: New file.
* vector.c: New file.
* mes.c: Remove vector and gc functions, include vector.c, gc.c.
* GNUmakefile (mes.o): Add gc, vector dependencies.
* scaffold/mini-mes.c (eval_apply): Support primitive-load through
read_input_file.
(getenv_, open_input_file, current_input_port,
set_current_input_port force_output, exit_, values, arity_, xassq,
is_p, minus, plus, divide, modulo multiply, logior, ash): New function.
(mes_symbols): Add symbols %gnuc, %mesc.
* scaffold/mini-mes.c (): New functions.
* scaffold/b-0.mes: New file.
* scaffold/t-0.mes: New file.
2017-03-26 19:13:01 +00:00
|
|
|
while (x != cell_nil)
|
|
|
|
{
|
2020-10-18 09:34:32 +00:00
|
|
|
assert_number ("less_p", x->car);
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
i = car (x);
|
|
|
|
v = i->value;
|
2020-07-17 12:30:01 +00:00
|
|
|
if (v <= n)
|
2018-04-05 19:35:31 +00:00
|
|
|
return cell_f;
|
2020-07-17 12:30:01 +00:00
|
|
|
n = v;
|
mescc: Run module/base-0.mes.
* gc.c: New file.
* vector.c: New file.
* mes.c: Remove vector and gc functions, include vector.c, gc.c.
* GNUmakefile (mes.o): Add gc, vector dependencies.
* scaffold/mini-mes.c (eval_apply): Support primitive-load through
read_input_file.
(getenv_, open_input_file, current_input_port,
set_current_input_port force_output, exit_, values, arity_, xassq,
is_p, minus, plus, divide, modulo multiply, logior, ash): New function.
(mes_symbols): Add symbols %gnuc, %mesc.
* scaffold/mini-mes.c (): New functions.
* scaffold/b-0.mes: New file.
* scaffold/t-0.mes: New file.
2017-03-26 19:13:01 +00:00
|
|
|
x = cdr (x);
|
|
|
|
}
|
|
|
|
return cell_t;
|
|
|
|
}
|
2016-10-22 18:07:12 +00:00
|
|
|
|
2020-10-18 09:34:32 +00:00
|
|
|
struct scm *
|
|
|
|
is_p (struct scm *x) /*:((name . "=") (arity . n)) */
|
2016-10-22 18:07:12 +00:00
|
|
|
{
|
2018-04-05 19:35:31 +00:00
|
|
|
if (x == cell_nil)
|
|
|
|
return cell_t;
|
2020-10-18 09:34:32 +00:00
|
|
|
assert_number ("is_p", x->car);
|
|
|
|
long n = x->car->value;
|
2016-10-22 18:07:12 +00:00
|
|
|
x = cdr (x);
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
struct scm *i;
|
|
|
|
long v;
|
2016-11-21 08:28:34 +00:00
|
|
|
while (x != cell_nil)
|
2016-10-22 18:07:12 +00:00
|
|
|
{
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
i = car (x);
|
|
|
|
v = i->value;
|
2020-07-17 12:30:01 +00:00
|
|
|
if (v != n)
|
2018-04-05 19:35:31 +00:00
|
|
|
return cell_f;
|
2016-10-22 18:07:12 +00:00
|
|
|
x = cdr (x);
|
|
|
|
}
|
2016-11-21 08:28:34 +00:00
|
|
|
return cell_t;
|
2016-10-22 18:07:12 +00:00
|
|
|
}
|
|
|
|
|
2020-10-18 09:34:32 +00:00
|
|
|
struct scm *
|
|
|
|
minus (struct scm *x) /*:((name . "-") (arity . n)) */
|
2016-10-22 18:07:12 +00:00
|
|
|
{
|
2020-10-18 09:34:32 +00:00
|
|
|
assert_number ("minus", x->car);
|
|
|
|
long n = x->car->value;
|
2016-10-22 18:07:12 +00:00
|
|
|
x = cdr (x);
|
2016-11-21 08:28:34 +00:00
|
|
|
if (x == cell_nil)
|
2016-10-22 18:07:12 +00:00
|
|
|
n = -n;
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
struct scm *i;
|
|
|
|
long v;
|
2016-11-21 08:28:34 +00:00
|
|
|
while (x != cell_nil)
|
2016-10-22 18:07:12 +00:00
|
|
|
{
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
i = car (x);
|
2020-07-17 12:30:01 +00:00
|
|
|
assert_number ("minus", i);
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
v = i->value;
|
2020-07-17 12:30:01 +00:00
|
|
|
n = n - v;
|
2016-10-22 18:07:12 +00:00
|
|
|
x = cdr (x);
|
|
|
|
}
|
core: Remove macros from cell creation: make_char .. make_string.
* src/gc.c (make_char, make_continuation, make_macro, make_number,
make_ref, make_string0, make_string_port): New function.
(make_string): Move from string.c.
* include/mes/macros.h (MAKE_CHAR, MAKE_CONTINUATION, MAKE_MACRO,
MAKE_NUMBER, MAKE_REF, MAKE_STRING0, MAKE_STRING_PORT): Remove macro.
Update users.
* include/mes/m2.h: Likewise.
2020-05-18 20:35:12 +00:00
|
|
|
return make_number (n);
|
2016-10-22 18:07:12 +00:00
|
|
|
}
|
|
|
|
|
2020-10-18 09:34:32 +00:00
|
|
|
struct scm *
|
|
|
|
plus (struct scm *x) /*:((name . "+") (arity . n)) */
|
2016-10-22 18:07:12 +00:00
|
|
|
{
|
2018-10-04 19:43:45 +00:00
|
|
|
long n = 0;
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
struct scm *i;
|
|
|
|
long v;
|
2016-11-21 08:28:34 +00:00
|
|
|
while (x != cell_nil)
|
2016-10-22 18:07:12 +00:00
|
|
|
{
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
i = car (x);
|
2020-07-17 12:30:01 +00:00
|
|
|
assert_number ("plus", i);
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
v = i->value;
|
2020-07-17 12:30:01 +00:00
|
|
|
n = n + v;
|
2016-10-22 18:07:12 +00:00
|
|
|
x = cdr (x);
|
|
|
|
}
|
core: Remove macros from cell creation: make_char .. make_string.
* src/gc.c (make_char, make_continuation, make_macro, make_number,
make_ref, make_string0, make_string_port): New function.
(make_string): Move from string.c.
* include/mes/macros.h (MAKE_CHAR, MAKE_CONTINUATION, MAKE_MACRO,
MAKE_NUMBER, MAKE_REF, MAKE_STRING0, MAKE_STRING_PORT): Remove macro.
Update users.
* include/mes/m2.h: Likewise.
2020-05-18 20:35:12 +00:00
|
|
|
return make_number (n);
|
2016-10-22 18:07:12 +00:00
|
|
|
}
|
|
|
|
|
2020-10-18 09:34:32 +00:00
|
|
|
struct scm *
|
|
|
|
divide (struct scm *x) /*:((name . "/") (arity . n)) */
|
2016-10-22 18:07:12 +00:00
|
|
|
{
|
2018-10-04 19:43:45 +00:00
|
|
|
long n = 1;
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
struct scm *i;
|
|
|
|
long v;
|
2018-04-05 19:35:31 +00:00
|
|
|
if (x != cell_nil)
|
|
|
|
{
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
i = car (x);
|
2020-07-17 12:30:01 +00:00
|
|
|
assert_number ("divide", i);
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
v = i->value;
|
2020-07-17 12:30:01 +00:00
|
|
|
n = v;
|
2018-04-05 19:35:31 +00:00
|
|
|
x = cdr (x);
|
|
|
|
}
|
2020-12-29 21:39:31 +00:00
|
|
|
int sign_p = 0;
|
|
|
|
size_t u = n;
|
|
|
|
if (n < 0)
|
|
|
|
{
|
|
|
|
sign_p = 1;
|
|
|
|
u = -n;
|
|
|
|
}
|
|
|
|
size_t w;
|
2016-11-21 08:28:34 +00:00
|
|
|
while (x != cell_nil)
|
2016-10-22 18:07:12 +00:00
|
|
|
{
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
i = car (x);
|
2020-07-17 12:30:01 +00:00
|
|
|
assert_number ("divide", i);
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
v = i->value;
|
2020-12-29 21:39:31 +00:00
|
|
|
sign_p = sign_p && v > 0 || !sign_p && v < 0;
|
|
|
|
w = v;
|
2020-07-17 12:30:01 +00:00
|
|
|
if (v == 0)
|
2019-05-27 19:33:20 +00:00
|
|
|
error (cstring_to_symbol ("divide-by-zero"), x);
|
2020-12-29 21:39:31 +00:00
|
|
|
if (u == 0)
|
2018-10-06 22:25:33 +00:00
|
|
|
break;
|
2020-12-29 21:39:31 +00:00
|
|
|
if (w != 1)
|
|
|
|
u = u / w;
|
2016-10-22 18:07:12 +00:00
|
|
|
x = cdr (x);
|
|
|
|
}
|
2020-12-29 21:39:31 +00:00
|
|
|
n = u;
|
|
|
|
if (sign_p)
|
|
|
|
n = -n;
|
core: Remove macros from cell creation: make_char .. make_string.
* src/gc.c (make_char, make_continuation, make_macro, make_number,
make_ref, make_string0, make_string_port): New function.
(make_string): Move from string.c.
* include/mes/macros.h (MAKE_CHAR, MAKE_CONTINUATION, MAKE_MACRO,
MAKE_NUMBER, MAKE_REF, MAKE_STRING0, MAKE_STRING_PORT): Remove macro.
Update users.
* include/mes/m2.h: Likewise.
2020-05-18 20:35:12 +00:00
|
|
|
return make_number (n);
|
2016-10-22 18:07:12 +00:00
|
|
|
}
|
|
|
|
|
2020-10-18 09:34:32 +00:00
|
|
|
struct scm *
|
|
|
|
modulo (struct scm *a, struct scm *b)
|
2016-10-22 18:07:12 +00:00
|
|
|
{
|
2018-01-25 06:00:48 +00:00
|
|
|
assert_number ("modulo", a);
|
|
|
|
assert_number ("modulo", b);
|
2020-10-18 09:34:32 +00:00
|
|
|
long x = a->value;
|
|
|
|
long y = b->value;
|
2019-05-27 19:33:20 +00:00
|
|
|
if (y == 0)
|
|
|
|
error (cstring_to_symbol ("divide-by-zero"), a);
|
2018-10-06 22:25:33 +00:00
|
|
|
while (x < 0)
|
2020-04-20 17:46:55 +00:00
|
|
|
x = x + y;
|
|
|
|
if (x != 0)
|
|
|
|
x = x % y;
|
|
|
|
|
core: Remove macros from cell creation: make_char .. make_string.
* src/gc.c (make_char, make_continuation, make_macro, make_number,
make_ref, make_string0, make_string_port): New function.
(make_string): Move from string.c.
* include/mes/macros.h (MAKE_CHAR, MAKE_CONTINUATION, MAKE_MACRO,
MAKE_NUMBER, MAKE_REF, MAKE_STRING0, MAKE_STRING_PORT): Remove macro.
Update users.
* include/mes/m2.h: Likewise.
2020-05-18 20:35:12 +00:00
|
|
|
return make_number (x);
|
2016-10-22 18:07:12 +00:00
|
|
|
}
|
|
|
|
|
2020-10-18 09:34:32 +00:00
|
|
|
struct scm *
|
|
|
|
multiply (struct scm *x) /*:((name . "*") (arity . n)) */
|
2016-10-22 18:07:12 +00:00
|
|
|
{
|
2018-10-04 19:43:45 +00:00
|
|
|
long n = 1;
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
struct scm *i;
|
|
|
|
long v;
|
2016-11-21 08:28:34 +00:00
|
|
|
while (x != cell_nil)
|
2016-10-22 18:07:12 +00:00
|
|
|
{
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
i = car (x);
|
2020-07-17 12:30:01 +00:00
|
|
|
assert_number ("multiply", i);
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
v = i->value;
|
2020-07-17 12:30:01 +00:00
|
|
|
n = n * v;
|
2016-10-22 18:07:12 +00:00
|
|
|
x = cdr (x);
|
|
|
|
}
|
core: Remove macros from cell creation: make_char .. make_string.
* src/gc.c (make_char, make_continuation, make_macro, make_number,
make_ref, make_string0, make_string_port): New function.
(make_string): Move from string.c.
* include/mes/macros.h (MAKE_CHAR, MAKE_CONTINUATION, MAKE_MACRO,
MAKE_NUMBER, MAKE_REF, MAKE_STRING0, MAKE_STRING_PORT): Remove macro.
Update users.
* include/mes/m2.h: Likewise.
2020-05-18 20:35:12 +00:00
|
|
|
return make_number (n);
|
2016-10-22 18:07:12 +00:00
|
|
|
}
|
|
|
|
|
2020-10-18 09:34:32 +00:00
|
|
|
struct scm *
|
|
|
|
logand (struct scm *x) /*:((arity . n)) */
|
2017-08-27 10:53:01 +00:00
|
|
|
{
|
2021-04-20 13:24:27 +00:00
|
|
|
long n = -1;
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
struct scm *i;
|
|
|
|
long v;
|
2017-08-27 10:53:01 +00:00
|
|
|
while (x != cell_nil)
|
|
|
|
{
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
i = car (x);
|
2020-07-17 12:30:01 +00:00
|
|
|
assert_number ("multiply", i);
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
v = i->value;
|
2020-07-17 12:30:01 +00:00
|
|
|
n = n & v;
|
2017-08-27 10:53:01 +00:00
|
|
|
x = cdr (x);
|
|
|
|
}
|
core: Remove macros from cell creation: make_char .. make_string.
* src/gc.c (make_char, make_continuation, make_macro, make_number,
make_ref, make_string0, make_string_port): New function.
(make_string): Move from string.c.
* include/mes/macros.h (MAKE_CHAR, MAKE_CONTINUATION, MAKE_MACRO,
MAKE_NUMBER, MAKE_REF, MAKE_STRING0, MAKE_STRING_PORT): Remove macro.
Update users.
* include/mes/m2.h: Likewise.
2020-05-18 20:35:12 +00:00
|
|
|
return make_number (n);
|
2017-08-27 10:53:01 +00:00
|
|
|
}
|
|
|
|
|
2020-10-18 09:34:32 +00:00
|
|
|
struct scm *
|
|
|
|
logior (struct scm *x) /*:((arity . n)) */
|
2016-10-22 18:07:12 +00:00
|
|
|
{
|
2018-10-04 19:43:45 +00:00
|
|
|
long n = 0;
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
struct scm *i;
|
|
|
|
long v;
|
2016-11-21 08:28:34 +00:00
|
|
|
while (x != cell_nil)
|
2016-10-22 18:07:12 +00:00
|
|
|
{
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
i = car (x);
|
2020-07-17 12:30:01 +00:00
|
|
|
assert_number ("logior", i);
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
v = i->value;
|
2020-07-17 12:30:01 +00:00
|
|
|
n = n | v;
|
2016-10-22 18:07:12 +00:00
|
|
|
x = cdr (x);
|
|
|
|
}
|
core: Remove macros from cell creation: make_char .. make_string.
* src/gc.c (make_char, make_continuation, make_macro, make_number,
make_ref, make_string0, make_string_port): New function.
(make_string): Move from string.c.
* include/mes/macros.h (MAKE_CHAR, MAKE_CONTINUATION, MAKE_MACRO,
MAKE_NUMBER, MAKE_REF, MAKE_STRING0, MAKE_STRING_PORT): Remove macro.
Update users.
* include/mes/m2.h: Likewise.
2020-05-18 20:35:12 +00:00
|
|
|
return make_number (n);
|
2016-10-22 18:07:12 +00:00
|
|
|
}
|
2016-12-20 19:10:43 +00:00
|
|
|
|
2020-10-18 09:34:32 +00:00
|
|
|
struct scm *
|
|
|
|
lognot (struct scm *x)
|
2017-08-27 10:53:01 +00:00
|
|
|
{
|
2018-01-25 06:00:48 +00:00
|
|
|
assert_number ("lognot", x);
|
2020-10-18 09:34:32 +00:00
|
|
|
long n = ~x->value;
|
core: Remove macros from cell creation: make_char .. make_string.
* src/gc.c (make_char, make_continuation, make_macro, make_number,
make_ref, make_string0, make_string_port): New function.
(make_string): Move from string.c.
* include/mes/macros.h (MAKE_CHAR, MAKE_CONTINUATION, MAKE_MACRO,
MAKE_NUMBER, MAKE_REF, MAKE_STRING0, MAKE_STRING_PORT): Remove macro.
Update users.
* include/mes/m2.h: Likewise.
2020-05-18 20:35:12 +00:00
|
|
|
return make_number (n);
|
2017-08-27 10:53:01 +00:00
|
|
|
}
|
|
|
|
|
2020-10-18 09:34:32 +00:00
|
|
|
struct scm *
|
|
|
|
logxor (struct scm *x) /*:((arity . n)) */
|
2018-05-16 20:30:08 +00:00
|
|
|
{
|
2018-10-04 19:43:45 +00:00
|
|
|
long n = 0;
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
struct scm *i;
|
|
|
|
long v;
|
2018-05-16 20:30:08 +00:00
|
|
|
while (x != cell_nil)
|
|
|
|
{
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
i = car (x);
|
2020-07-17 12:30:01 +00:00
|
|
|
assert_number ("logxor", i);
|
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-29 12:38:38 +00:00
|
|
|
v = i->value;
|
2020-07-17 12:30:01 +00:00
|
|
|
n = n ^ v;
|
2018-05-16 20:30:08 +00:00
|
|
|
x = cdr (x);
|
|
|
|
}
|
core: Remove macros from cell creation: make_char .. make_string.
* src/gc.c (make_char, make_continuation, make_macro, make_number,
make_ref, make_string0, make_string_port): New function.
(make_string): Move from string.c.
* include/mes/macros.h (MAKE_CHAR, MAKE_CONTINUATION, MAKE_MACRO,
MAKE_NUMBER, MAKE_REF, MAKE_STRING0, MAKE_STRING_PORT): Remove macro.
Update users.
* include/mes/m2.h: Likewise.
2020-05-18 20:35:12 +00:00
|
|
|
return make_number (n);
|
2018-05-16 20:30:08 +00:00
|
|
|
}
|
|
|
|
|
2020-10-18 09:34:32 +00:00
|
|
|
struct scm *
|
|
|
|
ash (struct scm *n, struct scm *count)
|
2016-12-20 19:10:43 +00:00
|
|
|
{
|
2018-01-25 06:00:48 +00:00
|
|
|
assert_number ("ash", n);
|
|
|
|
assert_number ("ash", count);
|
2020-10-18 09:34:32 +00:00
|
|
|
long cn = n->value;
|
|
|
|
long ccount = count->value;
|
2020-04-20 17:46:55 +00:00
|
|
|
long result;
|
|
|
|
if (ccount < 0)
|
|
|
|
result = cn >> -ccount;
|
|
|
|
else
|
|
|
|
result = cn << ccount;
|
core: Remove macros from cell creation: make_char .. make_string.
* src/gc.c (make_char, make_continuation, make_macro, make_number,
make_ref, make_string0, make_string_port): New function.
(make_string): Move from string.c.
* include/mes/macros.h (MAKE_CHAR, MAKE_CONTINUATION, MAKE_MACRO,
MAKE_NUMBER, MAKE_REF, MAKE_STRING0, MAKE_STRING_PORT): Remove macro.
Update users.
* include/mes/m2.h: Likewise.
2020-05-18 20:35:12 +00:00
|
|
|
return make_number (result);
|
2016-12-20 19:10:43 +00:00
|
|
|
}
|