Skip to content

Commit

Permalink
feat: remove redundant
Browse files Browse the repository at this point in the history
  • Loading branch information
Sway007 committed Nov 15, 2024
1 parent 9de0104 commit eeb1188
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
18 changes: 2 additions & 16 deletions packages/shader-lab/src/preprocessor/PpParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ShaderPosition, ShaderRange } from "../common";
import LexerUtils from "../lexer/Utils";
import { MacroDefine } from "./MacroDefine";
import { BaseToken } from "../common/BaseToken";
import { EPpKeyword, EPpToken, PpConstant, SkipTokens } from "./constants";
import { EPpKeyword, EPpToken, PpConstant } from "./constants";
import PpScanner from "./PpScanner";
import { PpUtils } from "./Utils";
import { ShaderLab } from "../ShaderLab";
Expand Down Expand Up @@ -644,21 +644,7 @@ export class PpParser {
}

private static _onToken(token: BaseToken, scanner: PpScanner) {
if (SkipTokens.indexOf(token.lexeme) !== -1) {
this._skipBlock(token, scanner);
} else {
this._expandToken(token, scanner);
}
}

private static _skipBlock(token: BaseToken, scanner: PpScanner) {
const start = scanner.current - token.lexeme.length;
scanner.scanPairedBlock("{", "}");
const end = scanner.current;
const startPosition = ShaderLab.createPosition(start);
const endPosition = ShaderLab.createPosition(end);
const range = ShaderLab.createRange(startPosition, endPosition);
this.expandSegments.push({ rangeInBlock: range, replace: "" });
this._expandToken(token, scanner);
}

private static _expandToken(token: BaseToken, scanner: PpScanner) {
Expand Down
2 changes: 0 additions & 2 deletions packages/shader-lab/src/preprocessor/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,3 @@ export const PpKeyword = new Map<string, EPpKeyword>([
]);

export type PpConstant = boolean | number;

export const SkipTokens = ["EditorProperties", "EditorMacros", "Editor"];

0 comments on commit eeb1188

Please sign in to comment.