2012-12-03 16:48:01 -08:00
|
|
|
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
2012-07-05 16:07:53 -07:00
|
|
|
// Functions for building ASTs, without having to fuss with spans.
|
|
|
|
|
//
|
|
|
|
|
// To start with, it will be use dummy spans, but it might someday do
|
|
|
|
|
// something smarter.
|
|
|
|
|
|
2013-01-08 19:37:25 -08:00
|
|
|
use core::prelude::*;
|
|
|
|
|
|
2012-09-04 11:37:29 -07:00
|
|
|
use ast::{ident, node_id};
|
2012-12-23 17:41:37 -05:00
|
|
|
use ast;
|
2012-11-12 19:32:48 -08:00
|
|
|
use ast_util::{ident_to_path, respan, dummy_sp};
|
2012-12-23 17:41:37 -05:00
|
|
|
use ast_util;
|
|
|
|
|
use attr;
|
2012-09-04 11:37:29 -07:00
|
|
|
use codemap::span;
|
2013-01-08 19:37:25 -08:00
|
|
|
use ext::base::{ext_ctxt, mk_ctxt};
|
2012-12-13 13:05:22 -08:00
|
|
|
use ext::quote::rt::*;
|
2012-07-05 16:07:53 -07:00
|
|
|
|
2012-12-23 17:41:37 -05:00
|
|
|
use core::vec;
|
|
|
|
|
|
2012-07-23 18:50:53 -07:00
|
|
|
// Transitional reexports so qquote can find the paths it is looking for
|
|
|
|
|
mod syntax {
|
2012-09-21 18:10:45 -07:00
|
|
|
#[legacy_exports];
|
2012-09-07 18:08:21 -07:00
|
|
|
pub use ext;
|
|
|
|
|
pub use parse;
|
2012-07-23 18:50:53 -07:00
|
|
|
}
|
|
|
|
|
|
2012-07-18 16:18:02 -07:00
|
|
|
fn path(ids: ~[ident], span: span) -> @ast::path {
|
2012-07-24 16:58:48 -07:00
|
|
|
@{span: span,
|
2012-07-05 16:07:53 -07:00
|
|
|
global: false,
|
2012-07-18 16:18:02 -07:00
|
|
|
idents: ids,
|
2012-08-20 12:23:37 -07:00
|
|
|
rp: None,
|
2012-07-05 16:07:53 -07:00
|
|
|
types: ~[]}
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-23 17:41:37 -05:00
|
|
|
fn path_global(ids: ~[ident], span: span) -> @ast::path {
|
|
|
|
|
@{span: span,
|
|
|
|
|
global: true,
|
|
|
|
|
idents: ids,
|
|
|
|
|
rp: None,
|
|
|
|
|
types: ~[]}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-11 15:00:40 -07:00
|
|
|
trait append_types {
|
2012-10-15 14:56:42 -07:00
|
|
|
fn add_ty(ty: @ast::Ty) -> @ast::path;
|
|
|
|
|
fn add_tys(+tys: ~[@ast::Ty]) -> @ast::path;
|
2012-07-11 15:00:40 -07:00
|
|
|
}
|
2012-07-05 16:07:53 -07:00
|
|
|
|
2012-08-07 18:10:06 -07:00
|
|
|
impl @ast::path: append_types {
|
2012-10-15 14:56:42 -07:00
|
|
|
fn add_ty(ty: @ast::Ty) -> @ast::path {
|
2012-09-04 13:29:32 -07:00
|
|
|
@{types: vec::append_one(self.types, ty),
|
|
|
|
|
.. *self}
|
2012-07-05 16:07:53 -07:00
|
|
|
}
|
|
|
|
|
|
2012-10-15 14:56:42 -07:00
|
|
|
fn add_tys(+tys: ~[@ast::Ty]) -> @ast::path {
|
2012-09-04 13:29:32 -07:00
|
|
|
@{types: vec::append(self.types, tys),
|
|
|
|
|
.. *self}
|
2012-07-05 16:07:53 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-11 15:00:40 -07:00
|
|
|
trait ext_ctxt_ast_builder {
|
|
|
|
|
fn ty_param(id: ast::ident, +bounds: ~[ast::ty_param_bound])
|
|
|
|
|
-> ast::ty_param;
|
2012-10-15 14:56:42 -07:00
|
|
|
fn arg(name: ident, ty: @ast::Ty) -> ast::arg;
|
2012-07-11 15:00:40 -07:00
|
|
|
fn expr_block(e: @ast::expr) -> ast::blk;
|
2012-10-15 14:56:42 -07:00
|
|
|
fn fn_decl(+inputs: ~[ast::arg], output: @ast::Ty) -> ast::fn_decl;
|
2012-08-17 11:26:35 -07:00
|
|
|
fn item(name: ident, span: span, +node: ast::item_) -> @ast::item;
|
2012-07-11 15:00:40 -07:00
|
|
|
fn item_fn_poly(name: ident,
|
|
|
|
|
+inputs: ~[ast::arg],
|
2012-10-15 14:56:42 -07:00
|
|
|
output: @ast::Ty,
|
2012-07-11 15:00:40 -07:00
|
|
|
+ty_params: ~[ast::ty_param],
|
|
|
|
|
+body: ast::blk) -> @ast::item;
|
|
|
|
|
fn item_fn(name: ident,
|
|
|
|
|
+inputs: ~[ast::arg],
|
2012-10-15 14:56:42 -07:00
|
|
|
output: @ast::Ty,
|
2012-07-11 15:00:40 -07:00
|
|
|
+body: ast::blk) -> @ast::item;
|
|
|
|
|
fn item_enum_poly(name: ident,
|
2012-08-17 11:26:35 -07:00
|
|
|
span: span,
|
2012-08-08 17:14:25 -07:00
|
|
|
+enum_definition: ast::enum_def,
|
2012-07-11 15:00:40 -07:00
|
|
|
+ty_params: ~[ast::ty_param]) -> @ast::item;
|
2012-08-17 11:47:01 -07:00
|
|
|
fn item_enum(name: ident, span: span,
|
2012-08-17 11:26:35 -07:00
|
|
|
+enum_definition: ast::enum_def) -> @ast::item;
|
2012-10-15 14:56:42 -07:00
|
|
|
fn variant(name: ident, span: span, +tys: ~[@ast::Ty]) -> ast::variant;
|
2012-08-17 11:26:35 -07:00
|
|
|
fn item_mod(name: ident, span: span, +items: ~[@ast::item]) -> @ast::item;
|
2012-10-15 14:56:42 -07:00
|
|
|
fn ty_path_ast_builder(path: @ast::path) -> @ast::Ty;
|
2012-07-11 15:00:40 -07:00
|
|
|
fn item_ty_poly(name: ident,
|
2012-08-17 11:26:35 -07:00
|
|
|
span: span,
|
2012-10-15 14:56:42 -07:00
|
|
|
ty: @ast::Ty,
|
2012-07-11 15:00:40 -07:00
|
|
|
+params: ~[ast::ty_param]) -> @ast::item;
|
2012-10-15 14:56:42 -07:00
|
|
|
fn item_ty(name: ident, span: span, ty: @ast::Ty) -> @ast::item;
|
|
|
|
|
fn ty_vars(+ty_params: ~[ast::ty_param]) -> ~[@ast::Ty];
|
2012-12-23 17:41:37 -05:00
|
|
|
fn ty_vars_global(+ty_params: ~[ast::ty_param]) -> ~[@ast::Ty];
|
2012-10-15 14:56:42 -07:00
|
|
|
fn ty_field_imm(name: ident, ty: @ast::Ty) -> ast::ty_field;
|
|
|
|
|
fn ty_rec(+v: ~[ast::ty_field]) -> @ast::Ty;
|
2012-07-23 18:50:53 -07:00
|
|
|
fn field_imm(name: ident, e: @ast::expr) -> ast::field;
|
2012-09-23 04:39:27 -07:00
|
|
|
fn rec(+v: ~[ast::field]) -> @ast::expr;
|
2012-07-23 18:50:53 -07:00
|
|
|
fn block(+stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk;
|
|
|
|
|
fn stmt_let(ident: ident, e: @ast::expr) -> @ast::stmt;
|
|
|
|
|
fn stmt_expr(e: @ast::expr) -> @ast::stmt;
|
|
|
|
|
fn block_expr(b: ast::blk) -> @ast::expr;
|
2012-11-29 18:37:33 -08:00
|
|
|
fn move_expr(e: @ast::expr) -> @ast::expr;
|
2012-10-15 14:56:42 -07:00
|
|
|
fn ty_option(ty: @ast::Ty) -> @ast::Ty;
|
2012-11-29 18:37:33 -08:00
|
|
|
fn ty_infer() -> @ast::Ty;
|
|
|
|
|
fn ty_nil_ast_builder() -> @ast::Ty;
|
2012-07-11 15:00:40 -07:00
|
|
|
}
|
|
|
|
|
|
2012-08-07 18:10:06 -07:00
|
|
|
impl ext_ctxt: ext_ctxt_ast_builder {
|
2012-10-15 14:56:42 -07:00
|
|
|
fn ty_option(ty: @ast::Ty) -> @ast::Ty {
|
2013-01-08 19:37:25 -08:00
|
|
|
self.ty_path_ast_builder(path_global(~[
|
|
|
|
|
self.ident_of(~"core"),
|
|
|
|
|
self.ident_of(~"option"),
|
|
|
|
|
self.ident_of(~"Option")
|
|
|
|
|
], dummy_sp()).add_ty(ty))
|
2012-08-07 11:46:52 -07:00
|
|
|
}
|
|
|
|
|
|
2012-07-23 18:50:53 -07:00
|
|
|
fn block_expr(b: ast::blk) -> @ast::expr {
|
|
|
|
|
@{id: self.next_id(),
|
|
|
|
|
callee_id: self.next_id(),
|
|
|
|
|
node: ast::expr_block(b),
|
2012-11-12 19:32:48 -08:00
|
|
|
span: dummy_sp()}
|
2012-07-23 18:50:53 -07:00
|
|
|
}
|
|
|
|
|
|
2012-10-23 11:16:31 -07:00
|
|
|
fn move_expr(e: @ast::expr) -> @ast::expr {
|
|
|
|
|
@{id: self.next_id(),
|
|
|
|
|
callee_id: self.next_id(),
|
|
|
|
|
node: ast::expr_unary_move(e),
|
|
|
|
|
span: e.span}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-23 18:50:53 -07:00
|
|
|
fn stmt_expr(e: @ast::expr) -> @ast::stmt {
|
2012-12-27 14:36:00 -05:00
|
|
|
@spanned { node: ast::stmt_expr(e, self.next_id()),
|
|
|
|
|
span: dummy_sp()}
|
2012-07-23 18:50:53 -07:00
|
|
|
}
|
|
|
|
|
|
2012-12-06 16:19:50 -08:00
|
|
|
fn stmt_let(ident: ident, e: @ast::expr) -> @ast::stmt {
|
|
|
|
|
let ext_cx = self;
|
|
|
|
|
quote_stmt!( let $ident = $e; )
|
2012-07-23 18:50:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn field_imm(name: ident, e: @ast::expr) -> ast::field {
|
2012-12-27 14:36:00 -05:00
|
|
|
spanned { node: { mutbl: ast::m_imm, ident: name, expr: e },
|
|
|
|
|
span: dummy_sp()}
|
2012-07-23 18:50:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn rec(+fields: ~[ast::field]) -> @ast::expr {
|
|
|
|
|
@{id: self.next_id(),
|
|
|
|
|
callee_id: self.next_id(),
|
2012-08-20 12:23:37 -07:00
|
|
|
node: ast::expr_rec(fields, None),
|
2012-11-12 19:32:48 -08:00
|
|
|
span: dummy_sp()}
|
2012-07-23 18:50:53 -07:00
|
|
|
}
|
|
|
|
|
|
2012-10-15 14:56:42 -07:00
|
|
|
fn ty_field_imm(name: ident, ty: @ast::Ty) -> ast::ty_field {
|
2012-12-27 14:36:00 -05:00
|
|
|
spanned { node: { ident: name, mt: { ty: ty, mutbl: ast::m_imm } },
|
|
|
|
|
span: dummy_sp() }
|
2012-07-23 14:46:39 -07:00
|
|
|
}
|
|
|
|
|
|
2012-10-15 14:56:42 -07:00
|
|
|
fn ty_rec(+fields: ~[ast::ty_field]) -> @ast::Ty {
|
2012-07-23 14:46:39 -07:00
|
|
|
@{id: self.next_id(),
|
|
|
|
|
node: ast::ty_rec(fields),
|
2012-11-12 19:32:48 -08:00
|
|
|
span: dummy_sp()}
|
2012-07-23 14:46:39 -07:00
|
|
|
}
|
|
|
|
|
|
2012-10-15 14:56:42 -07:00
|
|
|
fn ty_infer() -> @ast::Ty {
|
2012-07-23 18:50:53 -07:00
|
|
|
@{id: self.next_id(),
|
|
|
|
|
node: ast::ty_infer,
|
2012-11-12 19:32:48 -08:00
|
|
|
span: dummy_sp()}
|
2012-07-23 18:50:53 -07:00
|
|
|
}
|
|
|
|
|
|
2012-07-05 16:07:53 -07:00
|
|
|
fn ty_param(id: ast::ident, +bounds: ~[ast::ty_param_bound])
|
|
|
|
|
-> ast::ty_param
|
|
|
|
|
{
|
|
|
|
|
{ident: id, id: self.next_id(), bounds: @bounds}
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-15 14:56:42 -07:00
|
|
|
fn arg(name: ident, ty: @ast::Ty) -> ast::arg {
|
2012-07-05 16:07:53 -07:00
|
|
|
{mode: ast::infer(self.next_id()),
|
|
|
|
|
ty: ty,
|
2012-11-06 18:41:06 -08:00
|
|
|
pat: @{id: self.next_id(),
|
|
|
|
|
node: ast::pat_ident(
|
|
|
|
|
ast::bind_by_value,
|
2012-11-12 19:32:48 -08:00
|
|
|
ast_util::ident_to_path(dummy_sp(), name),
|
2012-11-06 18:41:06 -08:00
|
|
|
None),
|
2012-11-12 19:32:48 -08:00
|
|
|
span: dummy_sp()},
|
2012-07-05 16:07:53 -07:00
|
|
|
id: self.next_id()}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-23 18:50:53 -07:00
|
|
|
fn block(+stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk {
|
2012-07-05 16:07:53 -07:00
|
|
|
let blk = {view_items: ~[],
|
2012-07-23 18:50:53 -07:00
|
|
|
stmts: stmts,
|
2012-08-20 12:23:37 -07:00
|
|
|
expr: Some(e),
|
2012-07-05 16:07:53 -07:00
|
|
|
id: self.next_id(),
|
|
|
|
|
rules: ast::default_blk};
|
|
|
|
|
|
2012-12-27 14:36:00 -05:00
|
|
|
spanned { node: blk, span: dummy_sp() }
|
2012-07-05 16:07:53 -07:00
|
|
|
}
|
|
|
|
|
|
2012-07-23 18:50:53 -07:00
|
|
|
fn expr_block(e: @ast::expr) -> ast::blk {
|
|
|
|
|
self.block(~[], e)
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-05 16:07:53 -07:00
|
|
|
fn fn_decl(+inputs: ~[ast::arg],
|
2012-10-15 14:56:42 -07:00
|
|
|
output: @ast::Ty) -> ast::fn_decl {
|
2012-07-05 16:07:53 -07:00
|
|
|
{inputs: inputs,
|
|
|
|
|
output: output,
|
2012-07-13 18:43:52 -07:00
|
|
|
cf: ast::return_val}
|
2012-07-05 16:07:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn item(name: ident,
|
2012-08-17 11:26:35 -07:00
|
|
|
span: span,
|
2012-07-05 16:07:53 -07:00
|
|
|
+node: ast::item_) -> @ast::item {
|
2012-08-28 11:11:15 -07:00
|
|
|
|
|
|
|
|
// XXX: Would be nice if our generated code didn't violate
|
|
|
|
|
// Rust coding conventions
|
2012-11-12 19:32:48 -08:00
|
|
|
let non_camel_case_attribute = respan(dummy_sp(), {
|
2012-08-28 11:11:15 -07:00
|
|
|
style: ast::attr_outer,
|
2012-11-12 19:32:48 -08:00
|
|
|
value: respan(dummy_sp(),
|
2012-08-28 11:11:15 -07:00
|
|
|
ast::meta_list(~"allow", ~[
|
2012-11-12 19:32:48 -08:00
|
|
|
@respan(dummy_sp(),
|
2012-09-20 18:15:39 -07:00
|
|
|
ast::meta_word(~"non_camel_case_types"))
|
2012-08-28 11:11:15 -07:00
|
|
|
])),
|
|
|
|
|
is_sugared_doc: false
|
|
|
|
|
});
|
|
|
|
|
|
2012-07-05 16:07:53 -07:00
|
|
|
@{ident: name,
|
2012-08-28 11:11:15 -07:00
|
|
|
attrs: ~[non_camel_case_attribute],
|
2012-07-05 16:07:53 -07:00
|
|
|
id: self.next_id(),
|
|
|
|
|
node: node,
|
|
|
|
|
vis: ast::public,
|
2012-08-17 11:26:35 -07:00
|
|
|
span: span}
|
2012-07-05 16:07:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn item_fn_poly(name: ident,
|
|
|
|
|
+inputs: ~[ast::arg],
|
2012-10-15 14:56:42 -07:00
|
|
|
output: @ast::Ty,
|
2012-07-05 16:07:53 -07:00
|
|
|
+ty_params: ~[ast::ty_param],
|
|
|
|
|
+body: ast::blk) -> @ast::item {
|
|
|
|
|
self.item(name,
|
2012-11-12 19:32:48 -08:00
|
|
|
dummy_sp(),
|
2012-07-05 16:07:53 -07:00
|
|
|
ast::item_fn(self.fn_decl(inputs, output),
|
2012-08-23 18:17:16 -07:00
|
|
|
ast::impure_fn,
|
2012-07-05 16:07:53 -07:00
|
|
|
ty_params,
|
|
|
|
|
body))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn item_fn(name: ident,
|
|
|
|
|
+inputs: ~[ast::arg],
|
2012-10-15 14:56:42 -07:00
|
|
|
output: @ast::Ty,
|
2012-07-05 16:07:53 -07:00
|
|
|
+body: ast::blk) -> @ast::item {
|
|
|
|
|
self.item_fn_poly(name, inputs, output, ~[], body)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn item_enum_poly(name: ident,
|
2012-08-17 11:26:35 -07:00
|
|
|
span: span,
|
2012-08-08 17:14:25 -07:00
|
|
|
+enum_definition: ast::enum_def,
|
2012-07-05 16:07:53 -07:00
|
|
|
+ty_params: ~[ast::ty_param]) -> @ast::item {
|
2012-08-17 11:26:35 -07:00
|
|
|
self.item(name, span, ast::item_enum(enum_definition, ty_params))
|
2012-07-05 16:07:53 -07:00
|
|
|
}
|
|
|
|
|
|
2012-08-17 11:26:35 -07:00
|
|
|
fn item_enum(name: ident, span: span,
|
|
|
|
|
+enum_definition: ast::enum_def) -> @ast::item {
|
|
|
|
|
self.item_enum_poly(name, span, enum_definition, ~[])
|
2012-07-05 16:07:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn variant(name: ident,
|
2012-08-17 11:26:35 -07:00
|
|
|
span: span,
|
2012-10-15 14:56:42 -07:00
|
|
|
+tys: ~[@ast::Ty]) -> ast::variant {
|
2012-09-21 18:43:30 -07:00
|
|
|
let args = tys.map(|ty| {ty: *ty, id: self.next_id()});
|
2012-07-05 16:07:53 -07:00
|
|
|
|
2012-12-27 14:36:00 -05:00
|
|
|
spanned { node: { name: name,
|
|
|
|
|
attrs: ~[],
|
|
|
|
|
kind: ast::tuple_variant_kind(args),
|
|
|
|
|
id: self.next_id(),
|
|
|
|
|
disr_expr: None,
|
|
|
|
|
vis: ast::public},
|
|
|
|
|
span: span}
|
2012-07-05 16:07:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn item_mod(name: ident,
|
2012-08-17 11:26:35 -07:00
|
|
|
span: span,
|
2012-07-05 16:07:53 -07:00
|
|
|
+items: ~[@ast::item]) -> @ast::item {
|
2013-01-08 19:37:25 -08:00
|
|
|
// XXX: Total hack: import `core::kinds::Owned` to work around a
|
|
|
|
|
// parser bug whereby `fn f<T: ::kinds::Owned>` doesn't parse.
|
|
|
|
|
let vi = ast::view_item_import(~[
|
2012-12-27 14:36:00 -05:00
|
|
|
@ast::spanned {
|
2013-01-08 19:37:25 -08:00
|
|
|
node: ast::view_path_simple(
|
|
|
|
|
self.ident_of(~"Owned"),
|
|
|
|
|
path(
|
|
|
|
|
~[
|
|
|
|
|
self.ident_of(~"core"),
|
|
|
|
|
self.ident_of(~"kinds"),
|
|
|
|
|
self.ident_of(~"Owned")
|
|
|
|
|
],
|
|
|
|
|
ast_util::dummy_sp()
|
|
|
|
|
),
|
|
|
|
|
ast::type_value_ns,
|
|
|
|
|
self.next_id()
|
|
|
|
|
),
|
|
|
|
|
span: ast_util::dummy_sp()
|
|
|
|
|
}
|
|
|
|
|
]);
|
|
|
|
|
let vi = @{
|
|
|
|
|
node: vi,
|
|
|
|
|
attrs: ~[],
|
|
|
|
|
vis: ast::private,
|
|
|
|
|
span: ast_util::dummy_sp()
|
|
|
|
|
};
|
|
|
|
|
|
2012-07-05 16:07:53 -07:00
|
|
|
self.item(name,
|
2012-08-17 11:26:35 -07:00
|
|
|
span,
|
2012-07-05 16:07:53 -07:00
|
|
|
ast::item_mod({
|
2013-01-08 19:37:25 -08:00
|
|
|
view_items: ~[vi],
|
2012-07-05 16:07:53 -07:00
|
|
|
items: items}))
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-15 14:56:42 -07:00
|
|
|
fn ty_path_ast_builder(path: @ast::path) -> @ast::Ty {
|
2012-07-05 16:07:53 -07:00
|
|
|
@{id: self.next_id(),
|
|
|
|
|
node: ast::ty_path(path, self.next_id()),
|
2012-08-17 11:26:35 -07:00
|
|
|
span: path.span}
|
2012-07-05 16:07:53 -07:00
|
|
|
}
|
|
|
|
|
|
2012-10-15 14:56:42 -07:00
|
|
|
fn ty_nil_ast_builder() -> @ast::Ty {
|
2012-07-16 14:44:27 -07:00
|
|
|
@{id: self.next_id(),
|
|
|
|
|
node: ast::ty_nil,
|
2012-11-12 19:32:48 -08:00
|
|
|
span: dummy_sp()}
|
2012-07-16 14:44:27 -07:00
|
|
|
}
|
|
|
|
|
|
2012-07-05 16:07:53 -07:00
|
|
|
fn item_ty_poly(name: ident,
|
2012-08-17 11:26:35 -07:00
|
|
|
span: span,
|
2012-10-15 14:56:42 -07:00
|
|
|
ty: @ast::Ty,
|
2012-07-05 16:07:53 -07:00
|
|
|
+params: ~[ast::ty_param]) -> @ast::item {
|
2012-08-17 11:26:35 -07:00
|
|
|
self.item(name, span, ast::item_ty(ty, params))
|
2012-07-05 16:07:53 -07:00
|
|
|
}
|
|
|
|
|
|
2012-10-15 14:56:42 -07:00
|
|
|
fn item_ty(name: ident, span: span, ty: @ast::Ty) -> @ast::item {
|
2012-08-17 11:26:35 -07:00
|
|
|
self.item_ty_poly(name, span, ty, ~[])
|
2012-07-05 16:07:53 -07:00
|
|
|
}
|
|
|
|
|
|
2012-10-15 14:56:42 -07:00
|
|
|
fn ty_vars(+ty_params: ~[ast::ty_param]) -> ~[@ast::Ty] {
|
2012-07-24 16:58:48 -07:00
|
|
|
ty_params.map(|p| self.ty_path_ast_builder(
|
2012-11-12 19:32:48 -08:00
|
|
|
path(~[p.ident], dummy_sp())))
|
2012-07-05 16:07:53 -07:00
|
|
|
}
|
2012-12-23 17:41:37 -05:00
|
|
|
|
|
|
|
|
fn ty_vars_global(+ty_params: ~[ast::ty_param]) -> ~[@ast::Ty] {
|
|
|
|
|
ty_params.map(|p| self.ty_path_ast_builder(
|
|
|
|
|
path(~[p.ident], dummy_sp())))
|
|
|
|
|
}
|
2012-07-05 16:07:53 -07:00
|
|
|
}
|