mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 20:00:19 +02:00
Add disjoint syntax object type
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES): (DOT_X_FILES, DOT_DOC_FILES, noinst_HEADERS): Add syntax.c and syntax.h. * libguile/evalext.c (scm_self_evaluating_p): * libguile/goops.c (class_syntax, scm_class_of, scm_goops_early_init): * libguile/init.c (scm_init_guile): * libguile/print.c (iprin1): * libguile/tags.h (scm_tc7_syntax): * module/oop/goops.scm (<syntax>): * module/system/base/types.scm (%tc7-syntax, cell->object): * module/system/vm/disassembler.scm (code-annotation): Wire up the new data type. * libguile/syntax.c: * libguile/syntax.h: New files. * module/ice-9/boot-9.scm: Move new definitions to (system syntax internal). * module/system/syntax.scm (print-syntax): New helper. * module/system/vm/assembler.scm (statically-allocatable?) (intern-constant, link-data): Arrange to be able to write syntax objects into images. * module/language/cps/types.scm (&syntax): New type. Remove &hash-table; it was never detected, an internal binding, and we need the bit to avoid going into bignum territory.
This commit is contained in:
parent
6ba3f35f26
commit
64c5cc58fc
15 changed files with 221 additions and 8 deletions
|
@ -212,6 +212,7 @@ libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES = \
|
||||||
strports.c \
|
strports.c \
|
||||||
struct.c \
|
struct.c \
|
||||||
symbols.c \
|
symbols.c \
|
||||||
|
syntax.c \
|
||||||
threads.c \
|
threads.c \
|
||||||
throw.c \
|
throw.c \
|
||||||
trees.c \
|
trees.c \
|
||||||
|
@ -316,6 +317,7 @@ DOT_X_FILES = \
|
||||||
strports.x \
|
strports.x \
|
||||||
struct.x \
|
struct.x \
|
||||||
symbols.x \
|
symbols.x \
|
||||||
|
syntax.x \
|
||||||
threads.x \
|
threads.x \
|
||||||
throw.x \
|
throw.x \
|
||||||
trees.x \
|
trees.x \
|
||||||
|
@ -418,6 +420,7 @@ DOT_DOC_FILES = \
|
||||||
strports.doc \
|
strports.doc \
|
||||||
struct.doc \
|
struct.doc \
|
||||||
symbols.doc \
|
symbols.doc \
|
||||||
|
syntax.doc \
|
||||||
threads.doc \
|
threads.doc \
|
||||||
throw.doc \
|
throw.doc \
|
||||||
trees.doc \
|
trees.doc \
|
||||||
|
@ -509,6 +512,7 @@ noinst_HEADERS = conv-integer.i.c conv-uinteger.i.c \
|
||||||
posix-w32.h \
|
posix-w32.h \
|
||||||
private-options.h \
|
private-options.h \
|
||||||
ports-internal.h \
|
ports-internal.h \
|
||||||
|
syntax.h \
|
||||||
weak-list.h
|
weak-list.h
|
||||||
|
|
||||||
# vm instructions
|
# vm instructions
|
||||||
|
|
|
@ -82,6 +82,7 @@ SCM_DEFINE (scm_self_evaluating_p, "self-evaluating?", 1, 0, 0,
|
||||||
case scm_tc7_dynamic_state:
|
case scm_tc7_dynamic_state:
|
||||||
case scm_tc7_frame:
|
case scm_tc7_frame:
|
||||||
case scm_tc7_keyword:
|
case scm_tc7_keyword:
|
||||||
|
case scm_tc7_syntax:
|
||||||
case scm_tc7_vm_cont:
|
case scm_tc7_vm_cont:
|
||||||
case scm_tc7_number:
|
case scm_tc7_number:
|
||||||
case scm_tc7_string:
|
case scm_tc7_string:
|
||||||
|
|
|
@ -110,6 +110,7 @@ static SCM class_applicable_struct_class;
|
||||||
static SCM class_applicable_struct_with_setter_class;
|
static SCM class_applicable_struct_with_setter_class;
|
||||||
static SCM class_number, class_list;
|
static SCM class_number, class_list;
|
||||||
static SCM class_keyword;
|
static SCM class_keyword;
|
||||||
|
static SCM class_syntax;
|
||||||
static SCM class_atomic_box;
|
static SCM class_atomic_box;
|
||||||
static SCM class_port, class_input_output_port;
|
static SCM class_port, class_input_output_port;
|
||||||
static SCM class_input_port, class_output_port;
|
static SCM class_input_port, class_output_port;
|
||||||
|
@ -227,6 +228,8 @@ SCM_DEFINE (scm_class_of, "class-of", 1, 0, 0,
|
||||||
return class_frame;
|
return class_frame;
|
||||||
case scm_tc7_keyword:
|
case scm_tc7_keyword:
|
||||||
return class_keyword;
|
return class_keyword;
|
||||||
|
case scm_tc7_syntax:
|
||||||
|
return class_syntax;
|
||||||
case scm_tc7_atomic_box:
|
case scm_tc7_atomic_box:
|
||||||
return class_atomic_box;
|
return class_atomic_box;
|
||||||
case scm_tc7_vm_cont:
|
case scm_tc7_vm_cont:
|
||||||
|
@ -1002,6 +1005,7 @@ SCM_DEFINE (scm_sys_goops_early_init, "%goops-early-init", 0, 0, 0,
|
||||||
class_dynamic_state = scm_variable_ref (scm_c_lookup ("<dynamic-state>"));
|
class_dynamic_state = scm_variable_ref (scm_c_lookup ("<dynamic-state>"));
|
||||||
class_frame = scm_variable_ref (scm_c_lookup ("<frame>"));
|
class_frame = scm_variable_ref (scm_c_lookup ("<frame>"));
|
||||||
class_keyword = scm_variable_ref (scm_c_lookup ("<keyword>"));
|
class_keyword = scm_variable_ref (scm_c_lookup ("<keyword>"));
|
||||||
|
class_syntax = scm_variable_ref (scm_c_lookup ("<syntax>"));
|
||||||
class_atomic_box = scm_variable_ref (scm_c_lookup ("<atomic-box>"));
|
class_atomic_box = scm_variable_ref (scm_c_lookup ("<atomic-box>"));
|
||||||
class_vm_cont = scm_variable_ref (scm_c_lookup ("<vm-continuation>"));
|
class_vm_cont = scm_variable_ref (scm_c_lookup ("<vm-continuation>"));
|
||||||
class_bytevector = scm_variable_ref (scm_c_lookup ("<bytevector>"));
|
class_bytevector = scm_variable_ref (scm_c_lookup ("<bytevector>"));
|
||||||
|
|
|
@ -124,6 +124,7 @@
|
||||||
#include "libguile/strports.h"
|
#include "libguile/strports.h"
|
||||||
#include "libguile/struct.h"
|
#include "libguile/struct.h"
|
||||||
#include "libguile/symbols.h"
|
#include "libguile/symbols.h"
|
||||||
|
#include "libguile/syntax.h"
|
||||||
#include "libguile/throw.h"
|
#include "libguile/throw.h"
|
||||||
#include "libguile/arrays.h"
|
#include "libguile/arrays.h"
|
||||||
#include "libguile/trees.h"
|
#include "libguile/trees.h"
|
||||||
|
@ -507,6 +508,7 @@ scm_i_init_guile (void *base)
|
||||||
scm_init_evalext ();
|
scm_init_evalext ();
|
||||||
scm_init_debug (); /* Requires macro smobs */
|
scm_init_debug (); /* Requires macro smobs */
|
||||||
scm_init_simpos ();
|
scm_init_simpos ();
|
||||||
|
scm_init_syntax ();
|
||||||
#if HAVE_MODULES
|
#if HAVE_MODULES
|
||||||
scm_init_dynamic_linking (); /* Requires smob_prehistory */
|
scm_init_dynamic_linking (); /* Requires smob_prehistory */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#include "libguile/ports-internal.h"
|
#include "libguile/ports-internal.h"
|
||||||
#include "libguile/strings.h"
|
#include "libguile/strings.h"
|
||||||
#include "libguile/strports.h"
|
#include "libguile/strports.h"
|
||||||
|
#include "libguile/syntax.h"
|
||||||
#include "libguile/vectors.h"
|
#include "libguile/vectors.h"
|
||||||
#include "libguile/numbers.h"
|
#include "libguile/numbers.h"
|
||||||
#include "libguile/vm.h"
|
#include "libguile/vm.h"
|
||||||
|
@ -716,6 +717,9 @@ iprin1 (SCM exp, SCM port, scm_print_state *pstate)
|
||||||
scm_puts ("#:", port);
|
scm_puts ("#:", port);
|
||||||
scm_iprin1 (scm_keyword_to_symbol (exp), port, pstate);
|
scm_iprin1 (scm_keyword_to_symbol (exp), port, pstate);
|
||||||
break;
|
break;
|
||||||
|
case scm_tc7_syntax:
|
||||||
|
scm_i_syntax_print (exp, port, pstate);
|
||||||
|
break;
|
||||||
case scm_tc7_atomic_box:
|
case scm_tc7_atomic_box:
|
||||||
scm_i_atomic_box_print (exp, port, pstate);
|
scm_i_atomic_box_print (exp, port, pstate);
|
||||||
break;
|
break;
|
||||||
|
|
120
libguile/syntax.c
Normal file
120
libguile/syntax.c
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
/* Copyright (C) 2017 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 3 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
|
* 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "libguile/_scm.h"
|
||||||
|
#include "libguile/keywords.h"
|
||||||
|
#include "libguile/ports.h"
|
||||||
|
#include "libguile/syntax.h"
|
||||||
|
#include "libguile/validate.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
scm_is_syntax (SCM x)
|
||||||
|
{
|
||||||
|
return SCM_HAS_TYP7 (x, scm_tc7_syntax);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define SCM_VALIDATE_SYNTAX(pos, scm) \
|
||||||
|
SCM_I_MAKE_VALIDATE_MSG2 (pos, scm, scm_is_syntax, "syntax object")
|
||||||
|
|
||||||
|
SCM_DEFINE (scm_syntax_p, "syntax?", 1, 0, 0,
|
||||||
|
(SCM obj),
|
||||||
|
"Return @code{#t} if the argument @var{obj} is a syntax object,\n"
|
||||||
|
"else @code{#f}.")
|
||||||
|
#define FUNC_NAME s_scm_syntax_p
|
||||||
|
{
|
||||||
|
return scm_from_bool (scm_is_syntax (obj));
|
||||||
|
}
|
||||||
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
SCM_DEFINE (scm_make_syntax, "make-syntax", 3, 0, 0,
|
||||||
|
(SCM exp, SCM wrap, SCM module),
|
||||||
|
"Make a new syntax object.")
|
||||||
|
#define FUNC_NAME s_scm_make_syntax
|
||||||
|
{
|
||||||
|
return scm_double_cell (scm_tc7_syntax, SCM_UNPACK (exp),
|
||||||
|
SCM_UNPACK (wrap), SCM_UNPACK (module));
|
||||||
|
}
|
||||||
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
SCM_DEFINE (scm_syntax_expression, "syntax-expression", 1, 0, 0,
|
||||||
|
(SCM obj),
|
||||||
|
"Return the expression contained in the syntax object @var{obj}.")
|
||||||
|
#define FUNC_NAME s_scm_syntax_expression
|
||||||
|
{
|
||||||
|
SCM_VALIDATE_SYNTAX (1, obj);
|
||||||
|
return SCM_CELL_OBJECT_1 (obj);
|
||||||
|
}
|
||||||
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
SCM_DEFINE (scm_syntax_wrap, "syntax-wrap", 1, 0, 0,
|
||||||
|
(SCM obj),
|
||||||
|
"Return the wrap contained in the syntax object @var{obj}.")
|
||||||
|
#define FUNC_NAME s_scm_syntax_wrap
|
||||||
|
{
|
||||||
|
SCM_VALIDATE_SYNTAX (1, obj);
|
||||||
|
return SCM_CELL_OBJECT_2 (obj);
|
||||||
|
}
|
||||||
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
SCM_DEFINE (scm_syntax_module, "syntax-module", 1, 0, 0,
|
||||||
|
(SCM obj),
|
||||||
|
"Return the module info contained in the syntax object @var{obj}.")
|
||||||
|
#define FUNC_NAME s_scm_syntax_module
|
||||||
|
{
|
||||||
|
SCM_VALIDATE_SYNTAX (1, obj);
|
||||||
|
return SCM_CELL_OBJECT_3 (obj);
|
||||||
|
}
|
||||||
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
static SCM print_syntax_var;
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_print_syntax_var (void)
|
||||||
|
{
|
||||||
|
print_syntax_var =
|
||||||
|
scm_c_private_variable ("system syntax", "print-syntax");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
scm_i_syntax_print (SCM obj, SCM port, scm_print_state *pstate)
|
||||||
|
{
|
||||||
|
static scm_i_pthread_once_t once = SCM_I_PTHREAD_ONCE_INIT;
|
||||||
|
scm_i_pthread_once (&once, init_print_syntax_var);
|
||||||
|
scm_call_2 (scm_variable_ref (print_syntax_var), obj, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
scm_init_syntax ()
|
||||||
|
{
|
||||||
|
#include "libguile/syntax.x"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Local Variables:
|
||||||
|
c-file-style: "gnu"
|
||||||
|
End:
|
||||||
|
*/
|
34
libguile/syntax.h
Normal file
34
libguile/syntax.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef SCM_SYNTAX_H
|
||||||
|
#define SCM_SYNTAX_H
|
||||||
|
|
||||||
|
/* Copyright (C) 2017 Free Software Foundation, Inc.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 3 of
|
||||||
|
* the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
|
* 02110-1301 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "libguile/__scm.h"
|
||||||
|
|
||||||
|
SCM_INTERNAL SCM scm_syntax_p (SCM obj);
|
||||||
|
SCM_INTERNAL SCM scm_make_syntax (SCM exp, SCM wrap, SCM module);
|
||||||
|
SCM_INTERNAL SCM scm_syntax_expression (SCM obj);
|
||||||
|
SCM_INTERNAL SCM scm_syntax_wrap (SCM obj);
|
||||||
|
SCM_INTERNAL SCM scm_syntax_module (SCM obj);
|
||||||
|
|
||||||
|
SCM_INTERNAL void scm_i_syntax_print (SCM obj, SCM port,
|
||||||
|
scm_print_state *pstate);
|
||||||
|
SCM_INTERNAL void scm_init_syntax (void);
|
||||||
|
|
||||||
|
#endif /* SCM_SYNTAX_H */
|
|
@ -416,7 +416,7 @@ typedef union SCM { struct { scm_t_bits n; } n; } SCM;
|
||||||
#define scm_tc7_frame 0x2f
|
#define scm_tc7_frame 0x2f
|
||||||
#define scm_tc7_keyword 0x35
|
#define scm_tc7_keyword 0x35
|
||||||
#define scm_tc7_atomic_box 0x37
|
#define scm_tc7_atomic_box 0x37
|
||||||
#define scm_tc7_unused_3d 0x3d
|
#define scm_tc7_syntax 0x3d
|
||||||
#define scm_tc7_unused_3f 0x3f
|
#define scm_tc7_unused_3f 0x3f
|
||||||
#define scm_tc7_program 0x45
|
#define scm_tc7_program 0x45
|
||||||
#define scm_tc7_vm_cont 0x47
|
#define scm_tc7_vm_cont 0x47
|
||||||
|
|
|
@ -4087,10 +4087,15 @@ when none is available, reading FILE-NAME with READER."
|
||||||
(module-export! to ids))
|
(module-export! to ids))
|
||||||
|
|
||||||
(steal-bindings! the-root-module (resolve-module '(system syntax internal))
|
(steal-bindings! the-root-module (resolve-module '(system syntax internal))
|
||||||
'(syntax-local-binding
|
'(syntax?
|
||||||
|
syntax-local-binding
|
||||||
%syntax-module
|
%syntax-module
|
||||||
syntax-locally-bound-identifiers
|
syntax-locally-bound-identifiers
|
||||||
syntax-session-id)))
|
syntax-session-id
|
||||||
|
make-syntax
|
||||||
|
syntax-expression
|
||||||
|
syntax-wrap
|
||||||
|
syntax-module)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,7 @@
|
||||||
#:use-module (language cps intset)
|
#:use-module (language cps intset)
|
||||||
#:use-module (rnrs bytevectors)
|
#:use-module (rnrs bytevectors)
|
||||||
#:use-module (srfi srfi-11)
|
#:use-module (srfi srfi-11)
|
||||||
|
#:use-module ((system syntax internal) #:select (syntax?))
|
||||||
#:export (;; Specific types.
|
#:export (;; Specific types.
|
||||||
&exact-integer
|
&exact-integer
|
||||||
&flonum
|
&flonum
|
||||||
|
@ -112,7 +113,7 @@
|
||||||
&bytevector
|
&bytevector
|
||||||
&bitvector
|
&bitvector
|
||||||
&array
|
&array
|
||||||
&hash-table
|
&syntax
|
||||||
|
|
||||||
;; Union types.
|
;; Union types.
|
||||||
&number &real
|
&number &real
|
||||||
|
@ -169,7 +170,7 @@
|
||||||
&bytevector
|
&bytevector
|
||||||
&bitvector
|
&bitvector
|
||||||
&array
|
&array
|
||||||
&hash-table
|
&syntax
|
||||||
|
|
||||||
&f64
|
&f64
|
||||||
&u64
|
&u64
|
||||||
|
@ -348,6 +349,7 @@ minimum, and maximum."
|
||||||
((bytevector? val) (return &bytevector (bytevector-length val)))
|
((bytevector? val) (return &bytevector (bytevector-length val)))
|
||||||
((bitvector? val) (return &bitvector (bitvector-length val)))
|
((bitvector? val) (return &bitvector (bitvector-length val)))
|
||||||
((array? val) (return &array (array-rank val)))
|
((array? val) (return &array (array-rank val)))
|
||||||
|
((syntax? val) (return &syntax 0))
|
||||||
((not (variable-bound? (make-variable val))) (return &unbound #f))
|
((not (variable-bound? (make-variable val))) (return &unbound #f))
|
||||||
|
|
||||||
(else (error "unhandled constant" val))))
|
(else (error "unhandled constant" val))))
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
<boolean> <char> <list> <pair> <null> <string> <symbol>
|
<boolean> <char> <list> <pair> <null> <string> <symbol>
|
||||||
<vector> <bytevector> <uvec> <foreign> <hashtable>
|
<vector> <bytevector> <uvec> <foreign> <hashtable>
|
||||||
<fluid> <dynamic-state> <frame> <vm> <vm-continuation>
|
<fluid> <dynamic-state> <frame> <vm> <vm-continuation>
|
||||||
<keyword> <atomic-box>
|
<keyword> <syntax> <atomic-box>
|
||||||
|
|
||||||
;; Numbers.
|
;; Numbers.
|
||||||
<number> <complex> <real> <integer> <fraction>
|
<number> <complex> <real> <integer> <fraction>
|
||||||
|
@ -1009,6 +1009,7 @@ slots as we go."
|
||||||
(define-standard-class <integer> (<real>))
|
(define-standard-class <integer> (<real>))
|
||||||
(define-standard-class <fraction> (<real>))
|
(define-standard-class <fraction> (<real>))
|
||||||
(define-standard-class <keyword> (<top>))
|
(define-standard-class <keyword> (<top>))
|
||||||
|
(define-standard-class <syntax> (<top>))
|
||||||
(define-standard-class <atomic-box> (<top>))
|
(define-standard-class <atomic-box> (<top>))
|
||||||
(define-standard-class <unknown> (<top>))
|
(define-standard-class <unknown> (<top>))
|
||||||
(define-standard-class <procedure> (<applicable>)
|
(define-standard-class <procedure> (<applicable>)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#:use-module (srfi srfi-11)
|
#:use-module (srfi srfi-11)
|
||||||
#:use-module (srfi srfi-26)
|
#:use-module (srfi srfi-26)
|
||||||
#:use-module (srfi srfi-60)
|
#:use-module (srfi srfi-60)
|
||||||
|
#:use-module (system syntax internal)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
#:use-module (ice-9 iconv)
|
#:use-module (ice-9 iconv)
|
||||||
#:use-module (ice-9 format)
|
#:use-module (ice-9 format)
|
||||||
|
@ -254,6 +255,7 @@ the matching bits, possibly with bitwise operations to extract it from BITS."
|
||||||
(define %tc7-dynamic-state #x2d)
|
(define %tc7-dynamic-state #x2d)
|
||||||
(define %tc7-frame #x2f)
|
(define %tc7-frame #x2f)
|
||||||
(define %tc7-keyword #x35)
|
(define %tc7-keyword #x35)
|
||||||
|
(define %tc7-syntax #x3d)
|
||||||
(define %tc7-program #x45)
|
(define %tc7-program #x45)
|
||||||
(define %tc7-vm-continuation #x47)
|
(define %tc7-vm-continuation #x47)
|
||||||
(define %tc7-bytevector #x4d)
|
(define %tc7-bytevector #x4d)
|
||||||
|
@ -464,6 +466,10 @@ using BACKEND."
|
||||||
(make-pointer address))
|
(make-pointer address))
|
||||||
(((_ & #x7f = %tc7-keyword) symbol)
|
(((_ & #x7f = %tc7-keyword) symbol)
|
||||||
(symbol->keyword (cell->object symbol backend)))
|
(symbol->keyword (cell->object symbol backend)))
|
||||||
|
(((_ & #x7f = %tc7-syntax) expression wrap module)
|
||||||
|
(make-syntax (cell->object expression backend)
|
||||||
|
(cell->object wrap backend)
|
||||||
|
(cell->object module backend)))
|
||||||
(((_ & #x7f = %tc7-vm-continuation))
|
(((_ & #x7f = %tc7-vm-continuation))
|
||||||
(inferior-object 'vm-continuation address))
|
(inferior-object 'vm-continuation address))
|
||||||
(((_ & #x7f = %tc7-weak-set))
|
(((_ & #x7f = %tc7-weak-set))
|
||||||
|
|
|
@ -20,7 +20,14 @@
|
||||||
|
|
||||||
(define-module (system syntax)
|
(define-module (system syntax)
|
||||||
#:use-module (system syntax internal)
|
#:use-module (system syntax internal)
|
||||||
#:re-export (syntax-local-binding
|
#:re-export (syntax?
|
||||||
|
syntax-local-binding
|
||||||
(%syntax-module . syntax-module)
|
(%syntax-module . syntax-module)
|
||||||
syntax-locally-bound-identifiers
|
syntax-locally-bound-identifiers
|
||||||
syntax-session-id))
|
syntax-session-id))
|
||||||
|
|
||||||
|
;; Used by syntax.c.
|
||||||
|
(define (print-syntax obj port)
|
||||||
|
;; FIXME: Use syntax->datum instad of syntax-expression, when
|
||||||
|
;; syntax->datum can operate on new syntax objects.
|
||||||
|
(format port "#<syntax ~s>" (syntax-expression obj)))
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#:use-module (system vm dwarf)
|
#:use-module (system vm dwarf)
|
||||||
#:use-module (system vm elf)
|
#:use-module (system vm elf)
|
||||||
#:use-module (system vm linker)
|
#:use-module (system vm linker)
|
||||||
|
#:use-module (system syntax internal)
|
||||||
#:use-module (language bytecode)
|
#:use-module (language bytecode)
|
||||||
#:use-module (rnrs bytevectors)
|
#:use-module (rnrs bytevectors)
|
||||||
#:use-module (ice-9 binary-ports)
|
#:use-module (ice-9 binary-ports)
|
||||||
|
@ -1017,7 +1018,8 @@ immediate, and @code{#f} otherwise."
|
||||||
"Return @code{#t} if a non-immediate constant can be allocated
|
"Return @code{#t} if a non-immediate constant can be allocated
|
||||||
statically, and @code{#f} if it would need some kind of runtime
|
statically, and @code{#f} if it would need some kind of runtime
|
||||||
allocation."
|
allocation."
|
||||||
(or (pair? x) (string? x) (stringbuf? x) (static-procedure? x) (array? x)))
|
(or (pair? x) (string? x) (stringbuf? x) (static-procedure? x)
|
||||||
|
(array? x) (syntax? x)))
|
||||||
|
|
||||||
(define (intern-constant asm obj)
|
(define (intern-constant asm obj)
|
||||||
"Add an object to the constant table, and return a label that can be
|
"Add an object to the constant table, and return a label that can be
|
||||||
|
@ -1045,6 +1047,10 @@ table, its existing label is used directly."
|
||||||
(append-reverse (field label (1+ i) (vector-ref obj i))
|
(append-reverse (field label (1+ i) (vector-ref obj i))
|
||||||
inits))
|
inits))
|
||||||
(reverse inits))))
|
(reverse inits))))
|
||||||
|
((syntax? obj)
|
||||||
|
(append (field label 1 (syntax-expression obj))
|
||||||
|
(field label 2 (syntax-wrap obj))
|
||||||
|
(field label 3 (syntax-module obj))))
|
||||||
((stringbuf? obj) '())
|
((stringbuf? obj) '())
|
||||||
((static-procedure? obj)
|
((static-procedure? obj)
|
||||||
`((static-patch! ,label 1 ,(static-procedure-code obj))))
|
`((static-patch! ,label 1 ,(static-procedure-code obj))))
|
||||||
|
@ -1181,6 +1187,7 @@ returned instead."
|
||||||
;(define-tc7-macro-assembler br-if-dynamic-state 45)
|
;(define-tc7-macro-assembler br-if-dynamic-state 45)
|
||||||
;(define-tc7-macro-assembler br-if-frame 47)
|
;(define-tc7-macro-assembler br-if-frame 47)
|
||||||
(define-tc7-macro-assembler br-if-keyword #x35)
|
(define-tc7-macro-assembler br-if-keyword #x35)
|
||||||
|
;(define-tc7-macro-assembler br-if-syntax #x3d)
|
||||||
;(define-tc7-macro-assembler br-if-vm 55)
|
;(define-tc7-macro-assembler br-if-vm 55)
|
||||||
;(define-tc7-macro-assembler br-if-vm-cont 71)
|
;(define-tc7-macro-assembler br-if-vm-cont 71)
|
||||||
;(define-tc7-macro-assembler br-if-rtl-program 69)
|
;(define-tc7-macro-assembler br-if-rtl-program 69)
|
||||||
|
@ -1391,6 +1398,7 @@ should be .data or .rodata), and return the resulting linker object.
|
||||||
(define tc7-narrow-stringbuf tc7-stringbuf)
|
(define tc7-narrow-stringbuf tc7-stringbuf)
|
||||||
(define tc7-wide-stringbuf (+ tc7-stringbuf stringbuf-wide-flag))
|
(define tc7-wide-stringbuf (+ tc7-stringbuf stringbuf-wide-flag))
|
||||||
(define tc7-ro-string (+ 21 #x200))
|
(define tc7-ro-string (+ 21 #x200))
|
||||||
|
(define tc7-syntax #x3d)
|
||||||
(define tc7-program 69)
|
(define tc7-program 69)
|
||||||
(define tc7-bytevector 77)
|
(define tc7-bytevector 77)
|
||||||
(define tc7-bitvector 95)
|
(define tc7-bitvector 95)
|
||||||
|
@ -1415,6 +1423,8 @@ should be .data or .rodata), and return the resulting linker object.
|
||||||
(* 2 word-size))
|
(* 2 word-size))
|
||||||
((simple-vector? x)
|
((simple-vector? x)
|
||||||
(* (1+ (vector-length x)) word-size))
|
(* (1+ (vector-length x)) word-size))
|
||||||
|
((syntax? x)
|
||||||
|
(* 4 word-size))
|
||||||
((simple-uniform-vector? x)
|
((simple-uniform-vector? x)
|
||||||
(* 4 word-size))
|
(* 4 word-size))
|
||||||
((uniform-vector-backing-store? x)
|
((uniform-vector-backing-store? x)
|
||||||
|
@ -1519,6 +1529,18 @@ should be .data or .rodata), and return the resulting linker object.
|
||||||
((keyword? obj)
|
((keyword? obj)
|
||||||
(write-placeholder asm buf pos))
|
(write-placeholder asm buf pos))
|
||||||
|
|
||||||
|
((syntax? obj)
|
||||||
|
(case word-size
|
||||||
|
((4) (bytevector-u32-set! buf pos tc7-syntax endianness))
|
||||||
|
((8) (bytevector-u64-set! buf pos tc7-syntax endianness))
|
||||||
|
(else (error "bad word size")))
|
||||||
|
(write-constant-reference buf (+ pos (* 1 word-size))
|
||||||
|
(syntax-expression obj))
|
||||||
|
(write-constant-reference buf (+ pos (* 2 word-size))
|
||||||
|
(syntax-wrap obj))
|
||||||
|
(write-constant-reference buf (+ pos (* 3 word-size))
|
||||||
|
(syntax-module obj)))
|
||||||
|
|
||||||
((number? obj)
|
((number? obj)
|
||||||
(write-placeholder asm buf pos))
|
(write-placeholder asm buf pos))
|
||||||
|
|
||||||
|
|
|
@ -210,6 +210,7 @@ address of that offset."
|
||||||
((13) "vector?")
|
((13) "vector?")
|
||||||
((15) "string?")
|
((15) "string?")
|
||||||
((53) "keyword?")
|
((53) "keyword?")
|
||||||
|
((#x3d) "syntax?")
|
||||||
((77) "bytevector?")
|
((77) "bytevector?")
|
||||||
((95) "bitvector?")
|
((95) "bitvector?")
|
||||||
(else (number->string tc7)))))
|
(else (number->string tc7)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue