Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove WGSLCompoundTrait #25

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions packages/wigsill/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ export interface WGSLBindableTrait<TBinding> extends WGSLItem {

export type WGSLBindPair<T> = [WGSLBindableTrait<T>, T];

export interface WGSLCompoundTrait extends WGSLItem {
getChildren(ctx: IResolutionCtx): WGSLItem[];
}

export function hasCompoundTrait<T>(value: T): value is T & WGSLCompoundTrait {
return !!value && typeof value === 'object' && 'getChildren' in value;
}

export interface WGSLMemoryTrait extends WGSLItem {
readonly size: number;
readonly baseAlignment: number;
Expand Down
14 changes: 2 additions & 12 deletions packages/wigsill/src/wgslCode.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import {
IResolutionCtx,
WGSLCompoundTrait,
WGSLItem,
WGSLSegment,
isWGSLItem,
} from './types';
import { IResolutionCtx, WGSLItem, WGSLSegment, isWGSLItem } from './types';

export class WGSLCode implements WGSLItem, WGSLCompoundTrait {
export class WGSLCode implements WGSLItem {
constructor(public readonly segments: WGSLSegment[]) {}

getChildren(): WGSLItem[] {
return this.segments.filter(isWGSLItem);
}

resolve(ctx: IResolutionCtx) {
let code = '';

Expand Down
14 changes: 1 addition & 13 deletions packages/wigsill/src/wgslPlaceholder.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import {
IResolutionCtx,
WGSLBindableTrait,
WGSLCompoundTrait,
WGSLItem,
WGSLSegment,
hasCompoundTrait,
} from './types';

export class WGSLPlaceholder
implements WGSLItem, WGSLBindableTrait<WGSLSegment>, WGSLCompoundTrait
implements WGSLItem, WGSLBindableTrait<WGSLSegment>
{
__bindingType!: WGSLSegment;
public debugLabel?: string | undefined;
Expand All @@ -28,16 +26,6 @@ export class WGSLPlaceholder
return ctx.requireBinding(this);
}

getChildren(ctx: IResolutionCtx): WGSLItem[] {
const segment = this.getSegment(ctx);

if (hasCompoundTrait(segment)) {
return segment.getChildren(ctx);
}

return [];
}

resolve(ctx: IResolutionCtx): string {
return ctx.resolve(this.getSegment(ctx));
}
Expand Down
Loading