📄 AtomicFunctionNode.js
¶
📊 Analysis Summary¶
Metric | Count |
---|---|
🔧 Functions | 13 |
🧱 Classes | 1 |
📦 Imports | 3 |
📊 Variables & Constants | 7 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 src/nodes/gpgpu/AtomicFunctionNode.js
📦 Imports¶
Name | Source |
---|---|
Node |
../core/Node.js |
expression |
../code/ExpressionNode.js |
nodeProxy |
../tsl/TSLCore.js |
Variables & Constants¶
Name | Type | Kind | Value | Exported |
---|---|---|---|---|
parents |
any |
let/var | properties.parents |
✗ |
method |
string |
let/var | this.method |
✗ |
a |
Node |
let/var | this.pointerNode |
✗ |
b |
Node |
let/var | this.valueNode |
✗ |
params |
any[] |
let/var | [] |
✗ |
methodSnippet |
string |
let/var | ${ builder.getMethod( method, type ) }( ${ params.join( ', ' ) } ) |
✗ |
isVoid |
boolean |
let/var | parents ? ( parents.length === 1 && parents[ 0 ].isStackNode === true ) : false |
✗ |
Functions¶
AtomicFunctionNode.getInputType(builder: NodeBuilder): string
¶
JSDoc:
/**
* Overwrites the default implementation to return the type of
* the pointer node.
*
* @param {NodeBuilder} builder - The current node builder.
* @return {string} The input type.
*/
Parameters:
builder
NodeBuilder
Returns: string
Calls:
this.pointerNode.getNodeType
AtomicFunctionNode.getNodeType(builder: NodeBuilder): string
¶
JSDoc:
/**
* Overwritten since the node type is inferred from the input type.
*
* @param {NodeBuilder} builder - The current node builder.
* @return {string} The node type.
*/
Parameters:
builder
NodeBuilder
Returns: string
Calls:
this.getInputType
AtomicFunctionNode.generate(builder: any): any
¶
Parameters:
builder
any
Returns: any
Calls:
builder.getNodeProperties
this.getNodeType
this.getInputType
params.push
a.build
b.build
builder.getMethod
params.join
builder.addLineFlowCode
expression( methodSnippet, type ).toConst
properties.constNode.build
Code
generate( builder ) {
const properties = builder.getNodeProperties( this );
const parents = properties.parents;
const method = this.method;
const type = this.getNodeType( builder );
const inputType = this.getInputType( builder );
const a = this.pointerNode;
const b = this.valueNode;
const params = [];
params.push( `&${ a.build( builder, inputType ) }` );
if ( b !== null ) {
params.push( b.build( builder, inputType ) );
}
const methodSnippet = `${ builder.getMethod( method, type ) }( ${ params.join( ', ' ) } )`;
const isVoid = parents ? ( parents.length === 1 && parents[ 0 ].isStackNode === true ) : false;
if ( isVoid ) {
builder.addLineFlowCode( methodSnippet, this );
} else {
if ( properties.constNode === undefined ) {
properties.constNode = expression( methodSnippet, type ).toConst();
}
return properties.constNode.build( builder );
}
}
atomicFunc(method: string, pointerNode: Node, valueNode: Node): AtomicFunctionNode
¶
Parameters:
method
string
pointerNode
Node
valueNode
Node
Returns: AtomicFunctionNode
Calls:
atomicNode( method, pointerNode, valueNode ).toStack
Code
atomicLoad(pointerNode: Node): AtomicFunctionNode
¶
Parameters:
pointerNode
Node
Returns: AtomicFunctionNode
Calls:
atomicFunc
atomicStore(pointerNode: Node, valueNode: Node): AtomicFunctionNode
¶
Parameters:
pointerNode
Node
valueNode
Node
Returns: AtomicFunctionNode
Calls:
atomicFunc
Code
atomicAdd(pointerNode: Node, valueNode: Node): AtomicFunctionNode
¶
Parameters:
pointerNode
Node
valueNode
Node
Returns: AtomicFunctionNode
Calls:
atomicFunc
Code
atomicSub(pointerNode: Node, valueNode: Node): AtomicFunctionNode
¶
Parameters:
pointerNode
Node
valueNode
Node
Returns: AtomicFunctionNode
Calls:
atomicFunc
Code
atomicMax(pointerNode: Node, valueNode: Node): AtomicFunctionNode
¶
Parameters:
pointerNode
Node
valueNode
Node
Returns: AtomicFunctionNode
Calls:
atomicFunc
Code
atomicMin(pointerNode: Node, valueNode: Node): AtomicFunctionNode
¶
Parameters:
pointerNode
Node
valueNode
Node
Returns: AtomicFunctionNode
Calls:
atomicFunc
Code
atomicAnd(pointerNode: Node, valueNode: Node): AtomicFunctionNode
¶
Parameters:
pointerNode
Node
valueNode
Node
Returns: AtomicFunctionNode
Calls:
atomicFunc
Code
atomicOr(pointerNode: Node, valueNode: Node): AtomicFunctionNode
¶
Parameters:
pointerNode
Node
valueNode
Node
Returns: AtomicFunctionNode
Calls:
atomicFunc
Code
atomicXor(pointerNode: Node, valueNode: Node): AtomicFunctionNode
¶
Parameters:
pointerNode
Node
valueNode
Node
Returns: AtomicFunctionNode
Calls:
atomicFunc
Code
Classes¶
AtomicFunctionNode
¶
Class Code
class AtomicFunctionNode extends Node {
static get type() {
return 'AtomicFunctionNode';
}
/**
* Constructs a new atomic function node.
*
* @param {string} method - The signature of the atomic function to construct.
* @param {Node} pointerNode - An atomic variable or element of an atomic buffer.
* @param {Node} valueNode - The value that mutates the atomic variable.
*/
constructor( method, pointerNode, valueNode ) {
super( 'uint' );
/**
* The signature of the atomic function to construct.
*
* @type {string}
*/
this.method = method;
/**
* An atomic variable or element of an atomic buffer.
*
* @type {Node}
*/
this.pointerNode = pointerNode;
/**
* A value that modifies the atomic variable.
*
* @type {Node}
*/
this.valueNode = valueNode;
/**
* Creates a list of the parents for this node for detecting if the node needs to return a value.
*
* @type {boolean}
* @default true
*/
this.parents = true;
}
/**
* Overwrites the default implementation to return the type of
* the pointer node.
*
* @param {NodeBuilder} builder - The current node builder.
* @return {string} The input type.
*/
getInputType( builder ) {
return this.pointerNode.getNodeType( builder );
}
/**
* Overwritten since the node type is inferred from the input type.
*
* @param {NodeBuilder} builder - The current node builder.
* @return {string} The node type.
*/
getNodeType( builder ) {
return this.getInputType( builder );
}
generate( builder ) {
const properties = builder.getNodeProperties( this );
const parents = properties.parents;
const method = this.method;
const type = this.getNodeType( builder );
const inputType = this.getInputType( builder );
const a = this.pointerNode;
const b = this.valueNode;
const params = [];
params.push( `&${ a.build( builder, inputType ) }` );
if ( b !== null ) {
params.push( b.build( builder, inputType ) );
}
const methodSnippet = `${ builder.getMethod( method, type ) }( ${ params.join( ', ' ) } )`;
const isVoid = parents ? ( parents.length === 1 && parents[ 0 ].isStackNode === true ) : false;
if ( isVoid ) {
builder.addLineFlowCode( methodSnippet, this );
} else {
if ( properties.constNode === undefined ) {
properties.constNode = expression( methodSnippet, type ).toConst();
}
return properties.constNode.build( builder );
}
}
}
Methods¶
getInputType(builder: NodeBuilder): string
¶
getNodeType(builder: NodeBuilder): string
¶
generate(builder: any): any
¶
Code
generate( builder ) {
const properties = builder.getNodeProperties( this );
const parents = properties.parents;
const method = this.method;
const type = this.getNodeType( builder );
const inputType = this.getInputType( builder );
const a = this.pointerNode;
const b = this.valueNode;
const params = [];
params.push( `&${ a.build( builder, inputType ) }` );
if ( b !== null ) {
params.push( b.build( builder, inputType ) );
}
const methodSnippet = `${ builder.getMethod( method, type ) }( ${ params.join( ', ' ) } )`;
const isVoid = parents ? ( parents.length === 1 && parents[ 0 ].isStackNode === true ) : false;
if ( isVoid ) {
builder.addLineFlowCode( methodSnippet, this );
} else {
if ( properties.constNode === undefined ) {
properties.constNode = expression( methodSnippet, type ).toConst();
}
return properties.constNode.build( builder );
}
}