switch over to using new serialize/deserialize code
This commit is contained in:
@@ -13,14 +13,19 @@ import std::serialization::serializer;
|
|||||||
import std::serialization::deserializer;
|
import std::serialization::deserializer;
|
||||||
import std::serialization::serializer_helpers;
|
import std::serialization::serializer_helpers;
|
||||||
import std::serialization::deserializer_helpers;
|
import std::serialization::deserializer_helpers;
|
||||||
|
import std::prettyprint::serializer;
|
||||||
import std::smallintmap::map;
|
import std::smallintmap::map;
|
||||||
import middle::trans::common::maps;
|
import middle::trans::common::maps;
|
||||||
import middle::{ty, typeck, last_use, ast_map};
|
import middle::{ty, typeck, last_use, ast_map};
|
||||||
import middle::typeck::method_origin;
|
import middle::typeck::{method_origin,
|
||||||
import middle::typeck::vtable_res;
|
serialize_method_origin,
|
||||||
import middle::typeck::vtable_origin;
|
deserialize_method_origin,
|
||||||
|
vtable_res,
|
||||||
|
vtable_origin};
|
||||||
import driver::session::session;
|
import driver::session::session;
|
||||||
import middle::freevars::freevar_entry;
|
import middle::freevars::{freevar_entry,
|
||||||
|
serialize_freevar_entry,
|
||||||
|
deserialize_freevar_entry};
|
||||||
import c = common;
|
import c = common;
|
||||||
import e = encoder;
|
import e = encoder;
|
||||||
|
|
||||||
@@ -302,13 +307,13 @@ impl of tr for span {
|
|||||||
|
|
||||||
impl serializer_helpers<S: serializer> for S {
|
impl serializer_helpers<S: serializer> for S {
|
||||||
fn emit_def_id(did: ast::def_id) {
|
fn emit_def_id(did: ast::def_id) {
|
||||||
astencode_gen::serialize_syntax_ast_def_id(self, did)
|
ast::serialize_def_id(self, did)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl deserializer_helpers<D: deserializer> for D {
|
impl deserializer_helpers<D: deserializer> for D {
|
||||||
fn read_def_id(xcx: extended_decode_ctxt) -> ast::def_id {
|
fn read_def_id(xcx: extended_decode_ctxt) -> ast::def_id {
|
||||||
let did = astencode_gen::deserialize_syntax_ast_def_id(self);
|
let did = ast::deserialize_def_id(self);
|
||||||
did.tr(xcx)
|
did.tr(xcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -330,7 +335,7 @@ impl deserializer_helpers<D: deserializer> for D {
|
|||||||
|
|
||||||
fn encode_ast(ebml_w: ebml::writer, item: ast::inlined_item) {
|
fn encode_ast(ebml_w: ebml::writer, item: ast::inlined_item) {
|
||||||
ebml_w.wr_tag(c::tag_tree as uint) {||
|
ebml_w.wr_tag(c::tag_tree as uint) {||
|
||||||
astencode_gen::serialize_syntax_ast_inlined_item(ebml_w, item)
|
ast::serialize_inlined_item(ebml_w, item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,7 +380,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
|
|||||||
fn decode_ast(par_doc: ebml::doc) -> ast::inlined_item {
|
fn decode_ast(par_doc: ebml::doc) -> ast::inlined_item {
|
||||||
let chi_doc = par_doc[c::tag_tree];
|
let chi_doc = par_doc[c::tag_tree];
|
||||||
let d = ebml::ebml_deserializer(chi_doc);
|
let d = ebml::ebml_deserializer(chi_doc);
|
||||||
astencode_gen::deserialize_syntax_ast_inlined_item(d)
|
ast::deserialize_inlined_item(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item)
|
fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item)
|
||||||
@@ -400,12 +405,12 @@ fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item)
|
|||||||
// Encoding and decoding of ast::def
|
// Encoding and decoding of ast::def
|
||||||
|
|
||||||
fn encode_def(ebml_w: ebml::writer, def: ast::def) {
|
fn encode_def(ebml_w: ebml::writer, def: ast::def) {
|
||||||
astencode_gen::serialize_syntax_ast_def(ebml_w, def)
|
ast::serialize_def(ebml_w, def)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decode_def(xcx: extended_decode_ctxt, doc: ebml::doc) -> ast::def {
|
fn decode_def(xcx: extended_decode_ctxt, doc: ebml::doc) -> ast::def {
|
||||||
let dsr = ebml::ebml_deserializer(doc);
|
let dsr = ebml::ebml_deserializer(doc);
|
||||||
let def = astencode_gen::deserialize_syntax_ast_def(dsr);
|
let def = ast::deserialize_def(dsr);
|
||||||
def.tr(xcx)
|
def.tr(xcx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,13 +453,12 @@ impl of tr for ast::def {
|
|||||||
// Encoding and decoding of freevar information
|
// Encoding and decoding of freevar information
|
||||||
|
|
||||||
fn encode_freevar_entry(ebml_w: ebml::writer, fv: freevar_entry) {
|
fn encode_freevar_entry(ebml_w: ebml::writer, fv: freevar_entry) {
|
||||||
astencode_gen::serialize_middle_freevars_freevar_entry(ebml_w, fv)
|
serialize_freevar_entry(ebml_w, fv)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl helper for ebml::ebml_deserializer {
|
impl helper for ebml::ebml_deserializer {
|
||||||
fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry {
|
fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry {
|
||||||
let fv =
|
let fv = deserialize_freevar_entry(self);
|
||||||
astencode_gen::deserialize_middle_freevars_freevar_entry(self);
|
|
||||||
fv.tr(xcx)
|
fv.tr(xcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -469,16 +473,16 @@ impl of tr for freevar_entry {
|
|||||||
// Encoding and decoding of method_origin
|
// Encoding and decoding of method_origin
|
||||||
|
|
||||||
fn encode_method_origin(ebml_w: ebml::writer, mo: method_origin) {
|
fn encode_method_origin(ebml_w: ebml::writer, mo: method_origin) {
|
||||||
astencode_gen::serialize_middle_typeck_method_origin(ebml_w, mo)
|
serialize_method_origin(ebml_w, mo)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl helper for ebml::ebml_deserializer {
|
impl helper for ebml::ebml_deserializer {
|
||||||
fn read_method_origin(xcx: extended_decode_ctxt) -> method_origin {
|
fn read_method_origin(xcx: extended_decode_ctxt) -> method_origin {
|
||||||
let fv = astencode_gen::deserialize_middle_typeck_method_origin(self);
|
let fv = deserialize_method_origin(self);
|
||||||
fv.tr(xcx)
|
fv.tr(xcx)
|
||||||
}
|
}
|
||||||
fn read_is_last_use(xcx: extended_decode_ctxt) -> last_use::is_last_use {
|
fn read_is_last_use(xcx: extended_decode_ctxt) -> last_use::is_last_use {
|
||||||
let lu = astencode_gen::deserialize_middle_last_use_is_last_use(self);
|
let lu = last_use::deserialize_is_last_use(self);
|
||||||
lu.tr(xcx)
|
lu.tr(xcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -692,7 +696,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
|||||||
ebml_w.tag(c::tag_table_def) {||
|
ebml_w.tag(c::tag_table_def) {||
|
||||||
ebml_w.id(id);
|
ebml_w.id(id);
|
||||||
ebml_w.tag(c::tag_table_val) {||
|
ebml_w.tag(c::tag_table_val) {||
|
||||||
astencode_gen::serialize_syntax_ast_def(ebml_w, def)
|
ast::serialize_def(ebml_w, def)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -774,7 +778,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
|||||||
ebml_w.tag(c::tag_table_last_use) {||
|
ebml_w.tag(c::tag_table_last_use) {||
|
||||||
ebml_w.id(id);
|
ebml_w.id(id);
|
||||||
ebml_w.tag(c::tag_table_val) {||
|
ebml_w.tag(c::tag_table_val) {||
|
||||||
astencode_gen::serialize_middle_last_use_is_last_use(ebml_w, m)
|
last_use::serialize_is_last_use(ebml_w, m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -786,8 +790,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
|
|||||||
ebml_w.tag(c::tag_table_method_map) {||
|
ebml_w.tag(c::tag_table_method_map) {||
|
||||||
ebml_w.id(id);
|
ebml_w.id(id);
|
||||||
ebml_w.tag(c::tag_table_val) {||
|
ebml_w.tag(c::tag_table_val) {||
|
||||||
astencode_gen::
|
serialize_method_origin(ebml_w, mo)
|
||||||
serialize_middle_typeck_method_origin(ebml_w, mo)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -901,3 +904,128 @@ fn decode_side_tables(xcx: extended_decode_ctxt,
|
|||||||
#debug[">< Side table doc loaded"];
|
#debug[">< Side table doc loaded"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ______________________________________________________________________
|
||||||
|
// Testing of astencode_gen
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
fn encode_item_ast(ebml_w: ebml::writer, item: @ast::item) {
|
||||||
|
ebml_w.wr_tag(c::tag_tree as uint) {||
|
||||||
|
ast::serialize_item(ebml_w, *item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
fn decode_item_ast(par_doc: ebml::doc) -> @ast::item {
|
||||||
|
let chi_doc = par_doc[c::tag_tree];
|
||||||
|
let d = ebml::ebml_deserializer(chi_doc);
|
||||||
|
@ast::deserialize_item(d)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
fn new_parse_sess() -> parser::parse_sess {
|
||||||
|
let cm = codemap::new_codemap();
|
||||||
|
let handler = diagnostic::mk_handler(option::none);
|
||||||
|
let sess = @{
|
||||||
|
cm: cm,
|
||||||
|
mutable next_id: 1,
|
||||||
|
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
|
||||||
|
mutable chpos: 0u,
|
||||||
|
mutable byte_pos: 0u
|
||||||
|
};
|
||||||
|
ret sess;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
iface fake_ext_ctxt {
|
||||||
|
fn session() -> fake_session;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
type fake_options = {cfg: ast::crate_cfg};
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
type fake_session = {opts: @fake_options,
|
||||||
|
parse_sess: parser::parse_sess};
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
impl of fake_ext_ctxt for fake_session {
|
||||||
|
fn session() -> fake_session {self}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
fn mk_ctxt() -> fake_ext_ctxt {
|
||||||
|
let opts : fake_options = {cfg: []};
|
||||||
|
{opts: @opts, parse_sess: new_parse_sess()} as fake_ext_ctxt
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
fn roundtrip(in_item: @ast::item) {
|
||||||
|
#debug["in_item = %s", pprust::item_to_str(in_item)];
|
||||||
|
let mbuf = io::mem_buffer();
|
||||||
|
let ebml_w = ebml::writer(io::mem_buffer_writer(mbuf));
|
||||||
|
encode_item_ast(ebml_w, in_item);
|
||||||
|
let ebml_doc = ebml::doc(@io::mem_buffer_buf(mbuf));
|
||||||
|
let out_item = decode_item_ast(ebml_doc);
|
||||||
|
#debug["out_item = %s", pprust::item_to_str(out_item)];
|
||||||
|
|
||||||
|
let exp_str =
|
||||||
|
io::with_str_writer {|w| ast::serialize_item(w, *in_item) };
|
||||||
|
let out_str =
|
||||||
|
io::with_str_writer {|w| ast::serialize_item(w, *out_item) };
|
||||||
|
|
||||||
|
#debug["expected string: %s", exp_str];
|
||||||
|
#debug["actual string : %s", out_str];
|
||||||
|
|
||||||
|
assert exp_str == out_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_basic() {
|
||||||
|
let ext_cx = mk_ctxt();
|
||||||
|
roundtrip(#ast(item){
|
||||||
|
fn foo() {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_smalltalk() {
|
||||||
|
let ext_cx = mk_ctxt();
|
||||||
|
roundtrip(#ast(item){
|
||||||
|
fn foo() -> int { 3 + 4 } // first smalltalk program ever executed.
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_more() {
|
||||||
|
let ext_cx = mk_ctxt();
|
||||||
|
roundtrip(#ast(item){
|
||||||
|
fn foo(x: uint, y: uint) -> uint {
|
||||||
|
let z = x + y;
|
||||||
|
ret z;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_simplification() {
|
||||||
|
let ext_cx = mk_ctxt();
|
||||||
|
let item_in = ast::ii_item(#ast(item) {
|
||||||
|
fn new_int_alist<B: copy>() -> alist<int, B> {
|
||||||
|
fn eq_int(&&a: int, &&b: int) -> bool { a == b }
|
||||||
|
ret {eq_fn: eq_int, mut data: []};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let item_out = simplify_ast(item_in);
|
||||||
|
let item_exp = ast::ii_item(#ast(item) {
|
||||||
|
fn new_int_alist<B: copy>() -> alist<int, B> {
|
||||||
|
ret {eq_fn: eq_int, mut data: []};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
alt (item_out, item_exp) {
|
||||||
|
(ast::ii_item(item_out), ast::ii_item(item_exp)) {
|
||||||
|
assert pprust::item_to_str(item_out) == pprust::item_to_str(item_exp);
|
||||||
|
}
|
||||||
|
_ { fail; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,18 +5,20 @@ import syntax::print::pprust::path_to_str;
|
|||||||
import std::map::*;
|
import std::map::*;
|
||||||
import option::*;
|
import option::*;
|
||||||
import syntax::{ast, ast_util, visit};
|
import syntax::{ast, ast_util, visit};
|
||||||
|
import syntax::ast::{serialize_span, deserialize_span};
|
||||||
import middle::resolve;
|
import middle::resolve;
|
||||||
import syntax::codemap::span;
|
import syntax::codemap::span;
|
||||||
|
|
||||||
export annotate_freevars;
|
export annotate_freevars;
|
||||||
export freevar_map;
|
export freevar_map;
|
||||||
export freevar_info;
|
export freevar_info;
|
||||||
export freevar_entry;
|
export freevar_entry, serialize_freevar_entry, deserialize_freevar_entry;
|
||||||
export get_freevars;
|
export get_freevars;
|
||||||
export has_freevars;
|
export has_freevars;
|
||||||
|
|
||||||
// A vector of defs representing the free variables referred to in a function.
|
// A vector of defs representing the free variables referred to in a function.
|
||||||
// (The def_upvar will already have been stripped).
|
// (The def_upvar will already have been stripped).
|
||||||
|
#[auto_serialize]
|
||||||
type freevar_entry = {
|
type freevar_entry = {
|
||||||
def: ast::def, //< The variable being accessed free.
|
def: ast::def, //< The variable being accessed free.
|
||||||
span: span //< First span where it is accessed (there can be multiple)
|
span: span //< First span where it is accessed (there can be multiple)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import std::map::hashmap;
|
|||||||
// (by `break` or conditionals), and for handling loops.
|
// (by `break` or conditionals), and for handling loops.
|
||||||
|
|
||||||
// Marks expr_paths that are last uses.
|
// Marks expr_paths that are last uses.
|
||||||
|
#[auto_serialize]
|
||||||
enum is_last_use {
|
enum is_last_use {
|
||||||
is_last_use,
|
is_last_use,
|
||||||
has_last_use,
|
has_last_use,
|
||||||
|
|||||||
@@ -14,13 +14,17 @@ import middle::ty::{node_id_to_type, arg, block_ty,
|
|||||||
import util::ppaux::ty_to_str;
|
import util::ppaux::ty_to_str;
|
||||||
import std::smallintmap;
|
import std::smallintmap;
|
||||||
import std::map::{hashmap, int_hash};
|
import std::map::{hashmap, int_hash};
|
||||||
|
import std::serialization::{serialize_uint, deserialize_uint};
|
||||||
import syntax::print::pprust::*;
|
import syntax::print::pprust::*;
|
||||||
|
|
||||||
export check_crate;
|
export check_crate;
|
||||||
export method_map, method_origin, method_static, method_param, method_iface;
|
export method_map;
|
||||||
export vtable_map, vtable_res, vtable_origin, vtable_static, vtable_param,
|
export method_origin, serialize_method_origin, deserialize_method_origin;
|
||||||
vtable_iface;
|
export vtable_map;
|
||||||
|
export vtable_res;
|
||||||
|
export vtable_origin;
|
||||||
|
|
||||||
|
#[auto_serialize]
|
||||||
enum method_origin {
|
enum method_origin {
|
||||||
method_static(ast::def_id),
|
method_static(ast::def_id),
|
||||||
// iface id, method num, param num, bound num
|
// iface id, method num, param num, bound num
|
||||||
@@ -37,6 +41,7 @@ enum vtable_origin {
|
|||||||
vtable_param(uint, uint),
|
vtable_param(uint, uint),
|
||||||
vtable_iface(ast::def_id, [ty::t]),
|
vtable_iface(ast::def_id, [ty::t]),
|
||||||
}
|
}
|
||||||
|
|
||||||
type vtable_map = hashmap<ast::node_id, vtable_res>;
|
type vtable_map = hashmap<ast::node_id, vtable_res>;
|
||||||
|
|
||||||
type ty_table = hashmap<ast::def_id, ty::t>;
|
type ty_table = hashmap<ast::def_id, ty::t>;
|
||||||
|
|||||||
@@ -26,45 +26,45 @@ fn deserialize_span<D>(_d: D) -> span {
|
|||||||
ast_util::dummy_sp()
|
ast_util::dummy_sp()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type spanned<T> = {node: T, span: span};
|
type spanned<T> = {node: T, span: span};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type ident = str;
|
type ident = str;
|
||||||
|
|
||||||
// Functions may or may not have names.
|
// Functions may or may not have names.
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type fn_ident = option<ident>;
|
type fn_ident = option<ident>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type path_ = {global: bool, idents: [ident], types: [@ty]};
|
type path_ = {global: bool, idents: [ident], types: [@ty]};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type path = spanned<path_>;
|
type path = spanned<path_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type crate_num = int;
|
type crate_num = int;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type node_id = int;
|
type node_id = int;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type def_id = {crate: crate_num, node: node_id};
|
type def_id = {crate: crate_num, node: node_id};
|
||||||
|
|
||||||
const local_crate: crate_num = 0;
|
const local_crate: crate_num = 0;
|
||||||
const crate_node_id: node_id = 0;
|
const crate_node_id: node_id = 0;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum ty_param_bound {
|
enum ty_param_bound {
|
||||||
bound_copy,
|
bound_copy,
|
||||||
bound_send,
|
bound_send,
|
||||||
bound_iface(@ty),
|
bound_iface(@ty),
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type ty_param = {ident: ident, id: node_id, bounds: @[ty_param_bound]};
|
type ty_param = {ident: ident, id: node_id, bounds: @[ty_param_bound]};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum def {
|
enum def {
|
||||||
def_fn(def_id, purity),
|
def_fn(def_id, purity),
|
||||||
def_self(node_id),
|
def_self(node_id),
|
||||||
@@ -119,30 +119,30 @@ enum crate_directive_ {
|
|||||||
|
|
||||||
type crate_directive = spanned<crate_directive_>;
|
type crate_directive = spanned<crate_directive_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type meta_item = spanned<meta_item_>;
|
type meta_item = spanned<meta_item_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum meta_item_ {
|
enum meta_item_ {
|
||||||
meta_word(ident),
|
meta_word(ident),
|
||||||
meta_list(ident, [@meta_item]),
|
meta_list(ident, [@meta_item]),
|
||||||
meta_name_value(ident, lit),
|
meta_name_value(ident, lit),
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type blk = spanned<blk_>;
|
type blk = spanned<blk_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type blk_ = {view_items: [@view_item], stmts: [@stmt], expr: option<@expr>,
|
type blk_ = {view_items: [@view_item], stmts: [@stmt], expr: option<@expr>,
|
||||||
id: node_id, rules: blk_check_mode};
|
id: node_id, rules: blk_check_mode};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type pat = {id: node_id, node: pat_, span: span};
|
type pat = {id: node_id, node: pat_, span: span};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type field_pat = {ident: ident, pat: @pat};
|
type field_pat = {ident: ident, pat: @pat};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum pat_ {
|
enum pat_ {
|
||||||
pat_wild,
|
pat_wild,
|
||||||
// A pat_ident may either be a new bound variable,
|
// A pat_ident may either be a new bound variable,
|
||||||
@@ -162,10 +162,10 @@ enum pat_ {
|
|||||||
pat_range(@expr, @expr),
|
pat_range(@expr, @expr),
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum mutability { m_mutbl, m_imm, m_const, }
|
enum mutability { m_mutbl, m_imm, m_const, }
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum proto {
|
enum proto {
|
||||||
proto_bare, // native fn
|
proto_bare, // native fn
|
||||||
proto_any, // fn
|
proto_any, // fn
|
||||||
@@ -181,7 +181,7 @@ pure fn is_blockish(p: ast::proto) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum binop {
|
enum binop {
|
||||||
add,
|
add,
|
||||||
subtract,
|
subtract,
|
||||||
@@ -204,7 +204,7 @@ enum binop {
|
|||||||
gt,
|
gt,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum unop {
|
enum unop {
|
||||||
box(mutability),
|
box(mutability),
|
||||||
uniq(mutability),
|
uniq(mutability),
|
||||||
@@ -213,23 +213,23 @@ enum unop {
|
|||||||
|
|
||||||
// Generally, after typeck you can get the inferred value
|
// Generally, after typeck you can get the inferred value
|
||||||
// using ty::resolved_T(...).
|
// using ty::resolved_T(...).
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum inferable<T> {
|
enum inferable<T> {
|
||||||
expl(T), infer(node_id)
|
expl(T), infer(node_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// "resolved" mode: the real modes.
|
// "resolved" mode: the real modes.
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum rmode { by_ref, by_val, by_mutbl_ref, by_move, by_copy }
|
enum rmode { by_ref, by_val, by_mutbl_ref, by_move, by_copy }
|
||||||
|
|
||||||
// inferable mode.
|
// inferable mode.
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type mode = inferable<rmode>;
|
type mode = inferable<rmode>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type stmt = spanned<stmt_>;
|
type stmt = spanned<stmt_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum stmt_ {
|
enum stmt_ {
|
||||||
stmt_decl(@decl, node_id),
|
stmt_decl(@decl, node_id),
|
||||||
|
|
||||||
@@ -240,48 +240,48 @@ enum stmt_ {
|
|||||||
stmt_semi(@expr, node_id),
|
stmt_semi(@expr, node_id),
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum init_op { init_assign, init_move, }
|
enum init_op { init_assign, init_move, }
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type initializer = {op: init_op, expr: @expr};
|
type initializer = {op: init_op, expr: @expr};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type local_ = // FIXME: should really be a refinement on pat
|
type local_ = // FIXME: should really be a refinement on pat
|
||||||
{is_mutbl: bool, ty: @ty, pat: @pat,
|
{is_mutbl: bool, ty: @ty, pat: @pat,
|
||||||
init: option<initializer>, id: node_id};
|
init: option<initializer>, id: node_id};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type local = spanned<local_>;
|
type local = spanned<local_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type decl = spanned<decl_>;
|
type decl = spanned<decl_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum decl_ { decl_local([@local]), decl_item(@item), }
|
enum decl_ { decl_local([@local]), decl_item(@item), }
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type arm = {pats: [@pat], guard: option<@expr>, body: blk};
|
type arm = {pats: [@pat], guard: option<@expr>, body: blk};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type field_ = {mutbl: mutability, ident: ident, expr: @expr};
|
type field_ = {mutbl: mutability, ident: ident, expr: @expr};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type field = spanned<field_>;
|
type field = spanned<field_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum blk_check_mode { default_blk, unchecked_blk, unsafe_blk, }
|
enum blk_check_mode { default_blk, unchecked_blk, unsafe_blk, }
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum expr_check_mode { claimed_expr, checked_expr, }
|
enum expr_check_mode { claimed_expr, checked_expr, }
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type expr = {id: node_id, node: expr_, span: span};
|
type expr = {id: node_id, node: expr_, span: span};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum alt_mode { alt_check, alt_exhaustive, }
|
enum alt_mode { alt_check, alt_exhaustive, }
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum expr_ {
|
enum expr_ {
|
||||||
expr_vec([@expr], mutability),
|
expr_vec([@expr], mutability),
|
||||||
expr_rec([field], option<@expr>),
|
expr_rec([field], option<@expr>),
|
||||||
@@ -337,14 +337,14 @@ enum expr_ {
|
|||||||
expr_mac(mac),
|
expr_mac(mac),
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type capture_item = {
|
type capture_item = {
|
||||||
id: int,
|
id: int,
|
||||||
name: ident, // Currently, can only capture a local var.
|
name: ident, // Currently, can only capture a local var.
|
||||||
span: span
|
span: span
|
||||||
};
|
};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type capture_clause = {
|
type capture_clause = {
|
||||||
copies: [@capture_item],
|
copies: [@capture_item],
|
||||||
moves: [@capture_item]
|
moves: [@capture_item]
|
||||||
@@ -359,19 +359,19 @@ enum blk_sort {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type mac = spanned<mac_>;
|
type mac = spanned<mac_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type mac_arg = option<@expr>;
|
type mac_arg = option<@expr>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type mac_body_ = {span: span};
|
type mac_body_ = {span: span};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type mac_body = option<mac_body_>;
|
type mac_body = option<mac_body_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum mac_ {
|
enum mac_ {
|
||||||
mac_invoc(@path, mac_arg, mac_body),
|
mac_invoc(@path, mac_arg, mac_body),
|
||||||
mac_embed_type(@ty),
|
mac_embed_type(@ty),
|
||||||
@@ -382,10 +382,10 @@ enum mac_ {
|
|||||||
mac_var(uint)
|
mac_var(uint)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type lit = spanned<lit_>;
|
type lit = spanned<lit_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum lit_ {
|
enum lit_ {
|
||||||
lit_str(str),
|
lit_str(str),
|
||||||
lit_int(i64, int_ty),
|
lit_int(i64, int_ty),
|
||||||
@@ -397,33 +397,33 @@ enum lit_ {
|
|||||||
|
|
||||||
// NB: If you change this, you'll probably want to change the corresponding
|
// NB: If you change this, you'll probably want to change the corresponding
|
||||||
// type structure in middle/ty.rs as well.
|
// type structure in middle/ty.rs as well.
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type mt = {ty: @ty, mutbl: mutability};
|
type mt = {ty: @ty, mutbl: mutability};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type ty_field_ = {ident: ident, mt: mt};
|
type ty_field_ = {ident: ident, mt: mt};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type ty_field = spanned<ty_field_>;
|
type ty_field = spanned<ty_field_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type ty_method = {ident: ident, attrs: [attribute],
|
type ty_method = {ident: ident, attrs: [attribute],
|
||||||
decl: fn_decl, tps: [ty_param], span: span};
|
decl: fn_decl, tps: [ty_param], span: span};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, }
|
enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, }
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
|
enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum float_ty { ty_f, ty_f32, ty_f64, }
|
enum float_ty { ty_f, ty_f32, ty_f64, }
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type ty = {id: node_id, node: ty_, span: span};
|
type ty = {id: node_id, node: ty_, span: span};
|
||||||
|
|
||||||
// Not represented directly in the AST, referred to by name through a ty_path.
|
// Not represented directly in the AST, referred to by name through a ty_path.
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum prim_ty {
|
enum prim_ty {
|
||||||
ty_int(int_ty),
|
ty_int(int_ty),
|
||||||
ty_uint(uint_ty),
|
ty_uint(uint_ty),
|
||||||
@@ -432,17 +432,17 @@ enum prim_ty {
|
|||||||
ty_bool,
|
ty_bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type region = {id: node_id, node: region_};
|
type region = {id: node_id, node: region_};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum region_ {
|
enum region_ {
|
||||||
re_inferred,
|
re_inferred,
|
||||||
re_named(ident),
|
re_named(ident),
|
||||||
re_self
|
re_self
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum ty_ {
|
enum ty_ {
|
||||||
ty_nil,
|
ty_nil,
|
||||||
ty_bot, /* bottom type */
|
ty_bot, /* bottom type */
|
||||||
@@ -472,19 +472,19 @@ 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
|
So, the constr_arg type is parameterized: it's instantiated with uint for
|
||||||
declarations, and ident for uses.
|
declarations, and ident for uses.
|
||||||
*/
|
*/
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum constr_arg_general_<T> { carg_base, carg_ident(T), carg_lit(@lit), }
|
enum constr_arg_general_<T> { carg_base, carg_ident(T), carg_lit(@lit), }
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type fn_constr_arg = constr_arg_general_<uint>;
|
type fn_constr_arg = constr_arg_general_<uint>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type sp_constr_arg<T> = spanned<constr_arg_general_<T>>;
|
type sp_constr_arg<T> = spanned<constr_arg_general_<T>>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type ty_constr_arg = sp_constr_arg<@path>;
|
type ty_constr_arg = sp_constr_arg<@path>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type constr_arg = spanned<fn_constr_arg>;
|
type constr_arg = spanned<fn_constr_arg>;
|
||||||
|
|
||||||
// Constrained types' args are parameterized by paths, since
|
// Constrained types' args are parameterized by paths, since
|
||||||
@@ -492,34 +492,34 @@ type constr_arg = spanned<fn_constr_arg>;
|
|||||||
// The implicit root of such path, in the constraint-list for a
|
// The implicit root of such path, in the constraint-list for a
|
||||||
// constrained type, is * (referring to the base record)
|
// constrained type, is * (referring to the base record)
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type constr_general_<ARG, ID> =
|
type constr_general_<ARG, ID> =
|
||||||
{path: @path, args: [@spanned<constr_arg_general_<ARG>>], id: ID};
|
{path: @path, args: [@spanned<constr_arg_general_<ARG>>], id: ID};
|
||||||
|
|
||||||
// In the front end, constraints have a node ID attached.
|
// In the front end, constraints have a node ID attached.
|
||||||
// Typeck turns this to a def_id, using the output of resolve.
|
// Typeck turns this to a def_id, using the output of resolve.
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type constr_general<ARG> = spanned<constr_general_<ARG, node_id>>;
|
type constr_general<ARG> = spanned<constr_general_<ARG, node_id>>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type constr_ = constr_general_<uint, node_id>;
|
type constr_ = constr_general_<uint, node_id>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type constr = spanned<constr_general_<uint, node_id>>;
|
type constr = spanned<constr_general_<uint, node_id>>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type ty_constr_ = constr_general_<@path, node_id>;
|
type ty_constr_ = constr_general_<@path, node_id>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type ty_constr = spanned<ty_constr_>;
|
type ty_constr = spanned<ty_constr_>;
|
||||||
|
|
||||||
/* The parser generates ast::constrs; resolve generates
|
/* The parser generates ast::constrs; resolve generates
|
||||||
a mapping from each function to a list of ty::constr_defs,
|
a mapping from each function to a list of ty::constr_defs,
|
||||||
corresponding to these. */
|
corresponding to these. */
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type arg = {mode: mode, ty: @ty, ident: ident, id: node_id};
|
type arg = {mode: mode, ty: @ty, ident: ident, id: node_id};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type fn_decl =
|
type fn_decl =
|
||||||
{inputs: [arg],
|
{inputs: [arg],
|
||||||
output: @ty,
|
output: @ty,
|
||||||
@@ -527,7 +527,7 @@ type fn_decl =
|
|||||||
cf: ret_style,
|
cf: ret_style,
|
||||||
constraints: [@constr]};
|
constraints: [@constr]};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum purity {
|
enum purity {
|
||||||
pure_fn, // declared with "pure fn"
|
pure_fn, // declared with "pure fn"
|
||||||
unsafe_fn, // declared with "unsafe fn"
|
unsafe_fn, // declared with "unsafe fn"
|
||||||
@@ -535,58 +535,58 @@ enum purity {
|
|||||||
crust_fn, // declared with "crust fn"
|
crust_fn, // declared with "crust fn"
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum ret_style {
|
enum ret_style {
|
||||||
noreturn, // functions with return type _|_ that always
|
noreturn, // functions with return type _|_ that always
|
||||||
// raise an error or exit (i.e. never return to the caller)
|
// raise an error or exit (i.e. never return to the caller)
|
||||||
return_val, // everything else
|
return_val, // everything else
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type method = {ident: ident, attrs: [attribute],
|
type method = {ident: ident, attrs: [attribute],
|
||||||
tps: [ty_param], decl: fn_decl, body: blk,
|
tps: [ty_param], decl: fn_decl, body: blk,
|
||||||
id: node_id, span: span, self_id: node_id};
|
id: node_id, span: span, self_id: node_id};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type _mod = {view_items: [@view_item], items: [@item]};
|
type _mod = {view_items: [@view_item], items: [@item]};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum native_abi {
|
enum native_abi {
|
||||||
native_abi_rust_intrinsic,
|
native_abi_rust_intrinsic,
|
||||||
native_abi_cdecl,
|
native_abi_cdecl,
|
||||||
native_abi_stdcall,
|
native_abi_stdcall,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type native_mod =
|
type native_mod =
|
||||||
{view_items: [@view_item],
|
{view_items: [@view_item],
|
||||||
items: [@native_item]};
|
items: [@native_item]};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type variant_arg = {ty: @ty, id: node_id};
|
type variant_arg = {ty: @ty, id: node_id};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type variant_ = {name: ident, attrs: [attribute], args: [variant_arg],
|
type variant_ = {name: ident, attrs: [attribute], args: [variant_arg],
|
||||||
id: node_id, disr_expr: option<@expr>};
|
id: node_id, disr_expr: option<@expr>};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type variant = spanned<variant_>;
|
type variant = spanned<variant_>;
|
||||||
|
|
||||||
// FIXME: May want to just use path here, which would allow things like
|
// FIXME: May want to just use path here, which would allow things like
|
||||||
// 'import ::foo'
|
// 'import ::foo'
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type simple_path = [ident];
|
type simple_path = [ident];
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type path_list_ident_ = {name: ident, id: node_id};
|
type path_list_ident_ = {name: ident, id: node_id};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type path_list_ident = spanned<path_list_ident_>;
|
type path_list_ident = spanned<path_list_ident_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type view_path = spanned<view_path_>;
|
type view_path = spanned<view_path_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum view_path_ {
|
enum view_path_ {
|
||||||
|
|
||||||
// quux = foo::bar::baz
|
// quux = foo::bar::baz
|
||||||
@@ -603,10 +603,10 @@ enum view_path_ {
|
|||||||
view_path_list(@simple_path, [path_list_ident], node_id)
|
view_path_list(@simple_path, [path_list_ident], node_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type view_item = spanned<view_item_>;
|
type view_item = spanned<view_item_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum view_item_ {
|
enum view_item_ {
|
||||||
view_item_use(ident, [@meta_item], node_id),
|
view_item_use(ident, [@meta_item], node_id),
|
||||||
view_item_import([@view_path]),
|
view_item_import([@view_path]),
|
||||||
@@ -614,23 +614,23 @@ enum view_item_ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Meta-data associated with an item
|
// Meta-data associated with an item
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type attribute = spanned<attribute_>;
|
type attribute = spanned<attribute_>;
|
||||||
|
|
||||||
// Distinguishes between attributes that decorate items and attributes that
|
// Distinguishes between attributes that decorate items and attributes that
|
||||||
// are contained as statements within items. These two cases need to be
|
// are contained as statements within items. These two cases need to be
|
||||||
// distinguished for pretty-printing.
|
// distinguished for pretty-printing.
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum attr_style { attr_outer, attr_inner, }
|
enum attr_style { attr_outer, attr_inner, }
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type attribute_ = {style: attr_style, value: meta_item};
|
type attribute_ = {style: attr_style, value: meta_item};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type item = {ident: ident, attrs: [attribute],
|
type item = {ident: ident, attrs: [attribute],
|
||||||
id: node_id, node: item_, span: span};
|
id: node_id, node: item_, span: span};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum item_ {
|
enum item_ {
|
||||||
item_const(@ty, @expr),
|
item_const(@ty, @expr),
|
||||||
item_fn(fn_decl, [ty_param], blk),
|
item_fn(fn_decl, [ty_param], blk),
|
||||||
@@ -650,13 +650,13 @@ enum item_ {
|
|||||||
@ty /* self */, [@method]),
|
@ty /* self */, [@method]),
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type class_item_ = {privacy: privacy, decl: class_member};
|
type class_item_ = {privacy: privacy, decl: class_member};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type class_item = spanned<class_item_>;
|
type class_item = spanned<class_item_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum class_member {
|
enum class_member {
|
||||||
instance_var(ident, @ty, class_mutability, node_id),
|
instance_var(ident, @ty, class_mutability, node_id),
|
||||||
class_method(@item) // FIXME: methods aren't allowed to be
|
class_method(@item) // FIXME: methods aren't allowed to be
|
||||||
@@ -665,21 +665,21 @@ enum class_member {
|
|||||||
// item to separate out things with type params?
|
// item to separate out things with type params?
|
||||||
}
|
}
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum class_mutability { class_mutable, class_immutable }
|
enum class_mutability { class_mutable, class_immutable }
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum privacy { priv, pub }
|
enum privacy { priv, pub }
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type class_ctor = spanned<class_ctor_>;
|
type class_ctor = spanned<class_ctor_>;
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type class_ctor_ = {id: node_id,
|
type class_ctor_ = {id: node_id,
|
||||||
dec: fn_decl,
|
dec: fn_decl,
|
||||||
body: blk};
|
body: blk};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
type native_item =
|
type native_item =
|
||||||
{ident: ident,
|
{ident: ident,
|
||||||
attrs: [attribute],
|
attrs: [attribute],
|
||||||
@@ -687,7 +687,7 @@ type native_item =
|
|||||||
id: node_id,
|
id: node_id,
|
||||||
span: span};
|
span: span};
|
||||||
|
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum native_item_ {
|
enum native_item_ {
|
||||||
native_item_fn(fn_decl, [ty_param]),
|
native_item_fn(fn_decl, [ty_param]),
|
||||||
}
|
}
|
||||||
@@ -695,7 +695,7 @@ enum native_item_ {
|
|||||||
// The data we save and restore about an inlined item or method. This is not
|
// 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
|
// part of the AST that we parse from a file, but it becomes part of the tree
|
||||||
// that we trans.
|
// that we trans.
|
||||||
/*#[auto_serialize]*/
|
#[auto_serialize]
|
||||||
enum inlined_item {
|
enum inlined_item {
|
||||||
ii_item(@item),
|
ii_item(@item),
|
||||||
ii_method(def_id /* impl id */, @method)
|
ii_method(def_id /* impl id */, @method)
|
||||||
|
|||||||
@@ -117,13 +117,14 @@ fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item {
|
|||||||
meta_name_value(fld.fold_ident(id), s)
|
meta_name_value(fld.fold_ident(id), s)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
span: mi.span};
|
span: fld.new_span(mi.span)};
|
||||||
}
|
}
|
||||||
//used in noop_fold_item and noop_fold_crate
|
//used in noop_fold_item and noop_fold_crate
|
||||||
fn fold_attribute_(at: attribute, fmi: fn@(&&@meta_item) -> @meta_item) ->
|
fn fold_attribute_(at: attribute, fld: ast_fold) ->
|
||||||
attribute {
|
attribute {
|
||||||
ret {node: {style: at.node.style, value: *fmi(@at.node.value)},
|
ret {node: {style: at.node.style,
|
||||||
span: at.span};
|
value: *fold_meta_item_(@at.node.value, fld)},
|
||||||
|
span: fld.new_span(at.span)};
|
||||||
}
|
}
|
||||||
//used in noop_fold_native_item and noop_fold_fn_decl
|
//used in noop_fold_native_item and noop_fold_fn_decl
|
||||||
fn fold_arg_(a: arg, fld: ast_fold) -> arg {
|
fn fold_arg_(a: arg, fld: ast_fold) -> arg {
|
||||||
@@ -148,7 +149,7 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac {
|
|||||||
mac_aq(_,_) { /* fixme */ m.node }
|
mac_aq(_,_) { /* fixme */ m.node }
|
||||||
mac_var(_) { /* fixme */ m.node }
|
mac_var(_) { /* fixme */ m.node }
|
||||||
},
|
},
|
||||||
span: m.span};
|
span: fld.new_span(m.span)};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl {
|
fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl {
|
||||||
@@ -178,7 +179,7 @@ fn fold_ty_params(tps: [ty_param], fld: ast_fold) -> [ty_param] {
|
|||||||
|
|
||||||
fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ {
|
fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ {
|
||||||
let fold_meta_item = bind fold_meta_item_(_, fld);
|
let fold_meta_item = bind fold_meta_item_(_, fld);
|
||||||
let fold_attribute = bind fold_attribute_(_, fold_meta_item);
|
let fold_attribute = bind fold_attribute_(_, fld);
|
||||||
|
|
||||||
ret {directives: vec::map(c.directives, fld.fold_crate_directive),
|
ret {directives: vec::map(c.directives, fld.fold_crate_directive),
|
||||||
module: fld.fold_mod(c.module),
|
module: fld.fold_mod(c.module),
|
||||||
@@ -208,8 +209,7 @@ fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ {
|
|||||||
|
|
||||||
fn noop_fold_native_item(&&ni: @native_item, fld: ast_fold) -> @native_item {
|
fn noop_fold_native_item(&&ni: @native_item, fld: ast_fold) -> @native_item {
|
||||||
let fold_arg = bind fold_arg_(_, fld);
|
let fold_arg = bind fold_arg_(_, fld);
|
||||||
let fold_meta_item = bind fold_meta_item_(_, fld);
|
let fold_attribute = bind fold_attribute_(_, fld);
|
||||||
let fold_attribute = bind fold_attribute_(_, fold_meta_item);
|
|
||||||
|
|
||||||
ret @{ident: fld.fold_ident(ni.ident),
|
ret @{ident: fld.fold_ident(ni.ident),
|
||||||
attrs: vec::map(ni.attrs, fold_attribute),
|
attrs: vec::map(ni.attrs, fold_attribute),
|
||||||
@@ -231,8 +231,7 @@ fn noop_fold_native_item(&&ni: @native_item, fld: ast_fold) -> @native_item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn noop_fold_item(&&i: @item, fld: ast_fold) -> @item {
|
fn noop_fold_item(&&i: @item, fld: ast_fold) -> @item {
|
||||||
let fold_meta_item = bind fold_meta_item_(_, fld);
|
let fold_attribute = bind fold_attribute_(_, fld);
|
||||||
let fold_attribute = bind fold_attribute_(_, fold_meta_item);
|
|
||||||
|
|
||||||
ret @{ident: fld.fold_ident(i.ident),
|
ret @{ident: fld.fold_ident(i.ident),
|
||||||
attrs: vec::map(i.attrs, fold_attribute),
|
attrs: vec::map(i.attrs, fold_attribute),
|
||||||
@@ -252,7 +251,7 @@ fn noop_fold_class_item(&&ci: @class_item, fld: ast_fold)
|
|||||||
}
|
}
|
||||||
class_method(i) { class_method(fld.fold_item(i)) }
|
class_method(i) { class_method(fld.fold_item(i)) }
|
||||||
}},
|
}},
|
||||||
span: ci.span}
|
span: fld.new_span(ci.span)}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
|
fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
|
||||||
@@ -374,7 +373,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
|
|||||||
{mutbl: field.node.mutbl,
|
{mutbl: field.node.mutbl,
|
||||||
ident: fld.fold_ident(field.node.ident),
|
ident: fld.fold_ident(field.node.ident),
|
||||||
expr: fld.fold_expr(field.node.expr)},
|
expr: fld.fold_expr(field.node.expr)},
|
||||||
span: field.span};
|
span: fld.new_span(field.span)};
|
||||||
}
|
}
|
||||||
let fold_field = bind fold_field_(_, fld);
|
let fold_field = bind fold_field_(_, fld);
|
||||||
|
|
||||||
@@ -519,8 +518,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
|
|||||||
let fold_variant_arg = bind fold_variant_arg_(_, fld);
|
let fold_variant_arg = bind fold_variant_arg_(_, fld);
|
||||||
let args = vec::map(v.args, fold_variant_arg);
|
let args = vec::map(v.args, fold_variant_arg);
|
||||||
|
|
||||||
let fold_meta_item = bind fold_meta_item_(_, fld);
|
let fold_attribute = bind fold_attribute_(_, fld);
|
||||||
let fold_attribute = bind fold_attribute_(_, fold_meta_item);
|
|
||||||
let attrs = vec::map(v.attrs, fold_attribute);
|
let attrs = vec::map(v.attrs, fold_attribute);
|
||||||
|
|
||||||
let de = alt v.disr_expr {
|
let de = alt v.disr_expr {
|
||||||
|
|||||||
Reference in New Issue
Block a user