Skip to content

Latest commit

 

History

History
50 lines (32 loc) · 1.53 KB

ConstantValueNode.md

File metadata and controls

50 lines (32 loc) · 1.53 KB

ConstantValueNode

A node that represents a constant value from a TypeNode and a ValueNode.

Attributes

Data

Attribute Type Description
kind "constantValueNode" The node discriminator.

Children

Attribute Type Description
type TypeNode The type of the constant.
value ValueNode The value of the constant.

Functions

constantValueNode(type, value)

Helper function that creates a ConstantValueNode object from a type and a value node

const node = constantValueNode(numberTypeNode('u32'), numberValueNode(42));

constantValueNodeFromString(encoding, data)

Helper function that creates a ConstantValueNode object of type StringTypeNode from an encoding and a string of data.

constantValueNodeFromString('utf8', 'Hello');

// Equivalent to:
constantValueNode(stringTypeNode('utf8'), stringValueNode('Hello'));

constantValueNodeFromBytes(encoding, data)

Helper function that creates a ConstantValueNode object of type BytesTypeNode from an encoding and a string of data.

constantValueNodeFromBytes('base16', 'FF99CC');

// Equivalent to:
constantValueNode(bytesTypeNode(), bytesValueNode('base16', 'FF99CC'));