Skip to content

Commit

Permalink
Merge branch 'main' into feat/wgsl-slot
Browse files Browse the repository at this point in the history
  • Loading branch information
mhawryluk committed Jul 10, 2024
2 parents 1675c3f + 5507df0 commit 87ceda7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 35 deletions.
8 changes: 0 additions & 8 deletions packages/wigsill/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@ export interface WGSLBindableTrait<TBinding> {

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
16 changes: 1 addition & 15 deletions packages/wigsill/src/wgslSlot.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {
IResolutionCtx,
WGSLBindableTrait,
WGSLCompoundTrait,
WGSLItem,
WGSLSegment,
hasCompoundTrait,
isWGSLSegment,
} from './types';

Expand All @@ -20,9 +18,7 @@ export interface ResolvableSlot<T extends WGSLSegment> extends WGSLItem {
__bindingType: T;
}

export class WGSLSlot<T>
implements WGSLItem, WGSLBindableTrait<T>, WGSLCompoundTrait
{
export class WGSLSlot<T> implements WGSLItem, WGSLBindableTrait<T> {
__bindingType!: T;
__brand = 'Slot' as const;
public debugLabel?: string | undefined;
Expand All @@ -42,16 +38,6 @@ export class WGSLSlot<T>
return ctx.requireBinding(this);
}

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

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

return [];
}

resolve(ctx: IResolutionCtx): string {
const value = this.getValue(ctx);
if (!isWGSLSegment(value)) {
Expand Down

0 comments on commit 87ceda7

Please sign in to comment.