diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-03-01 19:37:52 -0800 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-03-02 06:47:25 -0800 |
| commit | 6473a87cec100682764f4d926541fc7eb455b00c (patch) | |
| tree | 695fd8037c9ee0b1f932ad4864ed867b05270d55 /src/comp/syntax | |
| parent | def72bda47977b3bc36143eba9692bff12a8303c (diff) | |
restructure to better support method inlining
Diffstat (limited to 'src/comp/syntax')
| -rw-r--r-- | src/comp/syntax/ast.rs | 8 | ||||
| -rw-r--r-- | src/comp/syntax/ast_util.rs | 23 | ||||
| -rw-r--r-- | src/comp/syntax/fold.rs | 1 |
3 files changed, 31 insertions, 1 deletions
diff --git a/src/comp/syntax/ast.rs b/src/comp/syntax/ast.rs index edc5ade4062..eea47191eef 100644 --- a/src/comp/syntax/ast.rs +++ b/src/comp/syntax/ast.rs @@ -534,6 +534,14 @@ enum native_item_ { native_item_fn(fn_decl, [ty_param]), } +// The data we save and restore about an inlined item or method. This is not +// part of the AST that we parse from a file, but it becomes part of the tree +// that we trans. +enum inlined_item { + ii_item(@item), + ii_method(def_id /* impl id */, @method) +} + // // Local Variables: // mode: rust diff --git a/src/comp/syntax/ast_util.rs b/src/comp/syntax/ast_util.rs index 5f303b8c4a8..04bd4236c9b 100644 --- a/src/comp/syntax/ast_util.rs +++ b/src/comp/syntax/ast_util.rs @@ -411,6 +411,29 @@ pure fn class_item_ident(ci: @class_item) -> ident { } } +impl inlined_item_methods for inlined_item { + fn ident() -> ident { + alt self { + ii_item(i) { i.ident } + ii_method(_, m) { m.ident } + } + } + + fn id() -> ast::node_id { + alt self { + ii_item(i) { i.id } + ii_method(_, m) { m.id } + } + } + + fn accept<E>(e: E, v: visit::vt<E>) { + alt self { + ii_item(i) { v.visit_item(i, e, v) } + ii_method(_, m) { visit::visit_method_helper(m, e, v) } + } + } +} + // Local Variables: // mode: rust // fill-column: 78; diff --git a/src/comp/syntax/fold.rs b/src/comp/syntax/fold.rs index 94a0ff6b879..7ceae548769 100644 --- a/src/comp/syntax/fold.rs +++ b/src/comp/syntax/fold.rs @@ -750,7 +750,6 @@ fn make_fold(afp: ast_fold_precursor) -> ast_fold { ret result; } - // // Local Variables: // mode: rust |
