Commit Graph
59 Commits
Author SHA1 Message Date
José Valim a050c00fbc Use meta on rewrites, closes #9714 2020-01-11 12:17:43 +01:00
Eric Meadows-Jönsson 1e4e05ef78 Change Bitwise macros to rewrites 2019-11-14 00:16:01 +01:00
Eric Meadows-Jönsson 5cfaf11478 Add reverse rewrite and inline rules 2019-11-14 00:16:01 +01:00
José Valim 0c8414d739 Add Kernel.is_map_key/2 2019-11-04 12:47:26 +01:00
José Valim 642ae17bc7 Remove redundant rewrite as it has been optimized in the VM 2019-11-02 17:12:27 +01:00
José Valim 0c1df34645 Standardize more TODOs 2018-12-21 13:42:54 +01:00
José Valim 7fba39dfe0 Do not inline non-BIFs 2018-08-06 00:08:42 +02:00
Fernando Tapia Rico 1e9446a2bb Minor improvements in match operators code (#8048)
Minor things I spotted while reading https://github.com/elixir-lang/elixir/pull/8043 :)
2018-08-05 10:57:15 +02:00
José Valim a2d81db23b Delete counter for vars in nested quotes (#8042)
Consider the following example:

    defmodule NestedQuote do
      defmacrop macro(arg) do
        quote bind_quoted: [arg: arg] do
          quote bind_quoted: [arg: arg], do: String.duplicate(arg, 2)
        end
      end

      defmacro __using__(_) do
        quote do
          def test do
            unquote(macro("foo"))
          end
        end
      end
    end

    defmodule UseNestedQuote do
      use NestedQuote
    end

It has two macro expansions, one inside __using__/1 when it invokes
macro/1, and another when used. The issue, however, is that the
`arg` of `String.duplicate(arg, 2)` gets tagged with the context
of `macro/1` but it should be tagged with the context of `__using__`
since it is a quote inside a quote. This patch addresses this.
2018-08-04 16:46:49 +02:00
Michał Muskała 887e8f2633 Rewrite match operators in elixir (#8043)
Until now, we left rewriting operators in matches to Erlang. This forced
us to inherit Erlang semantics, especially for the ++ operator, that
only allows lists of integers on the left side inside matches. The new
implementation just rewrites this operator regular improper list matching.
Additionally we rewrite matching on -/1 and +/1 operators to number
literals - matching with those operators and variables was never
supported.

Additionally do a bit of housekeeping and refactor code around rewriting
and validating remote calls.
2018-08-04 15:14:13 +02:00
Łukasz Samson 7ea42588ce Add Kernel.ceil/1 and Kernel.floor/1 buildins (#7888)
Fixes https://github.com/elixir-lang/elixir/issues/7882
2018-07-13 12:54:09 +02:00
José Valim 75541cf472 Condititionally compile and lazily compute __STACKTRACE__ (#7648)
Erlang/OTP 20 warns if the stacktrace is read outside of a
catch/rescue. This commit mirrors this behaviour by consistently
warning on `System.stacktrace/0` being used outside of a
catch/rescue.

Erlang/OTP 21 warns whenever System.stacktrace/:erlang.get_stacktrace
are used. Therefore we need to promote the usage of `__STACKTRACE__`
and make sure to conditionally compile it according to the OTP version.
This requires changes to the Exception normalization mechanism
so we compute `__STACKTRACE__` only when strictly required.

In future Elixir releases, `System.stacktrace/0` will warn when
used even inside catch/rescue.
2018-05-07 15:33:36 +02:00
Eksperimental d17ac42a5f Remove unused convenience vars in elixir_rewrite (#7612) 2018-04-28 12:06:00 +08:00
eksperimental 2921f0165b Mention in the docs every function inlined by the compiler
elixir_rewrite.erl has been audited, function by function:
- All missing "Inlined by the compiler." lines have been added.
- Standardize sentence avoid mentioning the function its inline to (System module).
- "Inline by the compiler." goes always before ##Options or ##Examples
2018-04-26 18:58:07 +08:00
eksperimental 36d4cbf384 Sort alphabetically elixir_rewrite.erl 2018-04-26 18:58:07 +08:00
Nikola Jichev 3900d2c203 Inline &Kernel.function_exported?/3 (#7515) 2018-03-29 13:15:12 +02:00
Nikola Jichev f963013036 Add Function module for introspecting functions (#7503)
Reason to add it is capturing functions when passing in module name,
function name and arity using variable, because the capture operator
can't handle them.

Done by delegating to `:erlang.make_fun(mod, f, arity)`, also exposed
some erlang functions for getting information for a function.
2018-03-28 11:52:00 +02:00
Kelvin Stinghen a5f64607ac Add Port.monitor/1 and Port.demonitor/1 functions (#6518) 2017-08-31 12:02:11 +02:00
Michał Muskała 3ac7593453 Inline String.duplicate to :binary.copy BIF (#6238)
Furthermore, also inline duplicate/2 inside the String module, since it's
used there in couple places.
2017-06-20 23:07:54 +02:00
Andrea Leopardi 0ab18f57fb Clean up the Map module by checking for maps and reusing code (#6205) 2017-06-12 11:06:42 +02:00
Aleksei Magusev 26f68bc79b Correct use of hyphens 2017-04-23 22:57:26 +02:00
Andrea Leopardi 24fb49305c Add Process.cancel_timer/2 (#6014) 2017-04-21 10:45:23 +02:00
José Valim c5a3ca4cdb Properly inline code and remove warnings 2017-03-23 19:01:13 +01:00
eksperimental 7c9cb0db81 Inline functions in Process module 2017-03-16 09:48:54 +01:00
José Valim 152cf2616b Move case inlining out of Elixir pass 2017-02-16 18:24:25 +01:00
José Valim 9c0d6a66d5 Assert valid match and guard constructs on Elixir pass 2017-02-08 15:58:34 +01:00
Andrea Leopardi b25033bb4b Hard-deprecate the "char_list" spelling (#5517) 2016-12-01 21:51:47 +01:00
José Valim 3c6b4c5278 Document the Port module 2016-11-14 22:20:56 +01:00
José Valim cbbccd8d9f Also inline Node.list/0/1 2016-11-06 22:19:26 +01:00
José Valim 8e2a1e5851 Remove Kernel.rand/0 and Kernel.rand/1
Since Enum.random/1 already provides the Kernel.rand/1
functionality.
2016-09-21 23:39:33 +02:00
Michał Muskała dadf98fbff Introduce Process.send_after/4 (#5182) 2016-09-07 22:39:12 +02:00
José Valim 786da1ffe0 Add Kernel.rand/0 and Kernel.rand/1
Thanks to Hal Fulton for the proposal and original code.
2016-09-07 13:07:52 +02:00
Michał Muskała 8277dcd776 Make sure bad remote call errors have file/line info (#5116)
Change how we mark the generated AST for suppressing dialyzer errors -
instead of [generated: true, location: 0], we provide proper line number.
This means, however, that on OTP 18, those nodes won't be recognized
as generated and warnings will be issued.
It was decided that proper error messages are more important than
avoiding bogus dialyzer warnings.
The old mark for generated code is left in places that made compiler
issue warnings on 18.

The bad remote call dialyzer warnings can be suppressed with the
@dialyzer :no_fail_call
module attribute.
2016-08-15 13:18:09 +01:00
Aleksei Magusev 3f9a4c044a Rewrite Enum.into/2,3 with empty map into Map.new/1,2 2016-07-09 16:31:30 +02:00
Aleksei Magusev 05db28b28f Rewrite Enum.reverse/1 to Enum.reverse/2 for non-lists 2016-07-08 23:33:54 +02:00
José Valim 478ec42778 Use the shortest possible representation when printing floats, closes #3413 2016-05-18 14:38:44 +02:00
eksperimental 9d4ec8b5f3 Fall-back functions: Kernel.to_char_list/1 and List.Chars.to_char_list/1 protocol 2016-05-09 00:35:44 +07:00
eksperimental 0aece49e2d Replace 'char_list' and 'char list' with 'charlist' 2016-05-07 03:20:57 +07:00
José Valim 7ce93f6c8b Normalize and document time and time units 2016-04-05 17:21:33 +02:00
Andrea Leopardi 32a70fabdc Add System.os_time/0,1
These functions are inlined to `:os.system_time/0,1`.
2016-03-30 23:03:39 +02:00
Aleksei Magusev 67e2e2edb8 Bypass List.Chars.to_char_list calls with list literals 2016-01-23 20:31:54 +01:00
Aleksei Magusev bc214c0d49 Bypass String.Chars.to_string calls with inspect result 2016-01-23 20:13:25 +01:00
Aleksei Magusev 6660e7e409 Make Access syntax fail to compile for unsupported values 2015-12-15 00:55:27 +01:00
Andrea Leopardi f62c76497d Add System.time_offset/0-1 2015-12-01 18:52:15 +01:00
Andrea Leopardi 75b78ba5c6 Add System.convert_time_unit/3 2015-12-01 14:54:22 +01:00
Andrea Leopardi 2093e823cd Add monotonic|system_time and unique_integer to System 2015-12-01 14:54:15 +01:00
José Valim 52253aa234 Add cancel and read timer functions to Process 2015-11-15 20:45:11 +01:00
José Valim 95b03739dd Add Process.get_keys/0 2015-10-19 12:33:48 +02:00
José Valim 71e5acc0b7 Ensure no warnings on rewrites 2015-10-11 12:55:59 -05:00
José Valim 8ac8a4c2e8 Clean up generated code 2015-10-11 12:32:29 -05:00