Permalink
Browse files

Allow meta compilation.

  • Loading branch information...
1 parent 96a2ab2 commit c9f808a6f400dd7c16489f928398c43f332a3eaa @josevalim josevalim committed Mar 1, 2012
Showing with 23 additions and 17 deletions.
  1. +4 −2 lib/elixir/builtin.ex
  2. +4 −2 lib/elixir/cli.ex
  3. +4 −2 lib/elixir/iex.ex
  4. +0 −10 lib/ex_unit/case.ex
  5. +1 −1 src/elixir_def_defaults.erl
  6. +10 −0 src/elixir_translator.erl
View
@@ -1,3 +1,5 @@
+import Elixir::Builtin, except: [raise: 1, raise: 2]
+
defmodule Elixir::Builtin do
@moduledoc """
`Elixir::Builtin` provides the default macros and functions
@@ -64,7 +66,7 @@ defmodule Elixir::Builtin do
Elixir module names can be dynamically generated. This is very
useful for macros. For instance, one could write:
- defmodule binary_to_atom("Foo#{1}", :utf8) do
+ defmodule binary_to_atom("Foo\#{1}", :utf8) do
# contents ...
end
@@ -630,7 +632,7 @@ defmodule Elixir::Builtin do
rescue: ArgumentError
IO.puts "Invalid argument given"
catch: value
- IO.puts "caught #{value}"
+ IO.puts "caught \#{value}"
after:
IO.puts "This is printed regardless if it failed or succeed"
end
View
@@ -24,16 +24,18 @@ defmodule Elixir::CLI do
end
rescue: exception
at_exit(1)
+ stacktrace = Code.stacktrace
IO.puts :standard_error, "** (#{exception.__record__(:name)}) #{exception.message}"
- print_stacktrace(Code.stacktrace)
+ print_stacktrace(stacktrace)
stop(1)
catch: :exit, reason when is_integer(reason)
at_exit(reason)
stop(reason)
catch: kind, reason
at_exit(1)
+ stacktrace = Code.stacktrace
IO.puts :standard_error, "** (#{kind}) #{inspect(reason)}"
- print_stacktrace(Code.stacktrace)
+ print_stacktrace(stacktrace)
stop(1)
end
end
View
@@ -24,12 +24,14 @@ defmodule Elixir::IEx do
rescue: TokenMissingError
{ binding, code }
rescue: exception
+ stacktrace = Code.stacktrace
IO.puts :standard_error, "** (#{exception.__record__(:name)}) #{exception.message}"
- print_stacktrace Code.stacktrace
+ print_stacktrace stacktrace
{ binding, '' }
catch: kind, error
+ stacktrace = Code.stacktrace
IO.puts :standard_error, "** (#{kind}) #{inspect(error)}"
- print_stacktrace Code.stacktrace
+ print_stacktrace stacktrace
{ binding, '' }
end
View
@@ -56,14 +56,4 @@ defmodule ExUnit::Case do
def message, [], true, do: unquote(contents)
end
end
-
- ## Helpers
-
- defp append_to_block({ :__BLOCK__, line, exprs }, other) do
- { :__BLOCK__, line, exprs ++ [other] }
- end
-
- defp append_to_block(expr, other) do
- { :__BLOCK__, 0, [expr, other] }
- end
end
@@ -16,7 +16,7 @@ unpack_each(Name, [{'//', Line, [Expr, _]}|T] = List, Acc, Clauses, S) ->
Base = build_match(Acc, Line, []),
{ Args, Invoke } = extract_defaults(List, [], []),
- Call = { Name, Line, Base ++ Invoke },
+ Call = { { '.', Line, [{'__LOCAL__', Line, nil}, Name] }, Line, Base ++ Invoke },
{ Clause, _ } = elixir_clauses:assigns_block(Line,
fun elixir_translator:translate/2, Base ++ Args, [Call], [], S),
View
@@ -395,6 +395,16 @@ translate_each({Atom, Line, Args} = Original, S) when is_atom(Atom) ->
Else -> Else
end;
+%% __LOCAL__ proxy calls
+
+translate_each({{'.', _, [{'__LOCAL__', _, Atom}, Name]}, Line, Args} = Original, S) when is_atom(Atom), is_atom(Name) ->
+ case handle_partials(Line, Original, S) of
+ error ->
+ { TArgs, NS } = translate_args(Args, S),
+ { { call, Line, { atom, Line, Name }, TArgs }, NS };
+ Else -> Else
+ end;
+
%% Dot calls
translate_each({{'.', _, [Left, Right]}, Line, Args} = Original, S) ->

0 comments on commit c9f808a

Please sign in to comment.