mirror of
https://github.com/gpujs/gpu.js.git
synced 2026-01-18 16:04:10 +00:00
Also cleanup moving methods around for reuse and so code can be more concise. Removed some older references, where now we use `this.thread.x` or `this.output.x`. Removed some older methods we no longer use (astFunctionPrototype). Removed some overloaded functions from webgl1 and webgl2 glsl. We no longer need them. Removed some references to `=== null` in favor of truthy. `if (undefined === null)` is true, and can lead to unexpected results, where we really wanted truthy, and is simpler to write.
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
const { assert, test, module: describe } = require('qunit');
|
|
const { WebGLFunctionNode } = require(process.cwd() + '/src');
|
|
|
|
describe('WebGLFunctionNode.astMemberExpression()');
|
|
|
|
// TODO: finish
|
|
function run(value, name, type) {
|
|
const expression = acorn.parse(value).body[0].expression;
|
|
const instance = {
|
|
isState: () => false,
|
|
astMemberExpressionUnroll: () => name,
|
|
declarations: {
|
|
[name]: type
|
|
},
|
|
astGetFirstAvailableName: () => name,
|
|
getVariableType: () => type,
|
|
astGeneric: () => {},
|
|
pushState: () => {},
|
|
popState: () => {},
|
|
isAstVariable: WebGLFunctionNode.prototype.isAstVariable,
|
|
getVariableSignature: WebGLFunctionNode.prototype.getVariableSignature,
|
|
memberExpressionPropertyMarkup: WebGLFunctionNode.prototype.memberExpressionPropertyMarkup,
|
|
};
|
|
return WebGLFunctionNode.prototype.astMemberExpression.call(instance, expression, []).join('');
|
|
}
|
|
|
|
// test('it[]', () => {
|
|
// console.log(run('it[0];', 'it', 'Array'));
|
|
// console.log(run('it[0][1];', 'it', 'Array'));
|
|
// console.log(run('it[0][1][2];', 'it', 'Array'));
|
|
// console.log(run('it[this.thread.x + 100];', 'it', 'Array'));
|
|
// });
|