diff --git a/src/compile/modifier.rs b/src/compile/modifier.rs index bb7fa9835..3f7e0c0ea 100644 --- a/src/compile/modifier.rs +++ b/src/compile/modifier.rs @@ -7,7 +7,7 @@ use crate::format::format_words; use super::*; impl Compiler { - fn desugar_operand( + fn desugar_function_pack( &self, modifier: &Sp, operand: Sp, @@ -42,6 +42,29 @@ impl Compiler { } Ok(Some(new)) } + Modifier::Primitive(Primitive::Rows) => { + let mut branches = pack.branches.into_iter(); + let mut new = Modified { + modifier: modifier.clone(), + operands: vec![branches.next().unwrap().map(Word::Func)], + }; + for branch in branches { + let mut lines = branch.value.lines; + (lines.first_mut().unwrap()) + .insert(0, span.clone().sp(Word::Modified(Box::new(new)))); + new = Modified { + modifier: modifier.clone(), + operands: vec![branch.span.clone().sp(Word::Func(Func { + id: FunctionId::Anonymous(branch.span.clone()), + signature: None, + lines, + closed: true, + }))], + }; + } + dbg!(&new); + Ok(Some(new)) + } Modifier::Primitive( Primitive::Fork | Primitive::Bracket | Primitive::Try | Primitive::Fill, ) => { @@ -117,7 +140,7 @@ impl Compiler { // De-sugar function pack if op_count == 1 { let operand = modified.code_operands().next().unwrap().clone(); - if let Some(new) = self.desugar_operand(&modified.modifier, operand)? { + if let Some(new) = self.desugar_function_pack(&modified.modifier, operand)? { return self.modified(new, call); } } @@ -350,7 +373,7 @@ impl Compiler { { let mut m = (**m).clone(); for op in m.operands.iter_mut().filter(|w| w.value.is_code()) { - if let Some(new) = self.desugar_operand(&m.modifier, op.clone())? { + if let Some(new) = self.desugar_function_pack(&m.modifier, op.clone())? { op.value = Word::Modified(new.into()); } op.value = Word::Modified( diff --git a/todo.md b/todo.md index 12bc41f2d..675573e74 100644 --- a/todo.md +++ b/todo.md @@ -1,7 +1,6 @@ # Uiua Todo - 0.12 - - `rows` function pack - Improve `un join` chained with other functions - Show array shape on hover - Unicode literals @@ -15,6 +14,7 @@ - `base` function - `chunks` function? - `pull` function? + - Channels - Plots - Media window - Trace images/audio in pad