Skip to content

Commit

Permalink
test: hoax
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpie123 committed May 13, 2022
1 parent 1e9f91c commit a67aa1f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
8 changes: 4 additions & 4 deletions lang/compile.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,10 @@
(match p
['vector-set! (seq
(SetLocal (Name secondary-pointer) e1)
(SetLocal (Name 'assert_scratch) (load-from-heap (GetLocal (Name secondary-pointer)) type-vect (Const 0)))
(SetLocal (Name assert_scratch) (load-from-heap (GetLocal (Name secondary-pointer)) type-vect (Const 0)))
(WatIf (64->32 (And
(32->64 (Ge (Sar e2 (Const int-shift)) (Const 0)))
(32->64 (Lt (Sar e2 (Const int-shift)) (GetLocal (Name 'assert_scratch))))))
(32->64 (Lt (Sar e2 (Const int-shift)) (GetLocal (Name assert_scratch))))))

(seq
(64->32 (Add (Xor (GetLocal (Name secondary-pointer)) (Const type-vect)) (Mul (Const 8) (Add (Const 1) (Sar e2 (Const int-shift))))))
Expand Down Expand Up @@ -264,10 +264,10 @@
;; Gets by index in an array-type structure (vector or string currently).
(define (compile-ref e1 e2 type)
(seq
(SetLocal (Name 'assert_scratch) (load-from-heap e1 type (Const 0)))
(SetLocal (Name assert_scratch) (load-from-heap e1 type (Const 0)))
(WatIf (64->32 (And
(32->64 (Ge (Sar e2 (Const int-shift)) (Const 0)))
(32->64 (Lt (Sar e2 (Const int-shift)) (GetLocal (Name 'assert_scratch))))))
(32->64 (Lt (Sar e2 (Const int-shift)) (GetLocal (Name assert_scratch))))))

(load-from-heap e1 type (Mul (Const 8) (Add (Const 1) (Sar e2 (Const int-shift)))))
(err)
Expand Down
12 changes: 6 additions & 6 deletions server/public/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,17 @@ function unwrap(raw) {
case typesEnum.T_EMPTY:
return "'()"
case typesEnum.T_CONS:
return "#<cons>"
return "#\<cons\>"
case typesEnum.T_BOX:
return "#<box>"
return "#\<box\>"
case typesEnum.T_VECT:
return "#<vector>"
return "#\<vector\>"
// return "'" + result_interior(raw) // TODO
case typesEnum.T_STR:
return "#<string>"
return "#\<string\>"
//return '"' + val_unwrap_str(raw) + '"' // TODO
case typesEnum.T_PROC:
return "#<procedure>"
return "#\<procedure\>"
case typesEnum.T_INVALID:
return "internal error"
}
Expand Down Expand Up @@ -204,7 +204,7 @@ function val_unwrap_int(raw) {
}

function val_unwrap_bool(raw) {
return raw === val_true
return (raw === val_true) + ""
}

function val_wrap_int(i) {
Expand Down
3 changes: 2 additions & 1 deletion tests/hoax/1.wkt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#lang wacket
#lang wacket
(make-vector 3 #t)
2 changes: 2 additions & 0 deletions tests/hoax/2.wkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#lang wacket
"abc"
2 changes: 2 additions & 0 deletions tests/hoax/3.wkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#lang wacket
(vector-ref (make-vector 3 #t) 0)
2 changes: 2 additions & 0 deletions tests/hoax/4.wkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#lang wacket
(string-ref "abcd" 2)
4 changes: 4 additions & 0 deletions tests/hoax/5.wkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#lang wacket
(let ((v (make-vector 3 #t)))
(begin (vector-set! v 1 #f)
(vector-ref v 1)))

0 comments on commit a67aa1f

Please sign in to comment.