about to try adding those typechecks.

This commit is contained in:
Danny Yoo 2011-03-29 18:23:33 -04:00
parent a3f323a687
commit 073688b1a9
2 changed files with 6 additions and 6 deletions

View File

@ -172,10 +172,10 @@
(let ([test-string (let ([test-string
(case domain (case domain
[(number) [(number)
(format "typeof(~a) === 'number'" (format "(typeof(~a) === 'number')"
operand-string)] operand-string)]
[(string) [(string)
(format "typeof(~a) === 'string'" (format "(typeof(~a) === 'string')"
operand-string)] operand-string)]
[(list) [(list)
(format "(~a === [] || (typeof(~a) === 'object' && (~a).length === 2))" (format "(~a === [] || (typeof(~a) === 'object' && (~a).length === 2))"
@ -183,10 +183,10 @@
[(pair) [(pair)
(format "(typeof(~a) === 'object' && (~a).length === 2)" (format "(typeof(~a) === 'object' && (~a).length === 2)"
operand-string operand-string)])]) operand-string operand-string)])])
(format "(~a ? ~a : raise(new Error('Expected ' + ~a + ' as argument ' + ~s + ' but received ' + ~a)))" (format "((~a) ? (~a) : raise(new Error('Expected ' + ~s + ' as argument ' + ~s + ' but received ' + ~a)))"
test-string test-string
operand-string operand-string
domain (symbol->string domain)
pos pos
operand-string))) operand-string)))
@ -209,7 +209,7 @@
(: maybe-typecheck-operand (OperandDomain Natural String CompileTimeEnvironmentEntry -> String)) (: maybe-typecheck-operand (OperandDomain Natural String CompileTimeEnvironmentEntry -> String))
(define (maybe-typecheck-operand domain-type position operand-string knowledge) (define (maybe-typecheck-operand domain-type position operand-string knowledge)
(cond (cond
[(redundant-check? domain-type knowledge) [#t #;(redundant-check? domain-type knowledge)
operand-string] operand-string]
[else [else
(assemble-domain-check domain-type operand-string position)])) (assemble-domain-check domain-type operand-string position)]))

View File

@ -172,7 +172,7 @@ var Primitives = (function() {
}, },
'/': function(MACHINE, arity) { '/': function(MACHINE, arity) {
if (arity === 0) { raise(new Error();) } if (arity === 0) { raise(new Error()); }
testArgument('number', testArgument('number',
isNumber, isNumber,
MACHINE.env[MACHINE.env.length - 1], MACHINE.env[MACHINE.env.length - 1],