Remove last uses of stxclass.

svn: r15976
This commit is contained in:
Sam Tobin-Hochstadt 2009-09-11 17:49:50 +00:00
parent 974cc561bb
commit 5fc019ba6c
3 changed files with 22 additions and 32 deletions

View File

@ -26,7 +26,7 @@ This file defines two sorts of primitives. All of them are provided into any mod
(require (except-in "../utils/utils.ss" extend)) (require (except-in "../utils/utils.ss" extend))
(require (for-syntax (require (for-syntax
stxclass syntax/parse
stxclass/util stxclass/util
scheme/base scheme/base
(rep type-rep) (rep type-rep)
@ -64,28 +64,31 @@ This file defines two sorts of primitives. All of them are provided into any mod
#:attributes (nm ty) #:attributes (nm ty)
(pattern [nm:opt-rename ty])) (pattern [nm:opt-rename ty]))
(define-syntax-class struct-clause (define-syntax-class struct-clause
#:literals (struct) ;#:literals (struct)
#:attributes (nm (body 1)) #:attributes (nm (body 1))
(pattern [struct nm:opt-rename (body ...)])) (pattern [struct nm:opt-rename (body ...)]
#:fail-unless (eq? 'struct (syntax-e #'struct)) #f))
(define-syntax-class opaque-clause (define-syntax-class opaque-clause
#:literals (opaque) ;#:literals (opaque)
#:attributes (ty pred opt) #:attributes (ty pred opt)
(pattern [opaque ty:id pred:id] (pattern [opaque ty:id pred:id]
#:fail-unless (eq? 'opaque (syntax-e #'opaque)) #f
#:with opt #'()) #:with opt #'())
(pattern [opaque ty:id pred:id #:name-exists] (pattern [opaque ty:id pred:id #:name-exists]
#:fail-unless (eq? 'opaque (syntax-e #'opaque)) #f
#:with opt #'(#:name-exists))) #:with opt #'(#:name-exists)))
(syntax-parse stx (syntax-parse stx
[(_ lib (~or [sc:simple-clause] [strc:struct-clause] [oc:opaque-clause]) ...) [(_ lib (~or sc:simple-clause strc:struct-clause oc:opaque-clause) ...)
#'(begin #'(begin
(require/opaque-type oc.ty oc.pred lib . oc.opt) ... (require/opaque-type oc.ty oc.pred lib . oc.opt) ...
(require/typed sc.nm sc.ty lib) ... (require/typed sc.nm sc.ty lib) ...
(require-typed-struct strc.nm (strc.body ...) lib) ...)] (require-typed-struct strc.nm (strc.body ...) lib) ...)]
[(_ nm:opt-rename ty lib (~or [#:struct-maker parent] #:opt) ...) [(_ nm:opt-rename ty lib (~optional [~seq #:struct-maker parent]) ...)
(with-syntax ([cnt* (generate-temporary #'nm.nm)] (with-syntax ([cnt* (generate-temporary #'nm.nm)]
[sm (if #'parent [sm (if (attribute parent)
#'(#:struct-maker parent) #'(#:struct-maker parent)
#'())]) #'())])
(let ([prop-name (if #'parent (let ([prop-name (if (attribute parent)
'typechecker:contract-def/maker 'typechecker:contract-def/maker
'typechecker:contract-def)]) 'typechecker:contract-def)])
(quasisyntax/loc stx (quasisyntax/loc stx
@ -101,14 +104,14 @@ This file defines two sorts of primitives. All of them are provided into any mod
(define-syntax-class name-exists-kw (define-syntax-class name-exists-kw
(pattern #:name-exists)) (pattern #:name-exists))
(syntax-parse stx (syntax-parse stx
[(_ ty:id pred:id lib (~or [ne:name-exists-kw] #:opt) ...) [(_ ty:id pred:id lib (~optional ne:name-exists-kw) ...)
(register-type-name #'ty (make-Opaque #'pred (syntax-local-certifier))) (register-type-name #'ty (make-Opaque #'pred (syntax-local-certifier)))
(quasisyntax/loc stx (quasisyntax/loc stx
(begin (begin
#,(syntax-property #'(define pred-cnt (any/c . c-> . boolean?)) #,(syntax-property #'(define pred-cnt (any/c . c-> . boolean?))
'typechecker:ignore #t) 'typechecker:ignore #t)
#,(internal #'(require/typed-internal pred (Any -> Boolean : (Opaque pred)))) #,(internal #'(require/typed-internal pred (Any -> Boolean : (Opaque pred))))
#,(if #'ne #,(if (attribute ne)
(internal (syntax/loc stx (define-type-alias-internal ty (Opaque pred)))) (internal (syntax/loc stx (define-type-alias-internal ty (Opaque pred))))
(syntax/loc stx (define-type-alias ty (Opaque pred)))) (syntax/loc stx (define-type-alias ty (Opaque pred))))
#,(syntax-property #'(require/contract pred pred-cnt lib) #,(syntax-property #'(require/contract pred pred-cnt lib)

View File

@ -8,11 +8,11 @@
(types utils convenience union subtype) (types utils convenience union subtype)
(private-in parse-type type-annotation) (private-in parse-type type-annotation)
(rep type-rep) (rep type-rep)
(except-in (utils tc-utils stxclass-util) define-pred-stxclass 3d atom byte-pregexp byte-regexp regexp bytes) (except-in (utils tc-utils stxclass-util))
(env lexical-env) (env lexical-env)
(only-in (env type-environments) lookup current-tvars extend-env) (only-in (env type-environments) lookup current-tvars extend-env)
scheme/private/class-internal scheme/private/class-internal
(except-in stxclass id) (except-in syntax/parse id)
(only-in srfi/1 split-at)) (only-in srfi/1 split-at))
(require (for-template scheme/base scheme/private/class-internal)) (require (for-template scheme/base scheme/private/class-internal))
@ -20,36 +20,23 @@
(import tc-if^ tc-lambda^ tc-app^ tc-let^ check-subforms^) (import tc-if^ tc-lambda^ tc-app^ tc-let^ check-subforms^)
(export tc-expr^) (export tc-expr^)
(define-syntax-class (3d pred)
(pattern s
#:with datum (syntax-e #'s)
#:when (pred #'datum)))
(define-pred-stxclass atom atom?)
(define-pred-stxclass byte-pregexp byte-pregexp?)
(define-pred-stxclass byte-regexp byte-regexp?)
(define-pred-stxclass regexp regexp?)
(define-pred-stxclass bytes bytes?)
;; return the type of a literal value ;; return the type of a literal value
;; scheme-value -> type ;; scheme-value -> type
(define (tc-literal v-stx [expected #f]) (define (tc-literal v-stx [expected #f])
(define-syntax-class exp (define-syntax-class exp
(pattern i (pattern i
#:when expected #:fail-unless expected #f
#:with datum (syntax-e #'i) #:with datum (syntax-e #'i)
#:when (subtype (-val #'datum) expected))) #:fail-unless (subtype (-val #'datum) expected) #f))
(syntax-parse v-stx (syntax-parse v-stx
[i:exp expected] [i:exp expected]
[i:boolean (-val #'i.datum)] [i:boolean (-val (syntax-e #'i))]
[i:identifier (-val #'i.datum)] [i:identifier (-val (syntax-e #'i))]
[i:exact-integer -Integer] [i:exact-integer -Integer]
[i:number -Number] [i:number -Number]
[i:str -String] [i:str -String]
[i:char -Char] [i:char -Char]
[i:keyword (-val #'i.datum)] [i:keyword (-val (syntax-e #'i))]
[i:bytes -Bytes] [i:bytes -Bytes]
[i:byte-pregexp -Byte-PRegexp] [i:byte-pregexp -Byte-PRegexp]
[i:byte-regexp -Byte-Regexp] [i:byte-regexp -Byte-Regexp]
@ -57,7 +44,7 @@
[(i ...) [(i ...)
(-Tuple (map tc-literal (syntax->list #'(i ...))))] (-Tuple (map tc-literal (syntax->list #'(i ...))))]
[i #:declare i (3d vector?) [i #:declare i (3d vector?)
(make-Vector (apply Un (map tc-literal (vector->list #'i.datum))))] (make-Vector (apply Un (map tc-literal (vector->list (syntax-e #'i)))))]
[_ Univ])) [_ Univ]))

View File

@ -4,7 +4,7 @@
(require (private base-types) (require (private base-types)
(for-syntax (for-syntax
(except-in stxclass id) (except-in syntax/parse id)
scheme/base scheme/base
(private type-contract) (private type-contract)
(types utils convenience) (types utils convenience)