1
Fork 0

hygiene infrastructure.

- added a hash table to memoize rename and mark operations.
- added rename, mark, and resolve fold fns
This commit is contained in:
John Clements 2013-05-16 17:42:08 -07:00
parent b621820dc4
commit fc4f304ef9
5 changed files with 194 additions and 110 deletions

View file

@ -346,21 +346,16 @@ mod test {
use std::serialize::Encodable;
use std;
use core::io;
use core::option::Option;
use core::option::Some;
use core::option::None;
use core::int;
use core::num::NumCast;
use codemap::{CodeMap, span, BytePos, spanned};
use codemap::{span, BytePos, spanned};
use opt_vec;
use ast;
use abi;
use ast_util::mk_ident;
use ast_util::new_ident;
use parse::parser::Parser;
use parse::token::{ident_interner, mk_ident_interner, mk_fresh_ident_interner};
use diagnostic::{span_handler, mk_span_handler, mk_handler, Emitter};
use util::parser_testing::{string_to_tts_and_sess,string_to_parser};
use util::parser_testing::{string_to_crate, string_to_expr, string_to_item};
use util::parser_testing::{string_to_expr, string_to_item};
use util::parser_testing::{string_to_stmt};
// map a string to tts, return the tt without its parsesess
@ -384,7 +379,7 @@ mod test {
// convert a vector of uints to a vector of ast::idents
fn ints_to_idents(ids: ~[uint]) -> ~[ast::ident] {
ids.map(|u| mk_ident(*u))
ids.map(|u| new_ident(*u))
}
#[test] fn path_exprs_1 () {
@ -393,7 +388,7 @@ mod test {
callee_id:2,
node:ast::expr_path(@ast::Path {span:sp(0,1),
global:false,
idents:~[mk_ident(100)],
idents:~[new_ident(100)],
rp:None,
types:~[]}),
span:sp(0,1)})
@ -456,7 +451,7 @@ mod test {
node:ast::expr_path(
@ast::Path{span:sp(7,8),
global:false,
idents:~[mk_ident(103)],
idents:~[new_ident(103)],
rp:None,
types:~[]
}),
@ -474,7 +469,7 @@ mod test {
@ast::Path{
span:sp(0,1),
global:false,
idents:~[mk_ident(101)],
idents:~[new_ident(101)],
rp:None,
types: ~[]}),
span: sp(0,1)},
@ -495,7 +490,7 @@ mod test {
@ast::Path{
span:sp(0,1),
global:false,
idents:~[mk_ident(101)],
idents:~[new_ident(101)],
rp: None,
types: ~[]},
None // no idea
@ -514,7 +509,7 @@ mod test {
span:sp(4,4), // this is bizarre...
// check this in the original parser?
global:false,
idents:~[mk_ident(105)],
idents:~[new_ident(105)],
rp: None,
types: ~[]},
2),
@ -524,7 +519,7 @@ mod test {
@ast::Path{
span:sp(0,1),
global:false,
idents:~[mk_ident(101)],
idents:~[new_ident(101)],
rp: None,
types: ~[]},
None // no idea
@ -540,7 +535,7 @@ mod test {
// assignment order of the node_ids.
assert_eq!(string_to_item(@~"fn a (b : int) { b; }"),
Some(
@ast::item{ident:mk_ident(100),
@ast::item{ident:new_ident(100),
attrs:~[],
id: 10, // fixme
node: ast::item_fn(ast::fn_decl{
@ -550,7 +545,7 @@ mod test {
node: ast::ty_path(@ast::Path{
span:sp(10,13),
global:false,
idents:~[mk_ident(106)],
idents:~[new_ident(106)],
rp: None,
types: ~[]},
2),
@ -561,7 +556,7 @@ mod test {
@ast::Path{
span:sp(6,7),
global:false,
idents:~[mk_ident(101)],
idents:~[new_ident(101)],
rp: None,
types: ~[]},
None // no idea
@ -592,7 +587,7 @@ mod test {
@ast::Path{
span:sp(17,18),
global:false,
idents:~[mk_ident(101)],
idents:~[new_ident(101)],
rp:None,
types: ~[]}),
span: sp(17,18)},