Add positional_count field to Lambda
This field is used for static optimization, determining if parameters are purely positional.
This commit is contained in:
@@ -200,10 +200,30 @@ impl Binder {
|
||||
|
||||
let compiled_fn = self.functions.pop().unwrap();
|
||||
|
||||
// 3. Static optimization: check if parameters are purely positional
|
||||
let positional_count = match ¶ms_bound.kind {
|
||||
BoundKind::Tuple { elements } => {
|
||||
let mut count = 0;
|
||||
let mut all_params = true;
|
||||
for e in elements {
|
||||
if matches!(e.kind, BoundKind::Parameter { .. }) {
|
||||
count += 1;
|
||||
} else {
|
||||
all_params = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if all_params { Some(count) } else { None }
|
||||
}
|
||||
BoundKind::Parameter { .. } => Some(1),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
Ok(self.make_node(identity, BoundKind::Lambda {
|
||||
params: Box::new(params_bound),
|
||||
params: Rc::new(params_bound),
|
||||
upvalues: compiled_fn.upvalues,
|
||||
body: Rc::new(body_bound),
|
||||
positional_count,
|
||||
}))
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user