mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:17:35 +00:00
LibJS: Use a synthetic constructor if class with parent doesn't have one
We already did this but it called the @@iterator method of %Array.prototype% visible to the user for example by overriding that method. This should not be visible so we use a special version of SuperCall now.
This commit is contained in:
parent
b79f03182d
commit
ae349ec6a8
4 changed files with 100 additions and 4 deletions
|
@ -1492,17 +1492,34 @@ public:
|
|||
|
||||
class SuperCall final : public Expression {
|
||||
public:
|
||||
// This is here to be able to make a constructor like
|
||||
// constructor(...args) { super(...args); } which does not use @@iterator of %Array.prototype%.
|
||||
enum class IsPartOfSyntheticConstructor {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
|
||||
SuperCall(SourceRange source_range, Vector<CallExpression::Argument> arguments)
|
||||
: Expression(source_range)
|
||||
, m_arguments(move(arguments))
|
||||
, m_is_synthetic(IsPartOfSyntheticConstructor::No)
|
||||
{
|
||||
}
|
||||
|
||||
SuperCall(SourceRange source_range, IsPartOfSyntheticConstructor is_part_of_synthetic_constructor, CallExpression::Argument constructor_argument)
|
||||
: Expression(source_range)
|
||||
, m_arguments({ move(constructor_argument) })
|
||||
, m_is_synthetic(IsPartOfSyntheticConstructor::Yes)
|
||||
{
|
||||
VERIFY(is_part_of_synthetic_constructor == IsPartOfSyntheticConstructor::Yes);
|
||||
}
|
||||
|
||||
virtual Completion execute(Interpreter&, GlobalObject&) const override;
|
||||
virtual void dump(int indent) const override;
|
||||
|
||||
private:
|
||||
Vector<CallExpression::Argument> const m_arguments;
|
||||
IsPartOfSyntheticConstructor const m_is_synthetic;
|
||||
};
|
||||
|
||||
enum class AssignmentOp {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue