aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/sys_pre_expand.erl
AgeCommit message (Collapse)Author
2014-10-03Merge branch 'egil/maps/variable-keys/OTP-12218'Björn-Egil Dahlberg
* egil/maps/variable-keys/OTP-12218: (22 commits) compiler: Update test for Maps aliasing compiler: Properly support Map aliasing compiler: Refactor Map pairs aliasing compiler: Fix harmless need_heap error for Maps stdlib: Update Map tests stdlib: Use environment bindings for Maps keys in erl_eval matching debugger: Update Map tests compiler: Update Map tests compiler: Fix v3_core Maps pair chains compiler: Use expressions in core patterns compiler: Use variables in Map cerl inliner compiler: Reintroduce binary limit for Map keys compiler: Shameless v3_core hack for variables compiler: Use variables in Map beam assmebler compiler: Use variables in Map kernel pass compiler: Use variables in Map core pass compiler: Normalize unary ops on Maps key literals stdlib: Update Map tests stdlib: erl_lint Map key variables compiler: Maps are always patterns never values in matching ...
2014-08-22compiler: Normalize unary ops on Maps key literalsBjörn-Egil Dahlberg
Unary ops are normalized before core transformation, i.e. handle negative integers as map keys. Strictly speaking, map keys are expressions but by handling them as patterns we can normalize negative integers.
2014-04-28Introduce the attribute -optional_callbacks in the context of behavioursHans Bolinder
2014-04-03compiler,stdlib: Fix Map literals as keys for Maps in patternsBjörn-Egil Dahlberg
2014-03-01Fix expansion of map update argumentsAnthony Ramine
Reported-by: José Valim
2014-01-28Update erl_lint, erl_expand_records, sys_pre_expand for MapsBjörn-Egil Dahlberg
Update erlang lint and syntax expand for #{ K := V }
2014-01-28compiler: Handle literals, not just atoms, as keys in mapsBjörn-Egil Dahlberg
2014-01-28Update erl_lint, erl_expand_records, sys_pre_expand for mapsBjörn Gustavsson
2013-12-12EEP 37: Funs with namesAnthony Ramine
This adds optional names to fun expressions. A named fun expression is parsed as a tuple `{named_fun,Loc,Name,Clauses}` in erl_parse. If a fun expression has a name, it must be present and be the same in every of its clauses. The function name shadows the environment of the expression shadowing the environment and it is shadowed by the environment of the clauses' arguments. An unused function name triggers a warning unless it is prefixed by _, just as every variable. Variable _ is allowed as a function name. It is not an error to put a named function in a record field default value. When transforming to Core Erlang, the named fun Fun is changed into the following expression: letrec 'Fun'/Arity = fun (Args) -> let <Fun> = 'Fun'/Arity in Case in 'Fun'/Arity where Args is the list of arguments of 'Fun'/Arity and Case the Core Erlang expression corresponding to the clauses of Fun. This transformation allows us to entirely skip any k_var to k_local transformation in the fun's clauses bodies.
2013-01-18Remove support for parameterized modulesBjörn Gustavsson
2013-01-09compiler: Remove support for packagesBjörn Gustavsson
2012-08-31Merge branch 'maint'Björn-Egil Dahlberg
Conflicts: lib/diameter/autoconf/vxworks/sed.general xcomp/README.md
2012-08-31Update copyright yearsBjörn-Egil Dahlberg
2012-08-17Remove support for tuple funsBjörn Gustavsson
Tuple funs were deprecated in R15B (in commit a4029940e309518f5500).
2012-08-02sys_pre_expand: Fix BASE never being setTomas Janousek
Commit a612e99fb5aaa934fe5a8591db0f083d7fa0b20a turned module attributes from 2-tuples to 3-tuples but forgot to update get_base/1, breaking BASE for parametric modules.
2012-06-20sys_pre_expand: Eliminate bottleneck for modules with many functionsBjörn Gustavsson
Use a gb_set instead of an ordset to store the set of defined functions in the module to avoid quadritic time complexity.
2011-11-07Merge branch 'bjorn/fun-improvements/OTP-9667'Björn Gustavsson
* bjorn/fun-improvements/OTP-9667: sys_pre_expand: Remove incorrect comment compiler: Eliminate use of deprecated erlang:hash/2 beam_asm: Fix broken NewIndex in fun entries beam_asm: Strenghten the calculation of Uniq for funs
2011-11-07sys_pre_expand: Remove incorrect commentBjörn Gustavsson
sys_pre_expand does not keep track of used or new variables (and have not done since about the time Core Erlang was introduced).
2011-11-07compiler: Eliminate use of deprecated erlang:hash/2Björn Gustavsson
Now that beam_asm computes the Index and Uniq values for funs, there is no need to compute those values in the sys_pre_expand and v3_kernel modules, thus eliminating the calls to the deprecated erlang:hash/2 function. It would be tempting to stop generating the name for the fun in sys_pre_expand so that we did not have to add the Info field to a tuple. But: * The debugger depends on the name being there. (Simple solution: Let the debugger generate the name itself.) * When a fun has been inlined into another function, the fun name in 'id' annotation will be used to notice the inlining and change the final clause of the top-level case from generating a 'function_clause' exception to a case_clause exception. (Possible workaround: Have the inliner set an inlined attribute on functions that have been inlined, or have the inliner rewrite 'function_clause' exceptions itself.)
2011-11-07EEP-23: Allow variables in fun M:F/ABjörn Gustavsson
Currently, the external fun syntax "fun M:F/A" only supports literals. That is, "fun lists:reverse/1" is allowed but not "fun M:F/A". In many real-life situations, some or all of M, F, A are not known until run-time, and one is forced to either use the undocumented erlang:make_fun/3 BIF or to use a "tuple fun" (which is deprecated). EEP-23 suggests that the parser (erl_parse) should immediately transform "fun M:F/A" to "erlang:make_fun(M, F, A)". We have not followed that approach in this implementation, because we want the abstract code to mirror the source code as closely as possible, and we also consider erlang:make_fun/3 to be an implementation detail that we might want to remove in the future. Instead, we will change the abstract format for "fun M:F/A" (in a way that is not backwards compatible), and while we are at it, we will move the translation from "fun M:F/A" to "erlang:make_fun(M, F, A)" from sys_pre_expand down to the v3_core pass. We will also update the debugger and xref to use the new format. We did consider making the abstract format backward compatible if no variables were used in the fun, but decided against it. Keeping it backward compatible would mean that there would be different abstract formats for the no-variable and variable case, and tools would have to handle both formats, probably forever. Reference: http://www.erlang.org/eeps/eep-0023.html
2011-10-07Automatically generate 'behaviour_info' function from '-callback' attributesStavros Aronis
'behaviour_info(callbacks)' is a special function that is defined in a module which describes a behaviour and returns a list of its callbacks. This function is now automatically generated using the '-callback' specs. An error is returned by lint if user defines both '-callback' attributes and the behaviour_info/1 function. If no type info is needed for a callback use a generic spec for it.
2011-09-29Update copyright yearsBjörn-Egil Dahlberg
2011-09-14sys_pre_expand: Don't duplicate options given in the source codeBjörn Gustavsson
Any compiler options given with a -compile() attribute in source file would be included both at the beginning and the end of the option list for the compiler. Including the options twice is harmless during compilation, but since the options will also be available in Mod:module_info(compile), including them twice will waste memory. Include the options from the source first in the list so that they override options given on the command line.
2010-06-02Teach compiler to override autoimport with importPatrik Nyblom
2010-06-02First prototype for local functions overriding autoimportedPatrik Nyblom
Import directives still not sorted out!
2010-02-10Merge branch 'ks/compiler' into ccase/r13b04_devErlang/OTP
* ks/compiler: compiler: keep line numbers for attributes compiler Makefile: alphabetize module names compile.erl: eliminate compiler warning
2010-02-10compiler: keep line numbers for attributesKostis Sagonas
In the future, we might want to generate warnings for attributes, referring to them with line numbers. sys_pre_expand used to replace line number for attributes with 0. Change sys_pre_expand to retain the real line number. v3_core used to throw away the line numbers. Change v3_core so that it retains the line numbers in annotations. While at it, do some tidying as suggested by tidier.
2009-11-20The R13B03 release.OTP_R13B03Erlang/OTP