mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-31 11:37:30 +09:00
1317090: Remove js::FindBody;
This commit is contained in:
parent
578e96b2cc
commit
bf35c6ba70
2 changed files with 0 additions and 74 deletions
|
|
@ -886,76 +886,6 @@ const Class JSFunction::class_ = {
|
||||||
|
|
||||||
const Class* const js::FunctionClassPtr = &JSFunction::class_;
|
const Class* const js::FunctionClassPtr = &JSFunction::class_;
|
||||||
|
|
||||||
/* Find the body of a function (not including braces). */
|
|
||||||
bool
|
|
||||||
js::FindBody(JSContext* cx, HandleFunction fun, HandleLinearString src, size_t* bodyStart,
|
|
||||||
size_t* bodyEnd)
|
|
||||||
{
|
|
||||||
// We don't need principals, since those are only used for error reporting.
|
|
||||||
CompileOptions options(cx);
|
|
||||||
options.setFileAndLine("internal-findBody", 0);
|
|
||||||
|
|
||||||
// For asm.js/wasm modules, there's no script.
|
|
||||||
if (fun->hasScript())
|
|
||||||
options.setVersion(fun->nonLazyScript()->getVersion());
|
|
||||||
|
|
||||||
AutoKeepAtoms keepAtoms(cx->perThreadData);
|
|
||||||
|
|
||||||
AutoStableStringChars stableChars(cx);
|
|
||||||
if (!stableChars.initTwoByte(cx, src))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
const mozilla::Range<const char16_t> srcChars = stableChars.twoByteRange();
|
|
||||||
TokenStream ts(cx, options, srcChars.begin().get(), srcChars.length(), nullptr);
|
|
||||||
int nest = 0;
|
|
||||||
bool onward = true;
|
|
||||||
// Skip arguments list.
|
|
||||||
do {
|
|
||||||
TokenKind tt;
|
|
||||||
if (!ts.getToken(&tt))
|
|
||||||
return false;
|
|
||||||
switch (tt) {
|
|
||||||
case TOK_NAME:
|
|
||||||
case TOK_YIELD:
|
|
||||||
if (nest == 0)
|
|
||||||
onward = false;
|
|
||||||
break;
|
|
||||||
case TOK_LP:
|
|
||||||
nest++;
|
|
||||||
break;
|
|
||||||
case TOK_RP:
|
|
||||||
if (--nest == 0)
|
|
||||||
onward = false;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while (onward);
|
|
||||||
TokenKind tt;
|
|
||||||
if (!ts.getToken(&tt))
|
|
||||||
return false;
|
|
||||||
if (tt == TOK_ARROW) {
|
|
||||||
if (!ts.getToken(&tt))
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool braced = tt == TOK_LC;
|
|
||||||
MOZ_ASSERT_IF(fun->isExprBody(), !braced);
|
|
||||||
*bodyStart = ts.currentToken().pos.begin;
|
|
||||||
if (braced)
|
|
||||||
*bodyStart += 1;
|
|
||||||
mozilla::RangedPtr<const char16_t> end = srcChars.end();
|
|
||||||
if (end[-1] == '}') {
|
|
||||||
end--;
|
|
||||||
} else {
|
|
||||||
MOZ_ASSERT(!braced);
|
|
||||||
for (; unicode::IsSpaceOrBOM2(end[-1]); end--)
|
|
||||||
;
|
|
||||||
}
|
|
||||||
*bodyEnd = end - srcChars.begin();
|
|
||||||
MOZ_ASSERT(*bodyStart <= *bodyEnd);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
JSString*
|
JSString*
|
||||||
js::FunctionToString(JSContext* cx, HandleFunction fun, bool prettyPrint)
|
js::FunctionToString(JSContext* cx, HandleFunction fun, bool prettyPrint)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -802,10 +802,6 @@ CloneFunctionAndScript(JSContext* cx, HandleFunction fun, HandleObject parent,
|
||||||
gc::AllocKind kind = gc::AllocKind::FUNCTION,
|
gc::AllocKind kind = gc::AllocKind::FUNCTION,
|
||||||
HandleObject proto = nullptr);
|
HandleObject proto = nullptr);
|
||||||
|
|
||||||
extern bool
|
|
||||||
FindBody(JSContext* cx, HandleFunction fun, HandleLinearString src, size_t* bodyStart,
|
|
||||||
size_t* bodyEnd);
|
|
||||||
|
|
||||||
} // namespace js
|
} // namespace js
|
||||||
|
|
||||||
inline js::FunctionExtended*
|
inline js::FunctionExtended*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue