mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 04:26:32 +08:00
This change makes it easier to run the script from directly `roll_py.deps` without having to fetch the dependencies first. This also makes it easier to track which dependencies our tooling have. Change-Id: I1ce55074ee6a1fffa6f2a2f05a56d0d74b4aca90 Bug: 1255619 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3431346 Reviewed-by: Mathias Bynens <mathias@chromium.org> Commit-Queue: Johan Bay <jobay@chromium.org>
61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
import { Base } from "./base.js";
|
|
import { const_data, const_value } from "./helpers.js";
|
|
|
|
export class Default extends Base {
|
|
/**
|
|
* @param {import("../tokeniser").Tokeniser} tokeniser
|
|
*/
|
|
static parse(tokeniser) {
|
|
const assign = tokeniser.consume("=");
|
|
if (!assign) {
|
|
return null;
|
|
}
|
|
const def =
|
|
const_value(tokeniser) ||
|
|
tokeniser.consumeKind("string") ||
|
|
tokeniser.consume("null", "[", "{") ||
|
|
tokeniser.error("No value for default");
|
|
const expression = [def];
|
|
if (def.value === "[") {
|
|
const close =
|
|
tokeniser.consume("]") ||
|
|
tokeniser.error("Default sequence value must be empty");
|
|
expression.push(close);
|
|
} else if (def.value === "{") {
|
|
const close =
|
|
tokeniser.consume("}") ||
|
|
tokeniser.error("Default dictionary value must be empty");
|
|
expression.push(close);
|
|
}
|
|
return new Default({
|
|
source: tokeniser.source,
|
|
tokens: { assign },
|
|
expression,
|
|
});
|
|
}
|
|
|
|
constructor({ source, tokens, expression }) {
|
|
super({ source, tokens });
|
|
expression.parent = this;
|
|
Object.defineProperty(this, "expression", { value: expression });
|
|
}
|
|
|
|
get type() {
|
|
return const_data(this.expression[0]).type;
|
|
}
|
|
get value() {
|
|
return const_data(this.expression[0]).value;
|
|
}
|
|
get negative() {
|
|
return const_data(this.expression[0]).negative;
|
|
}
|
|
|
|
/** @param {import("../writer.js").Writer)} w */
|
|
write(w) {
|
|
return w.ts.wrap([
|
|
w.token(this.tokens.assign),
|
|
...this.expression.map((t) => w.token(t)),
|
|
]);
|
|
}
|
|
}
|