378 Commits

Author SHA1 Message Date
Zoltan Herczeg
dc458111ba Local functions should not be created globally. (#3290)
Fixes #3286.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-08 14:03:19 +01:00
Zoltan Herczeg
e1fc90db0e Delay the variable construction in the function body. (#3289)
Local variables inside the function body should be constructed after the
parameters are initialized. Furthermore arguments should be available
during parameter initialization.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-11-08 12:18:23 +01:00
Robert Fancsik
525c35f148 Introduce jerry_get_resource_name API function (#3236)
This new API function adds possibility to query the resource name of the currently executed script (including modules) or a function object.
This patch closes #2170.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-11-06 15:05:49 +01:00
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
1edfa81c76 Implement correct construction of let/const declarations and function statements. (#3259)
Various cbc opcodes are added to support the different instantiations.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-10-30 16:01:55 +01:00
Robert Fancsik
448c239f08
Export statement parsing should construct new ident literal (#3256)
This patch fixes #3253.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-28 15:30:47 +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
Zoltan Herczeg
f0e432c9b9
Set post-processing mode after an arrow expression scanning is completed (#3215)
Fixes #3214.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-10-14 11:26:16 +02:00
Robert Fancsik
fc2a2f94fd Properly release scanner info in parser_parse_for_statement_start (#3211)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-10 12:44:29 +02:00
Dániel Bátyai
cfaecc6698
Fix an undefined read during module cleanup after parse error (#3181)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-10-03 11:01:11 +02:00
Dániel Bátyai
f1883b9e7d
Provide support for native modules with ES6 imports (#3090)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-10-02 12:20:43 +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
Robert Fancsik
32962f067e
Fix class/function parsing in single-statement blocks (#3179)
This patch fixes #3151 and fixes #3174.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-02 11:16:52 +02:00
Robert Fancsik
195b0d3c3a
Fix duplicated argument validation for default arguments (#3178)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-10-02 10:10:23 +02:00
Zoltan Herczeg
a8fb4eee1e Fix three minor issues. (#3165)
1) Remove an unnecessary check.
 2) Check that comma is not allowed between question mark and colon
 3) Create a hex decoding variant which does not throw error.

These are quality improvements, they have no negative impact.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-27 17:38:02 +02:00
Zoltan Herczeg
0121b2bbcf Fix object initializers for get and set properties. (#3164)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-27 10:28:53 +02:00
Zoltan Herczeg
97a0febaff Fix comma after an arrow function. (#3153)
Fixes #3152.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-24 12:34:24 +02:00
Zoltan Herczeg
8f7565db5f Colon tokens are not optional. (#3150)
Colon tokens must be present before the next statement is executed.

Fixes #3145

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-24 12:33:06 +02:00
Zoltan Herczeg
35a3df3f28 Fix scanning of do-while statement. (#3149)
The newline before the while part is misinterpreted.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-23 15:38:15 +02:00
Zoltan Herczeg
f2013fcb1a Free scanner info even if for statement parsing is failed. (#3141)
Fixes #3140.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-23 15:27:59 +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
25b81c106c Implement statement parsing in the scanner. (#3137)
To implement let/const, the code affected by for statements needs to be identified,
and this patch implements the basic infrastructure for that. The short term benefit
is that scanner info blocks are not generated for do-while blocks.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-20 12:15:16 +02:00
Zoltan Herczeg
a7c654617d There is no need to update the scanner info chain after a for/while statement. (#3138)
Fixes #3131.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-20 02:27:05 -07:00
Zoltan Herczeg
40e63d1207 Implement seeking in the pre-scanner info. (#3126)
After changing the lexing position, the current
position of the scanner info must be moved as well.

Fixes #3101
Fixes #3102

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-17 17:28:11 +02:00
Robert Fancsik
4452e79204 Class expression scanning must be continued with post primary expression scanning. (#3120)
This patch fixes #3117 and fixes #3119.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-09-16 12:58:14 +02:00
Robert Fancsik
8d9788d1b5 Fix incorrect assertion while decoding the literal argument index (#3118)
This patch fixes #3114.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-09-16 12:56:48 +02:00
Zoltan Herczeg
62025cfa41 Support new Function parsing in the pre-scanner. (#3110)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-16 11:58:15 +02:00
Robert Fancsik
83c44d20b3 Fix skipping empty statements during class literal scanning (#3124)
This patch fixes #3123

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-09-16 11:26:08 +02:00
Zoltan Herczeg
951d7e6842 Implement var statement pre-scanning. (#3103)
The patch also checks whether pre-scanning is successful when scanning is,
so no need for explicit pre-scanner checks anymore.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-13 06:36:41 -07:00
Zoltan Herczeg
376cfea47e Parse rest function arguments in the pre-scanner. (#3099)
Fixes #3097.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-12 09:04:00 -07:00
Zoltan Herczeg
57de923770 Support get/set function declarations in classes in the pre-scanner. (#3098)
Fixes #3094
Fixes #3095
Fixes #3096

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-12 16:09:13 +02:00
Zoltan Herczeg
f3d3c34c30 Fix pre-scanner function name parsing. (#3093)
The function names of classes were incorrectly parsed.
Also made the parsing more strict (more issues were captured by the pre-scanner).

Fixes #3088
Fixes #3089

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
2019-09-11 16:55:58 +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
Robert Fancsik
2933947534 Properly decode literal index before CBC_MOV_IDENT (#3056)
This patch fixes #3055.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-09-07 12:23:49 +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
Robert Fancsik
c6a4a86257
Improve ecma_string_t descriptor (#3016)
This patch introduces several changes conntect to ecma-strings:
 - Extend the size of the reference counter to 28 bytes from 13
 - Extend the size of the string hash to 32 bytes from 16 to use the extact FNV-1a hash
 - Introduce ECMA_STATIC_STRING_FLAG to reduce the number of string ref/derefs for static strings.
 - Introduce ECMA_STRING_CONTAINER_ASCII_STRING to store run-time allocated ASCII strings more efficiently
 - Remove ECMA_STRING_CONTAINER_LIT_NUMBER to half the storage size of the parsing time allocated floating point numbers
 - Rework the global number storage, to store only the floating point numbers
 - Optimize the lookup in the global number/string/symbol tables via reduce the number of NULL checks during decompressing the next element pointers
 - Reduce the code duplication in ecma_concat_ecma_strings and ecma_append_chars_to_string
 - Improve ecma_string_get_char with optional arguments to make it more reusable.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-08-30 15:16:27 +02:00
Robert Fancsik
3af0079a0e Introduce CBC_MOV_IDENT opcode to improve performance (#3020)
After this patch CBC_ASSIGN_SET_IDENT is transformed to CBC_MOV_IDENT if the opcode has register stored literal argument.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
2019-08-26 15:59:27 +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
Dániel Bátyai
ec11a7b4e9
Resolve module paths relative to the current module (#2976)
The current module implementation resolves module paths relative to the
current working directory, but paths should be resolved relative to the
currently evaluated module/source.

This requires a change in the jerry_port_normalize_path port API
function, so that it also takes the current module path as an argument.
On the engine side, we now also create a module object for the main
script, so that we can properly identify the base path for other
modules.

Co-authored-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-07-17 14:44:18 +02:00
Dániel Bátyai
a44d584842
Fix 'eval' checking in import/export statements. (#2978)
Fixes #2975

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
2019-07-17 14:11:13 +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
Dániel Bátyai
c304b9a38a
Include file path in Syntax error messages (#2941)
When using ES6 modules it was not possible to identify which module
an error originates from.

This PR changes the error message to also include the file path using
the file:line:column format, and updates the source context printing for
unhandled exceptions to use the correct file.

Co-authored-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-07-11 12:33:02 +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