diff --git a/lumina-compiler/src/backend/cranelift/ssa/call.rs b/lumina-compiler/src/backend/cranelift/ssa/call.rs index 4e35163..a1e8d34 100644 --- a/lumina-compiler/src/backend/cranelift/ssa/call.rs +++ b/lumina-compiler/src/backend/cranelift/ssa/call.rs @@ -164,11 +164,12 @@ impl<'c, 'a, 'f> Translator<'c, 'a, 'f> { self.has_references_to_current_stack(&self.ctx.flayouts[id].params.as_slice()); if uses_current_stack { - self.fparams_from_funcid(false, id, cparams, &mut params); + self.fparams_from_funcid(true, id, cparams, &mut params); let fref = self.ins().declare_func_in_func(id); - let c = self.cins().call(fref, ¶ms); - let inst_values = self.f.builder.inst_results(c).to_vec(); - self.cins().return_(&inst_values); + self.cins().return_call(fref, ¶ms); + // let c = self.cins().call(fref, ¶ms); + // let inst_values = self.f.builder.inst_results(c).to_vec(); + // // self.cins().return_(&inst_values); } else { self.fparams_from_funcid(false, id, cparams, &mut params); let fref = self.ins().declare_func_in_func(id); diff --git a/luminapath/std/char/lib.lm b/luminapath/std/char/lib.lm index cf73321..2eb7fca 100644 --- a/luminapath/std/char/lib.lm +++ b/luminapath/std/char/lib.lm @@ -8,3 +8,9 @@ pub fn is_upper_letter c as u8 -> bool = pub fn is_number c as u8 -> bool = c >= '0' && c <= '9' + +pub fn to_digit c as u8 -> uint = + (c as uint) - ('0' as uint) + +pub fn from_digit c as uint -> u8 = + ((c as u8) + '0') diff --git a/luminapath/std/list/lib.lm b/luminapath/std/list/lib.lm index 997b267..2b46b1b 100644 --- a/luminapath/std/list/lib.lm +++ b/luminapath/std/list/lib.lm @@ -37,8 +37,8 @@ impl Listable a for List a | Nil -> Nothing | Concat left right -> - split left - . map #(\(v, leftright) -> (v, leftright ++ right)) + split left + . map #(\(v, leftright) -> (v, leftright ++ right)) pub fn ++ left right as List a, List a -> [a] = match left @@ -60,6 +60,21 @@ pub fn map f list as fn(a -> b), [a] -> [b] = | [x : xs] -> f x : map #f xs | [] -> [] +pub fn flat_map f list as fn(a -> [b]), [a] -> [b] = + match list + | [x : xs] -> f x ++ flat_map #f xs + | [] -> [] + +// TODO: we should split out equality operator from Compare, then we can use a constraint here instead +pub fn deduplicate f list as fn(a, a -> bool), [a] -> [a] = + match list + | [x : xs] -> + let next = deduplicate #f xs in + if any #(\a -> f x a) next + then next + else x : next + | [] -> [] + pub fn keep_map f list as fn(a -> Maybe b), [a] -> [b] = match list | [x : xs] -> @@ -134,6 +149,11 @@ pub fn count f list as fn(a -> bool), List a -> uint = pub fn from_range range f as (uint, uint), fn(uint -> a) -> List a = Slice (vec:to_slice (vec:from_range range #f)) +pub fn reverse list as [a] -> [a] = + match list + | [x : xs] -> reverse xs ++ [x] + | [] -> [] + pub fn itimes f n as fn(uint -> ()), uint -> () = next 0 where