Rework the core of class parsing/runtime semantic (#3598)

Changes:
 - Use the pre-scanner to provide information for the parser about the existence of the class constructor
 - The allocation of the super declarative environment is no longer needed
 - The VM frame context holds the information about the this binding status
 - Reduce the number of class related VM/CBC instructions
 - Improve ecma_op_function_{construct, call} to properly set new.target

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2020-03-16 14:37:47 +01:00
committed by GitHub
parent 56b9f098ab
commit bfd2639634
49 changed files with 1671 additions and 1490 deletions
@@ -35,7 +35,7 @@ assert (secretArray instanceof Array);
assert (!([] instanceof mySecretArray));
/* Add a new element to the bound function chain */
class myEpicSecretArray extends myArray { };
class myEpicSecretArray extends mySecretArray { };
var epicSecretArray = new myEpicSecretArray (1, 2, 3);
epicSecretArray.push (4);
@@ -13,6 +13,8 @@
* limitations under the License.
*/
// TODO: enable this test when super keyword is supported for normal functions
/*
var console = { assert : assert };
class C1 {
@@ -57,3 +59,4 @@ class C2 extends C1 {
}
(new C2).f ();
*/
+74
View File
@@ -258,3 +258,77 @@ assert (G.get() == 11);
assert (G.set() == 12);
G.constructor = 30;
assert (G.constructor === 30);
class H {
method() { assert (typeof H === 'function'); return H; }
}
let H_original = H;
var H_method = H.prototype.method;
C = undefined;
assert(C === undefined);
C = H_method();
assert(C === H_original);
var I = class C {
method() { assert(typeof C === 'function'); return C; }
}
let I_original = I;
var I_method = I.prototype.method;
I = undefined;
assert(I === undefined);
I = I_method();
assert(I == I_original);
var J_method;
class J {
static [(J_method = eval('(function() { return J; })'), "X")]() {}
}
var J_original = J;
J = 6;
assert (J_method() == J_original);
var K_method;
class K {
constructor () {
K_method = function() { return K; }
}
}
var K_original = K;
new K;
K = 6;
assert (K_method() == K_original);
var L_method;
class L extends (L_method = function() { return L; }) {
}
var L_original = L;
L = 6;
assert (L_method() == L_original);
/* Test cleanup class environment */
try {
class A {
[d]() {}
}
let d;
assert(false);
} catch (e) {
assert(e instanceof ReferenceError);
}
try {
class A extends d {}
let d;
assert(false);
} catch (e) {
assert(e instanceof ReferenceError);
}
try {
var a = 1 + 2 * 3 >> class A extends d {};
let d;
assert(false);
} catch (e) {
assert(e instanceof ReferenceError);
}