MCPcopy Create free account
hub / github.com/gpujs/gpu.js / _earlyThrows

Method _earlyThrows

src/backend/cpu/kernel.js:286–304  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

284 }
285
286 _earlyThrows() {
287 if (this.graphical) return '';
288 if (this.immutable) return '';
289 if (!this.pipeline) return '';
290 const arrayArguments = [];
291 for (let i = 0; i < this.argumentTypes.length; i++) {
292 if (this.argumentTypes[i] === 'Array') {
293 arrayArguments.push(this.argumentNames[i]);
294 }
295 }
296 if (arrayArguments.length === 0) return '';
297 const checks = [];
298 for (let i = 0; i < arrayArguments.length; i++) {
299 const argumentName = arrayArguments[i];
300 const checkSubKernels = this._mapSubKernels(subKernel => `user_${argumentName} === result_${subKernel.name}`).join(' || ');
301 checks.push(`user_${argumentName} === result${checkSubKernels ? ` || ${checkSubKernels}` : ''}`);
302 }
303 return `if (${checks.join(' || ')}) throw new Error('Source and destination arrays are the same. Use immutable = true');`;
304 }
305
306 _processArguments() {
307 const result = [];

Callers 1

getKernelStringMethod · 0.95

Calls 1

_mapSubKernelsMethod · 0.95

Tested by

no test coverage detected