MCPcopy Index your code
hub / github.com/gpujs/gpu.js / traceFunctionAST

Method traceFunctionAST

src/backend/function-node.js:214–258  ·  view source on GitHub ↗
(ast)

Source from the content-addressed store, hash-verified

212 }
213
214 traceFunctionAST(ast) {
215 const { contexts, declarations, functions, identifiers, functionCalls } = new FunctionTracer(ast);
216 this.contexts = contexts;
217 this.identifiers = identifiers;
218 this.functionCalls = functionCalls;
219 this.functions = functions;
220 for (let i = 0; i < declarations.length; i++) {
221 const declaration = declarations[i];
222 const { ast, inForLoopInit, inForLoopTest } = declaration;
223 const { init } = ast;
224 const dependencies = this.getDependencies(init);
225 let valueType = null;
226
227 if (inForLoopInit && inForLoopTest) {
228 valueType = 'Integer';
229 } else {
230 if (init) {
231 const realType = this.getType(init);
232 switch (realType) {
233 case 'Integer':
234 case 'Float':
235 case 'Number':
236 if (init.type === 'MemberExpression') {
237 valueType = realType;
238 } else {
239 valueType = 'Number';
240 }
241 break;
242 case 'LiteralInteger':
243 valueType = 'Number';
244 break;
245 default:
246 valueType = realType;
247 }
248 }
249 }
250 declaration.valueType = valueType;
251 declaration.dependencies = dependencies;
252 declaration.isSafe = this.isSafeDependencies(dependencies);
253 }
254
255 for (let i = 0; i < functions.length; i++) {
256 this.onNestedFunction(functions[i], this.source);
257 }
258 }
259
260 getDeclaration(ast) {
261 for (let i = 0; i < this.identifiers.length; i++) {

Callers 4

onNestedFunctionMethod · 0.95
getJsASTMethod · 0.95
runFunction · 0.80
runFunction · 0.80

Calls 4

getDependenciesMethod · 0.95
getTypeMethod · 0.95
isSafeDependenciesMethod · 0.95
onNestedFunctionMethod · 0.65

Tested by

no test coverage detected