MCPcopy Index your code
hub / github.com/processing/p5.js / arrayAccessNode

Function arrayAccessNode

src/strands/ir_builders.js:625–655  ·  view source on GitHub ↗
(strandsContext, bufferNode, indexNode, accessMode)

Source from the content-addressed store, hash-verified

623}
624
625export 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
657export function createStructArrayElementProxy(strandsContext, bufferNode, indexNode, schema) {
658 const { dag, cfg } = strandsContext;

Callers 1

getMethod · 0.90

Calls 2

createStrandsNodeFunction · 0.90
primitiveConstructorNodeFunction · 0.85

Tested by

no test coverage detected