Struct CompilingBlock

Source
pub struct CompilingBlock {
    pub proc_name: String,
    pub x: usize,
    pub y: usize,
    pub width: usize,
    pub height: usize,
    pub block_plug: Option<BlockPlug>,
    pub connect_from: Option<Edge>,
    pub arg_plugs: Vec<ArgPlug>,
    pub args: Vec<Edge>,
}
Expand description

A parsed visual block in the code, including its position, size, and connections.

This is an intermediate representation used during compilation before converting to a Block.

§Example

use trees_lang::compile::{CompilingBlock, ArgPlug, BlockPlug, Orientation,
                            CompileConfig, CharWidthMode, split_code, find_blocks, connect_blocks};

let code = vec![
    "    ".to_owned(),
    "    ┌───────┐".to_owned(),
    "    │ abc   │    ".to_owned(),
    "    └───┬───┘   ".to_owned(),
    "    ┌───┴──┐".to_owned(),
    "    │ def  │    ".to_owned(),
    "    └──────┘   ".to_owned(),
];

let config = CompileConfig {
  char_width: CharWidthMode::Mono
};
let splited_code = split_code(&code, &config);
let mut blocks = find_blocks(&splited_code, &config);
let head_block: CompilingBlock = connect_blocks(&splited_code, &mut blocks, &config).unwrap();

assert_eq!(head_block.proc_name, "abc");
assert_eq!(head_block.arg_plugs.len(), 1);
assert_eq!(head_block.args.len(), 1);

Fields§

§proc_name: String

Procedure name in the block.

§x: usize

X position (column) of the top-left of the block.

§y: usize

Y position (row) of the top-left of the block.

§width: usize

Width of the block.

§height: usize

Height of the block.

§block_plug: Option<BlockPlug>

Optional block plug for connecting this block to others.

§connect_from: Option<Edge>

Edge connecting block-plug of this block to another block.

This is setted by connect_blocks function. Before that, it is empty.

§arg_plugs: Vec<ArgPlug>

Argument plugs for this block.

§args: Vec<Edge>

Edges (connections) representing the arguments passed to this block.

This is setted by connect_blocks function. Before that, it is empty.

Trait Implementations§

Source§

impl Clone for CompilingBlock

Source§

fn clone(&self) -> CompilingBlock

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CompilingBlock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for CompilingBlock

Source§

fn eq(&self, other: &CompilingBlock) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for CompilingBlock

Source§

impl StructuralPartialEq for CompilingBlock

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.