Skip to content

Commit 2e8d2f2

Browse files
committed
refactor(inference): cleanup.
1 parent ee8cf6a commit 2e8d2f2

File tree

1 file changed

+18
-7
lines changed
  • crates/fuse-inference/src

1 file changed

+18
-7
lines changed

crates/fuse-inference/src/lib.rs

+18-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use std::collections::HashMap;
22

33
use fuse_ast::{
4-
Atom, BindingPatternKind, CallExpression, Chunk, Function, Identifier, VariableDeclaration,
4+
Atom, BinaryOperator, BinaryOperatorKind, BindingPatternKind, CallExpression, Chunk, Function,
5+
Identifier, VariableDeclaration,
56
};
67
use fuse_common::ReferenceType;
78
use fuse_visitor::{
8-
walk_call_expression_mut, walk_function_mut, walk_variable_declaration_mut, ScopeVisitor,
9-
VisitorMut,
9+
walk_binary_operator_mut, walk_call_expression_mut, walk_function_mut,
10+
walk_variable_declaration_mut, ScopeVisitor, VisitorMut,
1011
};
1112

1213
#[derive(Debug, PartialEq, Clone, Copy)]
@@ -30,19 +31,21 @@ impl PartialEq<ReferenceType> for ScopeId {
3031
}
3132
}
3233

33-
struct IdentifierMap(HashMap<Atom, ReferenceType>);
34+
struct IdentifierMap {
35+
map: HashMap<Atom, ReferenceType>,
36+
}
3437

3538
impl IdentifierMap {
3639
fn new() -> Self {
37-
Self(HashMap::new())
40+
Self{ map: HashMap::new() }
3841
}
3942

4043
fn insert(&mut self, atom: Atom, ref_id: ReferenceType) -> Option<ReferenceType> {
41-
self.0.insert(atom, ref_id)
44+
self.map.insert(atom, ref_id)
4245
}
4346

4447
fn get(&self, atom: &Atom) -> Option<ReferenceType> {
45-
self.0.get(atom).map(|r| r.clone())
48+
self.map.get(atom).map(|r| r.clone())
4649
}
4750
}
4851

@@ -185,6 +188,14 @@ impl<'ast> VisitorMut<'ast> for Inference<'ast> {
185188
self.declare_identifier(identifier);
186189
walk_function_mut(self, decl)
187190
}
191+
192+
fn visit_binary_operator_mut(&mut self, op: &'ast mut BinaryOperator) {
193+
match &op.kind {
194+
BinaryOperatorKind::Member(_) => {}
195+
_ => {}
196+
}
197+
walk_binary_operator_mut(self, op)
198+
}
188199
}
189200

190201
impl<'ast> ScopeVisitor for Inference<'ast> {

0 commit comments

Comments
 (0)