@@ -27,6 +27,7 @@ task name expr portType =
28data JSType
28data JSType
29 = JSNumber
29 = JSNumber
30 | JSBoolean
31 | JSBoolean
31 | JSString
32 | JSString
@@ -37,6 +38,7 @@ typeToString :: JSType -> String
37typeToString tipe =
38typeToString tipe =
38 case tipe of
39 case tipe of
39 JSNumber -> "a number"
40 JSNumber -> "a number"
41+ JSIntNumber -> "an integer"
40 JSBoolean -> "a boolean (true or false)"
42 JSBoolean -> "a boolean (true or false)"
41 JSString -> "a string"
43 JSString -> "a string"
42 JSArray -> "an array"
44 JSArray -> "an array"
@@ -82,12 +84,19 @@ check x jsType continue =
83 case jsType of
85 case jsType of
84 JSNumber -> [typeof "number"]
86 JSNumber -> [typeof "number"]
88+ [jsFold OpLAnd (typeof "number" : intChecks)]
85 JSBoolean -> [typeof "boolean"]
89 JSBoolean -> [typeof "boolean"]
86 JSString -> [typeof "string", instanceof "String"]
90 JSString -> [typeof "string", instanceof "String"]
87 JSArray -> [instanceof "Array"]
91 JSArray -> [instanceof "Array"]
88 JSObject fields ->
92 JSObject fields ->
89 [jsFold OpLAnd (typeof "object" : map member fields)]
93 [jsFold OpLAnd (typeof "object" : map member fields)]
96+ [ \x -> (ref "isFinite") `call` [x]
97+ , \x -> equal (obj ["Math","floor"] `call` [x]) x
92-- INBOUND
101-- INBOUND
@@ -127,8 +136,8 @@ toType tipe x =
127 toType (T.dealias args t) x
136 toType (T.dealias args t) x
129 T.Type (Var.Canonical Var.BuiltIn name)
138 T.Type (Var.Canonical Var.BuiltIn name)
130− | name == "Int" -> from JSNumber
131 | name == "Float" -> from JSNumber
139 | name == "Float" -> from JSNumber
140+ | name == "Int" -> from JSIntNumber
132 | name == "Bool" -> from JSBoolean
141 | name == "Bool" -> from JSBoolean
133 | name == "String" -> from JSString
142 | name == "String" -> from JSString