mirror of
https://github.com/RGBCube/serenity
synced 2025-06-30 15:02:06 +00:00
LibJS: Add argument(i) and argument_count() to Interpreter
Add some convenience accessors for retrieving arguments from the current call frame.
This commit is contained in:
parent
1549c5c48b
commit
cd1d369cdd
9 changed files with 49 additions and 34 deletions
|
@ -53,10 +53,10 @@ MathObject::~MathObject()
|
|||
|
||||
Value MathObject::abs(Interpreter& interpreter)
|
||||
{
|
||||
if (interpreter.call_frame().arguments.is_empty())
|
||||
if (!interpreter.argument_count())
|
||||
return js_nan();
|
||||
|
||||
auto number = interpreter.call_frame().arguments[0].to_number();
|
||||
auto number = interpreter.argument(0).to_number();
|
||||
if (number.is_nan())
|
||||
return js_nan();
|
||||
return Value(number.as_double() >= 0 ? number.as_double() : -number.as_double());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue