Remove the closure used with the PostScriptToken
class
This patch uses the same approach as used in lots of other parts of the code-base, which thus *slightly* reduces the size of this code.
This commit is contained in:
parent
81009d42cf
commit
ebbbc973a5
@ -109,61 +109,59 @@ const PostScriptTokenTypes = {
|
|||||||
IFELSE: 5,
|
IFELSE: 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
const PostScriptToken = (function PostScriptTokenClosure() {
|
class PostScriptToken {
|
||||||
const opCache = Object.create(null);
|
static get opCache() {
|
||||||
|
return shadow(this, "opCache", Object.create(null));
|
||||||
// eslint-disable-next-line no-shadow
|
|
||||||
class PostScriptToken {
|
|
||||||
constructor(type, value) {
|
|
||||||
this.type = type;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
static getOperator(op) {
|
|
||||||
const opValue = opCache[op];
|
|
||||||
if (opValue) {
|
|
||||||
return opValue;
|
|
||||||
}
|
|
||||||
return (opCache[op] = new PostScriptToken(
|
|
||||||
PostScriptTokenTypes.OPERATOR,
|
|
||||||
op
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
static get LBRACE() {
|
|
||||||
return shadow(
|
|
||||||
this,
|
|
||||||
"LBRACE",
|
|
||||||
new PostScriptToken(PostScriptTokenTypes.LBRACE, "{")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static get RBRACE() {
|
|
||||||
return shadow(
|
|
||||||
this,
|
|
||||||
"RBRACE",
|
|
||||||
new PostScriptToken(PostScriptTokenTypes.RBRACE, "}")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static get IF() {
|
|
||||||
return shadow(
|
|
||||||
this,
|
|
||||||
"IF",
|
|
||||||
new PostScriptToken(PostScriptTokenTypes.IF, "IF")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static get IFELSE() {
|
|
||||||
return shadow(
|
|
||||||
this,
|
|
||||||
"IFELSE",
|
|
||||||
new PostScriptToken(PostScriptTokenTypes.IFELSE, "IFELSE")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return PostScriptToken;
|
|
||||||
})();
|
constructor(type, value) {
|
||||||
|
this.type = type;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getOperator(op) {
|
||||||
|
const opValue = PostScriptToken.opCache[op];
|
||||||
|
if (opValue) {
|
||||||
|
return opValue;
|
||||||
|
}
|
||||||
|
return (PostScriptToken.opCache[op] = new PostScriptToken(
|
||||||
|
PostScriptTokenTypes.OPERATOR,
|
||||||
|
op
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
static get LBRACE() {
|
||||||
|
return shadow(
|
||||||
|
this,
|
||||||
|
"LBRACE",
|
||||||
|
new PostScriptToken(PostScriptTokenTypes.LBRACE, "{")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static get RBRACE() {
|
||||||
|
return shadow(
|
||||||
|
this,
|
||||||
|
"RBRACE",
|
||||||
|
new PostScriptToken(PostScriptTokenTypes.RBRACE, "}")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static get IF() {
|
||||||
|
return shadow(
|
||||||
|
this,
|
||||||
|
"IF",
|
||||||
|
new PostScriptToken(PostScriptTokenTypes.IF, "IF")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static get IFELSE() {
|
||||||
|
return shadow(
|
||||||
|
this,
|
||||||
|
"IFELSE",
|
||||||
|
new PostScriptToken(PostScriptTokenTypes.IFELSE, "IFELSE")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class PostScriptLexer {
|
class PostScriptLexer {
|
||||||
constructor(stream) {
|
constructor(stream) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user