-
Notifications
You must be signed in to change notification settings - Fork 13.4k
move most of front to libsyntax #16240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,9 @@ | |
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use syntax::fold::Folder; | ||
use syntax::{ast, fold, attr}; | ||
use syntax::codemap; | ||
use fold::Folder; | ||
use {ast, fold, attr}; | ||
use codemap; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this can be integrated into parsing and expansion, which would allow us to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, yes, but out of scope |
||
|
||
use std::gc::{Gc, GC}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ use diagnostic::{SpanHandler, mk_span_handler, default_handler, Auto}; | |
use parse::attr::ParserAttr; | ||
use parse::parser::Parser; | ||
|
||
use std::cell::RefCell; | ||
use std::cell::{Cell,RefCell}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't it idiomatic to have a space after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes it is |
||
use std::gc::Gc; | ||
use std::io::File; | ||
use std::rc::Rc; | ||
|
@@ -36,19 +36,38 @@ pub struct ParseSess { | |
pub span_diagnostic: SpanHandler, // better be the same as the one in the reader! | ||
/// Used to determine and report recursive mod inclusions | ||
included_mod_stack: RefCell<Vec<Path>>, | ||
pub node_id: Cell<ast::NodeId>, | ||
} | ||
|
||
pub fn new_parse_sess() -> ParseSess { | ||
ParseSess { | ||
span_diagnostic: mk_span_handler(default_handler(Auto, None), CodeMap::new()), | ||
included_mod_stack: RefCell::new(Vec::new()), | ||
node_id: Cell::new(1), | ||
} | ||
} | ||
|
||
pub fn new_parse_sess_special_handler(sh: SpanHandler) -> ParseSess { | ||
ParseSess { | ||
span_diagnostic: sh, | ||
included_mod_stack: RefCell::new(Vec::new()), | ||
node_id: Cell::new(1), | ||
} | ||
} | ||
|
||
impl ParseSess { | ||
pub fn next_node_id(&self) -> ast::NodeId { | ||
self.reserve_node_ids(1) | ||
} | ||
pub fn reserve_node_ids(&self, count: ast::NodeId) -> ast::NodeId { | ||
let v = self.node_id.get(); | ||
|
||
match v.checked_add(&count) { | ||
Some(next) => { self.node_id.set(next); } | ||
None => fail!("Input too large, ran out of node ids!") | ||
} | ||
|
||
v | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move the functionality of this entire file to
ast_map
, maybeMap::from_crate
?.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea