2009-06-08 22:43:28 +02:00
|
|
|
|
;;; open-coding primitive procedures
|
2009-05-12 22:29:34 +02:00
|
|
|
|
|
2012-01-26 12:02:42 +01:00
|
|
|
|
;; Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
|
2009-05-12 22:29:34 +02:00
|
|
|
|
|
2009-06-17 00:22:09 +01:00
|
|
|
|
;;;; 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
|
2009-05-12 22:29:34 +02:00
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
2009-05-22 16:07:41 +02:00
|
|
|
|
(define-module (language tree-il primitives)
|
2009-08-05 11:55:42 +02:00
|
|
|
|
#:use-module (system base pmatch)
|
2010-06-01 13:26:11 +02:00
|
|
|
|
#:use-module (rnrs bytevectors)
|
2009-05-12 22:29:34 +02:00
|
|
|
|
#:use-module (system base syntax)
|
|
|
|
|
|
#:use-module (language tree-il)
|
2010-01-07 23:40:59 +01:00
|
|
|
|
#:use-module (srfi srfi-4)
|
2009-05-12 22:29:34 +02:00
|
|
|
|
#:use-module (srfi srfi-16)
|
2009-05-22 16:07:41 +02:00
|
|
|
|
#:export (resolve-primitives! add-interesting-primitive!
|
2010-06-17 11:58:31 +02:00
|
|
|
|
expand-primitives!
|
2011-09-09 00:05:34 +02:00
|
|
|
|
effect-free-primitive? effect+exception-free-primitive?
|
2011-10-10 13:23:26 +02:00
|
|
|
|
constructor-primitive? accessor-primitive?
|
|
|
|
|
|
singly-valued-primitive?))
|
2009-05-22 16:07:41 +02:00
|
|
|
|
|
|
|
|
|
|
(define *interesting-primitive-names*
|
|
|
|
|
|
'(apply @apply
|
|
|
|
|
|
call-with-values @call-with-values
|
|
|
|
|
|
call-with-current-continuation @call-with-current-continuation
|
|
|
|
|
|
call/cc
|
2010-01-31 20:30:46 +01:00
|
|
|
|
dynamic-wind
|
2010-02-16 23:01:09 +01:00
|
|
|
|
@dynamic-wind
|
2009-05-22 16:07:41 +02:00
|
|
|
|
values
|
|
|
|
|
|
eq? eqv? equal?
|
2009-12-11 12:20:55 +01:00
|
|
|
|
memq memv
|
2009-05-22 16:07:41 +02:00
|
|
|
|
= < > <= >= zero?
|
|
|
|
|
|
+ * - / 1- 1+ quotient remainder modulo
|
2009-11-06 13:13:39 +01:00
|
|
|
|
ash logand logior logxor
|
2009-05-22 16:07:41 +02:00
|
|
|
|
not
|
2011-10-10 20:19:07 +02:00
|
|
|
|
pair? null? list? symbol? vector? string? struct?
|
|
|
|
|
|
acons cons cons*
|
2009-05-22 16:07:41 +02:00
|
|
|
|
|
|
|
|
|
|
list vector
|
|
|
|
|
|
|
|
|
|
|
|
car cdr
|
|
|
|
|
|
set-car! set-cdr!
|
|
|
|
|
|
|
|
|
|
|
|
caar cadr cdar cddr
|
|
|
|
|
|
|
|
|
|
|
|
caaar caadr cadar caddr cdaar cdadr cddar cdddr
|
|
|
|
|
|
|
|
|
|
|
|
caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr
|
2009-06-26 00:15:37 +02:00
|
|
|
|
cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr
|
|
|
|
|
|
|
2009-06-26 12:41:34 +02:00
|
|
|
|
vector-ref vector-set!
|
2009-11-30 22:16:59 +01:00
|
|
|
|
variable-ref variable-set!
|
2010-01-27 21:48:06 +01:00
|
|
|
|
variable-bound?
|
2009-06-26 12:41:34 +02:00
|
|
|
|
|
2010-02-19 11:50:51 +01:00
|
|
|
|
fluid-ref fluid-set!
|
|
|
|
|
|
|
prompt, abort -> call-with-prompt, abort-to-prompt
* module/ice-9/boot-9.scm (default-prompt-tag, make-prompt-tag): New
functions.
(call-with-prompt, abort-to-prompt): Rename from `prompt' and `abort',
respectively. These names are more clear, and allow `prompt' and
`abort' to have more convenient, less general bindings.
(default-throw-handler, custom-throw-handler, catch, %start-stack):
Adapt callers.
* module/ice-9/control.scm: Adapt re-export list.
(control): Remove binding, until we're sure that it is Sitaram's
control.
(abort): New binding, aborts to the nearest prompt with the default
tag.
(%): Use call-with-prompt.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
(*interesting-primitive-names*): Adapt for prompt/abort changes.
* test-suite/tests/control.test: Take advantage of the defaults for %
and abort.
2010-03-09 22:24:25 +01:00
|
|
|
|
@prompt call-with-prompt @abort abort-to-prompt
|
2010-06-11 15:33:09 +02:00
|
|
|
|
make-prompt-tag
|
prompt as part of guile's primitive language
* libguile/control.h:
* libguile/control.c: Remove scm_atcontrol and scm_atprompt.
(scm_c_make_prompt): Remove handler arg, as the handler is inline.
(scm_abort): New primitive, exported to Scheme as `abort'. The
compiler will also recognize calls to `abort', but this is the base
case.
(scm_init_control): Remove scm_register_control, just have this
function, which adds `abort' to the `(guile)' module.
* libguile/eval.c (eval): Add SCM_M_PROMPT case.
* libguile/init.c (scm_i_init_guile): Change scm_register_control call
into a nice orderly scm_init_control call.
* libguile/memoize.h: (scm_sym_at_prompt, SCM_M_PROMPT):
* libguile/memoize.c (MAKMEMO_PROMPT, scm_m_at_prompt, unmemoize): Add
prompt support to the memoizer.
* libguile/vm-i-system.c (prompt): Fix to not expect a handler on the
stack.
* module/ice-9/boot-9.scm (prompt): Add definition in terms of @prompt.
* module/ice-9/control.scm: Simplify, and don't play with the compiler
here, now that prompt and abort are primitive.
* module/ice-9/eval.scm (primitive-eval): Add a prompt case.
* module/language/tree-il/primitives.scm
(*interesting-primitive-names*): Add @prompt and prompt.
2010-02-19 22:44:24 +01:00
|
|
|
|
|
2011-10-10 20:19:07 +02:00
|
|
|
|
string-length string-ref string-set!
|
|
|
|
|
|
|
|
|
|
|
|
struct-vtable make-struct struct-ref struct-set!
|
2009-12-11 12:44:29 +01:00
|
|
|
|
|
2009-06-26 12:41:34 +02:00
|
|
|
|
bytevector-u8-ref bytevector-u8-set!
|
|
|
|
|
|
bytevector-s8-ref bytevector-s8-set!
|
2010-01-07 23:40:59 +01:00
|
|
|
|
u8vector-ref u8vector-set! s8vector-ref s8vector-set!
|
|
|
|
|
|
|
2009-06-26 12:41:34 +02:00
|
|
|
|
bytevector-u16-ref bytevector-u16-set!
|
|
|
|
|
|
bytevector-u16-native-ref bytevector-u16-native-set!
|
|
|
|
|
|
bytevector-s16-ref bytevector-s16-set!
|
|
|
|
|
|
bytevector-s16-native-ref bytevector-s16-native-set!
|
2010-01-07 23:40:59 +01:00
|
|
|
|
u16vector-ref u16vector-set! s16vector-ref s16vector-set!
|
2009-06-26 12:41:34 +02:00
|
|
|
|
|
|
|
|
|
|
bytevector-u32-ref bytevector-u32-set!
|
|
|
|
|
|
bytevector-u32-native-ref bytevector-u32-native-set!
|
|
|
|
|
|
bytevector-s32-ref bytevector-s32-set!
|
|
|
|
|
|
bytevector-s32-native-ref bytevector-s32-native-set!
|
2010-01-07 23:40:59 +01:00
|
|
|
|
u32vector-ref u32vector-set! s32vector-ref s32vector-set!
|
2009-06-26 12:41:34 +02:00
|
|
|
|
|
|
|
|
|
|
bytevector-u64-ref bytevector-u64-set!
|
|
|
|
|
|
bytevector-u64-native-ref bytevector-u64-native-set!
|
|
|
|
|
|
bytevector-s64-ref bytevector-s64-set!
|
|
|
|
|
|
bytevector-s64-native-ref bytevector-s64-native-set!
|
2010-01-07 23:40:59 +01:00
|
|
|
|
u64vector-ref u64vector-set! s64vector-ref s64vector-set!
|
2009-06-26 12:41:34 +02:00
|
|
|
|
|
|
|
|
|
|
bytevector-ieee-single-ref bytevector-ieee-single-set!
|
|
|
|
|
|
bytevector-ieee-single-native-ref bytevector-ieee-single-native-set!
|
|
|
|
|
|
bytevector-ieee-double-ref bytevector-ieee-double-set!
|
2010-01-07 23:40:59 +01:00
|
|
|
|
bytevector-ieee-double-native-ref bytevector-ieee-double-native-set!
|
|
|
|
|
|
f32vector-ref f32vector-set! f64vector-ref f64vector-set!))
|
2009-05-22 16:07:41 +02:00
|
|
|
|
|
|
|
|
|
|
(define (add-interesting-primitive! name)
|
|
|
|
|
|
(hashq-set! *interesting-primitive-vars*
|
2009-11-28 01:19:31 +01:00
|
|
|
|
(or (module-variable (current-module) name)
|
|
|
|
|
|
(error "unbound interesting primitive" name))
|
2009-06-26 12:41:34 +02:00
|
|
|
|
name))
|
2009-05-22 16:07:41 +02:00
|
|
|
|
|
|
|
|
|
|
(define *interesting-primitive-vars* (make-hash-table))
|
|
|
|
|
|
|
|
|
|
|
|
(for-each add-interesting-primitive! *interesting-primitive-names*)
|
|
|
|
|
|
|
2011-09-09 00:05:34 +02:00
|
|
|
|
(define *primitive-constructors*
|
|
|
|
|
|
;; Primitives that return a fresh object.
|
2011-09-23 18:02:05 +02:00
|
|
|
|
'(acons cons cons* list vector make-struct make-struct/no-tail
|
2011-10-10 13:23:26 +02:00
|
|
|
|
make-prompt-tag))
|
|
|
|
|
|
|
|
|
|
|
|
(define *primitive-accessors*
|
|
|
|
|
|
;; Primitives that are pure, but whose result depends on the mutable
|
|
|
|
|
|
;; memory pointed to by their operands.
|
|
|
|
|
|
'(vector-ref
|
|
|
|
|
|
car cdr
|
|
|
|
|
|
memq memv
|
|
|
|
|
|
struct-vtable struct-ref
|
2011-10-10 20:19:07 +02:00
|
|
|
|
string-ref
|
2011-10-10 13:23:26 +02:00
|
|
|
|
bytevector-u8-ref bytevector-s8-ref
|
|
|
|
|
|
bytevector-u16-ref bytevector-u16-native-ref
|
|
|
|
|
|
bytevector-s16-ref bytevector-s16-native-ref
|
|
|
|
|
|
bytevector-u32-ref bytevector-u32-native-ref
|
|
|
|
|
|
bytevector-s32-ref bytevector-s32-native-ref
|
|
|
|
|
|
bytevector-u64-ref bytevector-u64-native-ref
|
|
|
|
|
|
bytevector-s64-ref bytevector-s64-native-ref
|
|
|
|
|
|
bytevector-ieee-single-ref bytevector-ieee-single-native-ref
|
|
|
|
|
|
bytevector-ieee-double-ref bytevector-ieee-double-native-ref))
|
2011-09-09 00:05:34 +02:00
|
|
|
|
|
2009-08-06 16:01:24 +02:00
|
|
|
|
(define *effect-free-primitives*
|
2011-09-09 00:05:34 +02:00
|
|
|
|
`(values
|
2009-08-06 16:01:24 +02:00
|
|
|
|
eq? eqv? equal?
|
|
|
|
|
|
= < > <= >= zero?
|
|
|
|
|
|
+ * - / 1- 1+ quotient remainder modulo
|
|
|
|
|
|
not
|
2011-10-10 20:19:07 +02:00
|
|
|
|
pair? null? list? symbol? vector? struct? string?
|
|
|
|
|
|
string-length
|
2011-10-10 13:23:26 +02:00
|
|
|
|
;; These all should get expanded out by expand-primitives!.
|
2009-08-06 16:01:24 +02:00
|
|
|
|
caar cadr cdar cddr
|
|
|
|
|
|
caaar caadr cadar caddr cdaar cdadr cddar cdddr
|
|
|
|
|
|
caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr
|
|
|
|
|
|
cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr
|
2011-10-10 13:23:26 +02:00
|
|
|
|
,@*primitive-constructors*
|
|
|
|
|
|
,@*primitive-accessors*))
|
2009-08-06 16:01:24 +02:00
|
|
|
|
|
2010-06-17 11:58:31 +02:00
|
|
|
|
;; Like *effect-free-primitives* above, but further restricted in that they
|
|
|
|
|
|
;; cannot raise exceptions.
|
|
|
|
|
|
(define *effect+exception-free-primitives*
|
|
|
|
|
|
'(values
|
|
|
|
|
|
eq? eqv? equal?
|
|
|
|
|
|
not
|
2011-10-10 20:19:07 +02:00
|
|
|
|
pair? null? list? symbol? vector? struct? string?
|
2011-10-10 13:23:26 +02:00
|
|
|
|
acons cons cons* list vector))
|
2009-08-06 16:01:24 +02:00
|
|
|
|
|
2011-09-21 08:53:06 +02:00
|
|
|
|
;; Primitives that only return one value.
|
|
|
|
|
|
(define *singly-valued-primitives*
|
|
|
|
|
|
'(eq? eqv? equal?
|
|
|
|
|
|
memq memv
|
|
|
|
|
|
= < > <= >= zero?
|
|
|
|
|
|
+ * - / 1- 1+ quotient remainder modulo
|
|
|
|
|
|
ash logand logior logxor
|
|
|
|
|
|
not
|
|
|
|
|
|
pair? null? list? symbol? vector? acons cons cons*
|
|
|
|
|
|
list vector
|
|
|
|
|
|
car cdr
|
|
|
|
|
|
set-car! set-cdr!
|
|
|
|
|
|
caar cadr cdar cddr
|
|
|
|
|
|
caaar caadr cadar caddr cdaar cdadr cddar cdddr
|
|
|
|
|
|
caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr
|
|
|
|
|
|
cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr
|
|
|
|
|
|
vector-ref vector-set!
|
|
|
|
|
|
variable-ref variable-set!
|
|
|
|
|
|
variable-bound?
|
|
|
|
|
|
fluid-ref fluid-set!
|
|
|
|
|
|
make-prompt-tag
|
|
|
|
|
|
struct? struct-vtable make-struct struct-ref struct-set!
|
2011-10-10 20:19:07 +02:00
|
|
|
|
string-length string-ref string-set!
|
2011-09-21 08:53:06 +02:00
|
|
|
|
bytevector-u8-ref bytevector-u8-set!
|
|
|
|
|
|
bytevector-s8-ref bytevector-s8-set!
|
|
|
|
|
|
u8vector-ref u8vector-set! s8vector-ref s8vector-set!
|
|
|
|
|
|
bytevector-u16-ref bytevector-u16-set!
|
|
|
|
|
|
bytevector-u16-native-ref bytevector-u16-native-set!
|
|
|
|
|
|
bytevector-s16-ref bytevector-s16-set!
|
|
|
|
|
|
bytevector-s16-native-ref bytevector-s16-native-set!
|
|
|
|
|
|
u16vector-ref u16vector-set! s16vector-ref s16vector-set!
|
|
|
|
|
|
bytevector-u32-ref bytevector-u32-set!
|
|
|
|
|
|
bytevector-u32-native-ref bytevector-u32-native-set!
|
|
|
|
|
|
bytevector-s32-ref bytevector-s32-set!
|
|
|
|
|
|
bytevector-s32-native-ref bytevector-s32-native-set!
|
|
|
|
|
|
u32vector-ref u32vector-set! s32vector-ref s32vector-set!
|
|
|
|
|
|
bytevector-u64-ref bytevector-u64-set!
|
|
|
|
|
|
bytevector-u64-native-ref bytevector-u64-native-set!
|
|
|
|
|
|
bytevector-s64-ref bytevector-s64-set!
|
|
|
|
|
|
bytevector-s64-native-ref bytevector-s64-native-set!
|
|
|
|
|
|
u64vector-ref u64vector-set! s64vector-ref s64vector-set!
|
|
|
|
|
|
bytevector-ieee-single-ref bytevector-ieee-single-set!
|
|
|
|
|
|
bytevector-ieee-single-native-ref bytevector-ieee-single-native-set!
|
|
|
|
|
|
bytevector-ieee-double-ref bytevector-ieee-double-set!
|
|
|
|
|
|
bytevector-ieee-double-native-ref bytevector-ieee-double-native-set!
|
|
|
|
|
|
f32vector-ref f32vector-set! f64vector-ref f64vector-set!))
|
|
|
|
|
|
|
2009-08-06 16:01:24 +02:00
|
|
|
|
(define *effect-free-primitive-table* (make-hash-table))
|
2010-06-17 11:58:31 +02:00
|
|
|
|
(define *effect+exceptions-free-primitive-table* (make-hash-table))
|
2011-09-21 08:53:06 +02:00
|
|
|
|
(define *singly-valued-primitive-table* (make-hash-table))
|
2009-08-06 16:01:24 +02:00
|
|
|
|
|
2010-06-17 11:58:31 +02:00
|
|
|
|
(for-each (lambda (x)
|
|
|
|
|
|
(hashq-set! *effect-free-primitive-table* x #t))
|
2009-08-06 16:01:24 +02:00
|
|
|
|
*effect-free-primitives*)
|
2010-06-17 11:58:31 +02:00
|
|
|
|
(for-each (lambda (x)
|
|
|
|
|
|
(hashq-set! *effect+exceptions-free-primitive-table* x #t))
|
|
|
|
|
|
*effect+exception-free-primitives*)
|
2011-09-21 08:53:06 +02:00
|
|
|
|
(for-each (lambda (x)
|
|
|
|
|
|
(hashq-set! *singly-valued-primitive-table* x #t))
|
|
|
|
|
|
*singly-valued-primitives*)
|
2009-08-06 16:01:24 +02:00
|
|
|
|
|
2011-09-09 00:05:34 +02:00
|
|
|
|
(define (constructor-primitive? prim)
|
|
|
|
|
|
(memq prim *primitive-constructors*))
|
2011-10-10 13:23:26 +02:00
|
|
|
|
(define (accessor-primitive? prim)
|
|
|
|
|
|
(memq prim *primitive-accessors*))
|
2009-08-06 16:01:24 +02:00
|
|
|
|
(define (effect-free-primitive? prim)
|
|
|
|
|
|
(hashq-ref *effect-free-primitive-table* prim))
|
2010-06-17 11:58:31 +02:00
|
|
|
|
(define (effect+exception-free-primitive? prim)
|
|
|
|
|
|
(hashq-ref *effect+exceptions-free-primitive-table* prim))
|
2011-09-21 08:53:06 +02:00
|
|
|
|
(define (singly-valued-primitive? prim)
|
|
|
|
|
|
(hashq-ref *singly-valued-primitive-table* prim))
|
2009-08-06 16:01:24 +02:00
|
|
|
|
|
2009-05-22 16:07:41 +02:00
|
|
|
|
(define (resolve-primitives! x mod)
|
|
|
|
|
|
(post-order!
|
|
|
|
|
|
(lambda (x)
|
|
|
|
|
|
(record-case x
|
|
|
|
|
|
((<toplevel-ref> src name)
|
2009-06-07 00:53:31 +02:00
|
|
|
|
(and=> (hashq-ref *interesting-primitive-vars*
|
|
|
|
|
|
(module-variable mod name))
|
|
|
|
|
|
(lambda (name) (make-primitive-ref src name))))
|
2009-05-22 16:07:41 +02:00
|
|
|
|
((<module-ref> src mod name public?)
|
|
|
|
|
|
;; for the moment, we're disabling primitive resolution for
|
|
|
|
|
|
;; public refs because resolve-interface can raise errors.
|
|
|
|
|
|
(let ((m (and (not public?) (resolve-module mod))))
|
2009-06-07 00:53:31 +02:00
|
|
|
|
(and m
|
|
|
|
|
|
(and=> (hashq-ref *interesting-primitive-vars*
|
|
|
|
|
|
(module-variable m name))
|
|
|
|
|
|
(lambda (name) (make-primitive-ref src name))))))
|
2009-05-22 16:07:41 +02:00
|
|
|
|
(else #f)))
|
|
|
|
|
|
x))
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-05-12 22:29:34 +02:00
|
|
|
|
|
|
|
|
|
|
(define *primitive-expand-table* (make-hash-table))
|
|
|
|
|
|
|
|
|
|
|
|
(define (expand-primitives! x)
|
|
|
|
|
|
(pre-order!
|
|
|
|
|
|
(lambda (x)
|
|
|
|
|
|
(record-case x
|
|
|
|
|
|
((<application> src proc args)
|
|
|
|
|
|
(and (primitive-ref? proc)
|
|
|
|
|
|
(let ((expand (hashq-ref *primitive-expand-table*
|
|
|
|
|
|
(primitive-ref-name proc))))
|
|
|
|
|
|
(and expand (apply expand src args)))))
|
|
|
|
|
|
(else #f)))
|
|
|
|
|
|
x))
|
|
|
|
|
|
|
|
|
|
|
|
;;; I actually did spend about 10 minutes trying to redo this with
|
|
|
|
|
|
;;; syntax-rules. Patches appreciated.
|
|
|
|
|
|
;;;
|
|
|
|
|
|
(define-macro (define-primitive-expander sym . clauses)
|
|
|
|
|
|
(define (inline-args args)
|
|
|
|
|
|
(let lp ((in args) (out '()))
|
|
|
|
|
|
(cond ((null? in) `(list ,@(reverse out)))
|
|
|
|
|
|
((symbol? in) `(cons* ,@(reverse out) ,in))
|
|
|
|
|
|
((pair? (car in))
|
|
|
|
|
|
(lp (cdr in)
|
2010-01-31 00:02:00 +01:00
|
|
|
|
(cons (if (eq? (caar in) 'quote)
|
|
|
|
|
|
`(make-const src ,@(cdar in))
|
|
|
|
|
|
`(make-application src (make-primitive-ref src ',(caar in))
|
|
|
|
|
|
,(inline-args (cdar in))))
|
2009-05-12 22:29:34 +02:00
|
|
|
|
out)))
|
|
|
|
|
|
((symbol? (car in))
|
|
|
|
|
|
;; assume it's locally bound
|
|
|
|
|
|
(lp (cdr in) (cons (car in) out)))
|
2010-01-31 00:02:00 +01:00
|
|
|
|
((self-evaluating? (car in))
|
2009-05-12 22:29:34 +02:00
|
|
|
|
(lp (cdr in) (cons `(make-const src ,(car in)) out)))
|
|
|
|
|
|
(else
|
|
|
|
|
|
(error "what what" (car in))))))
|
|
|
|
|
|
(define (consequent exp)
|
|
|
|
|
|
(cond
|
|
|
|
|
|
((pair? exp)
|
2009-08-05 11:55:42 +02:00
|
|
|
|
(pmatch exp
|
|
|
|
|
|
((if ,test ,then ,else)
|
|
|
|
|
|
`(if ,test
|
|
|
|
|
|
,(consequent then)
|
|
|
|
|
|
,(consequent else)))
|
|
|
|
|
|
(else
|
|
|
|
|
|
`(make-application src (make-primitive-ref src ',(car exp))
|
|
|
|
|
|
,(inline-args (cdr exp))))))
|
2009-05-12 22:29:34 +02:00
|
|
|
|
((symbol? exp)
|
|
|
|
|
|
;; assume locally bound
|
|
|
|
|
|
exp)
|
|
|
|
|
|
((number? exp)
|
|
|
|
|
|
`(make-const src ,exp))
|
2010-05-01 00:31:18 +02:00
|
|
|
|
((not exp)
|
|
|
|
|
|
;; failed match
|
|
|
|
|
|
#f)
|
2009-05-12 22:29:34 +02:00
|
|
|
|
(else (error "bad consequent yall" exp))))
|
|
|
|
|
|
`(hashq-set! *primitive-expand-table*
|
|
|
|
|
|
',sym
|
|
|
|
|
|
(case-lambda
|
|
|
|
|
|
,@(let lp ((in clauses) (out '()))
|
|
|
|
|
|
(if (null? in)
|
|
|
|
|
|
(reverse (cons '(else #f) out))
|
|
|
|
|
|
(lp (cddr in)
|
|
|
|
|
|
(cons `((src . ,(car in))
|
|
|
|
|
|
,(consequent (cadr in))) out)))))))
|
|
|
|
|
|
|
2009-08-06 17:46:38 +02:00
|
|
|
|
(define-primitive-expander zero? (x)
|
|
|
|
|
|
(= x 0))
|
|
|
|
|
|
|
2011-09-09 00:05:34 +02:00
|
|
|
|
;; FIXME: All the code that uses `const?' is redundant with `peval'.
|
|
|
|
|
|
|
2009-05-12 22:29:34 +02:00
|
|
|
|
(define-primitive-expander +
|
|
|
|
|
|
() 0
|
2011-06-17 19:30:31 +02:00
|
|
|
|
(x) (values x)
|
2009-08-05 11:55:42 +02:00
|
|
|
|
(x y) (if (and (const? y)
|
|
|
|
|
|
(let ((y (const-exp y)))
|
2009-09-06 14:13:48 +02:00
|
|
|
|
(and (number? y) (exact? y) (= y 1))))
|
2009-08-05 11:55:42 +02:00
|
|
|
|
(1+ x)
|
2009-10-16 17:56:39 +02:00
|
|
|
|
(if (and (const? y)
|
2009-12-11 14:56:49 +01:00
|
|
|
|
(let ((y (const-exp y)))
|
|
|
|
|
|
(and (number? y) (exact? y) (= y -1))))
|
2009-10-16 17:56:39 +02:00
|
|
|
|
(1- x)
|
|
|
|
|
|
(if (and (const? x)
|
|
|
|
|
|
(let ((x (const-exp x)))
|
2009-12-11 14:56:49 +01:00
|
|
|
|
(and (number? x) (exact? x) (= x 1))))
|
2009-10-16 17:56:39 +02:00
|
|
|
|
(1+ y)
|
|
|
|
|
|
(+ x y))))
|
2009-05-12 22:29:34 +02:00
|
|
|
|
(x y z . rest) (+ x (+ y z . rest)))
|
|
|
|
|
|
|
|
|
|
|
|
(define-primitive-expander *
|
|
|
|
|
|
() 1
|
2011-06-17 19:30:31 +02:00
|
|
|
|
(x) (values x)
|
2009-05-12 22:29:34 +02:00
|
|
|
|
(x y z . rest) (* x (* y z . rest)))
|
|
|
|
|
|
|
|
|
|
|
|
(define-primitive-expander -
|
|
|
|
|
|
(x) (- 0 x)
|
2009-08-05 11:55:42 +02:00
|
|
|
|
(x y) (if (and (const? y)
|
|
|
|
|
|
(let ((y (const-exp y)))
|
2009-09-06 14:13:48 +02:00
|
|
|
|
(and (number? y) (exact? y) (= y 1))))
|
2009-08-05 11:55:42 +02:00
|
|
|
|
(1- x)
|
|
|
|
|
|
(- x y))
|
2009-05-12 22:29:34 +02:00
|
|
|
|
(x y z . rest) (- x (+ y z . rest)))
|
|
|
|
|
|
|
|
|
|
|
|
(define-primitive-expander /
|
|
|
|
|
|
(x) (/ 1 x)
|
2009-05-24 13:09:01 +02:00
|
|
|
|
(x y z . rest) (/ x (* y z . rest)))
|
2009-05-12 22:29:34 +02:00
|
|
|
|
|
|
|
|
|
|
(define-primitive-expander caar (x) (car (car x)))
|
|
|
|
|
|
(define-primitive-expander cadr (x) (car (cdr x)))
|
|
|
|
|
|
(define-primitive-expander cdar (x) (cdr (car x)))
|
|
|
|
|
|
(define-primitive-expander cddr (x) (cdr (cdr x)))
|
|
|
|
|
|
(define-primitive-expander caaar (x) (car (car (car x))))
|
|
|
|
|
|
(define-primitive-expander caadr (x) (car (car (cdr x))))
|
|
|
|
|
|
(define-primitive-expander cadar (x) (car (cdr (car x))))
|
|
|
|
|
|
(define-primitive-expander caddr (x) (car (cdr (cdr x))))
|
|
|
|
|
|
(define-primitive-expander cdaar (x) (cdr (car (car x))))
|
|
|
|
|
|
(define-primitive-expander cdadr (x) (cdr (car (cdr x))))
|
|
|
|
|
|
(define-primitive-expander cddar (x) (cdr (cdr (car x))))
|
|
|
|
|
|
(define-primitive-expander cdddr (x) (cdr (cdr (cdr x))))
|
|
|
|
|
|
(define-primitive-expander caaaar (x) (car (car (car (car x)))))
|
|
|
|
|
|
(define-primitive-expander caaadr (x) (car (car (car (cdr x)))))
|
|
|
|
|
|
(define-primitive-expander caadar (x) (car (car (cdr (car x)))))
|
|
|
|
|
|
(define-primitive-expander caaddr (x) (car (car (cdr (cdr x)))))
|
|
|
|
|
|
(define-primitive-expander cadaar (x) (car (cdr (car (car x)))))
|
|
|
|
|
|
(define-primitive-expander cadadr (x) (car (cdr (car (cdr x)))))
|
|
|
|
|
|
(define-primitive-expander caddar (x) (car (cdr (cdr (car x)))))
|
|
|
|
|
|
(define-primitive-expander cadddr (x) (car (cdr (cdr (cdr x)))))
|
|
|
|
|
|
(define-primitive-expander cdaaar (x) (cdr (car (car (car x)))))
|
|
|
|
|
|
(define-primitive-expander cdaadr (x) (cdr (car (car (cdr x)))))
|
|
|
|
|
|
(define-primitive-expander cdadar (x) (cdr (car (cdr (car x)))))
|
|
|
|
|
|
(define-primitive-expander cdaddr (x) (cdr (car (cdr (cdr x)))))
|
|
|
|
|
|
(define-primitive-expander cddaar (x) (cdr (cdr (car (car x)))))
|
|
|
|
|
|
(define-primitive-expander cddadr (x) (cdr (cdr (car (cdr x)))))
|
|
|
|
|
|
(define-primitive-expander cdddar (x) (cdr (cdr (cdr (car x)))))
|
|
|
|
|
|
(define-primitive-expander cddddr (x) (cdr (cdr (cdr (cdr x)))))
|
|
|
|
|
|
|
|
|
|
|
|
(define-primitive-expander cons*
|
2011-06-17 19:30:31 +02:00
|
|
|
|
(x) (values x)
|
2009-05-12 22:29:34 +02:00
|
|
|
|
(x y) (cons x y)
|
|
|
|
|
|
(x y . rest) (cons x (cons* y . rest)))
|
|
|
|
|
|
|
2009-05-18 01:08:34 +02:00
|
|
|
|
(define-primitive-expander acons (x y z)
|
|
|
|
|
|
(cons (cons x y) z))
|
|
|
|
|
|
|
2009-11-06 11:16:54 +01:00
|
|
|
|
(define-primitive-expander apply (f a0 . args)
|
|
|
|
|
|
(@apply f a0 . args))
|
2009-05-18 01:08:34 +02:00
|
|
|
|
|
|
|
|
|
|
(define-primitive-expander call-with-values (producer consumer)
|
|
|
|
|
|
(@call-with-values producer consumer))
|
|
|
|
|
|
|
|
|
|
|
|
(define-primitive-expander call-with-current-continuation (proc)
|
|
|
|
|
|
(@call-with-current-continuation proc))
|
|
|
|
|
|
|
2009-05-21 21:13:24 +02:00
|
|
|
|
(define-primitive-expander call/cc (proc)
|
|
|
|
|
|
(@call-with-current-continuation proc))
|
|
|
|
|
|
|
2010-05-01 00:31:18 +02:00
|
|
|
|
(define-primitive-expander make-struct (vtable tail-size . args)
|
|
|
|
|
|
(if (and (const? tail-size)
|
|
|
|
|
|
(let ((n (const-exp tail-size)))
|
|
|
|
|
|
(and (number? n) (exact? n) (zero? n))))
|
|
|
|
|
|
(make-struct/no-tail vtable . args)
|
|
|
|
|
|
#f))
|
|
|
|
|
|
|
2010-01-07 23:40:59 +01:00
|
|
|
|
(define-primitive-expander u8vector-ref (vec i)
|
|
|
|
|
|
(bytevector-u8-ref vec i))
|
|
|
|
|
|
(define-primitive-expander u8vector-set! (vec i x)
|
|
|
|
|
|
(bytevector-u8-set! vec i x))
|
|
|
|
|
|
(define-primitive-expander s8vector-ref (vec i)
|
|
|
|
|
|
(bytevector-s8-ref vec i))
|
|
|
|
|
|
(define-primitive-expander s8vector-set! (vec i x)
|
|
|
|
|
|
(bytevector-s8-set! vec i x))
|
|
|
|
|
|
|
|
|
|
|
|
(define-primitive-expander u16vector-ref (vec i)
|
|
|
|
|
|
(bytevector-u16-native-ref vec (* i 2)))
|
|
|
|
|
|
(define-primitive-expander u16vector-set! (vec i x)
|
|
|
|
|
|
(bytevector-u16-native-set! vec (* i 2) x))
|
|
|
|
|
|
(define-primitive-expander s16vector-ref (vec i)
|
|
|
|
|
|
(bytevector-s16-native-ref vec (* i 2)))
|
|
|
|
|
|
(define-primitive-expander s16vector-set! (vec i x)
|
|
|
|
|
|
(bytevector-s16-native-set! vec (* i 2) x))
|
|
|
|
|
|
|
|
|
|
|
|
(define-primitive-expander u32vector-ref (vec i)
|
|
|
|
|
|
(bytevector-u32-native-ref vec (* i 4)))
|
|
|
|
|
|
(define-primitive-expander u32vector-set! (vec i x)
|
|
|
|
|
|
(bytevector-u32-native-set! vec (* i 4) x))
|
|
|
|
|
|
(define-primitive-expander s32vector-ref (vec i)
|
|
|
|
|
|
(bytevector-s32-native-ref vec (* i 4)))
|
|
|
|
|
|
(define-primitive-expander s32vector-set! (vec i x)
|
|
|
|
|
|
(bytevector-s32-native-set! vec (* i 4) x))
|
|
|
|
|
|
|
|
|
|
|
|
(define-primitive-expander u64vector-ref (vec i)
|
|
|
|
|
|
(bytevector-u64-native-ref vec (* i 8)))
|
|
|
|
|
|
(define-primitive-expander u64vector-set! (vec i x)
|
|
|
|
|
|
(bytevector-u64-native-set! vec (* i 8) x))
|
|
|
|
|
|
(define-primitive-expander s64vector-ref (vec i)
|
|
|
|
|
|
(bytevector-s64-native-ref vec (* i 8)))
|
|
|
|
|
|
(define-primitive-expander s64vector-set! (vec i x)
|
|
|
|
|
|
(bytevector-s64-native-set! vec (* i 8) x))
|
|
|
|
|
|
|
|
|
|
|
|
(define-primitive-expander f32vector-ref (vec i)
|
|
|
|
|
|
(bytevector-ieee-single-native-ref vec (* i 4)))
|
|
|
|
|
|
(define-primitive-expander f32vector-set! (vec i x)
|
|
|
|
|
|
(bytevector-ieee-single-native-set! vec (* i 4) x))
|
|
|
|
|
|
(define-primitive-expander f32vector-ref (vec i)
|
|
|
|
|
|
(bytevector-ieee-single-native-ref vec (* i 4)))
|
|
|
|
|
|
(define-primitive-expander f32vector-set! (vec i x)
|
|
|
|
|
|
(bytevector-ieee-single-native-set! vec (* i 4) x))
|
|
|
|
|
|
|
|
|
|
|
|
(define-primitive-expander f64vector-ref (vec i)
|
|
|
|
|
|
(bytevector-ieee-double-native-ref vec (* i 8)))
|
|
|
|
|
|
(define-primitive-expander f64vector-set! (vec i x)
|
|
|
|
|
|
(bytevector-ieee-double-native-set! vec (* i 8) x))
|
|
|
|
|
|
(define-primitive-expander f64vector-ref (vec i)
|
|
|
|
|
|
(bytevector-ieee-double-native-ref vec (* i 8)))
|
|
|
|
|
|
(define-primitive-expander f64vector-set! (vec i x)
|
|
|
|
|
|
(bytevector-ieee-double-native-set! vec (* i 8) x))
|
2010-01-31 20:30:46 +01:00
|
|
|
|
|
|
|
|
|
|
(hashq-set! *primitive-expand-table*
|
|
|
|
|
|
'dynamic-wind
|
|
|
|
|
|
(case-lambda
|
|
|
|
|
|
((src pre thunk post)
|
2012-01-26 12:02:42 +01:00
|
|
|
|
(let ((PRE (gensym "pre-"))
|
|
|
|
|
|
(THUNK (gensym "thunk-"))
|
|
|
|
|
|
(POST (gensym "post-")))
|
2011-11-09 16:44:59 +01:00
|
|
|
|
(make-let
|
|
|
|
|
|
src
|
|
|
|
|
|
'(pre thunk post)
|
|
|
|
|
|
(list PRE THUNK POST)
|
|
|
|
|
|
(list pre thunk post)
|
|
|
|
|
|
(make-dynwind
|
|
|
|
|
|
src
|
|
|
|
|
|
(make-lexical-ref #f 'pre PRE)
|
|
|
|
|
|
(make-application #f (make-lexical-ref #f 'thunk THUNK) '())
|
|
|
|
|
|
(make-lexical-ref #f 'post POST)))))
|
2010-01-31 20:30:46 +01:00
|
|
|
|
(else #f)))
|
2010-01-31 00:02:00 +01:00
|
|
|
|
|
2010-02-16 23:01:09 +01:00
|
|
|
|
(hashq-set! *primitive-expand-table*
|
|
|
|
|
|
'@dynamic-wind
|
|
|
|
|
|
(case-lambda
|
|
|
|
|
|
((src pre expr post)
|
2012-01-26 12:02:42 +01:00
|
|
|
|
(let ((PRE (gensym "pre-"))
|
|
|
|
|
|
(POST (gensym "post-")))
|
2010-02-16 23:01:09 +01:00
|
|
|
|
(make-let
|
|
|
|
|
|
src
|
|
|
|
|
|
'(pre post)
|
|
|
|
|
|
(list PRE POST)
|
|
|
|
|
|
(list pre post)
|
2010-02-18 17:23:49 +01:00
|
|
|
|
(make-dynwind
|
2010-02-16 23:01:09 +01:00
|
|
|
|
src
|
|
|
|
|
|
(make-lexical-ref #f 'pre PRE)
|
|
|
|
|
|
expr
|
|
|
|
|
|
(make-lexical-ref #f 'post POST)))))))
|
|
|
|
|
|
|
2010-02-19 11:50:51 +01:00
|
|
|
|
(hashq-set! *primitive-expand-table*
|
|
|
|
|
|
'fluid-ref
|
|
|
|
|
|
(case-lambda
|
|
|
|
|
|
((src fluid) (make-dynref src fluid))
|
|
|
|
|
|
(else #f)))
|
|
|
|
|
|
|
|
|
|
|
|
(hashq-set! *primitive-expand-table*
|
|
|
|
|
|
'fluid-set!
|
|
|
|
|
|
(case-lambda
|
|
|
|
|
|
((src fluid exp) (make-dynset src fluid exp))
|
|
|
|
|
|
(else #f)))
|
|
|
|
|
|
|
2010-01-31 00:02:00 +01:00
|
|
|
|
(hashq-set! *primitive-expand-table*
|
|
|
|
|
|
'@prompt
|
|
|
|
|
|
(case-lambda
|
2010-02-19 15:30:34 +01:00
|
|
|
|
((src tag exp handler)
|
|
|
|
|
|
(let ((args-sym (gensym)))
|
|
|
|
|
|
(make-prompt
|
|
|
|
|
|
src tag exp
|
|
|
|
|
|
;; If handler itself is a lambda, the inliner can do some
|
|
|
|
|
|
;; trickery here.
|
|
|
|
|
|
(make-lambda-case
|
|
|
|
|
|
(tree-il-src handler) '() #f 'args #f '() (list args-sym)
|
|
|
|
|
|
(make-application #f (make-primitive-ref #f 'apply)
|
|
|
|
|
|
(list handler
|
|
|
|
|
|
(make-lexical-ref #f 'args args-sym)))
|
|
|
|
|
|
#f))))
|
2010-01-31 00:02:00 +01:00
|
|
|
|
(else #f)))
|
|
|
|
|
|
|
|
|
|
|
|
(hashq-set! *primitive-expand-table*
|
prompt, abort -> call-with-prompt, abort-to-prompt
* module/ice-9/boot-9.scm (default-prompt-tag, make-prompt-tag): New
functions.
(call-with-prompt, abort-to-prompt): Rename from `prompt' and `abort',
respectively. These names are more clear, and allow `prompt' and
`abort' to have more convenient, less general bindings.
(default-throw-handler, custom-throw-handler, catch, %start-stack):
Adapt callers.
* module/ice-9/control.scm: Adapt re-export list.
(control): Remove binding, until we're sure that it is Sitaram's
control.
(abort): New binding, aborts to the nearest prompt with the default
tag.
(%): Use call-with-prompt.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
(*interesting-primitive-names*): Adapt for prompt/abort changes.
* test-suite/tests/control.test: Take advantage of the defaults for %
and abort.
2010-03-09 22:24:25 +01:00
|
|
|
|
'call-with-prompt
|
2010-01-31 00:02:00 +01:00
|
|
|
|
(case-lambda
|
2010-02-22 20:29:10 +01:00
|
|
|
|
((src tag thunk handler)
|
2012-03-02 13:02:19 +01:00
|
|
|
|
(let ((handler-sym (gensym))
|
|
|
|
|
|
(args-sym (gensym)))
|
|
|
|
|
|
(make-let
|
|
|
|
|
|
src '(handler) (list handler-sym) (list handler)
|
|
|
|
|
|
(make-prompt
|
|
|
|
|
|
src tag (make-application #f thunk '())
|
|
|
|
|
|
;; If handler itself is a lambda, the inliner can do some
|
|
|
|
|
|
;; trickery here.
|
|
|
|
|
|
(make-lambda-case
|
|
|
|
|
|
(tree-il-src handler) '() #f 'args #f '() (list args-sym)
|
|
|
|
|
|
(make-application
|
|
|
|
|
|
#f (make-primitive-ref #f 'apply)
|
|
|
|
|
|
(list (make-lexical-ref #f 'handler handler-sym)
|
|
|
|
|
|
(make-lexical-ref #f 'args args-sym)))
|
|
|
|
|
|
#f)))))
|
2010-01-31 00:02:00 +01:00
|
|
|
|
(else #f)))
|
2010-02-22 20:29:10 +01:00
|
|
|
|
|
abort always dispatches to VM bytecode, to detect same-invocation aborts
* libguile/control.h:
* libguile/control.c (scm_c_make_prompt): Take an extra arg, a cookie.
Continuations will be rewindable only if the abort has the same cookie
as the prompt.
(scm_at_abort): Redefine from scm_abort, and instead of taking rest
args, take the abort values as a list directly. Also, don't allow
rewinding, because we won't support rewinding the C stack with
delimited continuations.
* libguile/eval.c (eval): Adapt to scm_c_make_prompt change.
* libguile/vm-engine.c (vm_engine): Use vp->cookie to get a unique value
corresponding to this VM invocation.
* libguile/vm-i-system.c (prompt): Pass the cookie to scm_c_make_prompt.
(abort): Take an additional tail arg.
* libguile/vm.c (vm_abort): Parse out the abort tail arg. This is for
the @abort case, or the (apply abort ...) case.
(make_vm): Initialize the cookie to 0.
* libguile/vm.h (struct scm_vm): Add cookie.
* module/ice-9/boot-9.scm (abort): Define here as a trampoline to
@abort. Needed to make sure that a call to abort dispatches to a VM
opcode, so the cookie will be the same.
* module/language/tree-il.scm (<tree-il>): Add a "tail" field to
<abort>, for the (apply abort ...) case, or (@abort tag args). Should
be #<const ()> in the normal case. Add support throughout.
* module/language/tree-il/analyze.scm (analyze-lexicals): Add abort-tail
support here too.
* module/language/tree-il/compile-glil.scm (flatten): Compile the tail
argument appropriately.
* module/language/tree-il/primitives.scm (*primitive-expand-table*): Fix
@abort and abort cases to pass the tail arg to make-abort.
2010-02-22 21:53:24 +01:00
|
|
|
|
(hashq-set! *primitive-expand-table*
|
|
|
|
|
|
'@abort
|
|
|
|
|
|
(case-lambda
|
|
|
|
|
|
((src tag tail-args)
|
|
|
|
|
|
(make-abort src tag '() tail-args))
|
|
|
|
|
|
(else #f)))
|
2010-01-31 00:02:00 +01:00
|
|
|
|
(hashq-set! *primitive-expand-table*
|
prompt, abort -> call-with-prompt, abort-to-prompt
* module/ice-9/boot-9.scm (default-prompt-tag, make-prompt-tag): New
functions.
(call-with-prompt, abort-to-prompt): Rename from `prompt' and `abort',
respectively. These names are more clear, and allow `prompt' and
`abort' to have more convenient, less general bindings.
(default-throw-handler, custom-throw-handler, catch, %start-stack):
Adapt callers.
* module/ice-9/control.scm: Adapt re-export list.
(control): Remove binding, until we're sure that it is Sitaram's
control.
(abort): New binding, aborts to the nearest prompt with the default
tag.
(%): Use call-with-prompt.
* module/language/tree-il/primitives.scm (*primitive-expand-table*):
(*interesting-primitive-names*): Adapt for prompt/abort changes.
* test-suite/tests/control.test: Take advantage of the defaults for %
and abort.
2010-03-09 22:24:25 +01:00
|
|
|
|
'abort-to-prompt
|
2010-01-31 00:02:00 +01:00
|
|
|
|
(case-lambda
|
2010-02-19 10:49:24 +01:00
|
|
|
|
((src tag . args)
|
abort always dispatches to VM bytecode, to detect same-invocation aborts
* libguile/control.h:
* libguile/control.c (scm_c_make_prompt): Take an extra arg, a cookie.
Continuations will be rewindable only if the abort has the same cookie
as the prompt.
(scm_at_abort): Redefine from scm_abort, and instead of taking rest
args, take the abort values as a list directly. Also, don't allow
rewinding, because we won't support rewinding the C stack with
delimited continuations.
* libguile/eval.c (eval): Adapt to scm_c_make_prompt change.
* libguile/vm-engine.c (vm_engine): Use vp->cookie to get a unique value
corresponding to this VM invocation.
* libguile/vm-i-system.c (prompt): Pass the cookie to scm_c_make_prompt.
(abort): Take an additional tail arg.
* libguile/vm.c (vm_abort): Parse out the abort tail arg. This is for
the @abort case, or the (apply abort ...) case.
(make_vm): Initialize the cookie to 0.
* libguile/vm.h (struct scm_vm): Add cookie.
* module/ice-9/boot-9.scm (abort): Define here as a trampoline to
@abort. Needed to make sure that a call to abort dispatches to a VM
opcode, so the cookie will be the same.
* module/language/tree-il.scm (<tree-il>): Add a "tail" field to
<abort>, for the (apply abort ...) case, or (@abort tag args). Should
be #<const ()> in the normal case. Add support throughout.
* module/language/tree-il/analyze.scm (analyze-lexicals): Add abort-tail
support here too.
* module/language/tree-il/compile-glil.scm (flatten): Compile the tail
argument appropriately.
* module/language/tree-il/primitives.scm (*primitive-expand-table*): Fix
@abort and abort cases to pass the tail arg to make-abort.
2010-02-22 21:53:24 +01:00
|
|
|
|
(make-abort src tag args (make-const #f '())))
|
2010-01-31 00:02:00 +01:00
|
|
|
|
(else #f)))
|