Closed
Bug 492840
Opened 16 years ago
Closed 15 years ago
ES5: Implement Object.create
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla1.9.3a1
People
(Reporter: jimb, Assigned: Waldo)
References
Details
(Keywords: dev-doc-complete, Whiteboard: fixed-in-tracemonkey)
Attachments
(2 files, 2 obsolete files)
(deleted),
patch
|
mrbkap
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
Details | Diff | Splinter Review |
Object.create is specified by 15.2.3.5 in the ES5 draft:
http://wiki.ecmascript.org/doku.php?id=es3.1:es3.1_proposal_working_draft
Reporter | ||
Updated•16 years ago
|
Assignee | ||
Updated•16 years ago
|
Assignee: general → jwalden+bmo
Assignee | ||
Comment 1•15 years ago
|
||
This doesn't provide any new functionality, but newborn-proto-setting capability is an important step toward removing __proto__ support at some (likely distant) time in the future.
Attachment #402512 -
Flags: review?(jorendorff)
Assignee | ||
Comment 2•15 years ago
|
||
Attachment #402512 -
Attachment is obsolete: true
Attachment #402921 -
Flags: review?(jorendorff)
Attachment #402512 -
Flags: review?(jorendorff)
Assignee | ||
Comment 3•15 years ago
|
||
Attachment #402921 -
Attachment is obsolete: true
Attachment #402997 -
Flags: review?(mrbkap)
Attachment #402921 -
Flags: review?(jorendorff)
Comment 4•15 years ago
|
||
Waldo, please fix the test to call reportCompare() and update ecma_5/Object/jstests.list to remove the skip. Thanks.
Comment 5•15 years ago
|
||
Comment on attachment 402997 [details] [diff] [review]
Updated atop latest patch in bug 430133, add another test or two
>+MSG_DEF(JSMSG_NOT_OBJECT_OR_NULL, 244, 0, JSEXN_TYPEERR, "value is not null or an object")
You can use JSMSG_UNEXPECTED_TYPE with type being "null or an object" instead of adding a new message here.
>diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp
>--- a/js/src/jsobj.cpp
>+++ b/js/src/jsobj.cpp
>@@ -2673,16 +2673,80 @@ obj_defineProperties(JSContext* cx, uint
> for (size_t i = 0; i < len; i++) {
> if (!DefineProperty(cx, obj, (*descs)[i], true, dummy))
> return JS_FALSE;
> }
>
> return JS_TRUE;
> }
>
>+/* ES5 15.2.3.5: Object.create(O [, Properties]) */
>+static JSBool
>+obj_create(JSContext *cx, uintN argc, jsval *vp)
>+{
>+ jsval v = argc == 0 ? JSVAL_VOID : vp[2];
Nit: parentheses around argc == 0.
>+ if (argc < 1 || !JSVAL_IS_OBJECT(v)) {
The argc < 1 in this check is redundant with the above assignment (especially since we assign a non-object to v if argc is less than 1). I guess it's a little tricky, but I'd say to remove the redundant test.
>+ /*
>+ * Notwithstanding that Object.create seems more likely to be in run-once
>+ * code than performance-critical code, JS_GetScopeChain(cx) is going to
>+ * throw us off trace -- is there an alternative?
Hmm, so js_NewObjectWithGivenProto will use the parent of the prototype (if it's not null) if parent is null. You could use that if the given prototype is non-null. I don't know what we want the lexical scope of these objects to be. Parented to the prototype object's parent (which may be a different lexical scope)? Always parented to the static scope of Object.create? I assume the spec is silent on this issue because it doesn't address the possibility of multiple global objects...
Attachment #402997 -
Flags: review?(mrbkap) → review+
Assignee | ||
Comment 6•15 years ago
|
||
(reversing dependency on Object.defineProperty, whose patch this patch depends on)
Assignee | ||
Comment 7•15 years ago
|
||
Assignee | ||
Comment 8•15 years ago
|
||
http://hg.mozilla.org/tracemonkey/rev/9a24406ddbe7
http://hg.mozilla.org/tracemonkey/rev/aa8a6d3b5dc8
http://hg.mozilla.org/tracemonkey/rev/8cb0a325a704
Blocks: es5
Status: NEW → ASSIGNED
Whiteboard: fixed-in-tracemonkey
Target Milestone: --- → mozilla1.9.3a1
Assignee | ||
Comment 9•15 years ago
|
||
I wrote up a little bit here, but we certainly need to make the information more visible than simply buried in the JS reference:
https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Objects/Object/create
Keywords: dev-doc-needed
Comment 10•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Updated•14 years ago
|
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•