Commits

Anonymous committed 12bf028

Rename Erlang types variables (name collizions encountered in Chez Scheme v8.0).

  • Participants
  • Parent commits 1a2d445

Comments (0)

Files changed (1)

src/scheme-bert.ss

                  )
          
          ;; Erlang external term format types
-         (define SMALL_INT 97)
-         (define INT 98)
-         (define SMALL_BIGNUM 110)
-         (define LARGE_BIGNUM 111)
-         (define FLOAT 99)
-         (define ATOM 100)
-         (define SMALL_TUPLE 104)
-         (define LARGE_TUPLE 105)
-         (define NIL 106)
-         (define STRING 107)
-         (define LIST 108)
-         (define BIN 109)
-         (define MAGIC 131)
-         (define MAX_INT (- (bsl 1 31) 1))
-         (define MIN_INT (- (bsl 1 31)))
+         (define ERL_SMALL_ERL_INT 97)
+         (define ERL_INT 98)
+         (define ERL_SMALL_BIGNUM 110)
+         (define ERL_LARGE_BIGNUM 111)
+         (define ERL_FLOAT 99)
+         (define ERL_ATOM 100)
+         (define ERL_SMALL_TUPLE 104)
+         (define ERL_LARGE_TUPLE 105)
+         (define ERL_NIL 106)
+         (define ERL_STRING 107)
+         (define ERL_LIST 108)
+         (define ERL_BIN 109)
+         (define ERL_MAGIC 131)
+         (define MAX_ERL_INT (- (bsl 1 31) 1))
+         (define MIN_ERL_INT (- (bsl 1 31)))
 
          (define (dropwhile proc list)
            (let recur ((proc proc)
              (put-bytevector outpr b)))         
          
          (define (write-binary outpr data)
-           (write-1 outpr BIN)
+           (write-1 outpr ERL_BIN)
            (let ((b (string->bytevector data (native-transcoder))))
              (write-4 outpr (bytevector-length b))
              (put-bytevector outpr b)))
          
          (define (write-float outpr float)
-           (write-1 outpr FLOAT)
+           (write-1 outpr ERL_FLOAT)
            (let* ((str (fldigits float))
                   (len (string-length str)))
              (write-str outpr str)
                      (error "write-symbol" 
                             "Syntax error, unexpected character.")
                      (begin
-                       (write-1 outpr ATOM)
+                       (write-1 outpr ERL_ATOM)
                        (write-2 outpr len)
                        (write-str outpr str)))
                  (error "write-symbol" 
          (define (write-list outpr data)
            (cond
              ((null? data)
-              (write-1 outpr NIL))
+              (write-1 outpr ERL_NIL))
              ((fold/and (lambda (x) (isbyte? x)) data)
-              (write-1 outpr STRING)
+              (write-1 outpr ERL_STRING)
               (write-2 outpr (length data))
               (for-each (lambda (x) (write-1 outpr x)) data))
-             (else (write-1 outpr LIST)
+             (else (write-1 outpr ERL_LIST)
                    (write-4 outpr (length data))
                    (for-each (lambda (x) (write-any-raw outpr x)) data)
-                   (write-1 outpr NIL))))
+                   (write-1 outpr ERL_NIL))))
          
          (define (write-tuple outpr data)
            (let ((len (vector-length data)))
              (if (< len 256)
                  (begin
-                   (write-1 outpr SMALL_TUPLE)
+                   (write-1 outpr ERL_SMALL_TUPLE)
                    (write-1 outpr len))
                  (begin
-                   (write-1 outpr LARGE_TUPLE)
+                   (write-1 outpr ERL_LARGE_TUPLE)
                    (write-4 outpr len)))
              (let vector-do ((position 0))
                (unless (= position len)
          (define (write-fixnum outpr num)
            (cond
              ((isbyte? num)
-              (write-1 outpr SMALL_INT)
+              (write-1 outpr ERL_SMALL_ERL_INT)
               (write-1 outpr num))
-             ((and (>= num MIN_INT) (<= num MAX_INT))
-              (write-1 outpr INT)
+             ((and (>= num MIN_ERL_INT) (<= num MAX_ERL_INT))
+              (write-1 outpr ERL_INT)
               (write-4 outpr num))
              (else (write-bignum outpr num))))         
          
            (let ((n (ceiling (/ (bitwise-length num) 8)))) bitwise-length
              (if (< n 256)
                  (begin
-                   (write-1 outpr SMALL_BIGNUM)
+                   (write-1 outpr ERL_SMALL_BIGNUM)
                    (write-1 outpr n))
                  (begin
-                   (write-1 outpr LARGE_BIGNUM)
+                   (write-1 outpr ERL_LARGE_BIGNUM)
                    (write-4 outpr n)))
              (write-bignum-guts outpr num)))
          
              (else (error "write-any-raw" "Not implemented."))))
          
          (define (write-any outpr obj)
-           (write-1 outpr MAGIC)
+           (write-1 outpr ERL_MAGIC)
            (write-any-raw outpr obj))
          
          (define (convert obj)
          
          ;; frexp is analogous to frexp(1) found in C
          (define (frexp float)
-           (let ((FLOAT_BIAS 1022))
+           (let ((ERL_FLOAT_BIAS 1022))
              (define (frac1 sign expon frac)
                (let ((b (make-bytevector 8)))
                  (bytevector-u64-native-set!
-                  b 0 (bor (bsl (bor (bsl sign 11) FLOAT_BIAS) 52) frac))
+                  b 0 (bor (bsl (bor (bsl sign 11) ERL_FLOAT_BIAS) 52) frac))
                  (bytevector-ieee-double-native-ref b 0)))
              (let-values (((sign expon frac) (funpack float)))
                (cond
                   (values 0 0))
                  ((zero? expon)
                   (cons (frac1 sign exp (- frac 1))
-                        (+ (- (- FLOAT_BIAS) 52) (bitwise-length frac))))
+                        (+ (- (- ERL_FLOAT_BIAS) 52) (bitwise-length frac))))
                  (else 
                   (cons (frac1 sign expon frac) 
-                        (- expon FLOAT_BIAS)))))))
+                        (- expon ERL_FLOAT_BIAS)))))))
          
          (define (insert-decimal-exp place s)
            (let* ((s0 (if (= (string-length s) 1) "0"
            (read-any (open-bytevector-input-port bytevector)))
          
          (define (read-any inp)
-           (if (eq? (read-small-int inp) MAGIC)
+           (if (eq? (read-small-int inp) ERL_MAGIC)
                (read-any-raw inp)
                (error "read-any" "Bad Magic")))
          
          (define (read-any-raw inp)
            (let ((tag (read-small-int inp)))
              (cond
-               ((eq? tag ATOM) (read-atom inp))
-               ((eq? tag SMALL_INT) (read-small-int inp))
-               ((eq? tag INT) (read-int inp))
-               ((eq? tag SMALL_BIGNUM) (read-bignum-t inp 'small))               
-               ((eq? tag LARGE_BIGNUM) (read-bignum-t inp 'large))
-               ((eq? tag FLOAT) (read-float inp))
-               ((eq? tag SMALL_TUPLE) (read-tuple-t inp 'small))
-               ((eq? tag LARGE_TUPLE) (read-tuple-t inp 'large))
-               ((eq? tag NIL) (read-nil inp))
-               ((eq? tag STRING) (read-erl-string inp))               
-               ((eq? tag LIST) (read-list inp))
-               ((eq? tag BIN) (read-bin inp))
+               ((eq? tag ERL_ATOM) (read-atom inp))
+               ((eq? tag ERL_SMALL_ERL_INT) (read-small-int inp))
+               ((eq? tag ERL_INT) (read-int inp))
+               ((eq? tag ERL_SMALL_BIGNUM) (read-bignum-t inp 'small))               
+               ((eq? tag ERL_LARGE_BIGNUM) (read-bignum-t inp 'large))
+               ((eq? tag ERL_FLOAT) (read-float inp))
+               ((eq? tag ERL_SMALL_TUPLE) (read-tuple-t inp 'small))
+               ((eq? tag ERL_LARGE_TUPLE) (read-tuple-t inp 'large))
+               ((eq? tag ERL_NIL) (read-nil inp))
+               ((eq? tag ERL_STRING) (read-erl-string inp))               
+               ((eq? tag ERL_LIST) (read-list inp))
+               ((eq? tag ERL_BIN) (read-bin inp))
                (else
                 (error "read-any-raw"
                        (string-append 
            (let ((type (read-small-int inp))
                  (h (make-eq-hashtable)))
              (cond
-               ((eq? type LIST)
+               ((eq? type ERL_LIST)
                 (let recur ((len (read-int inp)))
                   (if (zero? len)
                       (begin
-                        (read-1 inp)     ;; NIL
+                        (read-1 inp)     ;; ERL_NIL
                         h)
                       (let* ((pair (read-any-raw inp))
                              (k (vector-ref pair 0))
                              (v (vector-ref pair 1)))
                         (hashtable-set! h k v)
                         (recur (- len 1))))))
-               ((eq? type NIL)
+               ((eq? type ERL_NIL)
                 h)
                (else
                 (error "read-dict"