Packages

Erlang code generator for Idris 2

Current section

Files

Jump to
idris2 src Idris.Idris2.Compiler.Erlang.Cmd.erl
Raw

src/Idris.Idris2.Compiler.Erlang.Cmd.erl

-module('Idris.Idris2.Compiler.Erlang.Cmd').
-compile('no_auto_import').
-compile('inline').
-compile({'inline_size',24}).
-export([
'case--compileAbstrToErlCmd-2456'/4,
'nested--1687-2296--in--un--escapeComponent'/2,
'nested--1687-2295--in--un--escapeChar'/2,
'un--pmapErlFun'/0,
'un--executeBeamCmd'/3,
'un--evalErlangSourceCmd'/2,
'un--escapeCmd'/1,
'un--compileErlToBeamCmd'/3,
'un--compileAbstrToErlCmd'/4,
'un--compileAbstrToBeamCmd'/3
]).
'case--compileAbstrToErlCmd-2456'(V0, V1, V2, V3) -> case V3 of 0 -> 10000; 1 -> 120; _ -> ('erlang':'throw'("Error: Unreachable branch")) end.
'nested--1687-2296--in--un--escapeComponent'(V0, V1) -> ('Idris.Idris2.Prelude.Types.Strings':'un--++'(<<"\x{27}"/utf8>>, ('Idris.Idris2.Prelude.Types.Strings':'un--++'((('Idris.Idris2.Prelude.Interfaces':'un--concat'('erased', 'erased', {'Idris.Builtin.MkPair', {'Idris.Prelude.Interfaces.dn--un--__mkFoldable', fun (V3) -> fun (V4) -> fun (V5) -> fun (V6) -> fun (V7) -> ('Idris.Idris2.Prelude.Types':'dn--un--foldr_Foldable__List'('erased', 'erased', V5, V6, V7)) end end end end end, fun (V8) -> fun (V9) -> fun (V10) -> fun (V11) -> fun (V12) -> ('Idris.Idris2.Prelude.Types':'dn--un--foldl_Foldable__List'('erased', 'erased', V10, V11, V12)) end end end end end}, {'Idris.Prelude.Interfaces.dn--un--__mkMonoid', fun (V13) -> fun (V14) -> ('Idris.Idris2.Prelude.Types':'dn--un--<+>_Semigroup__String'(V13, V14)) end end, ('Idris.Idris2.Prelude.Types':'dn--un--neutral_Monoid__String'())}}))(('Idris.Idris2.Prelude.Types':'dn--un--map_Functor__List'('erased', 'erased', fun (V2) -> ('nested--1687-2295--in--un--escapeChar'(V0, V2)) end, ('Idris.Idris2.Prelude.Types':'un--unpack'(V1)))))), <<"\x{27}"/utf8>>)))).
'nested--1687-2295--in--un--escapeChar'(V0, V1) -> case V1 of $\x{27} -> <<"\x{27}\x{22}\x{27}\x{22}\x{27}"/utf8>>; _ -> ('Idris.Idris2.Prelude.Types':'dn--un--cast_Cast__Char_String'(V1)) end.
'un--pmapErlFun'() -> <<"Collect = fun\x{a} Collect([]) -> [];\x{a} Collect([{Pid, MRef} | Next]) ->\x{a} receive\x{a} {Pid, Res} ->\x{a} erlang:demonitor(MRef, [flush]),\x{a} [{ok, Res} | Collect(Next)];\x{a} {\x{27}DOWN\x{27}, MRef, process, Pid, Reason} ->\x{a} [{error, Reason} | Collect(Next)]\x{a} end\x{a} end,\x{a} Pmap = fun(F, Es) ->\x{a} Parent = self(),\x{a} Running = [\x{a} spawn_monitor(fun() -> Parent ! {self(), F(E)} end)\x{a} || E <- Es],\x{a} Collect(Running)\x{a}end"/utf8>>.
'un--executeBeamCmd'(V0, V1, V2) -> ('un--escapeCmd'([V0 | [<<"-noshell"/utf8>> | [<<"-boot"/utf8>> | [<<"no_dot_erlang"/utf8>> | [<<"-pa"/utf8>> | [V1 | [<<"-run"/utf8>> | [V2 | []]]]]]]]])).
'un--evalErlangSourceCmd'(V0, V1) -> ('un--escapeCmd'([V0 | [<<"-noshell"/utf8>> | [<<"-boot"/utf8>> | [<<"no_dot_erlang"/utf8>> | [<<"-eval"/utf8>> | [V1 | []]]]]]])).
'un--escapeCmd'(V0) -> ('Idris.Idris2.Data.Strings':'un--unwords'(('Idris.Idris2.Prelude.Types':'dn--un--map_Functor__List'('erased', 'erased', fun (V1) -> ('nested--1687-2296--in--un--escapeComponent'(V0, V1)) end, V0)))).
'un--compileErlToBeamCmd'(V0, V1, V2) -> ('un--escapeCmd'(('Idris.Idris2.Prelude.Types.List':'un--++'('erased', [V0 | [<<"-W0"/utf8>> | [<<"-o"/utf8>> | [V2 | []]]]], V1)))).
'un--compileAbstrToErlCmd'(V0, V1, V2, V3) -> begin (V4 = case V0 of 0 -> 10000; 1 -> 120; _ -> ('erlang':'throw'("Error: Unreachable branch")) end), begin (V5 = ('Idris.Idris2.Prelude.Types.Strings':'un--++'(<<"[{paper, "/utf8>>, ('Idris.Idris2.Prelude.Types.Strings':'un--++'(('Idris.Idris2.Prelude.Show':'dn--un--show_Show__Int'(V4)), ('Idris.Idris2.Prelude.Types.Strings':'un--++'(<<"}, {ribbon, "/utf8>>, ('Idris.Idris2.Prelude.Types.Strings':'un--++'(('Idris.Idris2.Prelude.Show':'dn--un--show_Show__Int'(V4)), <<"}]"/utf8>>))))))))), begin (V21 = (('Idris.Idris2.Prelude.Interfaces':'un--concat'('erased', 'erased', {'Idris.Builtin.MkPair', {'Idris.Prelude.Interfaces.dn--un--__mkFoldable', fun (V9) -> fun (V10) -> fun (V11) -> fun (V12) -> fun (V13) -> ('Idris.Idris2.Prelude.Types':'dn--un--foldr_Foldable__List'('erased', 'erased', V11, V12, V13)) end end end end end, fun (V14) -> fun (V15) -> fun (V16) -> fun (V17) -> fun (V18) -> ('Idris.Idris2.Prelude.Types':'dn--un--foldl_Foldable__List'('erased', 'erased', V16, V17, V18)) end end end end end}, {'Idris.Prelude.Interfaces.dn--un--__mkMonoid', fun (V19) -> fun (V20) -> ('Idris.Idris2.Prelude.Types':'dn--un--<+>_Semigroup__String'(V19, V20)) end end, ('Idris.Idris2.Prelude.Types':'dn--un--neutral_Monoid__String'())}}))([('un--pmapErlFun'()) | [<<",\x{a}ModuleNameFromForms = fun(Forms) ->\x{a} lists:foldl(\x{a} fun\x{a} ({attribute, _, module, ModuleName}, _Acc) -> {ok, ModuleName};\x{a} (_, Acc) -> Acc\x{a} end, not_found, Forms)\x{a}end,\x{a}GenerateErl = fun(File, OutputDir) ->\x{a} {ok, Forms} = file:consult(File),\x{a} {ok, ModuleName} = ModuleNameFromForms(Forms),\x{a} OutputFile = filename:join(OutputDir, atom_to_list(ModuleName) ++ \x{22}.erl\x{22}),\x{a} ErlangSource = erl_prettypr:format(erl_syntax:form_list(Forms), "/utf8>> | [V5 | [<<"),\x{a} file:write_file(OutputFile, ErlangSource)\x{a}end,\x{a}Pmap(fun(File) -> GenerateErl(File, "/utf8>> | [('Idris.Idris2.Prelude.Show':'dn--un--show_Show__String'(V3)) | [<<") end, "/utf8>> | [('Idris.Idris2.Prelude.Show':'dn--un--show_Show__(List $a)'('erased', {'Idris.Prelude.Show.dn--un--__mkShow', fun (V6) -> ('Idris.Idris2.Prelude.Show':'dn--un--show_Show__String'(V6)) end, fun (V7) -> fun (V8) -> ('Idris.Idris2.Prelude.Show':'dn--un--showPrec_Show__String'(V7, V8)) end end}, V2)) | [<<"),\x{a}halt(0)"/utf8>> | []]]]]]]]]))), ('un--evalErlangSourceCmd'(V1, V21)) end end end.
'un--compileAbstrToBeamCmd'(V0, V1, V2) -> begin (V18 = (('Idris.Idris2.Prelude.Interfaces':'un--concat'('erased', 'erased', {'Idris.Builtin.MkPair', {'Idris.Prelude.Interfaces.dn--un--__mkFoldable', fun (V6) -> fun (V7) -> fun (V8) -> fun (V9) -> fun (V10) -> ('Idris.Idris2.Prelude.Types':'dn--un--foldr_Foldable__List'('erased', 'erased', V8, V9, V10)) end end end end end, fun (V11) -> fun (V12) -> fun (V13) -> fun (V14) -> fun (V15) -> ('Idris.Idris2.Prelude.Types':'dn--un--foldl_Foldable__List'('erased', 'erased', V13, V14, V15)) end end end end end}, {'Idris.Prelude.Interfaces.dn--un--__mkMonoid', fun (V16) -> fun (V17) -> ('Idris.Idris2.Prelude.Types':'dn--un--<+>_Semigroup__String'(V16, V17)) end end, ('Idris.Idris2.Prelude.Types':'dn--un--neutral_Monoid__String'())}}))([('un--pmapErlFun'()) | [<<",\x{a}CompileAbstr = fun(File, OutputDir) ->\x{a} {ok, Forms} = file:consult(File),\x{a} {ok, ModuleName, BinaryOrCode} = compile:noenv_forms(Forms, []),\x{a} OutputFile = filename:join(OutputDir, atom_to_list(ModuleName) ++ \x{22}.beam\x{22}),\x{a} file:write_file(OutputFile, BinaryOrCode)\x{a}end,\x{a}Pmap(fun(File) -> CompileAbstr(File, "/utf8>> | [('Idris.Idris2.Prelude.Show':'dn--un--show_Show__String'(V2)) | [<<") end, "/utf8>> | [('Idris.Idris2.Prelude.Show':'dn--un--show_Show__(List $a)'('erased', {'Idris.Prelude.Show.dn--un--__mkShow', fun (V3) -> ('Idris.Idris2.Prelude.Show':'dn--un--show_Show__String'(V3)) end, fun (V4) -> fun (V5) -> ('Idris.Idris2.Prelude.Show':'dn--un--showPrec_Show__String'(V4, V5)) end end}, V1)) | [<<"),\x{a}halt(0)"/utf8>> | []]]]]]]))), ('un--evalErlangSourceCmd'(V0, V18)) end.