forked from alex-eg/sex
promote the prelude's integer types like C's own
u8 and i32 are typedefs of <stdint.h> names nothing parses, so they had no rank: (+ a a) over two u8 200s was a u8 holding 144, and (+ n 1) over an i32 could not be typed at all.
This commit is contained in:
10
types.scm
10
types.scm
@@ -125,6 +125,16 @@
|
||||
(hash-table-set! +type-db+ name
|
||||
(list 'typedef name (last (strip-pub form)))))
|
||||
|
||||
;;; <stdint.h>, which nothing parses, as far as arithmetic asks: the
|
||||
;;; prelude's `u8' is a `uint8-t', so (+ a a) over two of them is an
|
||||
;;; `int', promoted like any narrow type. The 64-bit pair is `long' on
|
||||
;;; some hosts; it ranks above the narrower ones either way.
|
||||
(for-each (lambda (entry) (add-typedef (car entry) (cons 'typedef entry)))
|
||||
'((int8-t (signed char)) (uint8-t (unsigned char))
|
||||
(int16-t short) (uint16-t (unsigned short))
|
||||
(int32-t int) (uint32-t (unsigned int))
|
||||
(int64-t (long long)) (uint64-t (unsigned long long))))
|
||||
|
||||
;;; (define name value ...) -- a C #define, kept so a macro can read a
|
||||
;;; compile-time constant rather than re-parse the source.
|
||||
(define (add-define name form)
|
||||
|
||||
Reference in New Issue
Block a user