@@ -2,6 +2,7 @@ module Generate.JavaScript.Foreign (input, output) where
3import qualified Data.List as List
3import qualified Data.List as List
4import Generate.JavaScript.Helpers
4import Generate.JavaScript.Helpers
5+import AST.PrettyPrint (pretty)
5import AST.Type as T
6import AST.Type as T
6import qualified AST.Variable as Var
7import qualified AST.Variable as Var
7import Language.ECMAScript3.Syntax
8import Language.ECMAScript3.Syntax
@@ -65,16 +66,22 @@ check x jsType continue =
66input :: String -> CanonicalType -> Expression ()
67input :: String -> CanonicalType -> Expression ()
67input name tipe =
68input name tipe =
70+ [ string name, string (show (pretty t)), toTypeFunction t ]
68− case T.dealias tipe of
72+ case tipe of
69 App (Type signal) [t]
76 App (Type signal) [t]
70 | Var.isStream signal ->
77 | Var.isStream signal ->
71− obj ["_P","inputStream"] <| toTypeFunction t
78+ obj ["_P","inputStream"] `call` args t
73 | Var.isVarying signal ->
80 | Var.isVarying signal ->
74− obj ["_P","inputVarying"] <| toTypeFunction t
81+ obj ["_P","inputVarying"] `call` args t
76− dealiasedType ->
83+ _ ->
77− obj ["_P","inputValue"] <| toTypeFunction dealiasedType
84+ obj ["_P","inputValue"] `call` args tipe
80toTypeFunction :: CanonicalType -> Expression ()
87toTypeFunction :: CanonicalType -> Expression ()
@@ -166,16 +173,22 @@ toTuple types x =
167output :: String -> CanonicalType -> Expression () -> Expression ()
174output :: String -> CanonicalType -> Expression () -> Expression ()
168output name tipe value =
175output name tipe value =
177+ [ string name, fromTypeFunction t, value ]
169− case T.dealias tipe of
179+ case tipe of
170 App (Type signal) [t]
183 App (Type signal) [t]
171 | Var.isStream signal ->
184 | Var.isStream signal ->
172− obj ["_P","outputStream"] `call` [ fromTypeFunction t, value ]
185+ obj ["_P","outputStream"] `call` args t
174 | Var.isVarying signal ->
187 | Var.isVarying signal ->
175− obj ["_P","outputVarying"] `call` [ fromTypeFunction t, value ]
188+ obj ["_P","outputVarying"] `call` args t
177− dealiasedType ->
190+ _ ->
178− obj ["_P","outputValue"] `call` [ fromTypeFunction dealiasedType, value ]
191+ obj ["_P","outputValue"] `call` args tipe
181fromTypeFunction :: CanonicalType -> Expression ()
194fromTypeFunction :: CanonicalType -> Expression ()