From 3fc9ac4098b6c0f966a643fde65ef1ecfedfea04 Mon Sep 17 00:00:00 2001 From: Yura Lazarev Date: Tue, 28 Mar 2023 23:28:57 +0200 Subject: [PATCH 1/2] Fix for the DCE in case of reexports --- lib/Language/PureScript/Backend.hs | 4 +-- lib/Language/PureScript/Backend/IR/DCE.hs | 34 +++++++++---------- .../Language/PureScript/Backend/IR/DCESpec.hs | 8 ++--- .../PureScript/Backend/Lua/GoldenSpec.hs | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/Language/PureScript/Backend.hs b/lib/Language/PureScript/Backend.hs index 7b99195..5a802dd 100644 --- a/lib/Language/PureScript/Backend.hs +++ b/lib/Language/PureScript/Backend.hs @@ -82,10 +82,10 @@ compileModules outputDir foreignDir appOrModule = do dceStrategy = case appOrModule of AsApplication (AppEntryPoint modul entryIdent) -> - DCE.PreserveSpecified $ + DCE.EntryPoints $ NE.singleton ( IR.mkModuleName modul , NE.singleton (IR.identToName entryIdent) ) AsModule (ModuleEntryPoint modul) -> - DCE.PreserveModuleTopLevel (NE.singleton (IR.mkModuleName modul)) + DCE.EntryPointsSomeModules (NE.singleton (IR.mkModuleName modul)) diff --git a/lib/Language/PureScript/Backend/IR/DCE.hs b/lib/Language/PureScript/Backend/IR/DCE.hs index 9f60aae..f3db78a 100644 --- a/lib/Language/PureScript/Backend/IR/DCE.hs +++ b/lib/Language/PureScript/Backend/IR/DCE.hs @@ -35,9 +35,9 @@ import Language.PureScript.Backend.IR.Types import Relude.Unsafe qualified as Unsafe data Strategy - = PreserveSpecified (NonEmpty (ModuleName, NonEmpty Name)) - | PreserveModuleTopLevel (NonEmpty ModuleName) - | PreserveAllTopLevel + = EntryPoints (NonEmpty (ModuleName, NonEmpty Name)) + | EntryPointsSomeModules (NonEmpty ModuleName) + | EntryPointsAllModules deriving stock (Show) eliminateDeadCode :: Strategy -> [Module] -> [Module] @@ -62,11 +62,20 @@ eliminateDeadCode strategy modules = uncurry dceModule <$> reachableByModule where entryPoints :: [(ModuleName, [Name])] entryPoints = case strategy of - PreserveSpecified points -> toList (toList <<$>> points) - PreserveAllTopLevel -> (moduleName &&& topLevelNames) <$> modules - PreserveModuleTopLevel moduleNames -> - modules >>= \m@Module {moduleName = name} -> - guard (name `elem` moduleNames) $> (name, topLevelNames m) + EntryPoints points -> + toList (toList <<$>> points) + EntryPointsAllModules -> + modules >>= moduleEntryPoints + EntryPointsSomeModules modulesNames -> + filter (\m -> moduleName m `elem` modulesNames) modules + >>= moduleEntryPoints + + moduleEntryPoints :: Module -> [(ModuleName, [Name])] + moduleEntryPoints Module {..} = + mconcat + [ [(moduleName, moduleForeigns <> (moduleBindings >>= bindingNames))] + , Map.toList moduleReExports + ] (graph, vertexToV, keyToVertex) = buildGraph modules @@ -118,15 +127,6 @@ eliminateDeadCode strategy modules = uncurry dceModule <$> reachableByModule reachableQNames :: [QName] = [n | (_, qname, deps) <- adjacencies, n <- qname : deps] -topLevelNames :: Module -> [Name] -topLevelNames Module {moduleBindings, moduleForeigns} = - moduleForeigns <> namesFroBindings - where - namesFroBindings = - moduleBindings >>= \case - Standalone (name, _) -> [name] - RecursiveGroup bindings -> fst <$> toList bindings - type QName = (ModuleName, Name) data Node diff --git a/test/Language/PureScript/Backend/IR/DCESpec.hs b/test/Language/PureScript/Backend/IR/DCESpec.hs index 6e36a49..c6ddd54 100644 --- a/test/Language/PureScript/Backend/IR/DCESpec.hs +++ b/test/Language/PureScript/Backend/IR/DCESpec.hs @@ -18,7 +18,7 @@ import Test.Hspec.Hedgehog.Extended (test) spec :: Spec spec = describe "IR Dead Code Elimination" do test "test not eliminate a module with an exported entry point" do - let strategy = PreserveSpecified $ NE.singleton mainEntryPoint + let strategy = EntryPoints $ NE.singleton mainEntryPoint [entryPointModule] === eliminateDeadCode strategy [entryPointModule] test "eliminates unused non-exported binding" do @@ -27,7 +27,7 @@ spec = describe "IR Dead Code Elimination" do { moduleBindings = binding_ "unused" : moduleBindings entryPointModule } - strategy = PreserveSpecified $ NE.singleton mainEntryPoint + strategy = EntryPoints $ NE.singleton mainEntryPoint [entryModule {moduleBindings = [binding_ "main"]}] === eliminateDeadCode strategy [entryModule] @@ -47,7 +47,7 @@ spec = describe "IR Dead Code Elimination" do , moduleBindings = [b] , moduleExports = [name] } - strategy = PreserveSpecified $ NE.singleton mainEntryPoint + strategy = EntryPoints $ NE.singleton mainEntryPoint [entryModule, otherModule] === eliminateDeadCode strategy [entryModule, otherModule] @@ -66,7 +66,7 @@ spec = describe "IR Dead Code Elimination" do , moduleBindings = [binding_ "foo"] , moduleExports = [Name "foo"] } - strategy = PreserveSpecified $ NE.singleton mainEntryPoint + strategy = EntryPoints $ NE.singleton mainEntryPoint [entryModule] === eliminateDeadCode strategy [entryModule, otherModule] diff --git a/test/Language/PureScript/Backend/Lua/GoldenSpec.hs b/test/Language/PureScript/Backend/Lua/GoldenSpec.hs index a92d455..5b6abb5 100644 --- a/test/Language/PureScript/Backend/Lua/GoldenSpec.hs +++ b/test/Language/PureScript/Backend/Lua/GoldenSpec.hs @@ -169,7 +169,7 @@ compileCorefn outputDir moduleName = do & Oops.runOops & liftIO - optimizeAll DCE.PreserveAllTopLevel + optimizeAll DCE.EntryPointsAllModules <$> traverse (either (fail . show) (pure . snd) . IR.mkModule) (toList cfnModules) From 73a05e2b73ea20364373bcf31482c056a6aa298c Mon Sep 17 00:00:00 2001 From: Yura Lazarev Date: Wed, 29 Mar 2023 13:44:17 +0200 Subject: [PATCH 2/2] refactor: DCE, GoldenSpec --- lib/Language/PureScript/Backend/IR/DCE.hs | 17 +-- .../PureScript/Backend/Lua/GoldenSpec.hs | 6 +- test/ps/golden/Golden/Reexport/Exports.purs | 4 + test/ps/golden/Golden/Reexport/ReExports.purs | 9 ++ test/ps/golden/Golden/TestReexport.purs | 6 + .../Golden.Reexport.Exports/corefn.json | 1 + .../output/Golden.Reexport.Exports/golden.ir | 14 ++ .../output/Golden.Reexport.Exports/golden.lua | 4 + .../Golden.Reexport.ReExports/corefn.json | 1 + .../Golden.Reexport.ReExports/golden.ir | 16 +++ .../Golden.Reexport.ReExports/golden.lua | 4 + .../Golden.TestCaseStatements/golden.ir | 63 +-------- .../Golden.TestCaseStatements/golden.lua | 7 +- .../Golden.TestDataDeclarations2/golden.ir | 128 ------------------ .../Golden.TestDataDeclarations2/golden.lua | 49 ------- .../ps/output/Golden.TestReexport/corefn.json | 1 + test/ps/output/Golden.TestReexport/golden.ir | 80 +++++++++++ test/ps/output/Golden.TestReexport/golden.lua | 15 ++ 18 files changed, 167 insertions(+), 258 deletions(-) create mode 100644 test/ps/golden/Golden/Reexport/Exports.purs create mode 100644 test/ps/golden/Golden/Reexport/ReExports.purs create mode 100644 test/ps/golden/Golden/TestReexport.purs create mode 100644 test/ps/output/Golden.Reexport.Exports/corefn.json create mode 100644 test/ps/output/Golden.Reexport.Exports/golden.ir create mode 100644 test/ps/output/Golden.Reexport.Exports/golden.lua create mode 100644 test/ps/output/Golden.Reexport.ReExports/corefn.json create mode 100644 test/ps/output/Golden.Reexport.ReExports/golden.ir create mode 100644 test/ps/output/Golden.Reexport.ReExports/golden.lua create mode 100644 test/ps/output/Golden.TestReexport/corefn.json create mode 100644 test/ps/output/Golden.TestReexport/golden.ir create mode 100644 test/ps/output/Golden.TestReexport/golden.lua diff --git a/lib/Language/PureScript/Backend/IR/DCE.hs b/lib/Language/PureScript/Backend/IR/DCE.hs index f3db78a..8a8a23c 100644 --- a/lib/Language/PureScript/Backend/IR/DCE.hs +++ b/lib/Language/PureScript/Backend/IR/DCE.hs @@ -62,20 +62,15 @@ eliminateDeadCode strategy modules = uncurry dceModule <$> reachableByModule where entryPoints :: [(ModuleName, [Name])] entryPoints = case strategy of - EntryPoints points -> - toList (toList <<$>> points) - EntryPointsAllModules -> - modules >>= moduleEntryPoints + EntryPoints points -> toList (toList <<$>> points) + EntryPointsAllModules -> moduleEntryPoints <$> modules EntryPointsSomeModules modulesNames -> - filter (\m -> moduleName m `elem` modulesNames) modules - >>= moduleEntryPoints + moduleEntryPoints + <$> filter (moduleName >>> (`elem` modulesNames)) modules - moduleEntryPoints :: Module -> [(ModuleName, [Name])] + moduleEntryPoints :: Module -> (ModuleName, [Name]) moduleEntryPoints Module {..} = - mconcat - [ [(moduleName, moduleForeigns <> (moduleBindings >>= bindingNames))] - , Map.toList moduleReExports - ] + (moduleName, moduleForeigns <> (moduleBindings >>= bindingNames)) (graph, vertexToV, keyToVertex) = buildGraph modules diff --git a/test/Language/PureScript/Backend/Lua/GoldenSpec.hs b/test/Language/PureScript/Backend/Lua/GoldenSpec.hs index 5b6abb5..204b7e8 100644 --- a/test/Language/PureScript/Backend/Lua/GoldenSpec.hs +++ b/test/Language/PureScript/Backend/Lua/GoldenSpec.hs @@ -5,6 +5,7 @@ module Language.PureScript.Backend.Lua.GoldenSpec where import Control.Monad.Oops qualified as Oops import Data.List qualified as List +import Data.List.NonEmpty qualified as NE import Data.String qualified as String import Data.Tagged (Tagged (..)) import Data.Text qualified as Text @@ -73,7 +74,7 @@ spec = do [ "purs" , "compile" , "-v" - , "'golden/Golden/*.purs'" + , "'golden/Golden/**/*.purs'" , "'src/**/*.purs'" , -- , "'.spago/prelude/v6.0.0/src/**/*.purs'" "-g" @@ -169,7 +170,8 @@ compileCorefn outputDir moduleName = do & Oops.runOops & liftIO - optimizeAll DCE.EntryPointsAllModules + let irModuleName = IR.mkModuleName moduleName + optimizeAll (DCE.EntryPointsSomeModules (NE.singleton irModuleName)) <$> traverse (either (fail . show) (pure . snd) . IR.mkModule) (toList cfnModules) diff --git a/test/ps/golden/Golden/Reexport/Exports.purs b/test/ps/golden/Golden/Reexport/Exports.purs new file mode 100644 index 0000000..1f3c6c9 --- /dev/null +++ b/test/ps/golden/Golden/Reexport/Exports.purs @@ -0,0 +1,4 @@ +module Golden.Reexport.Exports (binding1) where + +binding1 :: Int +binding1 = 1 diff --git a/test/ps/golden/Golden/Reexport/ReExports.purs b/test/ps/golden/Golden/Reexport/ReExports.purs new file mode 100644 index 0000000..5eaf1ad --- /dev/null +++ b/test/ps/golden/Golden/Reexport/ReExports.purs @@ -0,0 +1,9 @@ +module Golden.Reexport.ReExports + ( module Reexported + , binding2 + ) where + +import Golden.Reexport.Exports (binding1) as Reexported + +binding2 :: Int +binding2 = 2 diff --git a/test/ps/golden/Golden/TestReexport.purs b/test/ps/golden/Golden/TestReexport.purs new file mode 100644 index 0000000..84a8a55 --- /dev/null +++ b/test/ps/golden/Golden/TestReexport.purs @@ -0,0 +1,6 @@ +module Golden.TestReexport where + +import Golden.Reexport.ReExports + +binding3 :: Array Int +binding3 = [ binding1 , binding2 ] diff --git a/test/ps/output/Golden.Reexport.Exports/corefn.json b/test/ps/output/Golden.Reexport.Exports/corefn.json new file mode 100644 index 0000000..4f8a842 --- /dev/null +++ b/test/ps/output/Golden.Reexport.Exports/corefn.json @@ -0,0 +1 @@ +{"builtWith":"0.15.7","comments":[],"decls":[{"annotation":{"meta":null,"sourceSpan":{"end":[3,16],"start":[3,1]}},"bindType":"NonRec","expression":{"annotation":{"meta":null,"sourceSpan":{"end":[4,13],"start":[4,12]}},"type":"Literal","value":{"literalType":"IntLiteral","value":1}},"identifier":"binding1"}],"exports":["binding1"],"foreign":[],"imports":[{"annotation":{"meta":null,"sourceSpan":{"end":[4,13],"start":[1,1]}},"moduleName":["Prim"]}],"moduleName":["Golden","Reexport","Exports"],"modulePath":"golden/Golden/Reexport/Exports.purs","reExports":{},"sourceSpan":{"end":[4,13],"start":[1,1]}} \ No newline at end of file diff --git a/test/ps/output/Golden.Reexport.Exports/golden.ir b/test/ps/output/Golden.Reexport.Exports/golden.ir new file mode 100644 index 0000000..8f0fdaa --- /dev/null +++ b/test/ps/output/Golden.Reexport.Exports/golden.ir @@ -0,0 +1,14 @@ +[Module + {moduleName = ModuleName "Golden.Reexport.Exports", + moduleBindings = + [Standalone + (Name "binding1", + Exp + {unExp = Lit (Integer 1), + expInfo = Info {refsFree = []}})], + moduleImports = [], + moduleExports = [Name "binding1"], + moduleReExports = fromList [], + moduleForeigns = [], + modulePath = "golden/Golden/Reexport/Exports.purs", + dataTypes = fromList []}] diff --git a/test/ps/output/Golden.Reexport.Exports/golden.lua b/test/ps/output/Golden.Reexport.Exports/golden.lua new file mode 100644 index 0000000..8742b1e --- /dev/null +++ b/test/ps/output/Golden.Reexport.Exports/golden.lua @@ -0,0 +1,4 @@ +local Golden_Reexport_Exports = (function() + local binding1 = 1 + return { binding1 = binding1 } +end)() diff --git a/test/ps/output/Golden.Reexport.ReExports/corefn.json b/test/ps/output/Golden.Reexport.ReExports/corefn.json new file mode 100644 index 0000000..bb247f3 --- /dev/null +++ b/test/ps/output/Golden.Reexport.ReExports/corefn.json @@ -0,0 +1 @@ +{"builtWith":"0.15.7","comments":[],"decls":[{"annotation":{"meta":null,"sourceSpan":{"end":[8,16],"start":[8,1]}},"bindType":"NonRec","expression":{"annotation":{"meta":null,"sourceSpan":{"end":[9,13],"start":[9,12]}},"type":"Literal","value":{"literalType":"IntLiteral","value":2}},"identifier":"binding2"}],"exports":["binding2"],"foreign":[],"imports":[{"annotation":{"meta":null,"sourceSpan":{"end":[6,56],"start":[6,1]}},"moduleName":["Golden","Reexport","Exports"]},{"annotation":{"meta":null,"sourceSpan":{"end":[9,13],"start":[1,1]}},"moduleName":["Prim"]}],"moduleName":["Golden","Reexport","ReExports"],"modulePath":"golden/Golden/Reexport/ReExports.purs","reExports":{"Golden.Reexport.Exports":["binding1"]},"sourceSpan":{"end":[9,13],"start":[1,1]}} \ No newline at end of file diff --git a/test/ps/output/Golden.Reexport.ReExports/golden.ir b/test/ps/output/Golden.Reexport.ReExports/golden.ir new file mode 100644 index 0000000..3147bf6 --- /dev/null +++ b/test/ps/output/Golden.Reexport.ReExports/golden.ir @@ -0,0 +1,16 @@ +[Module + {moduleName = ModuleName "Golden.Reexport.ReExports", + moduleBindings = + [Standalone + (Name "binding2", + Exp + {unExp = Lit (Integer 2), + expInfo = Info {refsFree = []}})], + moduleImports = [], + moduleExports = [Name "binding2"], + moduleReExports = + fromList + [(ModuleName "Golden.Reexport.Exports", [])], + moduleForeigns = [], + modulePath = "golden/Golden/Reexport/ReExports.purs", + dataTypes = fromList []}] diff --git a/test/ps/output/Golden.Reexport.ReExports/golden.lua b/test/ps/output/Golden.Reexport.ReExports/golden.lua new file mode 100644 index 0000000..cde51e3 --- /dev/null +++ b/test/ps/output/Golden.Reexport.ReExports/golden.lua @@ -0,0 +1,4 @@ +local Golden_Reexport_ReExports = (function() + local binding2 = 2 + return { binding2 = binding2 } +end)() diff --git a/test/ps/output/Golden.TestCaseStatements/golden.ir b/test/ps/output/Golden.TestCaseStatements/golden.ir index e0ef2f0..d7148a0 100644 --- a/test/ps/output/Golden.TestCaseStatements/golden.ir +++ b/test/ps/output/Golden.TestCaseStatements/golden.ir @@ -2106,11 +2106,6 @@ {moduleName = ModuleName "Golden.TestValues", moduleBindings = [Standalone - (Name "i", - Exp - {unExp = Lit (Integer 1), - expInfo = Info {refsFree = []}}), - Standalone (Name "f", Exp {unExp = @@ -2120,65 +2115,9 @@ (Exp {unExp = Lit (Boolean True), expInfo = Info {refsFree = []}})), - expInfo = Info {refsFree = []}}), - Standalone - (Name "c", - Exp - {unExp = Lit (Char 'c'), - expInfo = Info {refsFree = []}}), - Standalone - (Name "b", - Exp - {unExp = Lit (Boolean True), - expInfo = Info {refsFree = []}}), - Standalone - (Name "o", - Exp - {unExp = - Lit - (Object - [(PropName "i", - Exp - {unExp = RefFree (Local (Name "i")), - expInfo = Info {refsFree = [Local (Name "i")]}}), - (PropName "b", - Exp - {unExp = RefFree (Local (Name "b")), - expInfo = Info {refsFree = [Local (Name "b")]}}), - (PropName "c", - Exp - {unExp = RefFree (Local (Name "c")), - expInfo = Info {refsFree = [Local (Name "c")]}})]), - expInfo = - Info - {refsFree = - [Local (Name "i"), - Local (Name "b"), - Local (Name "c")]}}), - Standalone - (Name "a", - Exp - {unExp = - Lit - (Array - [Exp - {unExp = Lit (Integer 1), - expInfo = Info {refsFree = []}}, - Exp - {unExp = Lit (Integer 2), - expInfo = Info {refsFree = []}}, - Exp - {unExp = Lit (Integer 3), - expInfo = Info {refsFree = []}}]), expInfo = Info {refsFree = []}})], moduleImports = [], - moduleExports = - [Name "i", - Name "b", - Name "c", - Name "a", - Name "o", - Name "f"], + moduleExports = [Name "f"], moduleReExports = fromList [], moduleForeigns = [], modulePath = "golden/Golden/TestValues.purs", diff --git a/test/ps/output/Golden.TestCaseStatements/golden.lua b/test/ps/output/Golden.TestCaseStatements/golden.lua index 297b42a..9791a2f 100644 --- a/test/ps/output/Golden.TestCaseStatements/golden.lua +++ b/test/ps/output/Golden.TestCaseStatements/golden.lua @@ -1,11 +1,6 @@ local Golden_TestValues = (function() - local i = 1 local f = function() return true end - local c = "c" - local b = true - local o = { i = i, b = b, c = c } - local a = { 1, 2, 3 } - return { i = i, b = b, c = c, a = a, o = o, f = f } + return { f = f } end)() local Golden_TestCaseStatements = (function() local J = function(value0) diff --git a/test/ps/output/Golden.TestDataDeclarations2/golden.ir b/test/ps/output/Golden.TestDataDeclarations2/golden.ir index dee5867..d9ff54e 100644 --- a/test/ps/output/Golden.TestDataDeclarations2/golden.ir +++ b/test/ps/output/Golden.TestDataDeclarations2/golden.ir @@ -1,132 +1,4 @@ [Module - {moduleName = - ModuleName "Golden.TestDataDeclarations1", - moduleBindings = - [Standalone - (Name "U", - Exp - {unExp = - Ctor ProductType (TyName "Unit") (CtorName "U") [], - expInfo = Info {refsFree = []}}), - Standalone - (Name "CtorSameName", - Exp - {unExp = - Ctor - ProductType - (TyName "TySameName") - (CtorName "CtorSameName") - [], - expInfo = Info {refsFree = []}}), - Standalone - (Name "S0", - Exp - {unExp = - Ctor SumType (TyName "TSum") (CtorName "S0") [], - expInfo = Info {refsFree = []}}), - Standalone - (Name "S1", - Exp - {unExp = - Ctor - SumType - (TyName "TSum") - (CtorName "S1") - [FieldName "value0"], - expInfo = Info {refsFree = []}}), - Standalone - (Name "S2", - Exp - {unExp = - Ctor - SumType - (TyName "TSum") - (CtorName "S2") - [FieldName "value0", FieldName "value1"], - expInfo = Info {refsFree = []}}), - Standalone - (Name "PF", - Exp - {unExp = - Ctor - ProductType - (TyName "TProductWithFields") - (CtorName "PF") - [FieldName "value0"], - expInfo = Info {refsFree = []}}), - Standalone - (Name "P3", - Exp - {unExp = - Ctor - ProductType - (TyName "TProduct") - (CtorName "P3") - [FieldName "value0", - FieldName "value1", - FieldName "value2"], - expInfo = Info {refsFree = []}}), - Standalone - (Name "Nop", - Exp - {unExp = - Ctor SumType (TyName "Rec") (CtorName "Nop") [], - expInfo = Info {refsFree = []}}), - Standalone - (Name "More", - Exp - {unExp = - Ctor - SumType - (TyName "Rec") - (CtorName "More") - [FieldName "value0"], - expInfo = Info {refsFree = []}})], - moduleImports = [], - moduleExports = - [Name "U", - Name "P3", - Name "PF", - Name "S0", - Name "S1", - Name "S2", - Name "Nop", - Name "More", - Name "CtorSameName"], - moduleReExports = fromList [], - moduleForeigns = [], - modulePath = - "golden/Golden/TestDataDeclarations1.purs", - dataTypes = - fromList - [(TyName "Rec", - (SumType, - fromList - [(CtorName "More", [FieldName "value0"]), - (CtorName "Nop", [])])), - (TyName "TProduct", - (ProductType, - fromList - [(CtorName "P3", - [FieldName "value0", - FieldName "value1", - FieldName "value2"])])), - (TyName "TProductWithFields", - (ProductType, - fromList [(CtorName "PF", [FieldName "value0"])])), - (TyName "TSum", - (SumType, - fromList - [(CtorName "S0", []), - (CtorName "S1", [FieldName "value0"]), - (CtorName "S2", - [FieldName "value0", FieldName "value1"])])), - (TyName "TySameName", - (ProductType, - fromList [(CtorName "CtorSameName", [])])), - (TyName "Unit", - (ProductType, fromList [(CtorName "U", [])]))]}, - Module {moduleName = ModuleName "Golden.TestDataDeclarations2", moduleBindings = diff --git a/test/ps/output/Golden.TestDataDeclarations2/golden.lua b/test/ps/output/Golden.TestDataDeclarations2/golden.lua index 228d0a3..8043016 100644 --- a/test/ps/output/Golden.TestDataDeclarations2/golden.lua +++ b/test/ps/output/Golden.TestDataDeclarations2/golden.lua @@ -1,52 +1,3 @@ -local Golden_TestDataDeclarations1 = (function() - local U = function() - return { ["$ctor"] = "Golden_TestDataDeclarations1.U" } - end - local CtorSameName = function() - return { ["$ctor"] = "Golden_TestDataDeclarations1.CtorSameName" } - end - local S0 = function() - return { ["$ctor"] = "Golden_TestDataDeclarations1.S0" } - end - local S1 = function(value0) - return { ["$ctor"] = "Golden_TestDataDeclarations1.S1", value0 = value0 } - end - local S2 = function(value0, value1) - return { - ["$ctor"] = "Golden_TestDataDeclarations1.S2", - value0 = value0, - value1 = value1 - } - end - local PF = function(value0) - return { ["$ctor"] = "Golden_TestDataDeclarations1.PF", value0 = value0 } - end - local P3 = function(value0, value1, value2) - return { - ["$ctor"] = "Golden_TestDataDeclarations1.P3", - value0 = value0, - value1 = value1, - value2 = value2 - } - end - local Nop = function() - return { ["$ctor"] = "Golden_TestDataDeclarations1.Nop" } - end - local More = function(value0) - return { ["$ctor"] = "Golden_TestDataDeclarations1.More", value0 = value0 } - end - return { - U = U, - P3 = P3, - PF = PF, - S0 = S0, - S1 = S1, - S2 = S2, - Nop = Nop, - More = More, - CtorSameName = CtorSameName - } -end)() local Golden_TestDataDeclarations2 = (function() local CtorSameName = function() return { ["$ctor"] = "Golden_TestDataDeclarations2.CtorSameName" } diff --git a/test/ps/output/Golden.TestReexport/corefn.json b/test/ps/output/Golden.TestReexport/corefn.json new file mode 100644 index 0000000..ae653d4 --- /dev/null +++ b/test/ps/output/Golden.TestReexport/corefn.json @@ -0,0 +1 @@ +{"builtWith":"0.15.7","comments":[],"decls":[{"annotation":{"meta":null,"sourceSpan":{"end":[5,22],"start":[5,1]}},"bindType":"NonRec","expression":{"annotation":{"meta":null,"sourceSpan":{"end":[6,35],"start":[6,12]}},"type":"Literal","value":{"literalType":"ArrayLiteral","value":[{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[6,22],"start":[6,14]}},"type":"Var","value":{"identifier":"binding1","moduleName":["Golden","Reexport","Exports"]}},{"annotation":{"meta":{"metaType":"IsForeign"},"sourceSpan":{"end":[6,33],"start":[6,25]}},"type":"Var","value":{"identifier":"binding2","moduleName":["Golden","Reexport","ReExports"]}}]}},"identifier":"binding3"}],"exports":["binding3"],"foreign":[],"imports":[{"annotation":{"meta":null,"sourceSpan":{"end":[6,35],"start":[1,1]}},"moduleName":["Golden","Reexport","Exports"]},{"annotation":{"meta":null,"sourceSpan":{"end":[6,35],"start":[1,1]}},"moduleName":["Golden","Reexport","ReExports"]},{"annotation":{"meta":null,"sourceSpan":{"end":[6,35],"start":[1,1]}},"moduleName":["Prim"]}],"moduleName":["Golden","TestReexport"],"modulePath":"golden/Golden/TestReexport.purs","reExports":{},"sourceSpan":{"end":[6,35],"start":[1,1]}} \ No newline at end of file diff --git a/test/ps/output/Golden.TestReexport/golden.ir b/test/ps/output/Golden.TestReexport/golden.ir new file mode 100644 index 0000000..d8d66b2 --- /dev/null +++ b/test/ps/output/Golden.TestReexport/golden.ir @@ -0,0 +1,80 @@ +[Module + {moduleName = ModuleName "Golden.Reexport.Exports", + moduleBindings = + [Standalone + (Name "binding1", + Exp + {unExp = Lit (Integer 1), + expInfo = Info {refsFree = []}})], + moduleImports = [], + moduleExports = [Name "binding1"], + moduleReExports = fromList [], + moduleForeigns = [], + modulePath = "golden/Golden/Reexport/Exports.purs", + dataTypes = fromList []}, + Module + {moduleName = ModuleName "Golden.Reexport.ReExports", + moduleBindings = + [Standalone + (Name "binding2", + Exp + {unExp = Lit (Integer 2), + expInfo = Info {refsFree = []}})], + moduleImports = [], + moduleExports = [Name "binding2"], + moduleReExports = + fromList + [(ModuleName "Golden.Reexport.Exports", [])], + moduleForeigns = [], + modulePath = "golden/Golden/Reexport/ReExports.purs", + dataTypes = fromList []}, + Module + {moduleName = ModuleName "Golden.TestReexport", + moduleBindings = + [Standalone + (Name "binding3", + Exp + {unExp = + Lit + (Array + [Exp + {unExp = + RefFree + (Imported + (ModuleName "Golden.Reexport.Exports") + (Name "binding1")), + expInfo = + Info + {refsFree = + [Imported + (ModuleName "Golden.Reexport.Exports") + (Name "binding1")]}}, + Exp + {unExp = + RefFree + (Imported + (ModuleName "Golden.Reexport.ReExports") + (Name "binding2")), + expInfo = + Info + {refsFree = + [Imported + (ModuleName "Golden.Reexport.ReExports") + (Name "binding2")]}}]), + expInfo = + Info + {refsFree = + [Imported + (ModuleName "Golden.Reexport.Exports") + (Name "binding1"), + Imported + (ModuleName "Golden.Reexport.ReExports") + (Name "binding2")]}})], + moduleImports = + [ModuleName "Golden.Reexport.Exports", + ModuleName "Golden.Reexport.ReExports"], + moduleExports = [Name "binding3"], + moduleReExports = fromList [], + moduleForeigns = [], + modulePath = "golden/Golden/TestReexport.purs", + dataTypes = fromList []}] diff --git a/test/ps/output/Golden.TestReexport/golden.lua b/test/ps/output/Golden.TestReexport/golden.lua new file mode 100644 index 0000000..686aea4 --- /dev/null +++ b/test/ps/output/Golden.TestReexport/golden.lua @@ -0,0 +1,15 @@ +local Golden_Reexport_Exports = (function() + local binding1 = 1 + return { binding1 = binding1 } +end)() +local Golden_Reexport_ReExports = (function() + local binding2 = 2 + return { binding2 = binding2 } +end)() +local Golden_TestReexport = (function() + local binding3 = { + Golden_Reexport_Exports.binding1, + Golden_Reexport_ReExports.binding2 + } + return { binding3 = binding3 } +end)()