Skip to content

Commit

Permalink
Merge pull request #2 from wraith1995/origin/fix-match
Browse files Browse the repository at this point in the history
Don't use match_type; only use egg_head with egg_args
  • Loading branch information
wraith1995 authored Dec 5, 2022
2 parents 3e6abb6 + 3a8e582 commit f3d5c77
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ pub fn build_node(egraph: &mut EGraph<PythonNode, PythonAnalysis>, expr: &PyAny)
egraph.add(enode)
} else if let Ok(args) = expr.getattr("__match_args__") {
let args = args.downcast::<PyTuple>().unwrap();
let class = if let Ok(class) = expr.getattr("__egg_head__") {
class.downcast::<PyType>().unwrap()
} else {
expr.get_type()
};
let class = expr.get_type();

//let children = args.iter().map(|arg| expr.getattr(arg).unwrap());
let enode = PythonNode::op(class, args.iter().map(|child| build_node(egraph, expr.getattr(child).unwrap())));
egraph.add(enode)
Expand Down Expand Up @@ -65,11 +62,8 @@ pub fn build_pattern(ast: &mut PatternAst<PythonNode>, tree: &PyAny) -> Id {
ast.add(ENodeOrVar::ENode(enode))
} else if let Ok(args) = tree.getattr("__match_args__") {
let args = args.downcast::<PyTuple>().unwrap();
let class = if let Ok(class) = tree.getattr("__egg_head__") {
class.downcast::<PyType>().unwrap()
} else {
tree.get_type()
};
let class = tree.get_type();

//let children = args.iter().map(|arg| tree.getattr(arg).unwrap());
let enode = PythonNode::op(class, args.iter().map(|child| build_pattern(ast, tree.getattr(child).unwrap())));
ast.add(ENodeOrVar::ENode(enode))
Expand Down

0 comments on commit f3d5c77

Please sign in to comment.