Skip to content

Commit dfabd4a

Browse files
authored
Merge pull request RustPython#1093 from RustPython/getrow
Change get_row() into row()
2 parents fbd0c59 + f816a50 commit dfabd4a

File tree

8 files changed

+17
-26
lines changed

8 files changed

+17
-26
lines changed

bytecode/src/bytecode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ impl Location {
2020
Location { row, column }
2121
}
2222

23-
pub fn get_row(&self) -> usize {
23+
pub fn row(&self) -> usize {
2424
self.row
2525
}
2626

27-
pub fn get_column(&self) -> usize {
27+
pub fn column(&self) -> usize {
2828
self.column
2929
}
3030
}

compiler/src/compile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,7 @@ impl Compiler {
18031803
}
18041804

18051805
fn get_source_line_number(&mut self) -> usize {
1806-
self.current_source_location.get_row()
1806+
self.current_source_location.row()
18071807
}
18081808

18091809
fn create_qualified_name(&self, name: &str, suffix: &str) -> String {
@@ -1835,7 +1835,7 @@ fn get_doc(body: &[ast::LocatedStatement]) -> (&[ast::LocatedStatement], Option<
18351835
}
18361836

18371837
fn compile_location(location: &ast::Location) -> bytecode::Location {
1838-
bytecode::Location::new(location.get_row(), location.get_column())
1838+
bytecode::Location::new(location.row(), location.column())
18391839
}
18401840

18411841
fn compile_varargs(varargs: &ast::Varargs) -> bytecode::Varargs {

compiler/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl fmt::Display for CompileError {
5656
}?;
5757

5858
// Print line number:
59-
write!(f, " at line {:?}", self.location.get_row())
59+
write!(f, " at line {:?}", self.location.row())
6060
}
6161
}
6262

parser/src/lexer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ impl Location {
8585
Location { row, column }
8686
}
8787

88-
pub fn get_row(&self) -> usize {
88+
pub fn row(&self) -> usize {
8989
self.row
9090
}
9191

92-
pub fn get_column(&self) -> usize {
92+
pub fn column(&self) -> usize {
9393
self.column
9494
}
9595
}

vm/src/frame.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ impl Frame {
298298
trace!("Adding to traceback: {:?} {:?}", traceback, lineno);
299299
let raise_location = vm.ctx.new_tuple(vec![
300300
vm.ctx.new_str(filename.clone()),
301-
vm.ctx.new_int(lineno.get_row()),
301+
vm.ctx.new_int(lineno.row()),
302302
vm.ctx.new_str(run_obj_name.clone()),
303303
]);
304304
objlist::PyListRef::try_from_object(vm, traceback)?.append(raise_location, vm);

vm/src/stdlib/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ fn statement_to_ast(
205205
}?;
206206

207207
// set lineno on node:
208-
let lineno = vm.ctx.new_int(statement.location.get_row());
208+
let lineno = vm.ctx.new_int(statement.location.row());
209209
vm.set_attr(node.as_object(), "lineno", lineno).unwrap();
210210

211211
Ok(node)

vm/src/vm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ impl VirtualMachine {
252252
pub fn new_syntax_error(&self, error: &CompileError) -> PyObjectRef {
253253
let syntax_error_type = self.ctx.exceptions.syntax_error.clone();
254254
let syntax_error = self.new_exception(syntax_error_type, error.to_string());
255-
let lineno = self.new_int(error.location.get_row());
255+
let lineno = self.new_int(error.location.row());
256256
self.set_attr(&syntax_error, "lineno", lineno).unwrap();
257257
syntax_error
258258
}

wasm/lib/src/vm_class.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -289,29 +289,20 @@ impl WASMVirtualMachine {
289289
| ParseError::InvalidToken(ref loc)
290290
| ParseError::UnrecognizedToken((ref loc, ..), _) = parse_error
291291
{
292-
let _ = Reflect::set(
293-
&js_err,
294-
&"row".into(),
295-
&(loc.get_row() as u32).into(),
296-
);
297-
let _ = Reflect::set(
298-
&js_err,
299-
&"col".into(),
300-
&(loc.get_column() as u32).into(),
301-
);
292+
let _ =
293+
Reflect::set(&js_err, &"row".into(), &(loc.row() as u32).into());
294+
let _ =
295+
Reflect::set(&js_err, &"col".into(), &(loc.column() as u32).into());
302296
}
303297
if let ParseError::ExtraToken((_, _, ref loc))
304298
| ParseError::UnrecognizedToken((_, _, ref loc), _) = parse_error
305299
{
306-
let _ = Reflect::set(
307-
&js_err,
308-
&"endrow".into(),
309-
&(loc.get_row() as u32).into(),
310-
);
300+
let _ =
301+
Reflect::set(&js_err, &"endrow".into(), &(loc.row() as u32).into());
311302
let _ = Reflect::set(
312303
&js_err,
313304
&"endcol".into(),
314-
&(loc.get_column() as u32).into(),
305+
&(loc.column() as u32).into(),
315306
);
316307
}
317308
}

0 commit comments

Comments
 (0)