2011-07-05 18:23:07 -05:00
|
|
|
// The Rust abstract syntax tree.
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2011-09-12 18:13:28 -05:00
|
|
|
import codemap::{span, filename};
|
2012-03-14 16:18:53 -05:00
|
|
|
import std::serialization::{serializer,
|
|
|
|
deserializer,
|
|
|
|
serialize_option,
|
|
|
|
deserialize_option,
|
|
|
|
serialize_uint,
|
|
|
|
deserialize_uint,
|
|
|
|
serialize_int,
|
|
|
|
deserialize_int,
|
|
|
|
serialize_i64,
|
|
|
|
deserialize_i64,
|
|
|
|
serialize_u64,
|
|
|
|
deserialize_u64,
|
|
|
|
serialize_str,
|
|
|
|
deserialize_str,
|
|
|
|
serialize_bool,
|
|
|
|
deserialize_bool};
|
|
|
|
|
2012-04-13 03:46:56 -05:00
|
|
|
/* Note #1972 -- spans are serialized but not deserialized */
|
2012-03-14 16:18:53 -05:00
|
|
|
fn serialize_span<S>(_s: S, _v: span) {
|
|
|
|
}
|
|
|
|
|
|
|
|
fn deserialize_span<D>(_d: D) -> span {
|
|
|
|
ast_util::dummy_sp()
|
|
|
|
}
|
2011-07-05 04:48:19 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 08:36:51 -05:00
|
|
|
type spanned<T> = {node: T, span: span};
|
2011-08-12 10:57:21 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-09-02 17:34:58 -05:00
|
|
|
type ident = str;
|
2011-08-25 17:12:54 -05:00
|
|
|
|
2011-06-24 17:11:22 -05:00
|
|
|
// Functions may or may not have names.
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-31 19:05:20 -06:00
|
|
|
type fn_ident = option<ident>;
|
2010-08-18 11:00:10 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-04-24 17:52:52 -05:00
|
|
|
type path = {span: span,
|
|
|
|
global: bool,
|
|
|
|
idents: [ident],
|
|
|
|
rp: option<@region>,
|
|
|
|
types: [@ty]};
|
2010-10-04 19:25:52 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2010-10-05 20:21:44 -05:00
|
|
|
type crate_num = int;
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-06-19 15:41:21 -05:00
|
|
|
type node_id = int;
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-07-27 07:19:39 -05:00
|
|
|
type def_id = {crate: crate_num, node: node_id};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
const local_crate: crate_num = 0;
|
2011-12-16 09:55:22 -06:00
|
|
|
const crate_node_id: node_id = 0;
|
2010-10-18 18:15:25 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum ty_param_bound {
|
2012-01-19 19:56:05 -06:00
|
|
|
bound_copy,
|
|
|
|
bound_send,
|
|
|
|
bound_iface(@ty),
|
2011-12-28 10:50:12 -06:00
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-12-28 10:50:12 -06:00
|
|
|
type ty_param = {ident: ident, id: node_id, bounds: @[ty_param_bound]};
|
2010-11-24 20:01:20 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum def {
|
2012-01-19 19:56:05 -06:00
|
|
|
def_fn(def_id, purity),
|
2012-02-27 18:05:17 -06:00
|
|
|
def_self(node_id),
|
2012-01-19 19:56:05 -06:00
|
|
|
def_mod(def_id),
|
|
|
|
def_native_mod(def_id),
|
|
|
|
def_const(def_id),
|
2012-02-27 18:05:17 -06:00
|
|
|
def_arg(node_id, mode),
|
2012-02-28 21:28:29 -06:00
|
|
|
def_local(node_id, bool /* is_mutbl */),
|
2012-01-19 19:56:05 -06:00
|
|
|
def_variant(def_id /* enum */, def_id /* variant */),
|
|
|
|
def_ty(def_id),
|
2012-02-06 08:29:56 -06:00
|
|
|
def_prim_ty(prim_ty),
|
2012-01-19 19:56:05 -06:00
|
|
|
def_ty_param(def_id, uint),
|
2012-02-27 18:05:17 -06:00
|
|
|
def_binding(node_id),
|
2012-01-19 19:56:05 -06:00
|
|
|
def_use(def_id),
|
2012-02-27 18:05:17 -06:00
|
|
|
def_upvar(node_id /* local id of closed over var */,
|
|
|
|
@def /* closed over def */,
|
|
|
|
node_id /* expr node that creates the closure */),
|
2012-02-07 13:31:15 -06:00
|
|
|
def_class(def_id),
|
2012-03-09 17:55:13 -06:00
|
|
|
def_region(node_id)
|
2010-10-05 20:21:44 -05:00
|
|
|
}
|
2010-10-04 19:25:52 -05:00
|
|
|
|
2011-06-29 20:07:15 -05:00
|
|
|
// The set of meta_items that define the compilation environment of the crate,
|
|
|
|
// used to drive conditional compilation
|
2011-08-04 18:20:09 -05:00
|
|
|
type crate_cfg = [@meta_item];
|
2011-06-29 20:07:15 -05:00
|
|
|
|
2011-08-12 09:15:18 -05:00
|
|
|
type crate = spanned<crate_>;
|
2010-08-18 11:00:10 -05:00
|
|
|
|
2011-07-27 07:19:39 -05:00
|
|
|
type crate_ =
|
2011-08-04 18:20:09 -05:00
|
|
|
{directives: [@crate_directive],
|
2011-07-27 07:19:39 -05:00
|
|
|
module: _mod,
|
2011-08-04 18:20:09 -05:00
|
|
|
attrs: [attribute],
|
2011-07-27 07:19:39 -05:00
|
|
|
config: crate_cfg};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-01-19 16:24:03 -06:00
|
|
|
enum crate_directive_ {
|
2012-01-19 19:56:05 -06:00
|
|
|
cdir_src_mod(ident, [attribute]),
|
|
|
|
cdir_dir_mod(ident, [@crate_directive], [attribute]),
|
2011-12-07 15:29:04 -06:00
|
|
|
|
2012-01-19 19:56:05 -06:00
|
|
|
// NB: cdir_view_item is *not* processed by the rest of the compiler, the
|
2011-12-07 15:29:04 -06:00
|
|
|
// attached view_items are sunk into the crate's module during parsing,
|
2012-01-19 16:34:23 -06:00
|
|
|
// and processed (resolved, imported, etc.) there. This enum-variant
|
|
|
|
// exists only to preserve the view items in order in case we decide to
|
2011-12-07 15:29:04 -06:00
|
|
|
// pretty-print crates in the future.
|
2012-01-19 19:56:05 -06:00
|
|
|
cdir_view_item(@view_item),
|
2011-12-07 15:29:04 -06:00
|
|
|
|
2012-01-19 19:56:05 -06:00
|
|
|
cdir_syntax(@path),
|
2011-02-23 16:37:39 -06:00
|
|
|
}
|
|
|
|
|
2011-08-12 09:15:18 -05:00
|
|
|
type crate_directive = spanned<crate_directive_>;
|
2011-02-23 16:37:39 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type meta_item = spanned<meta_item_>;
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum meta_item_ {
|
2012-01-19 19:56:05 -06:00
|
|
|
meta_word(ident),
|
|
|
|
meta_list(ident, [@meta_item]),
|
|
|
|
meta_name_value(ident, lit),
|
2011-06-21 16:23:16 -05:00
|
|
|
}
|
2010-12-30 10:21:37 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type blk = spanned<blk_>;
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-31 19:05:20 -06:00
|
|
|
type blk_ = {view_items: [@view_item], stmts: [@stmt], expr: option<@expr>,
|
2011-11-23 13:57:34 -06:00
|
|
|
id: node_id, rules: blk_check_mode};
|
2010-08-18 11:00:10 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-07-27 07:19:39 -05:00
|
|
|
type pat = {id: node_id, node: pat_, span: span};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-07-27 07:19:39 -05:00
|
|
|
type field_pat = {ident: ident, pat: @pat};
|
2011-07-11 07:13:20 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum pat_ {
|
2012-01-19 19:56:05 -06:00
|
|
|
pat_wild,
|
2012-01-14 18:05:07 -06:00
|
|
|
// A pat_ident may either be a new bound variable,
|
2012-01-19 16:24:03 -06:00
|
|
|
// or a nullary enum (in which case the second field
|
2012-01-14 18:05:07 -06:00
|
|
|
// is none).
|
2012-01-19 16:24:03 -06:00
|
|
|
// In the nullary enum case, the parser can't determine
|
2012-01-14 18:05:07 -06:00
|
|
|
// which it is. The resolver determines this, and
|
|
|
|
// records this pattern's node_id in an auxiliary
|
2012-01-25 07:34:31 -06:00
|
|
|
// set (of "pat_idents that refer to nullary enums")
|
2012-01-31 19:05:20 -06:00
|
|
|
pat_ident(@path, option<@pat>),
|
2012-04-20 02:54:42 -05:00
|
|
|
pat_enum(@path, option<[@pat]>), // "none" means a * pattern where
|
|
|
|
// we don't bind the fields to names
|
2012-01-19 19:56:05 -06:00
|
|
|
pat_rec([field_pat], bool),
|
|
|
|
pat_tup([@pat]),
|
|
|
|
pat_box(@pat),
|
|
|
|
pat_uniq(@pat),
|
|
|
|
pat_lit(@expr),
|
|
|
|
pat_range(@expr, @expr),
|
2010-11-24 16:42:01 -06:00
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-15 13:25:39 -06:00
|
|
|
enum mutability { m_mutbl, m_imm, m_const, }
|
2010-11-29 16:18:26 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum proto {
|
2012-01-19 19:56:05 -06:00
|
|
|
proto_bare, // native fn
|
|
|
|
proto_any, // fn
|
|
|
|
proto_uniq, // fn~
|
|
|
|
proto_box, // fn@
|
|
|
|
proto_block, // fn&
|
2011-10-10 15:15:47 -05:00
|
|
|
}
|
2011-02-18 19:30:57 -06:00
|
|
|
|
2012-04-09 19:32:49 -05:00
|
|
|
#[auto_serialize]
|
|
|
|
enum vstore {
|
2012-04-13 03:46:56 -05:00
|
|
|
/* FIXME: Change uint to @expr (actually only constant exprs,
|
|
|
|
as per #2112)
|
|
|
|
*/
|
|
|
|
vstore_fixed(option<uint>), // [1,2,3,4]/_ or 4
|
2012-04-09 19:32:49 -05:00
|
|
|
vstore_uniq, // [1,2,3,4]/~
|
|
|
|
vstore_box, // [1,2,3,4]/@
|
2012-04-24 17:52:52 -05:00
|
|
|
vstore_slice(@region) // [1,2,3,4]/&(foo)?
|
2012-04-09 19:32:49 -05:00
|
|
|
}
|
|
|
|
|
2012-01-12 17:38:44 -06:00
|
|
|
pure fn is_blockish(p: ast::proto) -> bool {
|
|
|
|
alt p {
|
2012-01-19 00:37:22 -06:00
|
|
|
proto_any | proto_block { true }
|
|
|
|
proto_bare | proto_uniq | proto_box { false }
|
2012-01-12 17:38:44 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum binop {
|
2012-01-19 19:56:05 -06:00
|
|
|
add,
|
|
|
|
subtract,
|
|
|
|
mul,
|
|
|
|
div,
|
|
|
|
rem,
|
|
|
|
and,
|
|
|
|
or,
|
|
|
|
bitxor,
|
|
|
|
bitand,
|
|
|
|
bitor,
|
|
|
|
lsl,
|
|
|
|
lsr,
|
|
|
|
asr,
|
|
|
|
eq,
|
|
|
|
lt,
|
|
|
|
le,
|
|
|
|
ne,
|
|
|
|
ge,
|
|
|
|
gt,
|
2010-09-27 20:25:02 -05:00
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum unop {
|
2012-01-19 19:56:05 -06:00
|
|
|
box(mutability),
|
|
|
|
uniq(mutability),
|
2012-03-08 18:34:36 -06:00
|
|
|
deref, not, neg
|
2011-09-20 20:06:47 -05:00
|
|
|
}
|
2010-09-27 20:25:02 -05:00
|
|
|
|
2012-02-02 18:50:17 -06:00
|
|
|
// Generally, after typeck you can get the inferred value
|
|
|
|
// using ty::resolved_T(...).
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-02 18:50:17 -06:00
|
|
|
enum inferable<T> {
|
|
|
|
expl(T), infer(node_id)
|
|
|
|
}
|
|
|
|
|
|
|
|
// "resolved" mode: the real modes.
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-15 13:25:39 -06:00
|
|
|
enum rmode { by_ref, by_val, by_mutbl_ref, by_move, by_copy }
|
2012-02-02 18:50:17 -06:00
|
|
|
|
|
|
|
// inferable mode.
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-02 18:50:17 -06:00
|
|
|
type mode = inferable<rmode>;
|
2010-12-03 20:03:28 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type stmt = spanned<stmt_>;
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum stmt_ {
|
2012-01-19 19:56:05 -06:00
|
|
|
stmt_decl(@decl, node_id),
|
2012-01-04 16:16:41 -06:00
|
|
|
|
|
|
|
// expr without trailing semi-colon (must have unit type):
|
2012-01-19 19:56:05 -06:00
|
|
|
stmt_expr(@expr, node_id),
|
2012-01-04 16:16:41 -06:00
|
|
|
|
|
|
|
// expr with trailing semi-colon (may have any type):
|
2012-01-19 19:56:05 -06:00
|
|
|
stmt_semi(@expr, node_id),
|
2010-09-09 17:59:29 -05:00
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 19:56:05 -06:00
|
|
|
enum init_op { init_assign, init_move, }
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-07-27 07:19:39 -05:00
|
|
|
type initializer = {op: init_op, expr: @expr};
|
2011-03-24 20:04:29 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-04-13 03:46:56 -05:00
|
|
|
type local_ = /* FIXME: should really be a refinement on pat
|
|
|
|
(pending discussion of #1697, #2178...)
|
|
|
|
*/
|
2012-02-28 21:28:29 -06:00
|
|
|
{is_mutbl: bool, ty: @ty, pat: @pat,
|
|
|
|
init: option<initializer>, id: node_id};
|
2011-03-24 20:04:29 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type local = spanned<local_>;
|
2010-10-18 20:19:16 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type decl = spanned<decl_>;
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-10 07:33:36 -06:00
|
|
|
enum decl_ { decl_local([@local]), decl_item(@item), }
|
2010-09-09 17:59:29 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-31 19:05:20 -06:00
|
|
|
type arm = {pats: [@pat], guard: option<@expr>, body: blk};
|
2010-11-24 17:45:59 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-15 13:25:39 -06:00
|
|
|
type field_ = {mutbl: mutability, ident: ident, expr: @expr};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type field = spanned<field_>;
|
2010-11-30 18:31:43 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 19:56:05 -06:00
|
|
|
enum blk_check_mode { default_blk, unchecked_blk, unsafe_blk, }
|
2011-10-06 18:42:27 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 19:56:05 -06:00
|
|
|
enum expr_check_mode { claimed_expr, checked_expr, }
|
2011-03-25 23:53:57 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-07-27 07:19:39 -05:00
|
|
|
type expr = {id: node_id, node: expr_, span: span};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-15 02:35:11 -06:00
|
|
|
enum alt_mode { alt_check, alt_exhaustive, }
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum expr_ {
|
2012-04-09 19:32:49 -05:00
|
|
|
expr_vstore(@expr, vstore),
|
2012-01-19 19:56:05 -06:00
|
|
|
expr_vec([@expr], mutability),
|
2012-01-31 19:05:20 -06:00
|
|
|
expr_rec([field], option<@expr>),
|
2012-04-13 03:46:56 -05:00
|
|
|
expr_call(@expr, [@expr], bool), // True iff last argument is a block
|
2012-01-19 19:56:05 -06:00
|
|
|
expr_tup([@expr]),
|
2012-01-31 19:05:20 -06:00
|
|
|
expr_bind(@expr, [option<@expr>]),
|
2012-01-19 19:56:05 -06:00
|
|
|
expr_binary(binop, @expr, @expr),
|
|
|
|
expr_unary(unop, @expr),
|
|
|
|
expr_lit(@lit),
|
|
|
|
expr_cast(@expr, @ty),
|
2012-01-31 19:05:20 -06:00
|
|
|
expr_if(@expr, blk, option<@expr>),
|
2012-01-19 19:56:05 -06:00
|
|
|
expr_while(@expr, blk),
|
2012-03-09 18:11:56 -06:00
|
|
|
/* Conditionless loop (can be exited with break, cont, ret, or fail)
|
|
|
|
Same semantics as while(true) { body }, but typestate knows that the
|
|
|
|
(implicit) condition is always true. */
|
|
|
|
expr_loop(blk),
|
2012-02-15 02:35:11 -06:00
|
|
|
expr_alt(@expr, [arm], alt_mode),
|
2012-05-04 14:33:04 -05:00
|
|
|
expr_fn(proto, fn_decl, blk, capture_clause),
|
|
|
|
expr_fn_block(fn_decl, blk, capture_clause),
|
2012-03-27 05:33:13 -05:00
|
|
|
// Inner expr is always an expr_fn_block. We need the wrapping node to
|
|
|
|
// sanely type this (a function returning nil on the inside but bool on
|
|
|
|
// the outside).
|
2012-03-26 09:09:27 -05:00
|
|
|
expr_loop_body(@expr),
|
2012-01-19 19:56:05 -06:00
|
|
|
expr_block(blk),
|
2011-08-19 17:16:48 -05:00
|
|
|
|
2011-06-16 18:55:46 -05:00
|
|
|
/*
|
|
|
|
* FIXME: many of these @exprs should be constrained with
|
|
|
|
* is_lval once we have constrained types working.
|
2012-04-13 03:46:56 -05:00
|
|
|
* (See #34)
|
2011-06-16 18:55:46 -05:00
|
|
|
*/
|
2012-01-19 19:56:05 -06:00
|
|
|
expr_copy(@expr),
|
|
|
|
expr_move(@expr, @expr),
|
|
|
|
expr_assign(@expr, @expr),
|
|
|
|
expr_swap(@expr, @expr),
|
|
|
|
expr_assign_op(binop, @expr, @expr),
|
|
|
|
expr_field(@expr, ident, [@ty]),
|
|
|
|
expr_index(@expr, @expr),
|
|
|
|
expr_path(@path),
|
2012-03-08 18:34:36 -06:00
|
|
|
expr_addr_of(mutability, @expr),
|
2012-01-31 19:05:20 -06:00
|
|
|
expr_fail(option<@expr>),
|
2012-01-19 19:56:05 -06:00
|
|
|
expr_break,
|
|
|
|
expr_cont,
|
2012-01-31 19:05:20 -06:00
|
|
|
expr_ret(option<@expr>),
|
2012-01-19 19:56:05 -06:00
|
|
|
expr_log(int, @expr, @expr),
|
2011-08-19 17:16:48 -05:00
|
|
|
|
2012-03-14 14:16:46 -05:00
|
|
|
expr_new(/* arena */ @expr,
|
|
|
|
/* id for the alloc() call */ node_id,
|
|
|
|
/* value */ @expr),
|
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
/* just an assert, no significance to typestate */
|
2012-01-19 19:56:05 -06:00
|
|
|
expr_assert(@expr),
|
2011-08-19 17:16:48 -05:00
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
/* preds that typestate is aware of */
|
2012-01-19 19:56:05 -06:00
|
|
|
expr_check(expr_check_mode, @expr),
|
2012-01-31 19:05:20 -06:00
|
|
|
expr_if_check(@expr, blk, option<@expr>),
|
2012-01-19 19:56:05 -06:00
|
|
|
expr_mac(mac),
|
2011-07-08 18:35:09 -05:00
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-12-17 23:12:30 -06:00
|
|
|
type capture_item = {
|
|
|
|
id: int,
|
2012-05-04 14:33:04 -05:00
|
|
|
is_move: bool,
|
2011-12-17 23:12:30 -06:00
|
|
|
name: ident, // Currently, can only capture a local var.
|
|
|
|
span: span
|
|
|
|
};
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-05-07 13:31:57 -05:00
|
|
|
type capture_clause = @[capture_item];
|
2011-12-08 13:47:01 -06:00
|
|
|
|
2011-08-25 19:42:38 -05:00
|
|
|
/*
|
|
|
|
// Says whether this is a block the user marked as
|
|
|
|
// "unchecked"
|
2012-01-19 16:24:03 -06:00
|
|
|
enum blk_sort {
|
2012-01-19 19:56:05 -06:00
|
|
|
blk_unchecked, // declared as "exception to effect-checking rules"
|
|
|
|
blk_checked, // all typing rules apply
|
2011-08-25 19:42:38 -05:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type mac = spanned<mac_>;
|
2011-07-08 18:35:09 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-03-13 16:39:28 -05:00
|
|
|
type mac_arg = option<@expr>;
|
2012-02-01 00:50:12 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-01 00:50:12 -06:00
|
|
|
type mac_body_ = {span: span};
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-03-13 16:39:28 -05:00
|
|
|
type mac_body = option<mac_body_>;
|
2012-01-31 21:30:26 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum mac_ {
|
2012-02-01 00:50:12 -06:00
|
|
|
mac_invoc(@path, mac_arg, mac_body),
|
2012-01-19 19:56:05 -06:00
|
|
|
mac_embed_type(@ty),
|
|
|
|
mac_embed_block(blk),
|
|
|
|
mac_ellipsis,
|
2012-01-25 17:38:09 -06:00
|
|
|
// the span is used by the quoter/anti-quoter ...
|
|
|
|
mac_aq(span /* span of quote */, @expr), // anti-quote
|
2012-02-01 17:19:45 -06:00
|
|
|
mac_var(uint)
|
2010-09-09 17:59:29 -05:00
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type lit = spanned<lit_>;
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum lit_ {
|
2012-01-19 19:56:05 -06:00
|
|
|
lit_str(str),
|
|
|
|
lit_int(i64, int_ty),
|
|
|
|
lit_uint(u64, uint_ty),
|
|
|
|
lit_float(str, float_ty),
|
|
|
|
lit_nil,
|
|
|
|
lit_bool(bool),
|
2010-09-09 17:59:29 -05:00
|
|
|
}
|
|
|
|
|
2010-11-03 18:43:12 -05:00
|
|
|
// NB: If you change this, you'll probably want to change the corresponding
|
2010-12-21 14:13:51 -06:00
|
|
|
// type structure in middle/ty.rs as well.
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-15 13:25:39 -06:00
|
|
|
type mt = {ty: @ty, mutbl: mutability};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-07-27 07:19:39 -05:00
|
|
|
type ty_field_ = {ident: ident, mt: mt};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type ty_field = spanned<ty_field_>;
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-30 13:43:45 -06:00
|
|
|
type ty_method = {ident: ident, attrs: [attribute],
|
|
|
|
decl: fn_decl, tps: [ty_param], span: span};
|
2011-06-03 17:26:03 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 19:56:05 -06:00
|
|
|
enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, }
|
2011-12-07 14:06:12 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 19:56:05 -06:00
|
|
|
enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
|
2011-12-07 14:06:12 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 19:56:05 -06:00
|
|
|
enum float_ty { ty_f, ty_f32, ty_f64, }
|
2011-07-05 04:48:19 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-03-12 18:26:31 -05:00
|
|
|
type ty = {id: node_id, node: ty_, span: span};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-02-06 08:29:56 -06:00
|
|
|
// Not represented directly in the AST, referred to by name through a ty_path.
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-06 08:29:56 -06:00
|
|
|
enum prim_ty {
|
2012-01-19 19:56:05 -06:00
|
|
|
ty_int(int_ty),
|
|
|
|
ty_uint(uint_ty),
|
|
|
|
ty_float(float_ty),
|
|
|
|
ty_str,
|
2012-02-06 08:29:56 -06:00
|
|
|
ty_bool,
|
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-03-09 18:10:11 -06:00
|
|
|
type region = {id: node_id, node: region_};
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-04-30 12:37:58 -05:00
|
|
|
enum region_ { re_anon, re_named(ident) }
|
2012-03-08 12:49:43 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-06 08:29:56 -06:00
|
|
|
enum ty_ {
|
|
|
|
ty_nil,
|
|
|
|
ty_bot, /* bottom type */
|
2012-01-19 19:56:05 -06:00
|
|
|
ty_box(mt),
|
|
|
|
ty_uniq(mt),
|
|
|
|
ty_vec(mt),
|
|
|
|
ty_ptr(mt),
|
2012-04-24 17:52:52 -05:00
|
|
|
ty_rptr(@region, mt),
|
2012-01-19 19:56:05 -06:00
|
|
|
ty_rec([ty_field]),
|
|
|
|
ty_fn(proto, fn_decl),
|
|
|
|
ty_tup([@ty]),
|
|
|
|
ty_path(@path, node_id),
|
|
|
|
ty_constr(@ty, [@ty_constr]),
|
2012-04-09 19:32:49 -05:00
|
|
|
ty_vstore(@ty, vstore),
|
2012-01-19 19:56:05 -06:00
|
|
|
ty_mac(mac),
|
2011-08-10 14:51:50 -05:00
|
|
|
// ty_infer means the type should be inferred instead of it having been
|
|
|
|
// specified. This should only appear at the "top level" of a type and not
|
|
|
|
// nested in one.
|
2012-01-19 19:56:05 -06:00
|
|
|
ty_infer,
|
2010-09-09 17:59:29 -05:00
|
|
|
}
|
|
|
|
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2011-06-10 21:12:42 -05:00
|
|
|
/*
|
|
|
|
A constraint arg that's a function argument is referred to by its position
|
|
|
|
rather than name. This is so we could have higher-order functions that have
|
|
|
|
constraints (potentially -- right now there's no way to write that), and also
|
|
|
|
so that the typestate pass doesn't have to map a function name onto its decl.
|
|
|
|
So, the constr_arg type is parameterized: it's instantiated with uint for
|
|
|
|
declarations, and ident for uses.
|
|
|
|
*/
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 19:56:05 -06:00
|
|
|
enum constr_arg_general_<T> { carg_base, carg_ident(T), carg_lit(@lit), }
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type fn_constr_arg = constr_arg_general_<uint>;
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 08:36:51 -05:00
|
|
|
type sp_constr_arg<T> = spanned<constr_arg_general_<T>>;
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-11-30 06:38:38 -06:00
|
|
|
type ty_constr_arg = sp_constr_arg<@path>;
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type constr_arg = spanned<fn_constr_arg>;
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2011-07-19 19:52:34 -05:00
|
|
|
// Constrained types' args are parameterized by paths, since
|
|
|
|
// we refer to paths directly and not by indices.
|
|
|
|
// The implicit root of such path, in the constraint-list for a
|
|
|
|
// constrained type, is * (referring to the base record)
|
2011-06-10 21:12:42 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 08:36:51 -05:00
|
|
|
type constr_general_<ARG, ID> =
|
2012-05-18 00:15:07 -05:00
|
|
|
{path: @path, args: [@sp_constr_arg<ARG>], id: ID};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2011-07-19 19:52:34 -05:00
|
|
|
// In the front end, constraints have a node ID attached.
|
|
|
|
// Typeck turns this to a def_id, using the output of resolve.
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 08:36:51 -05:00
|
|
|
type constr_general<ARG> = spanned<constr_general_<ARG, node_id>>;
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type constr_ = constr_general_<uint, node_id>;
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type constr = spanned<constr_general_<uint, node_id>>;
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-11-30 06:38:38 -06:00
|
|
|
type ty_constr_ = constr_general_<@path, node_id>;
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type ty_constr = spanned<ty_constr_>;
|
2011-06-16 18:55:46 -05:00
|
|
|
|
2011-06-15 17:14:30 -05:00
|
|
|
/* The parser generates ast::constrs; resolve generates
|
|
|
|
a mapping from each function to a list of ty::constr_defs,
|
|
|
|
corresponding to these. */
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-07-27 07:19:39 -05:00
|
|
|
type arg = {mode: mode, ty: @ty, ident: ident, id: node_id};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-06-15 13:19:50 -05:00
|
|
|
type fn_decl =
|
2011-12-29 22:07:55 -06:00
|
|
|
{inputs: [arg],
|
2011-07-27 07:19:39 -05:00
|
|
|
output: @ty,
|
|
|
|
purity: purity,
|
2011-09-14 03:38:23 -05:00
|
|
|
cf: ret_style,
|
2011-08-04 18:20:09 -05:00
|
|
|
constraints: [@constr]};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum purity {
|
2012-01-19 19:56:05 -06:00
|
|
|
pure_fn, // declared with "pure fn"
|
|
|
|
unsafe_fn, // declared with "unsafe fn"
|
|
|
|
impure_fn, // declared with "fn"
|
2012-02-10 15:39:15 -06:00
|
|
|
crust_fn, // declared with "crust fn"
|
2011-05-04 13:28:13 -05:00
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum ret_style {
|
2012-01-19 19:56:05 -06:00
|
|
|
noreturn, // functions with return type _|_ that always
|
2011-05-14 21:02:30 -05:00
|
|
|
// raise an error or exit (i.e. never return to the caller)
|
2012-01-19 19:56:05 -06:00
|
|
|
return_val, // everything else
|
2011-05-14 21:02:30 -05:00
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-30 13:43:45 -06:00
|
|
|
type method = {ident: ident, attrs: [attribute],
|
|
|
|
tps: [ty_param], decl: fn_decl, body: blk,
|
2012-03-28 20:50:33 -05:00
|
|
|
id: node_id, span: span, self_id: node_id,
|
2012-05-08 09:06:24 -05:00
|
|
|
vis: visibility}; // always public, unless it's a
|
2012-03-28 20:50:33 -05:00
|
|
|
// class method
|
2010-12-14 17:32:13 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-04 18:20:09 -05:00
|
|
|
type _mod = {view_items: [@view_item], items: [@item]};
|
2010-08-18 11:00:10 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum native_abi {
|
2012-03-23 06:03:16 -05:00
|
|
|
native_abi_rust_intrinsic,
|
2012-01-19 19:56:05 -06:00
|
|
|
native_abi_cdecl,
|
|
|
|
native_abi_stdcall,
|
2011-02-23 13:06:37 -06:00
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-06-15 13:19:50 -05:00
|
|
|
type native_mod =
|
2011-11-20 12:15:40 -06:00
|
|
|
{view_items: [@view_item],
|
2011-08-04 18:20:09 -05:00
|
|
|
items: [@native_item]};
|
2011-02-01 12:40:04 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-07-27 07:19:39 -05:00
|
|
|
type variant_arg = {ty: @ty, id: node_id};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-25 18:23:43 -06:00
|
|
|
type variant_ = {name: ident, attrs: [attribute], args: [variant_arg],
|
2012-05-08 09:06:24 -05:00
|
|
|
id: node_id, disr_expr: option<@expr>, vis: visibility};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type variant = spanned<variant_>;
|
2010-11-24 13:36:35 -06:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-18 01:05:20 -06:00
|
|
|
type path_list_ident_ = {name: ident, id: node_id};
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-18 01:05:20 -06:00
|
|
|
type path_list_ident = spanned<path_list_ident_>;
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-18 01:05:20 -06:00
|
|
|
type view_path = spanned<view_path_>;
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-02-18 01:05:20 -06:00
|
|
|
enum view_path_ {
|
|
|
|
|
|
|
|
// quux = foo::bar::baz
|
|
|
|
//
|
|
|
|
// or just
|
|
|
|
//
|
|
|
|
// foo::bar::baz (with 'baz =' implicitly on the left)
|
2012-04-13 03:46:56 -05:00
|
|
|
view_path_simple(ident, @path, node_id),
|
2011-08-16 17:21:30 -05:00
|
|
|
|
2012-02-18 01:05:20 -06:00
|
|
|
// foo::bar::*
|
2012-04-13 03:46:56 -05:00
|
|
|
view_path_glob(@path, node_id),
|
2011-08-16 17:21:30 -05:00
|
|
|
|
2012-02-18 01:05:20 -06:00
|
|
|
// foo::bar::{a,b,c}
|
2012-04-13 03:46:56 -05:00
|
|
|
view_path_list(@path, [path_list_ident], node_id)
|
2012-02-18 01:05:20 -06:00
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-05-08 16:01:38 -05:00
|
|
|
type view_item = {node: view_item_, attrs: [attribute],
|
|
|
|
vis: visibility, span: span};
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum view_item_ {
|
2012-01-19 19:56:05 -06:00
|
|
|
view_item_use(ident, [@meta_item], node_id),
|
2012-02-18 01:05:20 -06:00
|
|
|
view_item_import([@view_path]),
|
|
|
|
view_item_export([@view_path])
|
2011-01-01 11:55:18 -06:00
|
|
|
}
|
|
|
|
|
2011-06-14 18:13:19 -05:00
|
|
|
// Meta-data associated with an item
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-08-12 09:15:18 -05:00
|
|
|
type attribute = spanned<attribute_>;
|
2011-06-14 18:13:19 -05:00
|
|
|
|
|
|
|
// Distinguishes between attributes that decorate items and attributes that
|
|
|
|
// are contained as statements within items. These two cases need to be
|
|
|
|
// distinguished for pretty-printing.
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 19:56:05 -06:00
|
|
|
enum attr_style { attr_outer, attr_inner, }
|
2011-06-14 18:13:19 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-07-27 07:19:39 -05:00
|
|
|
type attribute_ = {style: attr_style, value: meta_item};
|
2011-06-14 18:13:19 -05:00
|
|
|
|
2012-04-13 14:22:35 -05:00
|
|
|
/*
|
|
|
|
iface_refs appear in both impls and in classes that implement ifaces.
|
|
|
|
resolve maps each iface_ref's id to its defining iface.
|
|
|
|
*/
|
2012-04-11 18:18:00 -05:00
|
|
|
#[auto_serialize]
|
|
|
|
type iface_ref = {path: @path, id: node_id};
|
|
|
|
|
2012-05-08 09:06:24 -05:00
|
|
|
#[auto_serialize]
|
|
|
|
enum visibility { public, private }
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-13 03:58:31 -06:00
|
|
|
type item = {ident: ident, attrs: [attribute],
|
2012-05-08 09:06:24 -05:00
|
|
|
id: node_id, node: item_,
|
|
|
|
vis: visibility, span: span};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-04-18 23:26:25 -05:00
|
|
|
#[auto_serialize]
|
|
|
|
enum region_param {
|
|
|
|
rp_none,
|
|
|
|
rp_self
|
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum item_ {
|
2012-01-19 19:56:05 -06:00
|
|
|
item_const(@ty, @expr),
|
|
|
|
item_fn(fn_decl, [ty_param], blk),
|
|
|
|
item_mod(_mod),
|
|
|
|
item_native_mod(native_mod),
|
2012-04-18 23:26:25 -05:00
|
|
|
item_ty(@ty, [ty_param], region_param),
|
|
|
|
item_enum([variant], [ty_param], region_param),
|
2012-04-10 12:52:06 -05:00
|
|
|
item_res(fn_decl /* dtor */, [ty_param], blk /* dtor body */,
|
2012-04-18 23:26:25 -05:00
|
|
|
node_id /* dtor id */, node_id /* ctor id */,
|
|
|
|
region_param),
|
2012-01-31 21:30:40 -06:00
|
|
|
item_class([ty_param], /* ty params for class */
|
2012-04-13 14:22:35 -05:00
|
|
|
[@iface_ref], /* ifaces this class implements */
|
2012-03-28 20:50:33 -05:00
|
|
|
[@class_member], /* methods, etc. */
|
2012-05-14 16:13:32 -05:00
|
|
|
/* (not including ctor or dtor) */
|
2012-04-18 23:26:25 -05:00
|
|
|
class_ctor,
|
2012-05-14 16:13:32 -05:00
|
|
|
/* dtor is optional */
|
|
|
|
option<class_dtor>,
|
2012-04-18 23:26:25 -05:00
|
|
|
region_param
|
2012-01-31 21:30:40 -06:00
|
|
|
),
|
2012-04-24 17:52:52 -05:00
|
|
|
item_iface([ty_param], region_param, [ty_method]),
|
|
|
|
item_impl([ty_param], region_param, option<@iface_ref> /* iface */,
|
2012-01-19 19:56:05 -06:00
|
|
|
@ty /* self */, [@method]),
|
2011-05-11 08:10:24 -05:00
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-03-28 20:50:33 -05:00
|
|
|
type class_member = spanned<class_member_>;
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-03-28 20:50:33 -05:00
|
|
|
enum class_member_ {
|
2012-05-08 09:06:24 -05:00
|
|
|
instance_var(ident, @ty, class_mutability, node_id, visibility),
|
2012-03-19 12:19:00 -05:00
|
|
|
class_method(@method)
|
2012-01-31 21:30:40 -06:00
|
|
|
}
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-31 21:30:40 -06:00
|
|
|
enum class_mutability { class_mutable, class_immutable }
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-03-03 19:49:23 -06:00
|
|
|
type class_ctor = spanned<class_ctor_>;
|
2012-03-14 16:18:53 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-03-03 19:49:23 -06:00
|
|
|
type class_ctor_ = {id: node_id,
|
2012-03-28 16:17:41 -05:00
|
|
|
self_id: node_id,
|
2012-03-03 19:49:23 -06:00
|
|
|
dec: fn_decl,
|
|
|
|
body: blk};
|
|
|
|
|
2012-05-14 16:13:32 -05:00
|
|
|
#[auto_serialize]
|
|
|
|
type class_dtor = spanned<class_dtor_>;
|
|
|
|
|
|
|
|
#[auto_serialize]
|
|
|
|
type class_dtor_ = {id: node_id,
|
|
|
|
self_id: node_id,
|
|
|
|
body: blk};
|
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2011-07-27 07:19:39 -05:00
|
|
|
type native_item =
|
|
|
|
{ident: ident,
|
2011-08-04 18:20:09 -05:00
|
|
|
attrs: [attribute],
|
2011-07-27 07:19:39 -05:00
|
|
|
node: native_item_,
|
|
|
|
id: node_id,
|
|
|
|
span: span};
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-01-19 16:24:03 -06:00
|
|
|
enum native_item_ {
|
2012-01-19 19:56:05 -06:00
|
|
|
native_item_fn(fn_decl, [ty_param]),
|
2011-02-02 09:43:57 -06:00
|
|
|
}
|
|
|
|
|
2012-03-01 21:37:52 -06:00
|
|
|
// 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.
|
2012-03-15 09:15:49 -05:00
|
|
|
#[auto_serialize]
|
2012-03-01 21:37:52 -06:00
|
|
|
enum inlined_item {
|
|
|
|
ii_item(@item),
|
2012-03-21 09:42:20 -05:00
|
|
|
ii_method(def_id /* impl id */, @method),
|
|
|
|
ii_native(@native_item),
|
2012-04-10 12:52:06 -05:00
|
|
|
ii_ctor(class_ctor, ident, [ty_param], def_id /* parent id */)
|
2012-03-01 21:37:52 -06:00
|
|
|
}
|
|
|
|
|
2010-08-12 12:27:50 -05:00
|
|
|
//
|
|
|
|
// Local Variables:
|
|
|
|
// mode: rust
|
|
|
|
// fill-column: 78;
|
|
|
|
// indent-tabs-mode: nil
|
|
|
|
// c-basic-offset: 4
|
|
|
|
// buffer-file-coding-system: utf-8-unix
|
|
|
|
// End:
|
|
|
|
//
|