Expose isClassConstructor in Debugger.Object
Categories
(DevTools :: Debugger, enhancement, P2)
Tracking
(firefox72 fixed)
Tracking | Status | |
---|---|---|
firefox72 | --- | fixed |
People
(Reporter: nchevobbe, Assigned: nchevobbe)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
Assignee | ||
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Comment 1•5 years ago
|
||
:nchevobbe Do you have a samle snippet or good STR so I can see if a contributor wants to take this?
Assignee | ||
Comment 2•5 years ago
|
||
Steps to reproduce
- Open the console
- Evaluate the following:
class MyClass {};
MyClass;
Expected results
The result is class MyClass
Actual results
The result is function MyClass()
I remember looking into that at some point, and you have to go pretty deep in C++ code to see what's happening.
The underlying issue seems to be that classes are only syntax sugar on top of functions.
The attribute is describe in Debugger.Object.md#65-66
Assignee | ||
Comment 3•5 years ago
|
||
If someone wants to give it a try:
The property is retrieved from js/src/debugger/Object.cpp#290-298, using DebuggerObject::getClassName
which is defined in js/src/debugger/Object.cpp#1573-1592
That calls GetObjectClassName
defined in js/src/vm/JSObject-inl.h#613-620, which seems to use js/src/vm/JSObject.h#106.
Comment 4•5 years ago
•
|
||
If we want to do this, I think adding .isClassConstructor
would be better than changing .class
to return Class
. From a runtime perspective, a constructor is just a function.
Implementation-wise, JSFunction
objects already have an isClassConstructor()
method, so the same way we do the other isX
checks for function types should also work here, like https://searchfox.org/mozilla-central/rev/11d9c7b7fa82fdfb8ac2a8f0864e9d8d5fe2b926/js/src/debugger/Object.cpp#1544
Assignee | ||
Comment 5•5 years ago
|
||
(In reply to Logan Smyth [:loganfsmyth] from comment #4)
If we want to do this, I think adding
.isClassConstructor
would be better than changing.class
to returnClass
. From a runtime perspective, a constructor is just a function.Implementation-wise,
JSFunction
objects already have anisClassConstructor()
method, so the same way we do the otherisX
checks for function types should also work here, like https://searchfox.org/mozilla-central/rev/11d9c7b7fa82fdfb8ac2a8f0864e9d8d5fe2b926/js/src/debugger/Object.cpp#1544
Awesome! I might give it a try then :)
Assignee | ||
Comment 6•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Updated•5 years ago
|
Comment 8•5 years ago
|
||
bugherder |
Comment 9•5 years ago
|
||
bugherder landing |
Description
•