Skip to content

Commit

Permalink
Merge pull request #65 from mhawryluk/impr/function-arguments
Browse files Browse the repository at this point in the history
Make argument and returnType info available for entry function as well
  • Loading branch information
brendan-duncan authored Nov 19, 2024
2 parents 1141373 + 562a566 commit 8a1f7ae
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class FunctionInfo {
stage: string | null;
inputs: Array<InputInfo>;
outputs: Array<OutputInfo>;
arguments: Array<ArgumentInfo>; // only for non-entry functions
arguments: Array<ArgumentInfo>;
returnType: TypeInfo | null;
resources: Array<VariableInfo>;
startLine: number;
Expand Down
24 changes: 13 additions & 11 deletions src/wgsl_reflect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,18 +509,20 @@ export class WgslReflect {
fn.inputs = this._getInputs(node.args);
fn.outputs = this._getOutputs(node.returnType);
this.entry[stage.name].push(fn);
} else {
fn.arguments = node.args.map(
(arg) =>
new ArgumentInfo(
arg.name,
this._getTypeInfo(arg.type, arg.attributes)
)
);
fn.returnType = node.returnType
? this._getTypeInfo(node.returnType, node.attributes)
: null;
}

fn.arguments = node.args.map(
(arg) =>
new ArgumentInfo(
arg.name,
this._getTypeInfo(arg.type, arg.attributes)
)
);

fn.returnType = node.returnType
? this._getTypeInfo(node.returnType, node.attributes)
: null;

continue;
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/tests/struct.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, group } from "../test.js";
import { WgslParser } from "../../../wgsl_reflect.debug.js";
import { WgslParser } from "../../../wgsl_reflect.module.js";

group("struct", function () {
const shader = `
Expand Down
2 changes: 1 addition & 1 deletion test/tests/struct_layout.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, group } from "../test.js";
import { WgslReflect } from "../../../wgsl_reflect.debug.js";
import { WgslReflect } from "../../../wgsl_reflect.module.js";

group("struct_layout", function () {
const shader = `
Expand Down
2 changes: 1 addition & 1 deletion test/tests/test_parser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, group } from "../test.js";
import { WgslParser } from "../../../wgsl_reflect.debug.js";
import { WgslParser } from "../../../wgsl_reflect.module.js";

group("Parser", function () {
test("const2", function (test) {
Expand Down
2 changes: 1 addition & 1 deletion test/tests/test_reflect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, group } from "../test.js";
import { WgslReflect, ResourceType } from "../../../wgsl_reflect.debug.js";
import { WgslReflect, ResourceType } from "../../../wgsl_reflect.module.js";

group("Reflect", function () {
test("array_no_format", function (test) {
Expand Down
2 changes: 1 addition & 1 deletion test/tests/test_scanner.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, group } from "../test.js";
import { WgslScanner, TokenTypes } from "../../../wgsl_reflect.debug.js";
import { WgslScanner, TokenTypes } from "../../../wgsl_reflect.module.js";

group("Scanner", function () {
test("(1+2)-3;", function (test) {
Expand Down
10 changes: 4 additions & 6 deletions wgsl_reflect.module.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wgsl_reflect.module.js.map

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions wgsl_reflect.node.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wgsl_reflect.node.js.map

Large diffs are not rendered by default.

0 comments on commit 8a1f7ae

Please sign in to comment.