@@ -41,6 +41,15 @@ export interface ref<T> {
4141// TODO: Restrict calls to this function only from within TypeGPU functions
4242export const ref : DualFn < < T > ( value : T ) => ref < T > > = ( ( ) => {
4343 const gpuImpl = ( value : Snippet ) => {
44+ /**
45+ * Pointer type only exists if the ref was created from a reference (buttery-butter).
46+ *
47+ * @example
48+ * ```ts
49+ * const life = ref(42); // created from a value
50+ * const boid = ref(layout.$.boids[0]); // created from a reference
51+ * ```
52+ */
4453 const ptrType = createPtrFromOrigin (
4554 value . origin ,
4655 value . dataType as StorableData ,
@@ -116,35 +125,26 @@ export class RefOperator implements SelfResolvable {
116125 readonly [ $internal ] : true ;
117126 readonly snippet : Snippet ;
118127
119- /**
120- * Pointer params only exist if the ref was created from a reference (buttery-butter).
121- *
122- * @example
123- * ```ts
124- * const life = ref(42); // created from a value
125- * const boid = ref(layout.$.boids[0]); // created from a reference
126- * ```
127- */
128- readonly ptrType : Ptr | undefined ;
128+ readonly #ptrType: Ptr | undefined ;
129129
130130 constructor ( snippet : Snippet , ptrType : Ptr | undefined ) {
131131 this [ $internal ] = true ;
132132 this . snippet = snippet ;
133- this . ptrType = ptrType ;
133+ this . # ptrType = ptrType ;
134134 }
135135
136136 get [ $ownSnippet ] ( ) : Snippet {
137- if ( ! this . ptrType ) {
137+ if ( ! this . # ptrType) {
138138 throw new Error ( stitch `Cannot take a reference of ${ this . snippet } ` ) ;
139139 }
140- return snip ( this , this . ptrType , this . snippet . origin ) ;
140+ return snip ( this , this . # ptrType, this . snippet . origin ) ;
141141 }
142142
143143 [ $resolve ] ( ctx : ResolutionCtx ) : ResolvedSnippet {
144- if ( ! this . ptrType ) {
144+ if ( ! this . # ptrType) {
145145 throw new Error ( stitch `Cannot take a reference of ${ this . snippet } ` ) ;
146146 }
147- return snip ( stitch `(&${ this . snippet } )` , this . ptrType , this . snippet . origin ) ;
147+ return snip ( stitch `(&${ this . snippet } )` , this . # ptrType, this . snippet . origin ) ;
148148 }
149149}
150150
0 commit comments