diff --git a/src/code_generation/mod.rs b/src/flattening.rs similarity index 99% rename from src/code_generation/mod.rs rename to src/flattening.rs index 5939146..ff55f77 100644 --- a/src/code_generation/mod.rs +++ b/src/flattening.rs @@ -8,12 +8,14 @@ use crate::{ +#[derive(Debug)] struct LocalVariable { pub location : Span, pub typ : Option } // These are assignable connections +#[derive(Debug)] enum ConnectionRead { Local(usize), ArrayIdx{arr_local : usize, idx_local : usize}, @@ -21,6 +23,7 @@ enum ConnectionRead { FuncOutput{instantiation_idx : usize, field : usize}, Constant(Value) } +#[derive(Debug)] enum ConnectionWrite { Local(usize), ArrayIdx(Box<(ConnectionWrite, usize)>), @@ -30,12 +33,14 @@ enum ConnectionWrite { type SpanConnectionRead = (ConnectionRead, Span); +#[derive(Debug)] enum Instantiation { Named(ValueUUID), UnaryOp(Operator), BinaryOp(Operator) } +#[derive(Debug)] struct Connection { num_regs : u32, from : SpanConnectionRead, @@ -253,6 +258,7 @@ pub fn flatten(module : &Module, linker : &Linker, errors : &mut ErrorCollector) FlattenedModule { locals: result.locals, instantiations: result.instantiations, connections: result.connections } } +#[derive(Debug)] pub struct FlattenedModule { locals : Vec, instantiations : Vec, diff --git a/src/linker.rs b/src/linker.rs index 4a8ae70..672b4c7 100644 --- a/src/linker.rs +++ b/src/linker.rs @@ -1,6 +1,6 @@ use std::{collections::{HashMap, HashSet}, ops::{IndexMut, Index}}; -use crate::{ast::{Module, LinkInfo, Span, Value, GlobalReference}, arena_alloc::{ArenaAllocator, UUID}, parser::{FullParseResult, TokenTreeNode}, tokenizer::Token, errors::{ErrorCollector, error_info}, code_generation::flatten}; +use crate::{ast::{Module, LinkInfo, Span, Value, GlobalReference}, arena_alloc::{ArenaAllocator, UUID}, parser::{FullParseResult, TokenTreeNode}, tokenizer::Token, errors::{ErrorCollector, error_info}, flattening::flatten}; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct NamedUUIDMarker; @@ -493,8 +493,8 @@ impl Linker { if !md.link_info.is_fully_linked { continue; } - let _flt = flatten(md, &self, errors); - // TODO use + let flt = flatten(md, &self, errors); + println!("{:?}", flt); } } } diff --git a/src/main.rs b/src/main.rs index e949208..494ea29 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ mod tokenizer; mod parser; mod errors; mod ast; -mod code_generation; +mod flattening; mod arena_alloc; mod dev_aid;