Skip to content

Commit

Permalink
refactor: opt code
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoLei1990 committed Dec 23, 2024
1 parent 3ebe87e commit 78c1919
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions packages/shader-lab/src/parser/AST.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// #if _VERBOSE
import { BuiltinFunction, BuiltinVariable, NonGenericGalaceanType } from "./builtin";
// #endif
import { ClearableObjectPool, IPoolElement } from "@galacean/engine";
import { CodeGenVisitor } from "../codeGen";
import { ENonTerminal } from "./GrammarSymbol";
import { EKeyword, ETokenType, GalaceanDataType, ShaderRange, TokenType, TypeAny } from "../common";
import { BaseToken, BaseToken as Token } from "../common/BaseToken";
import { EKeyword, ETokenType, TokenType, ShaderRange, GalaceanDataType, TypeAny } from "../common";
import { ParserUtils } from "../ParserUtils";
import { ShaderLabUtils } from "../ShaderLabUtils";
import { ENonTerminal } from "./GrammarSymbol";
import SematicAnalyzer from "./SemanticAnalyzer";
import { ShaderData } from "./ShaderInfo";
import { ESymbolType, FnSymbol, StructSymbol, VarSymbol } from "./symbolTable";
import { ParserUtils } from "../ParserUtils";
import { IParamInfo, NodeChild, StructProp, SymbolType } from "./types";
import { ClearableObjectPool, IPoolElement } from "@galacean/engine";
import { ShaderLabUtils } from "../ShaderLabUtils";

function ASTNodeDecorator(nonTerminal: ENonTerminal) {
return function <T extends { new (...args: any[]): TreeNode }>(ASTNode: T) {
Expand Down Expand Up @@ -47,7 +47,7 @@ export abstract class TreeNode implements IPoolElement {
this.nt = nonTerminal;
}

set(loc: ShaderRange, children: NodeChild[], nt: ENonTerminal) {
set(loc: ShaderRange, children: NodeChild[]): void {
this._location = loc;
this._children = children;
this.init();
Expand Down Expand Up @@ -152,8 +152,8 @@ export namespace ASTNode {
return this._type ?? TypeAny;
}

override set(loc: ShaderRange, children: NodeChild[], nt: ENonTerminal) {
super.set(loc, children, nt);
override set(loc: ShaderRange, children: NodeChild[]) {
super.set(loc, children);
this._type = undefined;
}
}
Expand Down Expand Up @@ -273,10 +273,6 @@ export namespace ASTNode {
get lexeme(): string {
return (<Token>this.children[0]).lexeme;
}

override set(loc: ShaderRange, children: NodeChild[], nt: ENonTerminal) {
super.set(loc, children, nt);
}
}

// #if _VERBOSE
Expand Down

0 comments on commit 78c1919

Please sign in to comment.