Files
ladybird/Tests/LibJS/Bytecode/input/class-literal-fields.js
Andreas Kling ec2f4e4a7b LibJS: Wire NewClass to ClassBlueprint
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.
2026-02-11 23:57:41 +01:00

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);