View Source Hologram.Compiler.Encoder (hologram v0.2.0)
Summary
Functions
Prints debug info for intercepted encode_ir/2 calls.
Encodes Elixir or Erlang alias as JavaScript class name.
Encodes an Elixir function into a JavaScript statement.
Extracts JavaScript source code for the given ported Erlang function and generates interpreter function definition JavaScript statetement.
Encodes Elixir IR to JavaScript source code.
Encodes Elixir term into JavaScript. If the term can be encoded into JavaScript then the result is in the shape of {:ok, js}. If the term can't be encoded into JavaScript then an error message is returned in the shape of {:error, message}.
Encodes Elixir term into JavaScript, erroring out if the term can't be encoded into JavaScript.
Functions
@spec debug( {module(), atom(), [Hologram.Compiler.IR.t() | Hologram.Compiler.Context.t()]}, String.t() | %FunctionClauseError{}, integer() ) :: :ok
Prints debug info for intercepted encode_ir/2 calls.
Encodes Elixir or Erlang alias as JavaScript class name.
Examples
iex> encode_as_class_name(Aaa.Bbb.Ccc)
"Elixir_Aaa_Bbb_Ccc"
iex> encode_as_class_name(:erlang)
"Erlang"
iex> encode_as_class_name(:aaa_bbb)
"Erlang_Aaa_Bbb"
@spec encode_elixir_function( String.t(), atom(), non_neg_integer(), :public | :private, [Hologram.Compiler.IR.FunctionClause.t()], Hologram.Compiler.Context.t() ) :: String.t()
Encodes an Elixir function into a JavaScript statement.
Extracts JavaScript source code for the given ported Erlang function and generates interpreter function definition JavaScript statetement.
@spec encode_ir(Hologram.Compiler.IR.t(), Hologram.Compiler.Context.t()) :: String.t()
Encodes Elixir IR to JavaScript source code.
Examples
iex> ir = %IR.ListType{
...> data: [
...> %IR.IntegerType{value: 1},
...> %IR.AtomType{value: :abc}
...> ]
...> }
iex> encode_ir(ir, %Context{})
"Type.list([Type.integer(1), Type.atom("abc")])"
Encodes Elixir term into JavaScript. If the term can be encoded into JavaScript then the result is in the shape of {:ok, js}. If the term can't be encoded into JavaScript then an error message is returned in the shape of {:error, message}.
Encodes Elixir term into JavaScript, erroring out if the term can't be encoded into JavaScript.