(strandsContext, bufferNode, indexNode, accessMode)
| 623 | } |
| 624 | |
| 625 | export function arrayAccessNode(strandsContext, bufferNode, indexNode, accessMode) { |
| 626 | const { dag, cfg } = strandsContext; |
| 627 | |
| 628 | // Ensure index is a StrandsNode |
| 629 | let index; |
| 630 | if (indexNode instanceof StrandsNode) { |
| 631 | index = indexNode; |
| 632 | } else { |
| 633 | const { id, dimension } = primitiveConstructorNode( |
| 634 | strandsContext, |
| 635 | { baseType: BaseType.INT, dimension: 1 }, |
| 636 | indexNode |
| 637 | ); |
| 638 | index = createStrandsNode(id, dimension, strandsContext); |
| 639 | } |
| 640 | |
| 641 | // Array access returns a single float |
| 642 | const nodeData = DAG.createNodeData({ |
| 643 | nodeType: NodeType.OPERATION, |
| 644 | opCode: OpCode.Binary.ARRAY_ACCESS, |
| 645 | dependsOn: [bufferNode.id, index.id], |
| 646 | dimension: 1, |
| 647 | baseType: BaseType.FLOAT, |
| 648 | accessMode // 'read' or 'read_write' |
| 649 | }); |
| 650 | |
| 651 | const id = DAG.getOrCreateNode(dag, nodeData); |
| 652 | CFG.recordInBasicBlock(cfg, cfg.currentBlock, id); |
| 653 | |
| 654 | return { id, dimension: 1 }; |
| 655 | } |
| 656 | |
| 657 | export function createStructArrayElementProxy(strandsContext, bufferNode, indexNode, schema) { |
| 658 | const { dag, cfg } = strandsContext; |
no test coverage detected