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
impl Clone for CompilingBlock
Source§fn clone(&self) -> CompilingBlock
fn clone(&self) -> CompilingBlock
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CompilingBlock
impl Debug for CompilingBlock
Source§impl PartialEq for CompilingBlock
impl PartialEq for CompilingBlock
impl Eq for CompilingBlock
impl StructuralPartialEq for CompilingBlock
Auto Trait Implementations§
impl Freeze for CompilingBlock
impl RefUnwindSafe for CompilingBlock
impl Send for CompilingBlock
impl Sync for CompilingBlock
impl Unpin for CompilingBlock
impl UnwindSafe for CompilingBlock
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more