Skip to content

Commit

Permalink
Bug 1920955 - Part 48: Simplify ToTemporalDuration. r=sfink
Browse files Browse the repository at this point in the history
<tc39/proposal-temporal#2943> should address the fixme note.

Differential Revision: https://phabricator.services.mozilla.com/D223554

UltraBlame original commit: de7fc134aa463dddcc4f75ff9ef2ba2b9b670a6f
  • Loading branch information
marco-c committed Oct 9, 2024
1 parent 9e97b83 commit 5cb4f1e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 287 deletions.
257 changes: 35 additions & 222 deletions js/src/builtin/temporal/Duration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6570,17 +6570,8 @@ item
)
*
/
Wrapped
<
DurationObject
*
>
js
:
:
temporal
:
:
static
bool
ToTemporalDuration
(
JSContext
Expand All @@ -6591,155 +6582,37 @@ Handle
Value
>
item
)
{
/
/
Step
1
.
if
(
item
.
isObject
(
)
)
{
JSObject
Duration
*
itemObj
=
&
item
.
toObject
(
)
;
if
(
itemObj
-
>
canUnwrapAs
<
DurationObject
>
(
)
result
)
{
return
itemObj
;
}
}
/
/
Step
2
.
Duration
result
;
if
(
!
FIXME
:
spec
issue
-
Merge
with
ToTemporalDurationRecord
(
cx
item
&
result
)
)
{
return
nullptr
;
}
.
/
/
Step
Steps
1
-
3
.
return
CreateTemporalDuration
(
cx
result
)
;
}
/
*
*
*
ToTemporalDuration
(
item
)
*
/
bool
js
:
:
temporal
:
:
ToTemporalDuration
(
JSContext
*
cx
Handle
<
Value
>
item
Duration
*
result
)
{
auto
obj
=
ToTemporalDuration
ToTemporalDurationRecord
(
cx
item
)
;
if
(
!
obj
)
{
return
false
;
}
*
result
=
ToDuration
(
&
obj
.
unwrap
(
)
)
;
return
true
;
}
/
*
Expand Down Expand Up @@ -19174,111 +19047,51 @@ argc
vp
)
;
Handle
<
Value
>
item
=
args
.
get
(
0
)
;
/
/
Step
Steps
1
-
2
.
if
(
item
.
isObject
(
)
)
{
if
(
auto
*
duration
=
item
.
toObject
(
)
.
maybeUnwrapIf
<
DurationObject
>
(
)
)
{
auto
*
Duration
result
=
CreateTemporalDuration
(
cx
ToDuration
(
duration
)
)
;
if
(
!
result
)
{
return
false
;
}
ToTemporalDuration
(
cx
args
.
rval
get
(
0
)
.
setObject
(
*
&
result
)
;
)
{
return
true
false
;
}
}
/
/
Step
2
.
auto
result
*
obj
=
ToTemporalDuration
CreateTemporalDuration
(
cx
item
result
)
;
if
(
!
result
obj
)
{
return
Expand All @@ -19294,7 +19107,7 @@ rval
setObject
(
*
result
obj
)
;
return
Expand Down
Loading

0 comments on commit 5cb4f1e

Please sign in to comment.