(if (null? expressions)
(values '() '())
(let ((rest (lambda () (sort-expressions (cdr expressions)))))
- (if (block-declaration? (car expressions))
+ (if (scode-block-declaration? (car expressions))
(rest)
(receive (definitions others) (rest)
(if (scode-definition? (car expressions))
(let ((body*
(if (null? declarations)
body
- (make-scode-sequence (list (make-block-declaration declarations)
+ (make-scode-sequence (list (make-scode-block-declaration declarations)
body)))))
(cond ((and (< (length required) 256)
(< (length optional) 256)
(let ((actions
(and (scode-sequence? body)
(scode-sequence-actions body))))
- (if (and actions (block-declaration? (car actions)))
+ (if (and actions (scode-block-declaration? (car actions)))
(receiver name required optional rest auxiliary
- (block-declaration-text (car actions))
+ (scode-block-declaration-text (car actions))
(make-scode-sequence (cdr actions)))
(receiver name required optional rest auxiliary '() body))))))
(define lambda-unwrap-body!)
(define lambda-immediate-body)
(define lambda-names-vector)
-
-(define-structure (block-declaration
- (type vector)
- (named ((ucode-primitive string->symbol)
- "#[Block Declaration]")))
- (text #f read-only #t))
\f
;;;; Simple Lambda
(define (slambda-arity slambda offset)
(files "lambda")
(parent (runtime))
(export ()
- block-declaration-text
- block-declaration?
- make-block-declaration
make-scode-lambda
scode-lambda-body
scode-lambda-bound
make-scode-absolute-reference
make-scode-access
make-scode-assignment
+ make-scode-block-declaration
make-scode-combination
make-scode-comment
make-scode-conditional
scode-assignment-name
scode-assignment-value
scode-assignment?
+ scode-block-declaration-text
+ scode-block-declaration?
scode-combination-operands
scode-combination-operator
scode-combination?
declarations
(cons-sequence (make-scode-assignment name value)
body)))))
- ((block-declaration? expression)
+ ((scode-block-declaration? expression)
(lambda (names declarations body)
(receiver names
- (append (block-declaration-text expression)
+ (append (scode-block-declaration-text expression)
declarations)
body)))
(else
(if (null? declarations)
body*
- (&typed-pair-cons
- sequence-type
- (make-block-declaration declarations)
- body*))))
+ (&typed-pair-cons sequence-type
+ (make-scode-block-declaration declarations)
+ body*))))
\f
;;;; Open Block
(define (scode-disjunction-alternative disjunction)
(guarantee scode-disjunction? disjunction 'scode-disjunction-alternative)
(map-reference-trap (lambda () (system-pair-cdr disjunction))))
+
+;;;; Declaration
+
+(define (make-scode-block-declaration text)
+ (vector block-declaration-marker text))
+
+(define (scode-block-declaration? object)
+ (and (vector? object)
+ (fix:= 2 (vector-length object))
+ (eq? block-declaration-marker (vector-ref object 0))))
+
+(define (scode-block-declaration-text declaration)
+ (guarantee scode-block-declaration? declaration 'scode-block-declaration-text)
+ (vector-ref declaration 1))
+
+(define block-declaration-marker
+ '|#[Block Declaration]|)
\f
;;;; Lambda
(scan-defines (let ((declarations (apply append declarations)))
(if (pair? declarations)
(make-scode-sequence
- (list (make-block-declaration declarations)
+ (list (make-scode-block-declaration declarations)
body))
body))
make-scode-open-block))
make-scode-open-block))))
(if (pair? declarations)
(make-scode-open-block
- (cons (make-block-declaration declarations)
+ (cons (make-scode-block-declaration declarations)
(if (pair? expressions)
expressions
(list (output/unspecific)))))
(define (unsyntax-sequence-object environment seq)
(let loop ((actions (scode-sequence-actions seq)))
- (if (and (block-declaration? (car actions))
+ (if (and (scode-block-declaration? (car actions))
(pair? (cdr actions)))
`(BEGIN
- (DECLARE ,@(block-declaration-text (car actions)))
+ (DECLARE ,@(scode-block-declaration-text (car actions)))
,@(loop (cdr actions)))
`(BEGIN
,@(unsyntax-sequence-actions environment seq)))))
(define (unsyntax-lambda-body-sequence environment body)
(if (scode-sequence? body)
(let ((actions (scode-sequence-actions body)))
- (if (and (block-declaration? (car actions))
+ (if (and (scode-block-declaration? (car actions))
(pair? (cdr actions)))
- `((DECLARE ,@(block-declaration-text (car actions)))
+ `((DECLARE ,@(scode-block-declaration-text (car actions)))
,@(unsyntax-sequence environment
(make-scode-sequence (cdr actions))))
(unsyntax-sequence environment body)))