changed TestAndJump to emit else statements
This commit is contained in:
parent
31d4be5b3f
commit
63cfe79d76
|
@ -173,38 +173,39 @@ EOF
|
|||
(default stmt)]
|
||||
|
||||
[(TestAndJumpStatement? stmt)
|
||||
(default stmt)
|
||||
#;(let*: ([test : PrimitiveTest (TestAndJumpStatement-op stmt)]
|
||||
[jump : String (assemble-jump
|
||||
(make-Label (TestAndJumpStatement-label stmt)))])
|
||||
;; to help localize type checks, we add a type annotation here.
|
||||
(ann (cond
|
||||
(define test (TestAndJumpStatement-op stmt))
|
||||
|
||||
(: test-code String)
|
||||
(define test-code (cond
|
||||
[(TestFalse? test)
|
||||
(format "if (~a === false) { ~a }"
|
||||
(assemble-oparg (TestFalse-operand test))
|
||||
jump)]
|
||||
(format "if (~a === false)"
|
||||
(assemble-oparg (TestFalse-operand test)))]
|
||||
[(TestTrue? test)
|
||||
(format "if (~a !== false) { ~a }"
|
||||
(assemble-oparg (TestTrue-operand test))
|
||||
jump)]
|
||||
(format "if (~a !== false)"
|
||||
(assemble-oparg (TestTrue-operand test)))]
|
||||
[(TestOne? test)
|
||||
(format "if (~a === 1) { ~a }"
|
||||
(assemble-oparg (TestOne-operand test))
|
||||
jump)]
|
||||
(format "if (~a === 1)"
|
||||
(assemble-oparg (TestOne-operand test)))]
|
||||
[(TestZero? test)
|
||||
(format "if (~a === 0) { ~a }"
|
||||
(assemble-oparg (TestZero-operand test))
|
||||
jump)]
|
||||
(format "if (~a === 0)"
|
||||
(assemble-oparg (TestZero-operand test)))]
|
||||
|
||||
[(TestPrimitiveProcedure? test)
|
||||
(format "if (typeof(~a) === 'function') { ~a }"
|
||||
(assemble-oparg (TestPrimitiveProcedure-operand test))
|
||||
jump)]
|
||||
(format "if (typeof(~a) === 'function')"
|
||||
(assemble-oparg (TestPrimitiveProcedure-operand test)))]
|
||||
|
||||
[(TestClosureArityMismatch? test)
|
||||
(format "if (! RUNTIME.isArityMatching((~a).racketArity, ~a)) { ~a }"
|
||||
(format "if (! RUNTIME.isArityMatching((~a).racketArity, ~a))"
|
||||
(assemble-oparg (TestClosureArityMismatch-closure test))
|
||||
(assemble-oparg (TestClosureArityMismatch-n test))
|
||||
jump)])
|
||||
String))]
|
||||
(assemble-oparg (TestClosureArityMismatch-n test)))]))
|
||||
`(,test-code
|
||||
"{"
|
||||
,@(assemble-block-statements (BasicBlock-stmts
|
||||
(hash-ref blockht (TestAndJumpStatement-label stmt)))
|
||||
blockht)
|
||||
"} else {"
|
||||
,@(assemble-block-statements (rest stmts) blockht)
|
||||
"}")]
|
||||
|
||||
[(GotoStatement? stmt)
|
||||
(default stmt)]
|
||||
|
|
|
@ -369,7 +369,7 @@
|
|||
|
||||
;; Variable reference
|
||||
(check-equal? (run-my-parse #'(#%variable-reference x))
|
||||
(make-Top (make-Prefix (list (make-GlobalBucket 'x)))
|
||||
(make-Top (make-Prefix (list #f (make-GlobalBucket 'x)))
|
||||
(make-VariableReference (make-ToplevelRef 0 0 #f #t))))
|
||||
|
||||
;; todo: see what it would take to run a typed/racket/base language.
|
||||
|
|
Loading…
Reference in New Issue
Block a user