core: Rename variable type to binding.

This change allows us to use "variable" in the Guile sense, which is
an anonymous box for storing a value.

* include/mes/constants.h (TVARIABLE): Rename this...
(TBINDING): ...to this.
* include/mes/mes.h (scm): Rename the 'variable' field to 'binding'.
* include/mes/symbols.h (cell_type_variable): Rename this...
(cell_type_binding): ...to this.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Adjust accordingly.
* src/eval-apply.c (make_variable_): Rename this...
(make_binding_): ...to this.
(set_env_x, expand_variable_, eval_apply): Adjust accordingly.
* src/symbol.c (init_symbol): Adjust accordingly and rename the
'<cell:variable>' symbol to '<cell:binding>'.
* mes/module/mes/type-0.mes (cell:type-alist): Adjust accordingly.
(variable?): Rename this...
(binding?): ...to this.
* src/display.c (display_helper): Adjust accordingly and print
"binding" instead of "variable".
* mes/module/mes/display.mes (display): Likewise.
This commit is contained in:
Timothy Sample 2022-03-26 11:50:49 -06:00
parent 07c90bdebd
commit 91b1c6e233
9 changed files with 24 additions and 24 deletions

View File

@ -54,8 +54,8 @@
#define TSYMBOL 13
// CONSTANT TVALUES 14
#define TVALUES 14
// CONSTANT TVARIABLE 15
#define TVARIABLE 15
// CONSTANT TBINDING 15
#define TBINDING 15
// CONSTANT TVECTOR 16
#define TVECTOR 16
// CONSTANT TBROKEN_HEART 17

View File

@ -34,7 +34,7 @@ struct scm
char *bytes;
long length;
struct scm *ref;
struct scm *variable;
struct scm *binding;
struct scm *macro;
long port;
};

View File

@ -131,7 +131,7 @@ extern struct scm *cell_type_string;
extern struct scm *cell_type_struct;
extern struct scm *cell_type_symbol;
extern struct scm *cell_type_values;
extern struct scm *cell_type_variable;
extern struct scm *cell_type_binding;
extern struct scm *cell_type_vector;
extern struct scm *cell_type_broken_heart;
extern struct scm *cell_symbol_program;

View File

@ -123,8 +123,8 @@
(display " ")
(display (core:car x) port)
(display ">" port))
((variable? x)
(display "#<variable " port)
((binding? x)
(display "#<binding " port)
(write (list->string (car (core:car x))) port)
(display ">" port))
((number? x)

View File

@ -40,7 +40,7 @@
(cons <cell:struct> (quote <cell:struct>))
(cons <cell:symbol> (quote <cell:symbol>))
(cons <cell:values> (quote <cell:values>))
(cons <cell:variable> (quote <cell:variable>))
(cons <cell:binding> (quote <cell:binding>))
(cons <cell:vector> (quote <cell:vector>))
(cons <cell:broken-heart> (quote <cell:broken-heart>))))
@ -97,8 +97,8 @@
(define (values? x)
(eq? (core:type x) <cell:values>))
(define (variable? x)
(eq? (core:type x) <cell:variable>))
(define (binding? x)
(eq? (core:type x) <cell:binding>))
(define (variable-global? x)
(core:cdr x))

View File

@ -136,10 +136,10 @@ display_helper (struct scm *x, int cont, char *sep, int fd, int write_p)
display_helper (x->cdr, cont, "", fd, 0);
fdputs (">", fd);
}
else if (t == TVARIABLE)
else if (t == TBINDING)
{
fdputs ("#<variable ", fd);
display_helper (x->variable->car, cont, "", fd, 0);
fdputs ("#<binding ", fd);
display_helper (x->binding->car, cont, "", fd, 0);
fdputs (">", fd);
}
else if (t == TNUMBER)

View File

@ -124,8 +124,8 @@ struct scm *
set_env_x (struct scm *x, struct scm *e, struct scm *a)
{
struct scm *p;
if (x->type == TVARIABLE)
p = x->variable;
if (x->type == TBINDING)
p = x->binding;
else
p = assert_defined (x, module_variable (a, x));
if (p->type != TPAIR)
@ -149,9 +149,9 @@ make_closure_ (struct scm *args, struct scm *body, struct scm *a) /*:((int
}
struct scm *
make_variable_ (struct scm *var) /*:((internal)) */
make_binding_ (struct scm *handle) /*:((internal)) */
{
return make_cell (TVARIABLE, var, 0);
return make_cell (TBINDING, handle, 0);
}
struct scm *
@ -277,7 +277,7 @@ expand_variable_ (struct scm *x, struct scm *formals, int top_p) /*:((int
{
v = module_variable (R0, a);
if (v != cell_f)
x->car = make_variable_ (v);
x->car = make_binding_ (v);
}
}
x = x->cdr;
@ -706,9 +706,9 @@ eval:
R1 = assert_defined (R1, module_ref (R0, R1));
goto vm_return;
}
else if (t == TVARIABLE)
else if (t == TBINDING)
{
x = R1->variable;
x = R1->binding;
R1 = x->cdr;
goto vm_return;
}

View File

@ -402,7 +402,7 @@ gc_cellcpy (struct scm *dest, struct scm *src, size_t n)
if (t == TMACRO
|| t == TPAIR
|| t == TREF
|| t == TVARIABLE)
|| t == TBINDING)
dest->car_value = a - dist;
else
dest->car_value = a;
@ -560,7 +560,7 @@ gc_loop (struct scm *scan)
if (t == TMACRO
|| t == TPAIR
|| t == TREF
|| t == TVARIABLE)
|| t == TBINDING)
/* *INDENT-ON* */
{
car = gc_copy (scan->car);
@ -812,7 +812,7 @@ gc_dump_arena (struct scm *cells, long size)
if (t == TMACRO
|| t == TPAIR
|| t == TREF
|| t == TVARIABLE)
|| t == TBINDING)
{
dumps (ltoa ((cells->car - dist) / M2_CELL_SIZE));
/* dumps ("["); dumps (ltoa (a)); dumps ("]"); */

View File

@ -167,7 +167,7 @@ init_symbols_ () /*:((internal)) */
cell_type_struct = init_symbol (g_symbol, TSYMBOL, "<cell:struct>");
cell_type_symbol = init_symbol (g_symbol, TSYMBOL, "<cell:symbol>");
cell_type_values = init_symbol (g_symbol, TSYMBOL, "<cell:values>");
cell_type_variable = init_symbol (g_symbol, TSYMBOL, "<cell:variable>");
cell_type_binding = init_symbol (g_symbol, TSYMBOL, "<cell:binding>");
cell_type_vector = init_symbol (g_symbol, TSYMBOL, "<cell:vector>");
cell_type_broken_heart = init_symbol (g_symbol, TSYMBOL, "<cell:broken-heart>");
@ -211,7 +211,7 @@ init_symbols () /*:((internal)) */
a = acons (cell_type_struct, make_number (TSTRUCT), a);
a = acons (cell_type_symbol, make_number (TSYMBOL), a);
a = acons (cell_type_values, make_number (TVALUES), a);
a = acons (cell_type_variable, make_number (TVARIABLE), a);
a = acons (cell_type_binding, make_number (TBINDING), a);
a = acons (cell_type_vector, make_number (TVECTOR), a);
a = acons (cell_type_broken_heart, make_number (TBROKEN_HEART), a);