Changeset 13504 in project


Ignore:
Timestamp:
03/05/09 08:23:17 (11 years ago)
Author:
Kon Lovett
Message:

Renaming to new canonical style.

Location:
chicken/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/chicken-primitive-object-inlines.scm

    r13488 r13504  
    4343;; Immediate
    4444
    45 (define-inline (%immediate? ?x) (##core#inline "C_immp" x))
     45(define-inline (%immediate? x) (##core#inline "C_immp" x))
    4646
    4747
    4848;; Fixnum
    4949
    50 (define-inline (%fixnum? x) (##core#inline "C_fixnump" x))
     50(define-inline (%fixnum-type? x) (##core#inline "C_fixnump" x))
     51
     52(define-inline (%fixnum? x) (and (%immediate? x) (%fixnum-type? x)))
    5153
    5254
    5355;; Character
    5456
    55 (define-inline (%char? x) (##core#inline "C_charp" x))
     57(define-inline (%char-type? x) (##core#inline "C_charp" x))
     58
     59(define-inline (%char? x) (and (%immediate? x) (%char-type? x)))
    5660
    5761
    5862;; Boolean
    5963
    60 (define-inline (%boolean? x) (##core#inline "C_booleanp" x))
     64(define-inline (%boolean-type? x) (##core#inline "C_booleanp" x))
     65
     66(define-inline (%boolean? x) (and (%immediate? x) (%boolean-type? x)))
     67
     68(define-inline (%true-value? x) (and (%boolean? x) (##core#inline "C_and" x #t)))
     69
     70(define-inline (%false-value? x) (not (%true-value? x)))
    6171
    6272
    6373;; EOF
    6474
    65 (define-inline (%eof-object? x) (##core#inline "C_eofp" x))
     75(define-inline (%eof-object-type? x) (##core#inline "C_eofp" x))
     76
     77(define-inline (%eof-object? x) (and (%immediate? x) (%eof-object-type? x)))
    6678
    6779
    6880;; Null (the end-of-list value)
    6981
    70 (define-inline (%null? x) (##core#inline "C_i_nullp" x))
     82(define-inline (%eol-object-type? x) (##core#inline "C_i_nullp" x))
     83
     84(define-inline (%eol-object? x) (and (%immediate? x) (%eol-object-type? x)))
    7185
    7286
    7387;; Undefined (void)
    7488
    75 (define-inline (%undefined? x) (##core#inline "C_undefinedp" x))
     89(define-inline (%undefined-type? x) (##core#inline "C_undefinedp" x))
     90
     91(define-inline (%undefined-value? x) (and (%immediate? x) (%undefined-type? x)))
     92
     93(define-inline (%undefined-value) (##core#undefined))
    7694
    7795
    7896;; Unbound (the unbound value, not 'is a symbol unbound')
    7997
    80 (define-inline (%unbound? x) (##core#inline "C_unboundvaluep" x))
     98(define-inline (%unbound-type? x) (##core#inline "C_unboundvaluep" x))
     99
     100(define-inline (%unbound-value? x) (and (%immediate? x) (%unbound-type? x)))
    81101
    82102
     
    86106
    87107
     108;; Special
     109
     110(define-inline (%special? x) (##core#inline "C_specialp" x))
     111
     112
     113;; Wordblock (special block)
     114
     115(define-inline (%wordblock? x) (and (%block? x) (%special? x)))
     116
     117
     118;; Byteblock
     119
     120(define-inline (%byteblock-type? x) (##core#inline "C_byteblockp" x))
     121
     122(define-inline (%byteblock? x) (and (%block? x) (%byteblock-type? x)))
     123
     124
    88125;; Vector
    89126
    90127(define-inline (%vector-type? x) (##core#inline "C_vectorp" x))
    91128
     129(define-inline (%vector? x) (and (%block? x) (%vector-type? x)))
     130
    92131
    93132;; Bytevector (isa vector so be careful; refers to how allocated, not what stored)
     
    95134(define-inline (%bytevector-type? x) (##core#inline "C_bytevectorp" x))
    96135
     136(define-inline (%bytevector? x) (and (%block? x) (%bytevector-type? x)))
     137
    97138
    98139;; Pair
    99140
    100141(define-inline (%pair-type? x) (##core#inline "C_pairp" x))
     142
     143(define-inline (%pair? x) (and (%block? x) (%pair-type? x)))
    101144
    102145
     
    111154(define-inline (%structure-type? x) (##core#inline "C_structurep" x))
    112155
     156(define-inline (%structure? x) (and (%block? x) (%structure-type? x)))
     157
    113158
    114159;; Symbol
     
    116161(define-inline (%symbol-type? x) (##core#inline "C_symbolp" x))
    117162
    118 
    119 ;; Byteblock
    120 
    121 (define-inline (%byteblock? x) (##core#inline "C_byteblockp" x))
     163(define-inline (%symbol? x) (and (%block? x) (%symbol-type? x)))
    122164
    123165
     
    126168(define-inline (%string-type? x) (##core#inline "C_stringp" x))
    127169
     170(define-inline (%string? x) (and (%block? x) (%string-type? x)))
     171
    128172
    129173;; Flonum
     
    131175(define-inline (%flonum-type? x) (##core#inline "C_flonump" x))
    132176
     177(define-inline (%flonum? x) (and (%block? x) (%flonum-type? x)))
     178
    133179
    134180;; Lambda-info
     
    136182(define-inline (%lambda-info-type? x) (##core#inline "C_lambdainfop" x))
    137183
    138 
    139 ;; Special
    140 
    141 (define-inline (%special? x) (##core#inline "C_specialp" x))
     184(define-inline (%lambda-info? x) (and (%block? x) (%lambda-info-type? x)))
    142185
    143186
     
    146189(define-inline (%closure-type? x) (##core#inline "C_closurep" x))
    147190
     191(define-inline (%closure? x) (and (%block? x) (%closure-type? x)))
     192
    148193
    149194;; Port
     
    151196(define-inline (%port-type? x) (##core#inline "C_portp" x))
    152197
     198(define-inline (%port? x) (and (%block? x) (%port-type? x)))
     199
    153200
    154201;; Simple-pointer
     
    156203(define-inline (%simple-pointer-type? x) (##core#inline "C_pointerp" x))
    157204
     205(define-inline (%simple-pointer? x) (and (%block? x) (%simple-pointer-type? x)))
     206
    158207
    159208;; Tagged-Pointer
     
    161210(define-inline (%tagged-pointer-type? x) (##core#inline "C_taggedpointerp" x))
    162211
     212(define-inline (%tagged-pointer? x) (and (%block? x) (%tagged-pointer-type? x)))
     213
    163214
    164215;; Swig-Pointer
     
    166217(define-inline (%swig-pointer-type? x) (##core#inline "C_swigpointerp" x))
    167218
     219(define-inline (%swig-pointer? x) (and (%block? x) (%swig-pointer-type? x)))
     220
    168221
    169222;; Any-pointer
     
    171224(define-inline (%any-pointer-type? x) (##core#inline "C_anypointerp" x))
    172225
     226(define-inline (%pointer? x) (and (%block? x) (%any-pointer-type? x)))
     227
    173228
    174229;; Locative
     
    176231(define-inline (%locative-type? x) (##core#inline "C_locativep" x))
    177232
     233(define-inline (%locative? x) (and (%block? x) (%locative-type? x)))
     234
    178235
    179236;; Forwarded (block object moved to new address, forwarding pointer)
     
    184241
    185242;;; Values
    186 
    187243
    188244
     
    270326
    271327; generic-byteblock isa string, flonum, or lambda-info
    272 ;
    273 (define-inline (%generic-byteblock? x) (and (%block? x) (%byteblock? x)))
    274328
    275329
     
    278332(define-inline (%make-string size fill) (%make-block-byte size fill #f))
    279333
    280 (define-inline (%string? x) (and (%block? x) (%string-type? x)))
    281 
    282334(define-inline (%string-ref s i) (##core#inline "C_subchar" s i))
    283335
     
    291343;; Flonum (byteblock)
    292344
    293 (define-inline (%flonum? x) (and (%block? x) (%flonum-type? x)))
    294 
    295345
    296346;; Lambda-info (byteblock)
    297347
    298 (define-inline (%lambda-info? x) (and (%block? x) (%lambda-info-type? x)))
    299 
    300348
    301349;; Generic-vector
    302350
    303351; generic-vector isa vector, pair, structure, symbol, or keyword
    304 ;
    305352(define-inline (%generic-vector? x)
    306353  (and (%block? x)
     
    311358
    312359(define-inline (%make-vector size fill) (%make-word-block size fill #f))
    313 
    314 (define-inline (%vector? x) (and (%block? x) (%vector-type? x)))
    315360
    316361(define-inline (%vector-ref v i) (%block-word-ref v i))
     
    329374    bv ) )
    330375
    331 (define-inline (%bytevector? x) (and (%block? x) (%bytevector-type? x)))
    332 
    333376(define-inline (%bytevector-ref bv i) (%block-byte-ref bv i))
    334377
     
    340383  (let ([ln (%bytevector-length v1)])
    341384    (and (%eq? n %bytevector-length v2))
    342          (fx=? 0 (##core#inline "C_string_compare" v1 v2 n)) ) )
     385         (%fx=? 0 (##core#inline "C_string_compare" v1 v2 n)) ) )
    343386
    344387(define-inline (%string->bytevector s)
     
    372415;; Pair (wordblock)
    373416
    374 (define-inline (%pair? x) (and (%block? x) (%pair-type? x)))
     417(define-inline (%null? x) (%eol-object? x))
    375418
    376419(define-inline (%list? x) (or (%null? x) (%pair? x)))
     
    423466  (do ([l l0 (%cdr l)])
    424467      [(%null? (%cdr l)) l]) )
     468
     469(define-inline (%list-copy l0)
     470  (let loop ([ls l0])
     471    (if (%null? ls)
     472        '()
     473        (%cons (%car ls) (loop (%cdr ls))) ) ) )
    425474
    426475; each elm of ls must be a proper-list
     
    463512(define-inline (%make-structure t . s) (apply (##core#primitive "C_make_structure") t s))
    464513
    465 (define-inline (%generic-structure? x) (and (%block? x) (%structure-type? x)))
    466 
    467514(define-inline (%structure-instance? x s) (##core#inline "C_i_structurep" x s))
    468515
     
    475522
    476523(define-inline (%structure-tag r) (%block-word-ref r 0))
    477 
    478 
    479 ;; Special-block (wordblock)
    480 
    481 (define-inline (%special-block? x) (and (%block? x) (%special? x)))
    482524
    483525
     
    502544;(define-inline (%make-port n) (##core#inline_allocate ("C_a_i_port" 17)))
    503545
    504 (define-inline (%port? x) (and (%block? x) (%port-type? x)))
    505 
    506546(define-inline (%port-filep port) (%peek-unsigned-integer port 0))
    507547(define-inline (%port-input-mode? port) (%block-word-ref? port 1))
     
    541581;; Closure (wordblock)
    542582
    543 (define-inline (%closure? x) (and (%block? x) (%closure-type? x)))
    544 
    545583(define-inline (%closure-size c) (%block-size? c))
    546584
     
    552590;; Symbol (wordblock)
    553591
    554 (define-inline (%symbol? x) (and (%block? x) (%symbol-type? x)))
    555 
    556592(define-inline (%symbol-binding s) (%block-word-ref s 0))
    557593(define-inline (%symbol-string s) (%block-word-ref s 1))
     
    578614(define-inline (%make-locative typ obj idx weak?)
    579615  (##core#inline_allocate ("C_a_i_make_locative" 5) typ obj idx weak?))
    580 
    581 (define-inline (%locative? x) (and (%block? x) (%locative-type? x)))
    582616
    583617; Locative layout:
     
    607641;; Pointer (wordblock)
    608642
    609 (define-inline (%pointer? x) (and (%block? x) (%any-pointer-type? x)))
    610 
    611643; simple-pointer, tagged-pointer, swig-pointer, locative
    612644(define-inline (%generic-pointer? x) (or (%pointer? x) (%locative? x)))
    613645
    614646; simple-pointer, tagged-pointer, swig-pointer, locative, closure, port, symbol, keyword
    615 (define-inline (%pointer-like? x) (%special-block? x))
     647(define-inline (%pointer-like? x) (%wordblock? x))
    616648
    617649; These operate on pointer-like objects
     
    634666
    635667(define-inline (%make-simple-pointer) ((##core#primitive "C_make_pointer")))
    636 
    637 (define-inline (%simple-pointer? x) (and (%block? x) (%simple-pointer-type? x)))
    638668
    639669(define-inline (%make-pointer-null)
     
    657687(define-inline (%make-tagged-pointer t) ((##core#primitive "C_make_tagged_pointer") t))
    658688
    659 (define-inline (%tagged-pointer? x) (and (%block? x) (%tagged-pointer-type? x)))
    660 
    661689
    662690;; Swig-pointer (wordblock)
    663691
    664 (define-inline (%swig-pointer? x) (and (%block? x) (%swig-pointer-type? x)))
    665 
    666692
    667693
     
    670696
    671697
     698;;; Numbers
     699
     700(define-inline (%number? x) (or (%fixnum? x) (%flonum? x) ) )
     701
     702
    672703;;; Operations
    673704
  • chicken/trunk/chicken-thread-object-inlines.scm

    r13488 r13504  
    246246  (%eq? 'dead (%thread-state th)) )
    247247
     248;; Synonyms
     249
     250(define-inline (%current-thread)
     251  ##sys#current-thread )
     252
    248253
    249254;;; Condition-variable object:
Note: See TracChangeset for help on using the changeset viewer.