@@ -5,6 +5,7 @@ import Generate.JavaScript.Helpers
5import AST.Type as T
5import AST.Type as T
6import qualified AST.Variable as Var
6import qualified AST.Variable as Var
7import Language.ECMAScript3.Syntax
7import Language.ECMAScript3.Syntax
8+import Generate.JavaScript.Variable (canonical)
9data JSType = JSNumber | JSBoolean | JSString | JSArray | JSObject [String]
10data JSType = JSNumber | JSBoolean | JSString | JSArray | JSObject [String]
10 deriving Show
11 deriving Show
@@ -29,7 +30,7 @@ incoming tipe =
29 Aliased _ t -> incoming t
30 Aliased _ t -> incoming t
31 App (Type v) [t]
32 App (Type v) [t]
32− | Var.isSignal v -> obj ["Native","Ports","incomingSignal"] <| incoming t
33+ | Var.isSignal v -> obj ["_P","incomingSignal"] <| incoming t
34 _ -> ["v"] ==> inc tipe (ref "v")
35 _ -> ["v"] ==> inc tipe (ref "v")
@@ -50,8 +51,11 @@ inc tipe x =
50 from checks = check x checks x
51 from checks = check x checks x
53− | Var.isJson name -> obj ["Native","Json","fromJS"] <| x
54+ | Var.isJson name -> canonical fromJS <| x
54 | otherwise -> error "bad type got to incoming port generation code"
55 | otherwise -> error "bad type got to incoming port generation code"
57+ fromJS = Var.Canonical (Var.Module "Native.Json") "fromJS"
56 App f args ->
60 App f args ->
57 case f : args of
61 case f : args of
@@ -96,7 +100,7 @@ outgoing tipe =
96 Aliased _ t -> outgoing t
100 Aliased _ t -> outgoing t
98 App (Type v) [t]
102 App (Type v) [t]
99− | Var.isSignal v -> obj ["Native","Ports","outgoingSignal"] <| outgoing t
103+ | Var.isSignal v -> obj ["_P","outgoingSignal"] <| outgoing t
101 _ -> ["v"] ==> out tipe (ref "v")
105 _ -> ["v"] ==> out tipe (ref "v")
@@ -125,8 +129,10 @@ out tipe x =
125 | name `elem` ["Int","Float","Bool","String"] -> x
129 | name `elem` ["Int","Float","Bool","String"] -> x
127 Type name
131 Type name
128− | Var.isJson name -> obj ["Native","Json","toJS"] <| x
132+ | Var.isJson name -> canonical toJS <| x
129 | otherwise -> error "bad type got to outgoing port generation code"
133 | otherwise -> error "bad type got to outgoing port generation code"
135+ toJS = Var.Canonical (Var.Module "Native.Json") "toJS"
131 App f args ->
137 App f args ->
132 case f : args of
138 case f : args of