mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Derive the eval tail from the intent IR
This commit is contained in:
@@ -1549,12 +1549,12 @@ pub(crate) fn generate_node_impl(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
|
||||
Tail::SpawnAsyncFn
|
||||
} else if future_kernel {
|
||||
Tail::SpawnFuture
|
||||
} else if record.is_some() {
|
||||
Tail::Record
|
||||
} else if flip {
|
||||
Tail::Flip
|
||||
} else {
|
||||
Tail::Forward
|
||||
match ir::node_kind(&node) {
|
||||
ir::NodeKind::RecordIo => Tail::Record,
|
||||
ir::NodeKind::Flip => Tail::Flip,
|
||||
ir::NodeKind::Routing | ir::NodeKind::Opaque => Tail::Forward,
|
||||
}
|
||||
};
|
||||
let lower_tail = |form: Tail| match form {
|
||||
Tail::Forward => lift.clone(),
|
||||
|
||||
@@ -248,14 +248,14 @@ impl ValueBinding {
|
||||
}
|
||||
}
|
||||
|
||||
enum NodeKind {
|
||||
pub(crate) enum NodeKind {
|
||||
Flip,
|
||||
RecordIo,
|
||||
Routing,
|
||||
Opaque,
|
||||
}
|
||||
|
||||
fn node_kind(node: &Node) -> NodeKind {
|
||||
pub(crate) fn node_kind(node: &Node) -> NodeKind {
|
||||
if matches!(node.output.shape.element, Element::Opaque) {
|
||||
NodeKind::Opaque
|
||||
} else if has_attr_io(node) {
|
||||
@@ -604,6 +604,19 @@ mod tests {
|
||||
let model = analyze(&parsed).expect("representative resolves to a class");
|
||||
let raw = matches!(dialect(&parsed), Dialect::Poll);
|
||||
let node = build(&parsed);
|
||||
let expected_kind = match &model.class {
|
||||
Class::RecordIo(_) => "record-io",
|
||||
Class::Flip { .. } => "flip",
|
||||
Class::Routing(_) => "routing",
|
||||
Class::Opaque => "opaque",
|
||||
};
|
||||
let actual_kind = match node_kind(&node) {
|
||||
NodeKind::RecordIo => "record-io",
|
||||
NodeKind::Flip => "flip",
|
||||
NodeKind::Routing => "routing",
|
||||
NodeKind::Opaque => "opaque",
|
||||
};
|
||||
assert_eq!(actual_kind, expected_kind, "node_kind of {}", parsed.fn_name);
|
||||
let fields: Vec<&ParsedField> = parsed.fields.iter().filter(|field| !field.is_data_field).collect();
|
||||
for (index, field) in fields.iter().enumerate() {
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user