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

Method astCallExpression

src/backend/cpu/function-node.js:586–631  ·  view source on GitHub ↗

* @desc Parses the abstract syntax tree for *call* expression * @param {Object} ast - the AST object to parse * @param {Array} retArr - return array string * @returns {Array} the append retArr

(ast, retArr)

Source from the content-addressed store, hash-verified

584 * @returns {Array} the append retArr
585 */
586 astCallExpression(ast, retArr) {
587 if (ast.type !== 'CallExpression') {
588 // Failure, unknown expression
589 throw this.astErrorOutput('Unknown CallExpression', ast);
590 }
591 // Get the full function call, unrolled
592 let functionName = this.astMemberExpressionUnroll(ast.callee);
593
594 // Register the function into the called registry
595 if (this.calledFunctions.indexOf(functionName) < 0) {
596 this.calledFunctions.push(functionName);
597 }
598
599 const isMathFunction = this.isAstMathFunction(ast);
600
601 // track the function was called
602 if (this.onFunctionCall) {
603 this.onFunctionCall(this.name, functionName, ast.arguments);
604 }
605
606 // Call the function
607 retArr.push(functionName);
608
609 // Open arguments space
610 retArr.push('(');
611 const targetTypes = this.lookupFunctionArgumentTypes(functionName) || [];
612 // Add the arguments
613 for (let i = 0; i < ast.arguments.length; ++i) {
614 const argument = ast.arguments[i];
615
616 // in order to track return type, even though this is CPU
617 let argumentType = this.getType(argument);
618 if (!targetTypes[i]) {
619 this.triggerImplyArgumentType(functionName, i, argumentType, this);
620 }
621
622 if (i > 0) {
623 retArr.push(', ');
624 }
625 this.astGeneric(argument, retArr);
626 }
627 // Close arguments space
628 retArr.push(')');
629
630 return retArr;
631 }
632
633 /**
634 * @desc Parses the abstract syntax tree for *Array* Expression

Callers

nothing calls this directly

Calls 8

astErrorOutputMethod · 0.80
isAstMathFunctionMethod · 0.80
onFunctionCallMethod · 0.80
getTypeMethod · 0.80
astGenericMethod · 0.80

Tested by

no test coverage detected