diff --git a/knock/assert.rkt b/knock/assert.rkt index 8327110..6d54572 100644 --- a/knock/assert.rkt +++ b/knock/assert.rkt @@ -1,12 +1,57 @@ #lang racket (provide assert-integer assert-char assert-byte assert-codepoint - assert-box assert-cons - assert-natural assert-vector assert-string) + cons->address box->address address->type + mutable-box->address + vector->address string->address + mutable-vector->address mutable-string->address + assert-natural) (require a86/ast) (require "types.rkt") (define r9 'r9) +(define (cons->address r) + (seq (Cmp (reg-16-bit r) type-cons) + (Jne 'err) + (Sar r 16))) + +(define (box->address r) + (seq (And (reg-16-bit r) zero-mut) + (Cmp (reg-16-bit r) type-box) + (Jne 'err) + (Sar r 16))) + +(define (mutable-box->address r) + (seq (Cmp (reg-16-bit r) type-mutable-box) + (Jne 'err) + (Sar r 16))) + +(define (vector->address r) + (seq (And (reg-16-bit r) zero-mut) + (Cmp (reg-16-bit r) type-vector) + (Jne 'err) + (Sar r 16))) + +(define (mutable-vector->address r) + (seq (Cmp (reg-16-bit r) type-mutable-vector) + (Jne 'err) + (Sar r 16))) + +(define (mutable-string->address r) + (seq (Cmp (reg-16-bit r) type-mutable-string) + (Jne 'err) + (Sar r 16))) + +(define (string->address r) + (seq (And (reg-16-bit r) zero-mut) + (Cmp (reg-16-bit r) type-string) + (Jne 'err) + (Sar r 16))) + +(define (address->type r t) + (seq (Shl r 16) + (Mov (reg-16-bit r) t))) + (define (assert-type mask type) (λ (arg) (seq (Mov r9 arg) @@ -24,14 +69,6 @@ (define assert-char (assert-type mask-char type-char)) -(define assert-box - (assert-type ptr-mask type-box)) -(define assert-cons - (assert-type ptr-mask type-cons)) -(define assert-vector - (assert-type ptr-mask type-vect)) -(define assert-string - (assert-type ptr-mask type-str)) ;; Register -> Asm (define (assert-codepoint r) diff --git a/knock/compile-ops.rkt b/knock/compile-ops.rkt index 90bba9b..d72a33b 100644 --- a/knock/compile-ops.rkt +++ b/knock/compile-ops.rkt @@ -6,15 +6,13 @@ (require a86/ast) (define rax 'rax) -(define eax 'eax) ; 32-bit load/store -(define rbx 'rbx) ; heap -(define rdi 'rdi) ; arg -(define r8 'r8) ; scratch in op2 -(define r9 'r9) ; scratch -(define r10 'r10) ; scratch - -(define r15 'r15) ; stack pad (non-volatile) -(define rsp 'rsp) ; stack +(define rdi 'rdi) +(define rbx 'rbx) +(define r8 'r8) +(define r9 'r9) +(define r10 'r10) +(define r15 'r15) +(define rsp 'rsp) ;; Op0 -> Asm (define (compile-op0 p) @@ -59,54 +57,54 @@ (Call 'write_byte) unpad-stack)] ['box - (seq (Mov (Offset rbx 0) rax) ; memory write - (Mov rax rbx) ; put box in rax - (Xor rax type-box) ; tag as a box + (seq (Mov (Offset rbx 0) rax) + (Mov rax rbx) + (address->type rax type-mutable-box) + (Add rbx 8))] + ['box-immutable + (seq (Mov (Offset rbx 0) rax) + (Mov rax rbx) + (address->type rax type-immutable-box) (Add rbx 8))] ['unbox - (seq (assert-box rax) - (Xor rax type-box) + (seq (box->address rax) (Mov rax (Offset rax 0)))] ['car - (seq (assert-cons rax) - (Xor rax type-cons) + (seq (cons->address rax) (Mov rax (Offset rax 8)))] ['cdr - (seq (assert-cons rax) - (Xor rax type-cons) + (seq (cons->address rax) (Mov rax (Offset rax 0)))] - ['empty? (seq (Cmp rax (value->bits '())) if-equal)] - ['cons? (type-pred ptr-mask type-cons)] - ['box? (type-pred ptr-mask type-box)] - ['vector? (type-pred ptr-mask type-vect)] - ['string? (type-pred ptr-mask type-str)] + ['cons? + (seq (Mov r8 (value->bits #f)) + (Cmp (reg-16-bit rax) type-cons) + (Mov rax (value->bits #t)) + (Cmovne rax r8))] + ['box? + (seq (Mov r8 (value->bits #f)) + (And (reg-16-bit rax) zero-mut) + (Cmp (reg-16-bit rax) type-box) + (Mov rax (value->bits #t)) + (Cmovne rax r8))] + ['vector? + (seq (Mov r8 (value->bits #f)) + (And (reg-16-bit rax) zero-mut) + (Cmp (reg-16-bit rax) type-vector) + (Mov rax (value->bits #t)) + (Cmovne rax r8))] + ['string? + (seq (Mov r8 (value->bits #f)) + (And (reg-16-bit rax) zero-mut) + (Cmp (reg-16-bit rax) type-string) + (Mov rax (value->bits #t)) + (Cmovne rax r8))] ['vector-length - (let ((zero (gensym)) - (done (gensym))) - (seq (assert-vector rax) - (Xor rax type-vect) - (Cmp rax 0) - (Je zero) - (Mov rax (Offset rax 0)) - (Sal rax int-shift) - (Jmp done) - (Label zero) - (Mov rax 0) - (Label done)))] + (seq (vector->address rax) + (Mov rax (Offset rax 0)))] ['string-length - (let ((zero (gensym)) - (done (gensym))) - (seq (assert-string rax) - (Xor rax type-str) - (Cmp rax 0) - (Je zero) - (Mov rax (Offset rax 0)) - (Sal rax int-shift) - (Jmp done) - (Label zero) - (Mov rax 0) - (Label done)))])) + (seq (string->address rax) + (Mov rax (Offset rax 0)))])) ;; Op2 -> Asm @@ -140,56 +138,52 @@ (Pop rax) (Mov (Offset rbx 8) rax) (Mov rax rbx) - (Xor rax type-cons) + (address->type rax type-cons) (Add rbx 16))] ['eq? (seq (Pop r8) (Cmp rax r8) if-equal)] + ['set-box! + (seq (Pop r8) + (mutable-box->address r8) + (Mov (Offset r8 0) rax) + (Mov rax (value->bits (void))))] ['make-vector ;; size value (let ((loop (gensym)) (done (gensym)) (empty (gensym))) - (seq (Pop r8) ;; r8 = size + (seq (Pop r8) (assert-natural r8) - (Cmp r8 0) ; special case empty vector + (Cmp r8 0) ; special case empty string (Je empty) - (Mov r9 rbx) - (Xor r9 type-vect) - - (Sar r8 int-shift) + (address->type r9 type-mutable-vector) (Mov (Offset rbx 0) r8) (Add rbx 8) - (Label loop) (Mov (Offset rbx 0) rax) (Add rbx 8) - (Sub r8 1) + (Sub r8 (value->bits 1)) (Cmp r8 0) (Jne loop) - (Mov rax r9) (Jmp done) - (Label empty) - (Mov rax type-vect) + (Lea rax 'the_empty_sequence) + (address->type rax type-immutable-vector) (Label done)))] ['vector-ref ; vector index (seq (Pop r8) - (assert-vector r8) + (vector->address r8) (assert-integer rax) - (Cmp r8 type-vect) - (Je 'err) ; special case for empty vector (Cmp rax 0) (Jl 'err) - (Xor r8 type-vect) ; r8 = ptr (Mov r9 (Offset r8 0)) ; r9 = len - (Sar rax int-shift) ; rax = index - (Sub r9 1) + (Sub r9 (value->bits 1)) (Cmp r9 rax) (Jl 'err) - (Sal rax 3) + (Sal rax 1) (Add r8 rax) (Mov rax (Offset r8 8)))] ['make-string @@ -201,72 +195,51 @@ (assert-char rax) (Cmp r8 0) ; special case empty string (Je empty) - (Mov r9 rbx) - (Xor r9 type-str) - - (Sar r8 int-shift) + (address->type r9 type-mutable-string) (Mov (Offset rbx 0) r8) (Add rbx 8) - - (Sar rax char-shift) - - (Add r8 1) ; adds 1 - (Sar r8 1) ; when - (Sal r8 1) ; len is odd - (Label loop) - (Mov (Offset rbx 0) eax) - (Add rbx 4) - (Sub r8 1) + (Mov (Offset rbx 0) rax) + (Add rbx 8) + (Sub r8 (value->bits 1)) (Cmp r8 0) (Jne loop) - (Mov rax r9) (Jmp done) - (Label empty) - (Mov rax type-str) + (Lea rax 'the_empty_sequence) + (address->type rax type-immutable-string) (Label done)))] - ['string-ref + ['string-ref ; string index (seq (Pop r8) - (assert-string r8) + (string->address r8) (assert-integer rax) - (Cmp r8 type-str) - (Je 'err) ; special case for empty string (Cmp rax 0) (Jl 'err) - (Xor r8 type-str) ; r8 = ptr (Mov r9 (Offset r8 0)) ; r9 = len - (Sar rax int-shift) ; rax = index - (Sub r9 1) + (Sub r9 (value->bits 1)) (Cmp r9 rax) (Jl 'err) - (Sal rax 2) + (Sal rax 1) (Add r8 rax) - (Mov 'eax (Offset r8 8)) - (Sal rax char-shift) - (Xor rax type-char))])) + (Mov rax (Offset r8 8)))])) ;; Op3 -> Asm (define (compile-op3 p) (match p - ['vector-set! - (seq (Pop r10) - (Pop r8) - (assert-vector r8) + ['vector-set! ; vector index value + (seq (Pop r10) ; index + (Pop r8) ; value + (mutable-vector->address r8) (assert-integer r10) - (Cmp r8 type-vect) - (Je 'err) (Cmp r10 0) (Jl 'err) - (Xor r8 type-vect) ; r8 = ptr - (Mov r9 (Offset r8 0)) ; r9 = len - (Sar r10 int-shift) ; r10 = index - (Sub r9 1) + (Mov r9 (Offset r8 0)) ; r9 = len + (Sub r9 (value->bits 1)) (Cmp r9 r10) (Jl 'err) - (Sal r10 3) + (Sal r10 1) (Add r8 r10) (Mov (Offset r8 8) rax) (Mov rax (value->bits (void))))])) diff --git a/knock/compile.rkt b/knock/compile.rkt index 3767728..180e966 100644 --- a/knock/compile.rkt +++ b/knock/compile.rkt @@ -8,6 +8,7 @@ (require "ast.rkt") (require "compile-ops.rkt") (require "types.rkt") +(require "assert.rkt") (require a86/ast) (define rax 'rax) @@ -38,7 +39,10 @@ (compile-defines ds) (Label 'err) pad-stack - (Call 'raise_error))])) + (Call 'raise_error) + (Data) + (Label 'the_empty_sequence) + (Dq 0))])) ;; [Listof Defn] -> Asm (define (compile-defines ds) @@ -92,23 +96,23 @@ (define (compile-string s) (let ((len (string-length s))) (if (zero? len) - (seq (Mov rax type-str)) - (seq (Mov rax len) + (seq (Lea rax 'the_empty_sequence) + (address->type rax type-immutable-string)) + (seq (Mov rax (value->bits len)) (Mov (Offset rbx 0) rax) (compile-string-chars (string->list s) 8) (Mov rax rbx) - (Xor rax type-str) - (Add rbx - (+ 8 (* 4 (if (odd? len) (add1 len) len)))))))) + (address->type rax type-immutable-string) + (Add rbx (* 8 (add1 len))))))) ;; [Listof Char] Integer -> Asm (define (compile-string-chars cs i) (match cs ['() (seq)] [(cons c cs) - (seq (Mov rax (char->integer c)) - (Mov (Offset rbx i) 'eax) - (compile-string-chars cs (+ 4 i)))])) + (seq (Mov rax (value->bits c)) + (Mov (Offset rbx i) rax) + (compile-string-chars cs (+ 8 i)))])) ;; Op0 -> Asm (define (compile-prim0 p) @@ -263,14 +267,14 @@ (let ((ok (gensym))) (list (seq (Mov r8 rax) - (And r8 ptr-mask) - (Cmp r8 type-box) + (And (reg-16-bit r8) zero-mut) + (Cmp (reg-16-bit r8) type-box) (Je ok) (Add rsp (* 8 (length cm))) ; haven't pushed anything yet (Jmp next) (Label ok) - (Xor rax type-box) - (Mov rax (Offset rax 0)) + (Sar r8 16) + (Mov rax (Offset r8 0)) i1) cm1))])] [(Cons p1 p2) @@ -281,16 +285,15 @@ (let ((ok (gensym))) (list (seq (Mov r8 rax) - (And r8 ptr-mask) - (Cmp r8 type-cons) + (Cmp (reg-16-bit r8) type-cons) (Je ok) (Add rsp (* 8 (length cm))) ; haven't pushed anything yet (Jmp next) (Label ok) - (Xor rax type-cons) - (Mov r8 (Offset rax 0)) - (Push r8) ; push cdr - (Mov rax (Offset rax 8)) ; mov rax car + (Sar r8 16) + (Mov rax (Offset r8 0)) + (Push rax) ; push cdr + (Mov rax (Offset r8 8)) ; mov rax car i1 (Mov rax (Offset rsp (* 8 (- (sub1 (length cm1)) (length cm))))) i2) diff --git a/knock/parse.rkt b/knock/parse.rkt index 3f1c6b0..73ddaf1 100644 --- a/knock/parse.rkt +++ b/knock/parse.rkt @@ -256,11 +256,11 @@ (define (op1? x) (memq x '(add1 sub1 zero? char? integer->char char->integer write-byte eof-object? - box unbox empty? cons? box? car cdr + box box-immutable unbox empty? cons? box? car cdr vector? vector-length string? string-length))) (define (op2? x) - (memq x '(+ - < = eq? cons + (memq x '(+ - < = eq? cons set-box! make-vector vector-ref make-string string-ref))) (define (op3? x) diff --git a/knock/print.c b/knock/print.c index acb1413..8e9359e 100644 --- a/knock/print.c +++ b/knock/print.c @@ -72,13 +72,11 @@ void print_vect(val_vect_t *v) { uint64_t i; - if (!v) { printf("#()"); return; } - printf("#("); - for (i = 0; i < v->len; ++i) { + for (i = 0; i < val_unwrap_int(v->len); ++i) { print_result_interior(v->elems[i]); - if (i < v->len - 1) + if (i < val_unwrap_int(v->len) - 1) putchar(' '); } printf(")"); @@ -105,10 +103,9 @@ void print_cons(val_cons_t *cons) void print_str(val_str_t* s) { - if (!s) return; - uint64_t i; - for (i = 0; i < s->len; ++i) - print_str_char(s->codepoints[i]); + int64_t i; + for (i = 0; i < val_unwrap_int(s->len); ++i) + print_str_char(val_unwrap_char(s->chars[i])); } void print_str_char_u(val_char_t c) diff --git a/knock/types.h b/knock/types.h index b79f45b..5f6e4e4 100644 --- a/knock/types.h +++ b/knock/types.h @@ -2,27 +2,40 @@ #define TYPES_H /* + Important: must agree with types.rkt! + Bit layout of values - Values are either: - - Immediates: end in #b000 - - Pointers - - Immediates are either - - Integers: end in #b0 000 - - Characters: end in #b01 000 - - True: #b11 000 - - False: #b1 11 000 - - Eof: #b10 11 000 - - Void: #b11 11 000 - - Empty: #b100 11 000 + Values: + - Immediates: end in #b0 + - Pointers: end in #b1 + Immediates: + - Integers: end in #b00 + - Characters: end in #b010 + - #t: #b000110 + - #f: #b001110 + - eof: #b010110 + - void: #b011110 + - '(): #b100110 + + Addresses are assumed to have 0s in two most significant bytes + (canonical address form) So a tagged pointer shifts an address to + the left by 16 and uses those 16 bits to tag the pointer type. */ -#define imm_shift 3 -#define ptr_type_mask ((1 << imm_shift) - 1) -#define box_type_tag 1 -#define cons_type_tag 2 -#define vect_type_tag 3 -#define str_type_tag 4 + +#define imm_shift 1 +#define ptr_type_mask ((16 << imm_shift) - 1) + +#define ptr_type_tag 1 +#define box_immutable_type_tag ((0 << imm_shift) | ptr_type_tag) +#define box_mutable_type_tag ((1 << imm_shift) | ptr_type_tag) +#define cons_type_tag ((2 << imm_shift) | ptr_type_tag) +#define vect_immutable_type_tag ((4 << imm_shift) | ptr_type_tag) +#define vect_mutable_type_tag ((5 << imm_shift) | ptr_type_tag) +#define str_immutable_type_tag ((6 << imm_shift) | ptr_type_tag) +#define str_mutable_type_tag ((7 << imm_shift) | ptr_type_tag) +#define ptr_shift 16 + #define int_shift (1 + imm_shift) #define int_type_mask ((1 << int_shift) - 1) #define int_type_tag (0 << (int_shift - 1)) diff --git a/knock/types.rkt b/knock/types.rkt index c18ec17..0982b8d 100644 --- a/knock/types.rkt +++ b/knock/types.rkt @@ -2,19 +2,39 @@ (provide (all-defined-out)) (require ffi/unsafe) -(define imm-shift 3) -(define imm-mask #b111) -(define ptr-mask #b111) -(define type-box #b001) -(define type-cons #b010) -(define type-vect #b011) -(define type-str #b100) +(define imm-shift 1) +(define ptr-type-tag 1) + +(define (ptr-type-enum i) + (bitwise-xor (arithmetic-shift i imm-shift) ptr-type-tag)) + +;; Mutable and immutable must differ only in the lsb of the tag + +(define zero-mut #xFFFD) ; use to zero out mutability bit +(define ptr-type-mask #xFFFF) + +(define type-box (ptr-type-enum #b000)) +(define type-mutable-box (ptr-type-enum #b001)) +(define type-cons (ptr-type-enum #b010)) +;; skip +(define type-vector (ptr-type-enum #b100)) +(define type-mutable-vector (ptr-type-enum #b101)) +(define type-string (ptr-type-enum #b110)) +(define type-mutable-string (ptr-type-enum #b111)) + +(define type-immutable-box type-box) +(define type-immutable-vector type-vector) +(define type-immutable-string type-string) + +(define imm-mask #b1) (define int-shift (+ 1 imm-shift)) -(define mask-int #b1111) + +(define mask-int #b11) + (define char-shift (+ 2 imm-shift)) -(define type-int #b0000) -(define type-char #b01000) -(define mask-char #b11111) +(define type-int #b00) +(define type-char #b010) +(define mask-char #b111) (define (bits->value b) (cond [(= b (value->bits #t)) #t] @@ -27,33 +47,29 @@ [(char-bits? b) (integer->char (arithmetic-shift b (- char-shift)))] [(box-bits? b) - (box (bits->value (mem-ref b)))] + (box (bits->value (mem-ref (box-pointer b))))] [(cons-bits? b) - (cons (bits->value (mem-ref (+ b 8))) - (bits->value (mem-ref b)))] + (cons (bits->value (mem-ref (cons-car-pointer b))) + (bits->value (mem-ref (cons-cdr-pointer b))))] [(vect-bits? b) - (if (zero? (untag b)) - (vector) - (build-vector (mem-ref b) - (lambda (j) - (bits->value (mem-ref (+ b (* 8 (add1 j))))))))] + (build-vector (bits->value (mem-ref (vector-length-pointer b))) + (λ (j) + (bits->value (mem-ref (vector-ref-pointer b j)))))] [(str-bits? b) - (if (zero? (untag b)) - (string) - (build-string (mem-ref b) - (lambda (j) - (char-ref (+ b 8) j))))] + (build-string (bits->value (mem-ref (string-length-pointer b))) + (λ (j) + (bits->value (mem-ref (string-ref-pointer b j)))))] [else (error "invalid bits")])) (define (value->bits v) - (cond [(eq? v #t) #b00011000] - [(eq? v #f) #b00111000] + (cond [(eq? v #t) #b000110] + [(eq? v #f) #b001110] [(integer? v) (arithmetic-shift v int-shift)] - [(eof-object? v) #b01011000] - [(void? v) #b01111000] - [(empty? v) #b10011000] + [(eof-object? v) #b010110] + [(void? v) #b011110] + [(empty? v) #b100110] [(char? v) - (bitwise-ior type-char + (bitwise-xor type-char (arithmetic-shift (char->integer v) char-shift))] [else (error "not an immediate value" v)])) @@ -67,23 +83,50 @@ (zero? (bitwise-and v imm-mask))) (define (cons-bits? v) - (= type-cons (bitwise-and v imm-mask))) + (= type-cons (bitwise-and v ptr-type-mask))) (define (box-bits? v) - (= type-box (bitwise-and v imm-mask))) + (= type-box (bitwise-and v ptr-type-mask zero-mut))) (define (vect-bits? v) - (= type-vect (bitwise-and v imm-mask))) + (= type-vector (bitwise-and v ptr-type-mask zero-mut))) (define (str-bits? v) - (= type-str (bitwise-and v imm-mask))) + (= type-string (bitwise-and v ptr-type-mask zero-mut))) + +;; BoxValue* -> Address +(define (box-pointer v) + (untag v)) + +;; ConsValue* -> Address +(define (cons-car-pointer v) + (+ (untag v) 8)) + +;; ConsValue* -> Address +(define (cons-cdr-pointer v) + (untag v)) + +;; VectValue* -> Address +(define (vector-length-pointer v) + (untag v)) + +;; VectValue* Natural -> Address +(define (vector-ref-pointer v i) + (+ (untag v) (* 8 (add1 i)))) + +;; StrtValue* -> Address +(define (string-length-pointer v) + (untag v)) + +;; StrValue* Natural -> Address +(define (string-ref-pointer v i) + (+ (untag v) (* 8 (add1 i)))) (define (untag i) - (arithmetic-shift (arithmetic-shift i (- (integer-length ptr-mask))) - (integer-length ptr-mask))) + (arithmetic-shift i -16)) (define (mem-ref i) - (ptr-ref (cast (untag i) _int64 _pointer) _int64)) + (ptr-ref (cast i _int64 _pointer) _int64)) (define (char-ref i j) (integer->char (ptr-ref (cast (untag i) _int64 _pointer) _uint32 j))) diff --git a/knock/values.c b/knock/values.c index 62bca18..710b958 100644 --- a/knock/values.c +++ b/knock/values.c @@ -4,13 +4,16 @@ type_t val_typeof(val_t x) { switch (x & ptr_type_mask) { - case box_type_tag: + case box_immutable_type_tag: + case box_mutable_type_tag: return T_BOX; case cons_type_tag: return T_CONS; - case vect_type_tag: + case vect_immutable_type_tag: + case vect_mutable_type_tag: return T_VECT; - case str_type_tag: + case str_immutable_type_tag: + case str_mutable_type_tag: return T_STR; } @@ -38,14 +41,14 @@ int64_t val_unwrap_int(val_t x) { return x >> int_shift; } -val_t val_wrap_byte(unsigned char b) -{ - return (b << int_shift) | int_type_tag; -} val_t val_wrap_int(int64_t i) { return (i << int_shift) | int_type_tag; } +val_t val_wrap_byte(unsigned char b) +{ + return (b << int_shift) | int_type_tag; +} int val_unwrap_bool(val_t x) { @@ -77,36 +80,36 @@ val_t val_wrap_void(void) val_box_t* val_unwrap_box(val_t x) { - return (val_box_t *)(x ^ box_type_tag); + return (val_box_t *)(x >> ptr_shift); } val_t val_wrap_box(val_box_t* b) { - return ((val_t)b) | box_type_tag; + return ((val_t)b << ptr_shift) | box_mutable_type_tag; } val_cons_t* val_unwrap_cons(val_t x) { - return (val_cons_t *)(x ^ cons_type_tag); + return (val_cons_t *)(x >> ptr_shift); } val_t val_wrap_cons(val_cons_t *c) { - return ((val_t)c) | cons_type_tag; + return ((val_t)c << ptr_shift) | cons_type_tag; } val_vect_t* val_unwrap_vect(val_t x) { - return (val_vect_t *)(x ^ vect_type_tag); + return (val_vect_t *)(x >> ptr_shift); } val_t val_wrap_vect(val_vect_t *v) { - return ((val_t)v) | vect_type_tag; + return ((val_t)v << ptr_shift) | vect_mutable_type_tag; } val_str_t* val_unwrap_str(val_t x) { - return (val_str_t *)(x ^ str_type_tag); + return (val_str_t *)(x >> ptr_shift); } val_t val_wrap_str(val_str_t *v) { - return ((val_t)v) | str_type_tag; + return ((val_t)v << ptr_shift) | str_mutable_type_tag; } diff --git a/knock/values.h b/knock/values.h index b6ac44f..0c389b6 100644 --- a/knock/values.h +++ b/knock/values.h @@ -12,7 +12,7 @@ typedef enum type_t { T_INT, T_BOOL, T_CHAR, - T_EOF, + T_EOF, T_VOID, T_EMPTY, /* pointers */ @@ -31,12 +31,12 @@ typedef struct val_cons_t { val_t fst; } val_cons_t; typedef struct val_vect_t { - uint64_t len; + val_t len; val_t elems[]; } val_vect_t; typedef struct val_str_t { - uint64_t len; - val_char_t codepoints[]; + val_t len; + val_t chars[]; } val_str_t; /* return the type of x */