(strandsContext, structTypeInfo, rawUserArgs)
| 345 | } |
| 346 | |
| 347 | export function structConstructorNode(strandsContext, structTypeInfo, rawUserArgs) { |
| 348 | const { cfg, dag } = strandsContext; |
| 349 | const { identifer, properties } = structTypeInfo; |
| 350 | |
| 351 | if (!(rawUserArgs.length === properties.length)) { |
| 352 | FES.userError('type error', |
| 353 | `You've tried to construct a ${structTypeInfo.typeName} struct with ${rawUserArgs.length} properties, but it expects ${properties.length} properties.\n` + |
| 354 | `The properties it expects are:\n` + |
| 355 | `${properties.map(prop => prop.name + ' ' + prop.DataType.baseType + prop.DataType.dimension)}` |
| 356 | ); |
| 357 | } |
| 358 | |
| 359 | const dependsOn = []; |
| 360 | for (let i = 0; i < properties.length; i++) { |
| 361 | const expectedProperty = properties[i]; |
| 362 | const { originalNodeID, mappedDependencies } = mapPrimitiveDepsToIDs(strandsContext, expectedProperty.dataType, rawUserArgs[i]); |
| 363 | if (originalNodeID) { |
| 364 | dependsOn.push(originalNodeID); |
| 365 | } |
| 366 | else { |
| 367 | dependsOn.push( |
| 368 | constructTypeFromIDs(strandsContext, expectedProperty.dataType, mappedDependencies) |
| 369 | ); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | const nodeData = DAG.createNodeData({ |
| 374 | nodeType: NodeType.OPERATION, |
| 375 | opCode: OpCode.Nary.CONSTRUCTOR, |
| 376 | dimension: properties.length, |
| 377 | baseType: structTypeInfo.typeName , |
| 378 | dependsOn |
| 379 | }); |
| 380 | const id = DAG.getOrCreateNode(dag, nodeData); |
| 381 | CFG.recordInBasicBlock(cfg, cfg.currentBlock, id); |
| 382 | return { id, dimension: properties.length, components: structTypeInfo.components }; |
| 383 | } |
| 384 | |
| 385 | export function functionCallNode( |
| 386 | strandsContext, |
nothing calls this directly
no test coverage detected