Skip to main content

boa_engine/vm/flowgraph/
node.rs

1use crate::vm::flowgraph::Color;
2
3/// Represents the shape of a node in the flowgraph.
4#[derive(Debug, Clone, Copy)]
5pub enum NodeShape {
6    /// Represents the default shape used in the graph.
7    None,
8    /// Represents a rectangular node shape.
9    Record,
10    /// Represents a diamond node shape.
11    Diamond,
12}
13
14/// This represents a node in the flowgraph.
15#[derive(Debug, Clone)]
16pub struct Node {
17    /// The opcode location.
18    pub(super) location: usize,
19    /// The shape of the opcode.
20    pub(super) shape: NodeShape,
21    /// The label/contents of the node.
22    pub(super) label: Box<str>,
23    /// The background color of the node.
24    pub(super) color: Color,
25}
26
27impl Node {
28    /// Construct a new node.
29    pub(super) fn new(location: usize, shape: NodeShape, label: Box<str>, color: Color) -> Self {
30        Self {
31            location,
32            shape,
33            label,
34            color,
35        }
36    }
37}