Skip to content

Commit

Permalink
some random changes
Browse files Browse the repository at this point in the history
  • Loading branch information
simvux committed Dec 9, 2024
1 parent f859abd commit 2e564f4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
9 changes: 5 additions & 4 deletions lumina-compiler/src/backend/cranelift/ssa/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, &params);
let inst_values = self.f.builder.inst_results(c).to_vec();
self.cins().return_(&inst_values);
self.cins().return_call(fref, &params);
// let c = self.cins().call(fref, &params);
// 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);
Expand Down
6 changes: 6 additions & 0 deletions luminapath/std/char/lib.lm
Original file line number Diff line number Diff line change
Expand Up @@ -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')
24 changes: 22 additions & 2 deletions luminapath/std/list/lib.lm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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] ->
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2e564f4

Please sign in to comment.