diff options
| author | Eduard Burtescu <edy.burt@gmail.com> | 2014-02-26 16:06:45 +0200 |
|---|---|---|
| committer | Eduard Burtescu <edy.burt@gmail.com> | 2014-02-26 16:06:45 +0200 |
| commit | 05e4d944a9f7db17e759cd4e09fb82357b8cee28 (patch) | |
| tree | ad01af5adf976b29f72956c05de0dc395e45412f /src/libsyntax | |
| parent | 7a588ceff2143198f33a62d27b8cd735cb2b9b82 (diff) | |
| download | rust-05e4d944a9f7db17e759cd4e09fb82357b8cee28.tar.gz rust-05e4d944a9f7db17e759cd4e09fb82357b8cee28.zip | |
Replace callee_id with information stored in method_map.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 23 | ||||
| -rw-r--r-- | src/libsyntax/ast_map.rs | 13 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 23 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 11 |
8 files changed, 33 insertions, 72 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index c095cec1e7d..f6dca713e71 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -521,19 +521,6 @@ pub struct Expr { span: Span, } -impl Expr { - pub fn get_callee_id(&self) -> Option<NodeId> { - match self.node { - ExprMethodCall(callee_id, _, _, _) | - ExprIndex(callee_id, _, _) | - ExprBinary(callee_id, _, _, _) | - ExprAssignOp(callee_id, _, _, _) | - ExprUnary(callee_id, _, _) => Some(callee_id), - _ => None, - } - } -} - #[deriving(Clone, Eq, Encodable, Decodable, Hash)] pub enum Expr_ { ExprVstore(@Expr, ExprVstore), @@ -541,10 +528,10 @@ pub enum Expr_ { ExprBox(@Expr, @Expr), ExprVec(~[@Expr], Mutability), ExprCall(@Expr, ~[@Expr]), - ExprMethodCall(NodeId, Ident, ~[P<Ty>], ~[@Expr]), + ExprMethodCall(Ident, ~[P<Ty>], ~[@Expr]), ExprTup(~[@Expr]), - ExprBinary(NodeId, BinOp, @Expr, @Expr), - ExprUnary(NodeId, UnOp, @Expr), + ExprBinary(BinOp, @Expr, @Expr), + ExprUnary(UnOp, @Expr), ExprLit(@Lit), ExprCast(@Expr, P<Ty>), ExprIf(@Expr, P<Block>, Option<@Expr>), @@ -560,9 +547,9 @@ pub enum Expr_ { ExprBlock(P<Block>), ExprAssign(@Expr, @Expr), - ExprAssignOp(NodeId, BinOp, @Expr, @Expr), + ExprAssignOp(BinOp, @Expr, @Expr), ExprField(@Expr, Ident, ~[P<Ty>]), - ExprIndex(NodeId, @Expr, @Expr), + ExprIndex(@Expr, @Expr), /// Expression that looks like a "name". For example, /// `std::vec::from_elem::<uint>` is an ExprPath that's the "name" part diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 9194cfb0694..31c258b36c0 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -107,7 +107,6 @@ pub enum Node { /// NodeStructCtor represents a tuple struct. NodeStructCtor(@StructDef), - NodeCalleeScope(@Expr), } // The odd layout is to bring down the total size. @@ -128,7 +127,6 @@ enum MapEntry { EntryLocal(NodeId, @Pat), EntryBlock(NodeId, P<Block>), EntryStructCtor(NodeId, @StructDef), - EntryCalleeScope(NodeId, @Expr), // Roots for node trees. RootCrate, @@ -155,7 +153,6 @@ impl MapEntry { EntryLocal(id, _) => id, EntryBlock(id, _) => id, EntryStructCtor(id, _) => id, - EntryCalleeScope(id, _) => id, _ => return None }) } @@ -173,7 +170,6 @@ impl MapEntry { EntryLocal(_, p) => NodeLocal(p), EntryBlock(_, p) => NodeBlock(p), EntryStructCtor(_, p) => NodeStructCtor(p), - EntryCalleeScope(_, p) => NodeCalleeScope(p), _ => return None }) } @@ -368,7 +364,6 @@ impl Map { Some(NodeArg(pat)) | Some(NodeLocal(pat)) => pat.span, Some(NodeBlock(block)) => block.span, Some(NodeStructCtor(_)) => self.expect_item(self.get_parent(id)).span, - Some(NodeCalleeScope(expr)) => expr.span, _ => fail!("node_span: could not find span for id {}", id), } } @@ -493,11 +488,6 @@ impl<'a, F: FoldOps> Folder for Ctx<'a, F> { self.insert(expr.id, EntryExpr(self.parent, expr)); - // Expressions which are or might be calls: - for callee_id in expr.get_callee_id().iter() { - self.insert(*callee_id, EntryCalleeScope(self.parent, expr)); - } - expr } @@ -650,9 +640,6 @@ fn node_id_to_str(map: &Map, id: NodeId) -> ~str { Some(NodeExpr(expr)) => { format!("expr {} (id={})", pprust::expr_to_str(expr), id) } - Some(NodeCalleeScope(expr)) => { - format!("callee_scope {} (id={})", pprust::expr_to_str(expr), id) - } Some(NodeStmt(stmt)) => { format!("stmt {} (id={})", pprust::stmt_to_str(stmt), id) } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index f6066e5385d..f9d7696565a 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -450,12 +450,6 @@ impl<'a, O: IdVisitingOperation> Visitor<()> for IdVisitor<'a, O> { fn visit_expr(&mut self, expression: &Expr, env: ()) { - { - let optional_callee_id = expression.get_callee_id(); - for callee_id in optional_callee_id.iter() { - self.operation.visit_id(*callee_id) - } - } self.operation.visit_id(expression.id); visit::walk_expr(self, expression, env) } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 33cdf4d9add..1ddd579a2f1 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -502,15 +502,14 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn expr_binary(&self, sp: Span, op: ast::BinOp, lhs: @ast::Expr, rhs: @ast::Expr) -> @ast::Expr { - self.expr(sp, ast::ExprBinary(ast::DUMMY_NODE_ID, op, lhs, rhs)) + self.expr(sp, ast::ExprBinary(op, lhs, rhs)) } fn expr_deref(&self, sp: Span, e: @ast::Expr) -> @ast::Expr { self.expr_unary(sp, ast::UnDeref, e) } - fn expr_unary(&self, sp: Span, op: ast::UnOp, e: @ast::Expr) - -> @ast::Expr { - self.expr(sp, ast::ExprUnary(ast::DUMMY_NODE_ID, op, e)) + fn expr_unary(&self, sp: Span, op: ast::UnOp, e: @ast::Expr) -> @ast::Expr { + self.expr(sp, ast::ExprUnary(op, e)) } fn expr_managed(&self, sp: Span, e: @ast::Expr) -> @ast::Expr { @@ -543,7 +542,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { ident: ast::Ident, mut args: ~[@ast::Expr]) -> @ast::Expr { args.unshift(expr); - self.expr(span, ast::ExprMethodCall(ast::DUMMY_NODE_ID, ident, ~[], args)) + self.expr(span, ast::ExprMethodCall(ident, ~[], args)) } fn expr_block(&self, b: P<ast::Block>) -> @ast::Expr { self.expr(b.span, ast::ExprBlock(b)) diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 5f6eb86c3c8..e62abac443e 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -749,21 +749,19 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr { ExprCall(folder.fold_expr(f), args.map(|&x| folder.fold_expr(x))) } - ExprMethodCall(callee_id, i, ref tps, ref args) => { + ExprMethodCall(i, ref tps, ref args) => { ExprMethodCall( - folder.new_id(callee_id), folder.fold_ident(i), tps.map(|&x| folder.fold_ty(x)), args.map(|&x| folder.fold_expr(x))) } - ExprBinary(callee_id, binop, lhs, rhs) => { - ExprBinary(folder.new_id(callee_id), - binop, + ExprBinary(binop, lhs, rhs) => { + ExprBinary(binop, folder.fold_expr(lhs), folder.fold_expr(rhs)) } - ExprUnary(callee_id, binop, ohs) => { - ExprUnary(folder.new_id(callee_id), binop, folder.fold_expr(ohs)) + ExprUnary(binop, ohs) => { + ExprUnary(binop, folder.fold_expr(ohs)) } ExprLit(_) => e.node.clone(), ExprCast(expr, ty) => { @@ -802,9 +800,8 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr { ExprAssign(el, er) => { ExprAssign(folder.fold_expr(el), folder.fold_expr(er)) } - ExprAssignOp(callee_id, op, el, er) => { - ExprAssignOp(folder.new_id(callee_id), - op, + ExprAssignOp(op, el, er) => { + ExprAssignOp(op, folder.fold_expr(el), folder.fold_expr(er)) } @@ -813,10 +810,8 @@ pub fn noop_fold_expr<T: Folder>(e: @Expr, folder: &mut T) -> @Expr { folder.fold_ident(id), tys.map(|&x| folder.fold_ty(x))) } - ExprIndex(callee_id, el, er) => { - ExprIndex(folder.new_id(callee_id), - folder.fold_expr(el), - folder.fold_expr(er)) + ExprIndex(el, er) => { + ExprIndex(folder.fold_expr(el), folder.fold_expr(er)) } ExprPath(ref pth) => ExprPath(folder.fold_path(pth)), ExprLogLevel => ExprLogLevel, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index cbe371a06a5..2fd6d34adf1 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1683,11 +1683,11 @@ impl Parser { } pub fn mk_unary(&mut self, unop: ast::UnOp, expr: @Expr) -> ast::Expr_ { - ExprUnary(ast::DUMMY_NODE_ID, unop, expr) + ExprUnary(unop, expr) } pub fn mk_binary(&mut self, binop: ast::BinOp, lhs: @Expr, rhs: @Expr) -> ast::Expr_ { - ExprBinary(ast::DUMMY_NODE_ID, binop, lhs, rhs) + ExprBinary(binop, lhs, rhs) } pub fn mk_call(&mut self, f: @Expr, args: ~[@Expr]) -> ast::Expr_ { @@ -1695,11 +1695,11 @@ impl Parser { } fn mk_method_call(&mut self, ident: Ident, tps: ~[P<Ty>], args: ~[@Expr]) -> ast::Expr_ { - ExprMethodCall(ast::DUMMY_NODE_ID, ident, tps, args) + ExprMethodCall(ident, tps, args) } pub fn mk_index(&mut self, expr: @Expr, idx: @Expr) -> ast::Expr_ { - ExprIndex(ast::DUMMY_NODE_ID, expr, idx) + ExprIndex(expr, idx) } pub fn mk_field(&mut self, expr: @Expr, ident: Ident, tys: ~[P<Ty>]) -> ast::Expr_ { @@ -1707,7 +1707,7 @@ impl Parser { } pub fn mk_assign_op(&mut self, binop: ast::BinOp, lhs: @Expr, rhs: @Expr) -> ast::Expr_ { - ExprAssignOp(ast::DUMMY_NODE_ID, binop, lhs, rhs) + ExprAssignOp(binop, lhs, rhs) } pub fn mk_mac_expr(&mut self, lo: BytePos, hi: BytePos, m: Mac_) -> @Expr { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 8fb813407d0..688494ec5ee 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1235,7 +1235,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) -> io::IoResult<()> { try!(print_expr(s, func)); try!(print_call_post(s, *args)); } - ast::ExprMethodCall(_, ident, ref tys, ref args) => { + ast::ExprMethodCall(ident, ref tys, ref args) => { let base_args = args.slice_from(1); try!(print_expr(s, args[0])); try!(word(&mut s.s, ".")); @@ -1247,13 +1247,13 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) -> io::IoResult<()> { } try!(print_call_post(s, base_args)); } - ast::ExprBinary(_, op, lhs, rhs) => { + ast::ExprBinary(op, lhs, rhs) => { try!(print_expr(s, lhs)); try!(space(&mut s.s)); try!(word_space(s, ast_util::binop_to_str(op))); try!(print_expr(s, rhs)); } - ast::ExprUnary(_, op, expr) => { + ast::ExprUnary(op, expr) => { try!(word(&mut s.s, ast_util::unop_to_str(op))); try!(print_expr(s, expr)); } @@ -1442,7 +1442,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) -> io::IoResult<()> { try!(word_space(s, "=")); try!(print_expr(s, rhs)); } - ast::ExprAssignOp(_, op, lhs, rhs) => { + ast::ExprAssignOp(op, lhs, rhs) => { try!(print_expr(s, lhs)); try!(space(&mut s.s)); try!(word(&mut s.s, ast_util::binop_to_str(op))); @@ -1459,7 +1459,7 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) -> io::IoResult<()> { try!(word(&mut s.s, ">")); } } - ast::ExprIndex(_, expr, index) => { + ast::ExprIndex(expr, index) => { try!(print_expr(s, expr)); try!(word(&mut s.s, "[")); try!(print_expr(s, index)); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index feab4e0e84d..248ba593c1f 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -658,18 +658,17 @@ pub fn walk_expr<E: Clone, V: Visitor<E>>(visitor: &mut V, expression: &Expr, en } visitor.visit_expr(callee_expression, env.clone()) } - ExprMethodCall(_, _, ref types, ref arguments) => { + ExprMethodCall(_, ref types, ref arguments) => { walk_exprs(visitor, *arguments, env.clone()); for &typ in types.iter() { visitor.visit_ty(typ, env.clone()) } } - ExprBinary(_, _, left_expression, right_expression) => { + ExprBinary(_, left_expression, right_expression) => { visitor.visit_expr(left_expression, env.clone()); visitor.visit_expr(right_expression, env.clone()) } - ExprAddrOf(_, subexpression) | - ExprUnary(_, _, subexpression) => { + ExprAddrOf(_, subexpression) | ExprUnary(_, subexpression) => { visitor.visit_expr(subexpression, env.clone()) } ExprLit(_) => {} @@ -719,7 +718,7 @@ pub fn walk_expr<E: Clone, V: Visitor<E>>(visitor: &mut V, expression: &Expr, en visitor.visit_expr(right_hand_expression, env.clone()); visitor.visit_expr(left_hand_expression, env.clone()) } - ExprAssignOp(_, _, left_expression, right_expression) => { + ExprAssignOp(_, left_expression, right_expression) => { visitor.visit_expr(right_expression, env.clone()); visitor.visit_expr(left_expression, env.clone()) } @@ -729,7 +728,7 @@ pub fn walk_expr<E: Clone, V: Visitor<E>>(visitor: &mut V, expression: &Expr, en visitor.visit_ty(typ, env.clone()) } } - ExprIndex(_, main_expression, index_expression) => { + ExprIndex(main_expression, index_expression) => { visitor.visit_expr(main_expression, env.clone()); visitor.visit_expr(index_expression, env.clone()) } |
