Skip to content

Commit f91f70b

Browse files
committed
Remove redundant stuff
1 parent a652a2b commit f91f70b

File tree

4 files changed

+8
-21
lines changed

4 files changed

+8
-21
lines changed

typechecker/src/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{
22
collections::{HashMap, HashSet},
33
path::{Path, PathBuf},
4-
sync::{Arc, RwLockWriteGuard},
4+
sync::Arc,
55
};
66
use tracing::{span, Level};
77
use tracing_subscriber::EnvFilter;

typechecker/src/file.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use parser::{ast, get_row_col_position, parser::parser::Parser};
1111
use std::sync::atomic::Ordering;
1212

1313
use crate::build::ResolvedImports;
14+
use crate::symbol_table;
1415
use crate::{diagnostic::Position, semantic_analyzer::SemanticAnalyzer, symbol_table::SymbolTable};
15-
use crate::{get_module_name, symbol_table};
1616

1717
#[derive(Clone, Debug)]
1818
pub enum ImportKinds<'a> {
@@ -25,7 +25,6 @@ pub enum ImportKinds<'a> {
2525
#[derive(Clone, Debug)]
2626
pub struct EnderpyFile {
2727
pub id: symbol_table::Id,
28-
pub module: String,
2928
// if this source is found by following an import
3029
pub followed: bool,
3130
pub path: Arc<PathBuf>,
@@ -58,7 +57,6 @@ impl<'a> EnderpyFile {
5857
pub fn new(path: PathBuf, followed: bool) -> Self {
5958
let source =
6059
std::fs::read_to_string(&path).unwrap_or_else(|_| panic!("cannot read file {path:?}"));
61-
let module = get_module_name(&path);
6260

6361
let mut parser = Parser::new(&source);
6462
let parse_result = catch_unwind(AssertUnwindSafe(|| parser.parse()));
@@ -71,7 +69,7 @@ impl<'a> EnderpyFile {
7169
panic!("Cannot parse file : {path:?}");
7270
}
7371
};
74-
let line_starts = parser.lexer.line_starts.clone();
72+
let line_starts = parser.lexer.line_starts;
7573

7674
let id = if path.ends_with("builtins.pyi") {
7775
symbol_table::Id(0)
@@ -84,14 +82,10 @@ impl<'a> EnderpyFile {
8482
source,
8583
line_starts,
8684
followed,
87-
module,
8885
tree,
8986
path: Arc::new(path),
9087
}
9188
}
92-
pub fn module_name(&self) -> String {
93-
self.module.clone()
94-
}
9589

9690
pub fn path(&self) -> PathBuf {
9791
self.path.to_path_buf()

typechecker/src/semantic_analyzer.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ impl<'a> SemanticAnalyzer<'a> {
110110
}
111111
}
112112
Expression::Attribute(a) => {
113-
let member_access_info =
114-
get_member_access_info(&self.symbol_table, &self.file, &a.value);
113+
let member_access_info = get_member_access_info(&self.symbol_table, &a.value);
115114
let symbol_flags = if member_access_info.is_some_and(|x| x) {
116115
SymbolFlags::INSTANCE_MEMBER
117116
} else {
@@ -122,13 +121,8 @@ impl<'a> SemanticAnalyzer<'a> {
122121
self.symbol_table.current_scope().kind.as_function()
123122
{
124123
// TODO: some python usual names to be interned
125-
if intern_lookup(function_def.name) == "__init__"
124+
intern_lookup(function_def.name) == "__init__"
126125
|| intern_lookup(function_def.name) == "__new__"
127-
{
128-
true
129-
} else {
130-
false
131-
}
132126
} else {
133127
false
134128
};
@@ -841,7 +835,6 @@ pub struct MemberAccessInfo {}
841835
// or true if the member is an instance member and false if it is a class member
842836
pub fn get_member_access_info(
843837
symbol_table: &SymbolTable,
844-
file: &EnderpyFile,
845838
value: &parser::ast::Expression,
846839
//TODO: This is option to use the `?` operator. Remove it
847840
) -> Option<bool> {

typechecker/src/type_evaluator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ impl<'a> TypeEvaluator<'a> {
327327
// Case 1
328328
// This is self or cls
329329
let file = &self.build_manager.files.get(&symbol_table.id).unwrap();
330-
if get_member_access_info(symbol_table, file, &a.value).is_some() {
330+
if get_member_access_info(symbol_table, &a.value).is_some() {
331331
let enclosing_parent_class = symbol_table.get_enclosing_class_scope();
332332
if let Some(enclosing_parent_class) = enclosing_parent_class {
333333
let symbol_table_node =
@@ -1604,7 +1604,7 @@ impl<'a> TypeEvaluator<'a> {
16041604
) -> PythonType {
16051605
// TODO: handle default values
16061606

1607-
let name = f.function_node.name.clone();
1607+
let name = f.function_node.name;
16081608
let signature =
16091609
self.get_function_signature(&f.function_node.args, symbol_table, arguments_scope_id);
16101610
let return_type =
@@ -1634,7 +1634,7 @@ impl<'a> TypeEvaluator<'a> {
16341634
scope_id: u32,
16351635
) -> PythonType {
16361636
let arguments = f.function_node.args.clone();
1637-
let name = f.function_node.name.clone();
1637+
let name = f.function_node.name;
16381638
let signature = self.get_function_signature(&f.function_node.args, symbol_table, scope_id);
16391639
let return_type = f
16401640
.function_node

0 commit comments

Comments
 (0)