mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Decision tree compilation of list patterns
This commit is contained in:
parent
da1d937277
commit
ae71c7efe2
7 changed files with 479 additions and 38 deletions
|
@ -6,6 +6,7 @@ use crate::num::{
|
|||
ParsedNumResult,
|
||||
};
|
||||
use crate::scope::{PendingAbilitiesInScope, Scope};
|
||||
use roc_exhaustive::ListArity;
|
||||
use roc_module::ident::{Ident, Lowercase, TagName};
|
||||
use roc_module::symbol::Symbol;
|
||||
use roc_parse::ast::{self, StrLiteral, StrSegment};
|
||||
|
@ -189,6 +190,17 @@ impl ListPatterns {
|
|||
fn surely_exhaustive(&self) -> bool {
|
||||
self.patterns.is_empty() && matches!(self.opt_rest, Some(0))
|
||||
}
|
||||
|
||||
pub fn arity(&self) -> ListArity {
|
||||
match self.opt_rest {
|
||||
Some(i) => {
|
||||
let before = i;
|
||||
let after = self.patterns.len() - before;
|
||||
ListArity::Slice(before, after)
|
||||
}
|
||||
None => ListArity::Exact(self.patterns.len()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue