Skip to content

Commit 1350cc9

Browse files
committed
feat: code opt
1 parent a7d3cdf commit 1350cc9

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

packages/shader-lab/src/codeGen/GLESVisitor.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ export abstract class GLESVisitor extends CodeGenVisitor {
4545

4646
vertexMain(entry: string, data: ShaderData): string {
4747
const { symbolTable } = data;
48-
const fnSymbol = symbolTable.lookupBy(entry, ESymbolType.FN);
48+
const fnSymbol = symbolTable.lookup(entry, ESymbolType.FN);
4949
if (!fnSymbol?.astNode) throw `no entry function found: ${entry}`;
5050

5151
const fnNode = fnSymbol.astNode;
5252
VisitorContext.context.stage = EShaderStage.VERTEX;
5353

5454
const returnType = fnNode.protoType.returnType;
5555
if (typeof returnType.type === "string") {
56-
const varyStruct = symbolTable.lookupBy(returnType.type, ESymbolType.STRUCT);
56+
const varyStruct = symbolTable.lookup(returnType.type, ESymbolType.STRUCT);
5757
if (!varyStruct) {
5858
this._reportError(returnType.location, `invalid varying struct: ${returnType.type}`);
5959
} else {
@@ -67,7 +67,7 @@ export abstract class GLESVisitor extends CodeGenVisitor {
6767
if (paramList?.length) {
6868
for (const paramInfo of paramList) {
6969
if (typeof paramInfo.typeInfo.type === "string") {
70-
const structSymbol = symbolTable.lookupBy(paramInfo.typeInfo.type, ESymbolType.STRUCT);
70+
const structSymbol = symbolTable.lookup(paramInfo.typeInfo.type, ESymbolType.STRUCT);
7171
if (!structSymbol) {
7272
this._reportError(paramInfo.astNode.location, `Not found attribute struct "${paramInfo.typeInfo.type}".`);
7373
continue;
@@ -103,7 +103,7 @@ export abstract class GLESVisitor extends CodeGenVisitor {
103103

104104
private _fragmentMain(entry: string, data: ShaderData): string {
105105
const { symbolTable } = data;
106-
const fnSymbol = symbolTable.lookupBy(entry, ESymbolType.FN);
106+
const fnSymbol = symbolTable.lookup(entry, ESymbolType.FN);
107107
if (!fnSymbol?.astNode) throw `no entry function found: ${entry}`;
108108
const fnNode = fnSymbol.astNode;
109109

@@ -117,7 +117,7 @@ export abstract class GLESVisitor extends CodeGenVisitor {
117117

118118
const { type: returnDataType, location: returnLocation } = fnNode.protoType.returnType;
119119
if (typeof returnDataType === "string") {
120-
const mrtStruct = symbolTable.lookupBy(returnDataType, ESymbolType.STRUCT);
120+
const mrtStruct = symbolTable.lookup(returnDataType, ESymbolType.STRUCT);
121121
if (!mrtStruct) {
122122
this._reportError(returnLocation, `invalid mrt struct: ${returnDataType}`);
123123
} else {

packages/shader-lab/src/codeGen/VisitorContext.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export class VisitorContext {
121121
}
122122
return;
123123
}
124-
const sm = this._passSymbolTable.lookupBy(ident, type);
124+
const sm = this._passSymbolTable.lookup(ident, type);
125125
if (sm) {
126126
this._referencedGlobals[ident] = sm;
127127
}

packages/shader-lab/src/contentParser/ContentSymbolTable.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default class ContentSymbolTable extends BaseSymbolTable<ISymbol> {
2121
this._table.set(sm.ident, entry);
2222
}
2323

24-
lookupByType(ident: string, type: TokenType): ISymbol | undefined {
24+
lookup(ident: string, type: TokenType): ISymbol | undefined {
2525
const entry = this._table.get(ident);
2626
if (entry) {
2727
for (let length = entry.length, i = 0; i < length; i++) {

packages/shader-lab/src/contentParser/ShaderContentParser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class ShaderContentParser {
117117
const stack = ShaderContentParser._symbolTableStack.stack;
118118
for (let length = stack.length, i = length - 1; i >= 0; i--) {
119119
const symbolTable = stack[i];
120-
const ret = symbolTable.lookupByType(ident, type);
120+
const ret = symbolTable.lookup(ident, type);
121121
if (ret) return ret;
122122
}
123123
}

packages/shader-lab/src/parser/SemanticAnalyzer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export default class SematicAnalyzer {
8080
const stack = this.symbolTableStack.stack;
8181
for (let length = stack.length, i = length - 1; i >= 0; i--) {
8282
const symbolTable = stack[i];
83-
const ret = symbolTable.lookupBy(ident, symbolType, signature, astNode);
83+
const ret = symbolTable.lookup(ident, symbolType, signature, astNode);
8484
if (ret) return ret;
8585
}
8686
}

packages/shader-lab/src/parser/symbolTable/SymbolTable.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class SymbolTable extends BaseSymbolTable<SymbolInfo> {
2121
this._table.set(sm.ident, entry);
2222
}
2323

24-
lookupBy<T extends ESymbolType>(
24+
lookup<T extends ESymbolType>(
2525
ident: string,
2626
symbolType: T,
2727
signature?: GalaceanDataType[],

0 commit comments

Comments
 (0)