mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-03 22:38:41 +09:00
1216630 - Print class source when calling toString on the constructor.
This is accomplished in the following ways. LazyScripts and JSScripts now have 4 offsets: - Source begin and end for the actual source. This is used for lazy parsing. - toString begin and end for toString. Some kinds of functions, like async, only have a different begin offset. Class constructors have different offsets for both begin and end. For syntactically present (i.e. non-default) constructors, the class source span is remembered directly on the LazyScript or JSScript. The toString implementation then splices out the substring directly. For default constructors, a new SRC_CLASS SrcNote type is added. It's binary and has as its arguments the begin and end offsets of the class expression or statement. MakeDefaultConstructor reads the note and overrides the cloned self-hosted function's source object. This is probably the least intrusive way to accomplish this.
This commit is contained in:
parent
482fc16376
commit
f79ee2fd83
14 changed files with 248 additions and 74 deletions
|
|
@ -2550,6 +2550,14 @@ SrcNotes(JSContext* cx, HandleScript script, Sprinter* sp)
|
|||
return false;
|
||||
break;
|
||||
|
||||
case SRC_CLASS_SPAN: {
|
||||
unsigned startOffset = GetSrcNoteOffset(sn, 0);
|
||||
unsigned endOffset = GetSrcNoteOffset(sn, 1);
|
||||
if (!sp->jsprintf(" %u %u", startOffset, endOffset))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("unrecognized srcnote");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue