1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:07:46 +00:00

LibJS: Forward a string aproximation of the CallExpression to Call Ops

This gives us better debug output when analysing calls to `undefined`
and also fixes multiple test-js cases expecting an
`(evaluated from $Expression)` in the error message.

This also refactors out the generation of that string, to avoid code
duplication with the AST interpreter.
This commit is contained in:
Hendiadyoin1 2022-10-01 01:36:06 +02:00 committed by Linus Groh
parent a2ccf31a62
commit 490c097bc4
5 changed files with 42 additions and 17 deletions

View file

@ -604,11 +604,12 @@ public:
Construct,
};
Call(CallType type, Register callee, Register this_value)
Call(CallType type, Register callee, Register this_value, Optional<StringTableIndex> expression_string = {})
: Instruction(Type::Call)
, m_callee(callee)
, m_this_value(this_value)
, m_type(type)
, m_expression_string(expression_string)
{
}
@ -616,10 +617,13 @@ public:
String to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
Completion throw_type_error_for_callee(Bytecode::Interpreter&, StringView callee_type) const;
private:
Register m_callee;
Register m_this_value;
CallType m_type;
Optional<StringTableIndex> m_expression_string;
};
// NOTE: This instruction is variable-width depending on the number of arguments!