mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
Replace the ClassExpression const& reference in the NewClass instruction with a u32 class_blueprint_index. The interpreter now reads from the ClassBlueprint stored on the Executable and calls construct_class() instead of the AST-based create_class_constructor(). Literal field initializers (numbers, booleans, null, strings, negated numbers) are used directly in construct_class() without creating an ECMAScriptFunctionObject, avoiding function creation overhead for common field patterns like `x = 0` or `name = "hello"`. Set class_field_initializer_name on SharedFunctionInstanceData at codegen time for statically-known field keys (identifiers, private identifiers, string literals, and numeric literals). For computed keys, the name is set at runtime in construct_class(). ClassExpression AST nodes are no longer referenced from bytecode.
14 lines
238 B
JavaScript
14 lines
238 B
JavaScript
function test() {
|
|
class A {
|
|
x = 42;
|
|
y = -1;
|
|
z = true;
|
|
w = null;
|
|
s = "hi";
|
|
computed = 1 + 2;
|
|
}
|
|
return new A();
|
|
}
|
|
let a = test();
|
|
console.log(a.x, a.y, a.z, a.w, a.s, a.computed);
|