Fix uses of unstable/struct.

This commit is contained in:
Vincent St-Amour 2015-08-19 14:02:48 -05:00
parent e5a024b02e
commit ac462be47c
12 changed files with 56 additions and 12 deletions

View File

@ -1,6 +1,6 @@
(module serialize racket/base
(require syntax/modcollapse
unstable/struct
racket/struct
racket/list
racket/flonum
racket/fixnum

View File

@ -0,0 +1,43 @@
#lang racket/base
(require (for-syntax racket/base
racket/struct-info))
(provide make)
;; get-struct-info : identifier stx -> struct-info-list
(define-for-syntax (get-struct-info id ctx)
(define (bad-struct-name x)
(raise-syntax-error #f "expected struct name" ctx x))
(unless (identifier? id)
(bad-struct-name id))
(let ([value (syntax-local-value id (lambda () #f))])
(unless (struct-info? value)
(bad-struct-name id))
(extract-struct-info value)))
;; (make struct-name field-expr ...)
;; Checks that correct number of fields given.
(define-syntax (make stx)
(syntax-case stx ()
[(make S expr ...)
(let ()
(define info (get-struct-info #'S stx))
(define constructor (list-ref info 1))
(define accessors (list-ref info 3))
(unless (identifier? #'constructor)
(raise-syntax-error #f "constructor not available for struct" stx #'S))
(unless (andmap identifier? accessors)
(raise-syntax-error #f "incomplete info for struct type" stx #'S))
(let ([num-slots (length accessors)]
[num-provided (length (syntax->list #'(expr ...)))])
(unless (= num-provided num-slots)
(raise-syntax-error
#f
(format "wrong number of arguments for struct ~s (expected ~s, got ~s)"
(syntax-e #'S)
num-slots
num-provided)
stx)))
(with-syntax ([constructor constructor])
(syntax-property #'(constructor expr ...)
'disappeared-use
#'S)))]))

View File

@ -1,6 +1,6 @@
#lang racket/base
(require unstable/struct
(for-syntax racket/base racket/struct-info unstable/struct))
(require racket/struct
(for-syntax racket/base racket/struct-info racket/struct))
(provide match ?)
(define-syntax (match stx)

View File

@ -16,7 +16,7 @@
racket/syntax
racket/stxparam
syntax/stx
unstable/struct
racket/struct
syntax/parse/private/residual ;; keep abs. path
syntax/parse/private/runtime ;; keep abs.path
syntax/parse/private/runtime-reflect) ;; keep abs. path

View File

@ -3,7 +3,7 @@
racket/contract/base
syntax/private/id-table
racket/syntax
unstable/struct)
"make.rkt")
#|
An IAttr is (make-attr identifier number boolean)

View File

@ -5,7 +5,7 @@
syntax/private/id-table
racket/syntax
syntax/parse/private/residual-ct ;; keep abs. path
unstable/struct
"make.rkt"
"minimatch.rkt"
"kws.rkt"
"rep-attrs.rkt"

View File

@ -2,7 +2,7 @@
(require syntax/parse/private/residual-ct ;; keep abs. path
"rep-attrs.rkt"
"kws.rkt"
unstable/struct
"make.rkt"
(for-syntax racket/base
syntax/stx
racket/syntax))

View File

@ -6,12 +6,13 @@
syntax/parse/private/runtime)
racket/list
racket/contract/base
"make.rkt"
"minimatch.rkt"
syntax/private/id-table
syntax/stx
syntax/keyword
racket/syntax
unstable/struct
racket/struct
"txlift.rkt"
"rep-attrs.rkt"
"rep-data.rkt"

View File

@ -2,7 +2,7 @@
(require racket/list
racket/format
syntax/stx
unstable/struct
racket/struct
unstable/error
syntax/srcloc
"minimatch.rkt"

View File

@ -1,6 +1,6 @@
#lang racket/base
(require "../stx.rkt"
unstable/struct)
racket/struct)
(provide template-map-apply)

View File

@ -1,5 +1,5 @@
#lang racket/base
(require unstable/struct)
(require racket/struct)
(provide strip-context
replace-context)

View File

@ -1,6 +1,6 @@
#lang racket/base
(require "stx.rkt"
unstable/struct
racket/struct
(for-template racket/base
"private/template-runtime.rkt"))