156 Commits

Author SHA1 Message Date
Zoltan Herczeg
ab8fa74b86 Correctly handle variables imported or exported by modules. (#3270)
Remove var declaration workarounds and correctly create / use variables for modules.

Still missing: create lexical environment for automatic module conversion.
(Or remove this feature overall.)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-04 16:51:26 +01:00
Robert Fancsik
6f83da4c0b Implement the spread operator for array initialization (#3265)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-04 16:36:58 +01:00
Zoltan Herczeg
6a342fcdd6 Implement throwing ReferenceErrors for let/const variables. (#3264)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-10-31 11:09:02 +01:00
Zoltan Herczeg
3d797b8836 Implement the core of let/const statement. (#3239)
This patch implements the core part of let/const statements. Redeclarations are correctly
detected and separate contexts are correctly created for these statements. Register
optimizations are also emplyed whenever possible.

Lots of features are still missing:
 - checking the var statements in eval
 - const are treated as lets
 - single statement checks are missing
 - export declarations are exported as vars, let/const export is not supported

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-10-25 18:08:10 +02:00
Robert Fancsik
3b73562fa5 Revise ES2015 feature guards (#3240)
All the basic language element guards are merged into JERRY_ES2015 macro guard.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-24 14:44:51 +02:00
Zoltan Herczeg
7df87b7778
Create function variables using the data produced by the pre-scanner. (#3199)
The pre-scanner now is able to track all variable declarations and produces a compressed
stream which store this data for each function and catch block. When a function or
catch block is parsed, this information is decoded and the appropriate variables are
created. Furthermore a stack scope is created which contains the currently available
local variables and their register or literal index.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-10-17 15:20:04 +02:00
Robert Fancsik
2a89eec98b Reduce code duplication in js-parser-expr.c (#3159)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-02 12:17:45 +02:00
Zoltan Herczeg
5c7df1cb2d Rework simple arrow function scanning. (#3148)
The resulting code unifies the scanning of the two
different argument definition of arrow functions.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-23 15:25:37 +02:00
Zoltan Herczeg
fbde788d1f Scanner rework. (#3038)
The scanner was an on-demand tool of the parser, which was triggered by certain
statements. After the rework, the scanner runs only once, and collects all information.
This information is passed to the parser.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-11 11:15:46 +02:00
Péter Gál
1b84a17dc7 Correctly propagate super prop ref when parsing expressions (#3077)
The "super prop ref" flag is incorrectly used at multiple expressions
as it was only cleared if there was an assignment operation.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-09-06 16:56:04 +02:00
Zoltan Herczeg
96edec1a62 Improve expected identifier checks. (#3064)
Checks for "of" or "from" does not accept quoted strings.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-05 11:42:17 +02:00
Robert Fancsik
142f79ce05
Properly handle CBC_PUSH_THIS_LITERAL for unary lvalue operations (#3054)
This patch fixes #3048.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-09-05 09:52:58 +02:00
Péter Gál
c90306449e Correctly handle call arguments when using 'super' calls (#2996)
There are two interconnected changes here:
* Added missing argument number handling for `super.propname(..)` calls.
* The `super.propname.call(...)` is does not need extra 'this' binding helper.

Fixes #2990.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-07-31 15:13:06 +02:00
Robert Fancsik
2700e66c4b
Improve class literal parsing (#2970)
Until now "get"/"set" were always parsed as special 'keywords' for accessor methods,
but they should be parsed as simple class method if no identifier is followed by them.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-07-16 13:52:05 +02:00
Robert Fancsik
8766bb3b37 CBC_PUSH_THIS_LITERAL must be converted back to CBC_PUSH_THIS during emitting unary lvalue opcode (#2939)
This patch fixes #2937.

Co-authored-by: Gabor Loki loki@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-07-04 18:26:46 +02:00
Péter Gál
eef1efa394 Rework usages/naming of configuration macros [part 3] (#2927)
Reworked the JERRY_DEBUGGER macro to be a 0/1 switch.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-07-01 13:12:19 +02:00
Péter Gál
01ecc7bb7b Rework usages/naming of configuration macros [part 2] (#2903)
There are quite a few configuration macros in the project.
As discussed in the #2520 issue there are a few awkward constructs.

Main changes:

* The following macros are now 0/1 switches:
** Renamed CONFIG_ECMA_LCACHE_DISABLE to JERRY_LCACHE.
** Renamed CONFIG_ECMA_PROPERTY_HASHMAP_DISABLE to JERRY_PROPERTY_HASHMAP.
** Renamed CONFIG_DISABLE_UNICODE_CASE_CONVERSION to JERRY_UNICODE_CASE_CONVERSION.
** Renamed ENABLE_REGEXP_STRICT_MODE to JERRY_REGEXP_STRICT_MODE.
** Renamed JERRY_DISABLE_JS_PARSER to JERRY_PARSER.
** Renamed JERRY_ENABLE_ERROR_MESSAGES to JERRY_ERROR_MESSAGES.
** Renamed JERRY_ENABLE_EXTERNAL_CONTEXT to JERRY_EXTERNAL_CONTEXT.
** Renamed JERRY_ENABLE_LINE_INFO to JERRY_LINE_INFO.
** Renamed JERRY_ENABLE_LOGGING to JERRY_LOGGING.
** Renamed JERRY_ENABLE_SNAPSHOT_EXEC to JERRY_SNAPSHOT_EXEC.
** Renamed JERRY_ENABLE_SNAPSHOT_SAVE to JERRY_SNAPSHOT_SAVE.
** Renamed JERRY_SYSTEM_ALLOCATOR to JERRY_SYSTEM_ALLOCATOR.
** Renamed JERRY_VM_EXEC_STOP to JERRY_VM_EXEC_STOP.
** Renamed JMEM_GC_BEFORE_EACH_ALLOC to JERRY_MEM_GC_BEFORE_EACH_ALLOC.
** Renamed JMEM_STATS to JERRY_MEM_STATS.
** Renamed PARSER_DUMP_BYTE_CODE to JERRY_PARSER_DUMP_BYTE_CODE.
** Renamed REGEXP_DUMP_BYTE_CODE to JERRY_REGEXP_DUMP_BYTE_CODE.
* Recursion check changes:
** Renamed REGEXP_RECURSION_LIMIT to JERRY_REGEXP_RECURSION_LIMIT.
** Renamed VM_RECURSION_LIMIT to JERRY_VM_RECURSION_LIMIT.
* Attribute macro changes:
** Renamed JERRY_CONST_DATA to JERRY_ATTR_CONST_DATA.
** Renamed JERRY_HEAP_SECTION_ATTR to JERRY_ATTR_GLOBAL_HEAP.
  Now the macro can specify any attribute for the global heap object.
* Other macro changes:
** Renamed CONFIG_MEM_HEAP_AREA_SIZE to JERRY_GLOBAL_HEAP_SIZE.
   Then new macro now specify the global heap size in kilobytes.
* Updated documentations to reflect the new macro names.

For more deatils please see jerry-core/config.h.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-06-19 12:28:21 +02:00
Dániel Bátyai
1cdb3c6c56 Fix identifier handling inside export statements (#2843)
Fixes #2842

Co-authored-by: Marko Fabo <mfabo@inf.u-szeged.hu>
JerryScript-DCO-1.0-Signed-off-by: Marko Fabo mfabo@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-04-30 10:53:48 +02:00
legendecas
097e1862d2 Set constructor to prototype for ES2015 Classes (#2818)
JerryScript-DCO-1.0-Signed-off-by: legendecas legendecas@gmail.com
2019-04-29 13:36:23 +02:00
Daniel Vince
37b7645e6a Rework ES2015 module system and add missing features. (#2792)
Co-authored-by: Dániel Bátyai <dbatyai@inf.u-szeged.hu>
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
JerryScript-DCO-1.0-Signed-off-by: Daniel Vince vinced@inf.u-szeged.hu
2019-04-25 14:57:17 +02:00
Péter Gál
40f7b1c27f Rework usages/naming of configuration macros [part 1] (#2793)
There are quite a few configuration macros in the project.
As discussed in the #2520 issue there are a few awkward constructs.

Main changes:

* Renamed all CONFIG_DISABLE_<name>_BUILTIN macro to JERRY_BUILTIN_<name> format.
* The special JERRY_BUILTINS macro specifies the basic config for all es5.1 builtins.
* Renamed all CONFIG_DISABLE_ES2015_<name> to JERRY_ES2015_<name> format.
* The special JERRY_ES2015 macro specifies the basic config for all es2015 builtins.
* Renamed UNICODE_CASE_CONVERSION to JERRY_UNICODE_CASE_CONVERSION.
* Renamed ENABLE_REGEXP_STRICT_MODE to JERRY_REGEXP_STRICT_MODE.
* All options (in this change) can have a value of 0 or 1.
* Renamed ENABLE_REGEXP_STRICT_MODE to JERRY_REGEXP_STRICT_MODE.
  JERRY_REGEXP_STRICT_MODE is set to 0 by default.
* Reworked CONFIG_ECMA_NUMBER_TYPE macro to JERRY_NUMBER_TYPE_FLOAT64 name and now
  it uses the value 1 for 64 bit floating point numbers and 0 for 32 bit floating point
  number.
  By default the 64-bit floating point number mode is enabled.
* All new JERRY_ defines can be used wit the `#if ENABLED (JERRY_...)` construct to
  test if the feature is enabled or not.
* Added/replaced a few config.h includes to correctly propagate the macro values.
* Added sanity checks for each macro to avoid incorrectly set values.
* Updated profile documentation.
* The CMake feature names are not updated at this point.

JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
2019-04-09 10:14:46 +02:00
Robert Fancsik
a42f239abb Fix super keyword parsing for arrow functions. (#2664)
This patch fixes #2657.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-01-22 09:21:28 +01:00
Robert Fancsik
86e60ddf8d Fix inner classes in class heritage environment (#2686)
This patch is the proper fix for #2667, since #2269 did not fix the problem entirely.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-01-16 14:36:54 +01:00
Robert Fancsik
c305d70b11 Fix "arguments" and "eval" parsing (#2661)
This patch fixes #2656 and fixes #2659 as well.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-01-15 13:29:56 +01:00
Robert Fancsik
93ec226650 Extract binary lvalue operators (#2630)
This patch substitutes all binary lvalue operators with an assigment + the corresponding binary operator.
E.g. A += (expression) is pasred as A = A + (expression).

Due to this replacement, all the related binary lvalue CBC opcodes can be removed.
Also the arithmetic related VM instructions can put their result directly onto the stack, since no more checking is needed.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-01-10 08:47:45 +01:00
Robert Fancsik
ef2c3b46d7 Fix super property reference parsing (#2672)
`PARSER_CLASS_SUPER_PROP_REFERENCE` flag should be applied for only binary lvalue tokens.
This patch fixed #2671.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-01-08 09:33:26 +01:00
Robert Fancsik
1068b07cbe Ensure that inner classes do not inherit the parent's class HAS_SUPER flag. (#2669)
This patch fixes #2667.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-01-03 13:36:37 +01:00
Zoltan Herczeg
83ee9cfca3 Fix named function expression creation. (#2634)
Create a local lexical environment with the name of the function. While
this is not too memory efficient, some corner cases requires its existence.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2018-12-12 12:50:03 +01:00
Robert Fancsik
24817b27f9 Optimize property call opcodes (#2609)
In with contexts the object base value must be resolved before executing a call operation.
Since this happens rarely the base resolving code paths has been seperated to an other VM opcode
so these extra checks do not burden the general property call steps.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2018-11-29 09:00:22 +01:00
Roland Takacs
5151f9161f Use logical operators for bool converions. (#2620)
The explicit boolean type conversion (introduced by #2575) desn't work
with TizenRT if custom boolean representation is used. Of course,
TizenRT gives an opportunity to use the C99 standard boolean (that works
well if that is set).

I've replaced all the explicit boolean type conversions with double
negations that helps to work JerryScript well with custom boolean types.

JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs.uszeged@partner.samsung.com
2018-11-28 11:35:12 +01:00
Zoltan Herczeg
a0a6eaaee8
Support identifier references for object initializers. (#2597)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2018-11-22 10:07:11 +01:00
Akos Kiss
aeddb1cd88
Get rid of ? true : false (#2575)
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2018-10-29 14:51:59 +01:00
Zoltan Herczeg
93567fbb8f Support methods for object initializers. (#2567)
MethodDefinition in ES-2015 12.2.6.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2018-10-26 23:47:08 +02:00
Roland Takacs
ffbd6e6c5c Fix type conversion errors in case of TizenRT. (#2572)
JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs.uszeged@partner.samsung.com
2018-10-26 14:21:00 +02:00
Robert Fancsik
d1860d0e34 Implement ES2015 class feature (part II.) (#2439)
This patch is the second milestone of the implementation of this new language element.

Supported:
 - Single class inheritance
 - Functionality of 'super' keyword
 - Implicit constructor in class heritage
 - Specific behaviour while extending with the built-in 'Array' or '%TypedArray%' object
 - Abstract subclasses (Mix-ins)

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2018-10-25 16:00:48 +02:00
Zoltan Herczeg
bd42403600
Implement computed properties for object literals. (#2481)
Also disable ES5.1 property name dumplication checks
when ES2015 object literals are enabled.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2018-08-28 15:28:16 +02:00
Akos Kiss
b31e43075a Add explicit casts to enum-to-integer conversions (#2467)
Clang 6 is more picky about implicit conversions and complains
about loss of presicion and/or change of signedness.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2018-08-13 13:01:37 +09:00
Robert Fancsik
a6ace5efdf Improve lexer_expect_object_literal_id option handling (#2436)
This patch allows to add further options flags to `lexer_expect_object_literal_id` to handle unique behaviors more easily
also substitutes `PARSER_IS_CLASS` flag hence it is removed.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2018-07-30 15:12:35 +02:00
Zoltan Herczeg
f86d7459d1 Fixes for ES2015 classes. (#2424)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2018-07-13 14:59:53 +02:00
Robert Fancsik
43aae199ce Implement ES2015 class feature (part I.) (#2404)
This patch is the first milestone of the implementation of this new language element.

Currently supported:
 - Class statement
 - Class expression
 - Static methods

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2018-07-13 01:20:08 +09:00
Zoltan Herczeg
acdbbf2261
Add literal property to the byte code list. (#2397)
Initializing a property with a constant is frequent in object initializers.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2018-06-20 09:06:59 +02:00
László Langó
b4b0b7d572 Merged conditions of if statements where possible. (#2380)
JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
2018-06-06 15:08:17 +09:00
Zoltan Herczeg
5560c76b41 Convert certain push number opcodes to literals (#2328)
Binary operations are much faster with literal arguments.
The byte immediates are still kept for other cases, e.g. array declarations.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2018-05-18 17:22:53 +09:00
Akos Kiss
d0143adc82 Replace JERRY_JS_PARSER feature guard with JERRY_DISABLE_JS_PARSER (#2036)
* Replace JERRY_JS_PARSER feature guard with JERRY_DISABLE_JS_PARSER

All feature guards of jerry-core are deciding about the inclusion
or exclusion of a feature based on the state (defined or undefined)
of a macro -- except for the JS parser guard, which requires
`JERRY_JS_PARSER` to be defined with a value of either 0 or 1. This
has some issues:
- The engine cannot be built with a "clean" compiler invocation,
  i.e., without any `-D` command line macro definitions. This is
  painful for targets that must use a different build system from
  the project's own python/cmake-based one.
- Some build systems in targets and even some code in jerry-code
  are already confused about the different semantics of
  `JERRY_JS_PARSER`, and simply define it without a value and make
  decisions based on the macro being simply defined or not.

This patch renames the guard to `JERRY_DISABLE_JS_PARSER` and makes
use of it in jerry-core based on its state, not based on its value.
As obvious from the guard name, the default for the JS parser is
that it is included in the build.

The patch also touches those targets in the repository that
explicitly defined the original macro (correctly or incorrectly).

* Make cppcheck verbose

Cppcheck can be quite slow sometimes, especially on Travis CI,
which has a "10 mins without output means failure" rule. As the
code base of the project grows, we start to undeterministically
fall over that limit. Thus, this PR makes cppcheck verbose to
ensure that it keeps Travis CI continuously fed with output.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
2017-10-17 17:11:54 +02:00
Zoltan Herczeg
8a5bfd2279 Implement template literals. (#2025)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2017-09-27 11:24:51 +02:00
Zoltan Herczeg
c6a33dd407 Implement arrow function parsing. (#2022)
Note: the special this behaviour of arrow functions is not implemented.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2017-09-26 10:40:45 +02:00
Zoltan Herczeg
f5b385ca6c Tracking variables to reduce the memory consumption of scope chain. (#1819)
Currently we keep all local variables in the scope chain as long as
a nested function is alive. These variables consume memory although
several of them are never used. This patch focuses on removing those
unused ones whose can be detected at parsing time.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2017-05-15 09:00:57 +02:00
Robert Sipka
6254748081 Require JERRY_JS_PARSER macro to be defined (#1639)
JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2017-03-06 09:53:09 +01:00
Robert Sipka
e9ab1f14d3 Set js-parser feature in the build script. (#1482)
Renamed FEATURE_PARSER_DISABLE to FEATURE_JS_PARSER.
Fixed the build error that occurred in case of disabled js-parser.

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
2016-12-12 13:43:53 +01:00
Sergio Abraham Martinez Rodriguez
db05d85a9a Add feature to remove parser. (#1476)
Remove the parser so we can save space if we are
only interested in running snapshots.

Removing the parser enables the snapshot execution.

JerryScript-DCO-1.0-Signed-off-by: Sergio Martinez sergio.martinez.rodriguez@intel.com
2016-12-09 15:38:40 +01:00