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

Method astMemberExpression

src/backend/web-gl/function-node.js:1041–1312  ·  view source on GitHub ↗

* @desc Parses the abstract syntax tree for *Member* Expression * @param {Object} mNode - An ast Node * @param {Array} retArr - return array string * @returns {Array} the append retArr

(mNode, retArr)

Source from the content-addressed store, hash-verified

1039 * @returns {Array} the append retArr
1040 */
1041 astMemberExpression(mNode, retArr) {
1042 const {
1043 property,
1044 name,
1045 signature,
1046 origin,
1047 type,
1048 xProperty,
1049 yProperty,
1050 zProperty
1051 } = this.getMemberExpressionDetails(mNode);
1052 switch (signature) {
1053 case 'value.thread.value':
1054 case 'this.thread.value':
1055 if (name !== 'x' && name !== 'y' && name !== 'z') {
1056 throw this.astErrorOutput('Unexpected expression, expected `this.thread.x`, `this.thread.y`, or `this.thread.z`', mNode);
1057 }
1058 retArr.push(`threadId.${name}`);
1059 return retArr;
1060 case 'this.output.value':
1061 if (this.dynamicOutput) {
1062 switch (name) {
1063 case 'x':
1064 if (this.isState('casting-to-float')) {
1065 retArr.push('float(uOutputDim.x)');
1066 } else {
1067 retArr.push('uOutputDim.x');
1068 }
1069 break;
1070 case 'y':
1071 if (this.isState('casting-to-float')) {
1072 retArr.push('float(uOutputDim.y)');
1073 } else {
1074 retArr.push('uOutputDim.y');
1075 }
1076 break;
1077 case 'z':
1078 if (this.isState('casting-to-float')) {
1079 retArr.push('float(uOutputDim.z)');
1080 } else {
1081 retArr.push('uOutputDim.z');
1082 }
1083 break;
1084 default:
1085 throw this.astErrorOutput('Unexpected expression', mNode);
1086 }
1087 } else {
1088 switch (name) {
1089 case 'x':
1090 if (this.isState('casting-to-integer')) {
1091 retArr.push(this.output[0]);
1092 } else {
1093 retArr.push(this.output[0], '.0');
1094 }
1095 break;
1096 case 'y':
1097 if (this.isState('casting-to-integer')) {
1098 retArr.push(this.output[1]);

Callers

nothing calls this directly

Calls 9

astCallExpressionMethod · 0.95
astArrayExpressionMethod · 0.95
memberExpressionXYZMethod · 0.95
astErrorOutputMethod · 0.80
astGenericMethod · 0.80
isStateMethod · 0.45

Tested by

no test coverage detected