From 5507df02f2c1daa342de1d40910192a4d4b60a98 Mon Sep 17 00:00:00 2001 From: Marcin Hawryluk <70582973+mhawryluk@users.noreply.github.com> Date: Wed, 10 Jul 2024 10:37:32 +0200 Subject: [PATCH] Remove WGSLCompoundTrait (#25) --- packages/wigsill/src/types.ts | 8 -------- packages/wigsill/src/wgslCode.ts | 14 ++------------ packages/wigsill/src/wgslPlaceholder.ts | 14 +------------- 3 files changed, 3 insertions(+), 33 deletions(-) diff --git a/packages/wigsill/src/types.ts b/packages/wigsill/src/types.ts index d6020b76..bcf214a6 100644 --- a/packages/wigsill/src/types.ts +++ b/packages/wigsill/src/types.ts @@ -34,14 +34,6 @@ export interface WGSLBindableTrait extends WGSLItem { export type WGSLBindPair = [WGSLBindableTrait, T]; -export interface WGSLCompoundTrait extends WGSLItem { - getChildren(ctx: IResolutionCtx): WGSLItem[]; -} - -export function hasCompoundTrait(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; diff --git a/packages/wigsill/src/wgslCode.ts b/packages/wigsill/src/wgslCode.ts index 1e23983b..9efa6112 100644 --- a/packages/wigsill/src/wgslCode.ts +++ b/packages/wigsill/src/wgslCode.ts @@ -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 = ''; diff --git a/packages/wigsill/src/wgslPlaceholder.ts b/packages/wigsill/src/wgslPlaceholder.ts index 09c6530e..500ead43 100644 --- a/packages/wigsill/src/wgslPlaceholder.ts +++ b/packages/wigsill/src/wgslPlaceholder.ts @@ -1,14 +1,12 @@ import { IResolutionCtx, WGSLBindableTrait, - WGSLCompoundTrait, WGSLItem, WGSLSegment, - hasCompoundTrait, } from './types'; export class WGSLPlaceholder - implements WGSLItem, WGSLBindableTrait, WGSLCompoundTrait + implements WGSLItem, WGSLBindableTrait { __bindingType!: WGSLSegment; public debugLabel?: string | undefined; @@ -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)); }