Add a little code to resolve, to check that the fold interface works.
This commit is contained in:
parent
facc5f8826
commit
785d9b1594
@ -143,7 +143,7 @@ type ast_fold[ENV] =
|
||||
|
||||
// FIXME: Finish these.
|
||||
|
||||
fn fold_name[ENV](&ENV env, ast_fold[ENV] fld, &name n,
|
||||
fn fold_expr_name[ENV](&ENV env, ast_fold[ENV] fld, &name n,
|
||||
&option[referent] r) -> tup(name,option[referent]) {
|
||||
ret tup(n,r);
|
||||
}
|
||||
@ -214,7 +214,7 @@ fn fold_expr[ENV](&ENV env, ast_fold[ENV] fld, &@expr e) -> @expr {
|
||||
}
|
||||
|
||||
case (ast.expr_name(?n, ?r)) {
|
||||
auto nn = fold_name(env_, fld, n, r);
|
||||
auto nn = fold_expr_name(env_, fld, n, r);
|
||||
ret fld.fold_expr_name(env_, e.span, nn._0, nn._1);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,28 @@
|
||||
import front.ast;
|
||||
import driver.session;
|
||||
import util.common.span;
|
||||
|
||||
fn resolve_crate(session.session sess, ast.crate crate) -> ast.crate {
|
||||
ret crate;
|
||||
}
|
||||
type env = ();
|
||||
|
||||
fn resolve_name(&env e, &span sp, ast.name_ n) -> ast.name {
|
||||
auto s = "resolving name: ";
|
||||
s += n.ident;
|
||||
log s;
|
||||
ret fold.respan[ast.name_](sp, n);
|
||||
}
|
||||
|
||||
fn resolve_crate(session.session sess, @ast.crate crate) -> @ast.crate {
|
||||
let fold.ast_fold[env] fld = fold.new_identity_fold[env]();
|
||||
fld = @rec( fold_name = bind resolve_name(_,_,_)
|
||||
with *fld );
|
||||
ret fold.fold_crate[env]((), fld, crate);
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
// mode: rust
|
||||
// fill-column: 78;
|
||||
// indent-tabs-mode: nil
|
||||
// c-basic-offset: 4
|
||||
// buffer-file-coding-system: utf-8-unix
|
||||
// compile-command: "make -k -C ../.. 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
||||
// End:
|
||||
|
Loading…
x
Reference in New Issue
Block a user