on master help sign in
Start calling things ports again
commit116f789d0f7d6f0761e6e96d7a521117efb45456 authorEvan Czaplicki <info@elm-lang.org> dateMon 11 Apr 2016, 17:42 (11 years ago) parentf24673b
6 files changed+17−19
src/Generate/JavaScript.hs+1−1 src/Generate/JavaScript/BuiltIn.hs+7−7 src/Generate/JavaScript/Expression.hs+2−2 src/Parse/Declaration.hs+5−5 src/Parse/Helpers.hs+1−1 src/Parse/Module.hs+1−3
src/Generate/JavaScript.hs+1−1
@@ -48,7 +48,7 @@ generateEffectManager moduleName effects =
4848 Effects.Manager pkgName (Effects.Info _ _ _ _ managerType) ->
4949 let
5050 managers =
51− Var.native (ModuleName.inCore ["Native","Platform"]) "globalManagerInfo"
51+ Var.native (ModuleName.inCore ["Native","Platform"]) "effectManagers"
5252
5353 managerName =
5454 JS.StringLit () (ModuleName.canonicalToString moduleName)
src/Generate/JavaScript/BuiltIn.hs+7−7
@@ -3,7 +3,7 @@ module Generate.JavaScript.BuiltIn
33 , list, range
44 , recordUpdate
55 , eq, cmp
6− , effect, foreignCmd, foreignSub
6+ , effect, outgoingPort, incomingPort
77 , crash
88 )
99 where
@@ -91,14 +91,14 @@ effect effectName =
9191 JS.StringLit () (ModuleName.canonicalToString effectName)
9292
9393
94−foreignCmd :: String -> JS.Expression () -> JS.Expression ()
95−foreignCmd name converter =
96− Var.coreNative "Platform" "foreignCmd" `call` [ JS.StringLit () name, converter ]
94+outgoingPort :: String -> JS.Expression () -> JS.Expression ()
95+outgoingPort name converter =
96+ Var.coreNative "Platform" "outgoingPort" `call` [ JS.StringLit () name, converter ]
9797
9898
99−foreignSub :: String -> JS.Expression () -> JS.Expression ()
100−foreignSub name converter =
101− Var.coreNative "Platform" "foreignSub" `call` [ JS.StringLit () name, converter ]
99+incomingPort :: String -> JS.Expression () -> JS.Expression ()
100+incomingPort name converter =
101+ Var.coreNative "Platform" "incomingPort" `call` [ JS.StringLit () name, converter ]
102102
103103
104104
src/Generate/JavaScript/Expression.hs+2−2
@@ -210,11 +210,11 @@ generateCode expr =
210210 jsExpr $ BuiltIn.effect moduleName
211211
212212 ForeignCmd name tipe ->
213− jsExpr $ BuiltIn.foreignCmd name (Foreign.encode tipe)
213+ jsExpr $ BuiltIn.outgoingPort name (Foreign.encode tipe)
214214
215215 ForeignSub name tipe ->
216216 do jsDecoder <- generateJsExpr (Foreign.decode tipe)
217− jsExpr $ BuiltIn.foreignSub name jsDecoder
217+ jsExpr $ BuiltIn.incomingPort name jsDecoder
218218
219219 Program kind body ->
220220 generateProgram kind body
src/Parse/Declaration.hs+5−5
@@ -16,7 +16,7 @@ declaration =
1616 choice
1717 [ typeDecl
1818 , infixDecl
19− , foreignDecl
19+ , portDecl
2020 , definition
2121 ]
2222
@@ -87,10 +87,10 @@ infixDecl =
8787-- FOREIGN
8888
8989
90−foreignDecl :: IParser Decl.Raw
91−foreignDecl =
92− expecting "a foreign declaration" $
93− do try (reserved "foreign")
90+portDecl :: IParser Decl.Raw
91+portDecl =
92+ expecting "a port declaration" $
93+ do try (reserved "port")
9494 forcedWS
9595 name <- Help.lowVar
9696 padded hasType
src/Parse/Helpers.hs+1−1
@@ -31,7 +31,7 @@ reserveds =
3131 , "module", "where"
3232 , "import", "exposing"
3333 , "as"
34− , "deriving"
34+ , "port"
3535 ]
3636
3737
src/Parse/Module.hs+1−3
@@ -96,9 +96,7 @@ parseTag =
9696 return (Module.Effect (R.Region start end))
9797 ,
9898 do start <- getMyPosition
99− reserved "foreign"
100− whitespace
101− reserved "effect"
99+ reserved "port"
102100 whitespace
103101 reserved "module"
104102 end <- getMyPosition