Remove effect system from src.
This commit is contained in:
parent
d9d5eb82a7
commit
d2bd07dcb0
83 changed files with 507 additions and 1037 deletions
|
|
@ -44,7 +44,7 @@ fn default_environment(session.session sess,
|
|||
);
|
||||
}
|
||||
|
||||
impure fn parse_input(session.session sess,
|
||||
fn parse_input(session.session sess,
|
||||
parser.parser p,
|
||||
str input) -> @front.ast.crate {
|
||||
if (_str.ends_with(input, ".rc")) {
|
||||
|
|
@ -56,7 +56,7 @@ impure fn parse_input(session.session sess,
|
|||
fail;
|
||||
}
|
||||
|
||||
impure fn compile_input(session.session sess,
|
||||
fn compile_input(session.session sess,
|
||||
eval.env env,
|
||||
str input, str output,
|
||||
bool shared,
|
||||
|
|
@ -79,7 +79,7 @@ impure fn compile_input(session.session sess,
|
|||
ot);
|
||||
}
|
||||
|
||||
impure fn pretty_print_input(session.session sess,
|
||||
fn pretty_print_input(session.session sess,
|
||||
eval.env env,
|
||||
str input) {
|
||||
auto def = tup(0, 0);
|
||||
|
|
@ -116,7 +116,7 @@ fn get_os() -> session.os {
|
|||
if (_str.eq(s, "linux")) { ret session.os_linux; }
|
||||
}
|
||||
|
||||
impure fn main(vec[str] args) {
|
||||
fn main(vec[str] args) {
|
||||
|
||||
// FIXME: don't hard-wire this.
|
||||
auto target_cfg = rec(os = get_os(),
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ tag crate_directive_ {
|
|||
cdir_view_item(@view_item);
|
||||
cdir_meta(vec[@meta_item]);
|
||||
cdir_syntax(path);
|
||||
cdir_auth(path, effect);
|
||||
cdir_auth(path, _auth);
|
||||
}
|
||||
type crate_directive = spanned[crate_directive_];
|
||||
|
||||
|
|
@ -130,10 +130,8 @@ tag layer {
|
|||
layer_gc;
|
||||
}
|
||||
|
||||
tag effect {
|
||||
eff_pure;
|
||||
eff_impure;
|
||||
eff_unsafe;
|
||||
tag _auth {
|
||||
auth_unsafe;
|
||||
}
|
||||
|
||||
tag proto {
|
||||
|
|
@ -314,7 +312,7 @@ tag lit_ {
|
|||
type mt = rec(@ty ty, mutability mut);
|
||||
type ty_field = rec(ident ident, mt mt);
|
||||
type ty_arg = rec(mode mode, @ty ty);
|
||||
type ty_method = rec(effect effect, proto proto, ident ident,
|
||||
type ty_method = rec(proto proto, ident ident,
|
||||
vec[ty_arg] inputs, @ty output);
|
||||
type ty = spanned[ty_];
|
||||
tag ty_ {
|
||||
|
|
@ -332,7 +330,7 @@ tag ty_ {
|
|||
ty_chan(@ty);
|
||||
ty_tup(vec[mt]);
|
||||
ty_rec(vec[ty_field]);
|
||||
ty_fn(effect, proto, vec[ty_arg], @ty);
|
||||
ty_fn(proto, vec[ty_arg], @ty);
|
||||
ty_obj(vec[ty_method]);
|
||||
ty_path(path, option.t[def]);
|
||||
ty_type;
|
||||
|
|
@ -348,8 +346,7 @@ type constr_ = rec(path path, vec[@constr_arg] args);
|
|||
type constr = spanned[constr_];
|
||||
|
||||
type arg = rec(mode mode, @ty ty, ident ident, def_id id);
|
||||
type fn_decl = rec(effect effect,
|
||||
vec[arg] inputs,
|
||||
type fn_decl = rec(vec[arg] inputs,
|
||||
@ty output);
|
||||
type _fn = rec(fn_decl decl,
|
||||
proto proto,
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ fn peek(@pstate st) -> u8 {
|
|||
if (st.pos < st.len) {ret st.rep.(st.pos) as u8;}
|
||||
else {ret ' ' as u8;}
|
||||
}
|
||||
impure fn next(@pstate st) -> u8 { // ?? somehow not recognized as impure
|
||||
fn next(@pstate st) -> u8 { // ?? somehow not recognized as impure
|
||||
if (st.pos >= st.len) {fail;}
|
||||
auto ch = st.rep.(st.pos);
|
||||
st.pos = st.pos + 1u;
|
||||
|
|
@ -74,12 +74,12 @@ fn parse_ty_str(str rep, str_def sd) -> @ty.t {
|
|||
ret result;
|
||||
}
|
||||
|
||||
impure fn parse_ty(@pstate st, str_def sd) -> @ty.t {
|
||||
fn parse_ty(@pstate st, str_def sd) -> @ty.t {
|
||||
ret @rec(struct=parse_sty(st, sd),
|
||||
cname=option.none[str]);
|
||||
}
|
||||
|
||||
impure fn parse_mt(@pstate st, str_def sd) -> ty.mt {
|
||||
fn parse_mt(@pstate st, str_def sd) -> ty.mt {
|
||||
auto mut;
|
||||
alt (peek(st) as char) {
|
||||
case ('m') {next(st); mut = ast.mut;}
|
||||
|
|
@ -89,7 +89,7 @@ impure fn parse_mt(@pstate st, str_def sd) -> ty.mt {
|
|||
ret rec(ty=parse_ty(st, sd), mut=mut);
|
||||
}
|
||||
|
||||
impure fn parse_def(@pstate st, str_def sd) -> ast.def_id {
|
||||
fn parse_def(@pstate st, str_def sd) -> ast.def_id {
|
||||
auto def = "";
|
||||
while (peek(st) as char != '|') {
|
||||
def += _str.unsafe_from_byte(next(st));
|
||||
|
|
@ -98,7 +98,7 @@ impure fn parse_def(@pstate st, str_def sd) -> ast.def_id {
|
|||
ret sd(def);
|
||||
}
|
||||
|
||||
impure fn parse_sty(@pstate st, str_def sd) -> ty.sty {
|
||||
fn parse_sty(@pstate st, str_def sd) -> ty.sty {
|
||||
alt (next(st) as char) {
|
||||
case ('n') {ret ty.ty_nil;}
|
||||
case ('b') {ret ty.ty_bool;}
|
||||
|
|
@ -205,7 +205,7 @@ impure fn parse_sty(@pstate st, str_def sd) -> ty.sty {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn parse_int(@pstate st) -> int {
|
||||
fn parse_int(@pstate st) -> int {
|
||||
auto n = 0;
|
||||
while (true) {
|
||||
auto cur = peek(st) as char;
|
||||
|
|
@ -217,7 +217,7 @@ impure fn parse_int(@pstate st) -> int {
|
|||
ret n;
|
||||
}
|
||||
|
||||
impure fn parse_ty_fn(@pstate st, str_def sd) -> tup(vec[ty.arg], @ty.t) {
|
||||
fn parse_ty_fn(@pstate st, str_def sd) -> tup(vec[ty.arg], @ty.t) {
|
||||
check(next(st) as char == '[');
|
||||
let vec[ty.arg] inputs = vec();
|
||||
while (peek(st) as char != ']') {
|
||||
|
|
@ -565,7 +565,7 @@ fn get_tag_variants(session.session sess, ast.def_id def)
|
|||
ret infos;
|
||||
}
|
||||
|
||||
impure fn list_file_metadata(str path, io.writer out) {
|
||||
fn list_file_metadata(str path, io.writer out) {
|
||||
alt (get_metadata_section(path)) {
|
||||
case (option.some[vec[u8]](?bytes)) {
|
||||
list_crate_metadata(bytes, out);
|
||||
|
|
@ -584,7 +584,7 @@ fn read_path(&ebml.doc d) -> tup(str, uint) {
|
|||
ret tup(path, pos);
|
||||
}
|
||||
|
||||
impure fn list_crate_metadata(vec[u8] bytes, io.writer out) {
|
||||
fn list_crate_metadata(vec[u8] bytes, io.writer out) {
|
||||
auto md = ebml.new_doc(bytes);
|
||||
auto paths = ebml.get_doc(md, metadata.tag_paths);
|
||||
auto items = ebml.get_doc(md, metadata.tag_items);
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ fn val_eq(session.session sess, span sp, val av, val bv) -> bool {
|
|||
fail;
|
||||
}
|
||||
|
||||
impure fn eval_crate_directives(ctx cx,
|
||||
fn eval_crate_directives(ctx cx,
|
||||
env e,
|
||||
vec[@ast.crate_directive] cdirs,
|
||||
str prefix,
|
||||
|
|
@ -240,7 +240,7 @@ impure fn eval_crate_directives(ctx cx,
|
|||
}
|
||||
|
||||
|
||||
impure fn eval_crate_directives_to_mod(ctx cx, env e,
|
||||
fn eval_crate_directives_to_mod(ctx cx, env e,
|
||||
vec[@ast.crate_directive] cdirs,
|
||||
str prefix) -> ast._mod {
|
||||
let vec[@ast.view_item] view_items = vec();
|
||||
|
|
@ -254,7 +254,7 @@ impure fn eval_crate_directives_to_mod(ctx cx, env e,
|
|||
}
|
||||
|
||||
|
||||
impure fn eval_crate_directive_block(ctx cx,
|
||||
fn eval_crate_directive_block(ctx cx,
|
||||
env e,
|
||||
&ast.block blk,
|
||||
str prefix,
|
||||
|
|
@ -277,7 +277,7 @@ impure fn eval_crate_directive_block(ctx cx,
|
|||
}
|
||||
}
|
||||
|
||||
impure fn eval_crate_directive_expr(ctx cx,
|
||||
fn eval_crate_directive_expr(ctx cx,
|
||||
env e,
|
||||
@ast.expr x,
|
||||
str prefix,
|
||||
|
|
@ -349,7 +349,7 @@ impure fn eval_crate_directive_expr(ctx cx,
|
|||
}
|
||||
}
|
||||
|
||||
impure fn eval_crate_directive(ctx cx,
|
||||
fn eval_crate_directive(ctx cx,
|
||||
env e,
|
||||
@ast.crate_directive cdir,
|
||||
str prefix,
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ state type reader = state obj {
|
|||
fn is_eof() -> bool;
|
||||
fn curr() -> char;
|
||||
fn next() -> char;
|
||||
impure fn init();
|
||||
impure fn bump();
|
||||
fn init();
|
||||
fn bump();
|
||||
fn mark();
|
||||
fn get_mark_chpos() -> uint;
|
||||
fn get_chpos() -> uint;
|
||||
|
|
@ -24,7 +24,7 @@ state type reader = state obj {
|
|||
fn get_filemap() -> codemap.filemap;
|
||||
};
|
||||
|
||||
impure fn new_reader(io.reader rdr, str filename, codemap.filemap filemap)
|
||||
fn new_reader(io.reader rdr, str filename, codemap.filemap filemap)
|
||||
-> reader {
|
||||
state obj reader(str file,
|
||||
uint len,
|
||||
|
|
@ -53,7 +53,7 @@ impure fn new_reader(io.reader rdr, str filename, codemap.filemap filemap)
|
|||
else {ret -1 as char;}
|
||||
}
|
||||
|
||||
impure fn init() {
|
||||
fn init() {
|
||||
if (pos < len) {
|
||||
auto next = _str.char_range_at(file, pos);
|
||||
pos = next._1;
|
||||
|
|
@ -61,7 +61,7 @@ impure fn new_reader(io.reader rdr, str filename, codemap.filemap filemap)
|
|||
}
|
||||
}
|
||||
|
||||
impure fn bump() {
|
||||
fn bump() {
|
||||
if (pos < len) {
|
||||
chpos += 1u;
|
||||
if (ch == '\n') {
|
||||
|
|
@ -135,7 +135,6 @@ fn keyword_table() -> std.map.hashmap[str, token.token] {
|
|||
keywords.insert("state", token.STATE);
|
||||
keywords.insert("gc", token.GC);
|
||||
|
||||
keywords.insert("impure", token.IMPURE);
|
||||
keywords.insert("unsafe", token.UNSAFE);
|
||||
|
||||
keywords.insert("native", token.NATIVE);
|
||||
|
|
@ -274,14 +273,14 @@ fn is_whitespace(char c) -> bool {
|
|||
ret c == ' ' || c == '\t' || c == '\r' || c == '\n';
|
||||
}
|
||||
|
||||
impure fn consume_any_whitespace(reader rdr) {
|
||||
fn consume_any_whitespace(reader rdr) {
|
||||
while (is_whitespace(rdr.curr())) {
|
||||
rdr.bump();
|
||||
}
|
||||
be consume_any_line_comment(rdr);
|
||||
}
|
||||
|
||||
impure fn consume_any_line_comment(reader rdr) {
|
||||
fn consume_any_line_comment(reader rdr) {
|
||||
if (rdr.curr() == '/') {
|
||||
alt (rdr.next()) {
|
||||
case ('/') {
|
||||
|
|
@ -304,7 +303,7 @@ impure fn consume_any_line_comment(reader rdr) {
|
|||
}
|
||||
|
||||
|
||||
impure fn consume_block_comment(reader rdr) {
|
||||
fn consume_block_comment(reader rdr) {
|
||||
let int level = 1;
|
||||
while (level > 0) {
|
||||
if (rdr.curr() == '/' && rdr.next() == '*') {
|
||||
|
|
@ -342,7 +341,7 @@ fn digits_to_string(str s) -> int {
|
|||
ret accum_int;
|
||||
}
|
||||
|
||||
impure fn scan_exponent(reader rdr) -> option.t[str] {
|
||||
fn scan_exponent(reader rdr) -> option.t[str] {
|
||||
auto c = rdr.curr();
|
||||
auto res = "";
|
||||
|
||||
|
|
@ -368,7 +367,7 @@ impure fn scan_exponent(reader rdr) -> option.t[str] {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn scan_dec_digits(reader rdr) -> str {
|
||||
fn scan_dec_digits(reader rdr) -> str {
|
||||
|
||||
auto c = rdr.curr();
|
||||
let str res = "";
|
||||
|
|
@ -384,7 +383,7 @@ impure fn scan_dec_digits(reader rdr) -> str {
|
|||
ret res;
|
||||
}
|
||||
|
||||
impure fn scan_number(mutable char c, reader rdr) -> token.token {
|
||||
fn scan_number(mutable char c, reader rdr) -> token.token {
|
||||
auto accum_int = 0;
|
||||
let str dec_str = "";
|
||||
let bool is_dec_integer = false;
|
||||
|
|
@ -527,7 +526,7 @@ impure fn scan_number(mutable char c, reader rdr) -> token.token {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn scan_numeric_escape(reader rdr) -> char {
|
||||
fn scan_numeric_escape(reader rdr) -> char {
|
||||
|
||||
auto n_hex_digits = 0;
|
||||
|
||||
|
|
@ -563,7 +562,7 @@ impure fn scan_numeric_escape(reader rdr) -> char {
|
|||
}
|
||||
|
||||
|
||||
impure fn next_token(reader rdr) -> token.token {
|
||||
fn next_token(reader rdr) -> token.token {
|
||||
auto accum_str = "";
|
||||
|
||||
consume_any_whitespace(rdr);
|
||||
|
|
@ -602,7 +601,7 @@ impure fn next_token(reader rdr) -> token.token {
|
|||
ret scan_number(c, rdr);
|
||||
}
|
||||
|
||||
impure fn binop(reader rdr, token.binop op) -> token.token {
|
||||
fn binop(reader rdr, token.binop op) -> token.token {
|
||||
rdr.bump();
|
||||
if (rdr.curr() == '=') {
|
||||
rdr.bump();
|
||||
|
|
@ -856,7 +855,7 @@ tag cmnt_ {
|
|||
|
||||
type cmnt = rec(cmnt_ val, uint pos, bool space_after);
|
||||
|
||||
impure fn consume_whitespace(reader rdr) -> uint {
|
||||
fn consume_whitespace(reader rdr) -> uint {
|
||||
auto lines = 0u;
|
||||
while (is_whitespace(rdr.curr())) {
|
||||
if (rdr.curr() == '\n') {lines += 1u;}
|
||||
|
|
@ -865,7 +864,7 @@ impure fn consume_whitespace(reader rdr) -> uint {
|
|||
ret lines;
|
||||
}
|
||||
|
||||
impure fn read_line_comment(reader rdr) -> cmnt {
|
||||
fn read_line_comment(reader rdr) -> cmnt {
|
||||
auto p = rdr.get_chpos();
|
||||
rdr.bump(); rdr.bump();
|
||||
while (rdr.curr() == ' ') {rdr.bump();}
|
||||
|
|
@ -879,7 +878,7 @@ impure fn read_line_comment(reader rdr) -> cmnt {
|
|||
space_after=consume_whitespace(rdr) > 1u);
|
||||
}
|
||||
|
||||
impure fn read_block_comment(reader rdr) -> cmnt {
|
||||
fn read_block_comment(reader rdr) -> cmnt {
|
||||
auto p = rdr.get_chpos();
|
||||
rdr.bump(); rdr.bump();
|
||||
while (rdr.curr() == ' ') {rdr.bump();}
|
||||
|
|
@ -912,7 +911,7 @@ impure fn read_block_comment(reader rdr) -> cmnt {
|
|||
space_after=consume_whitespace(rdr) > 1u);
|
||||
}
|
||||
|
||||
impure fn gather_comments(str path) -> vec[cmnt] {
|
||||
fn gather_comments(str path) -> vec[cmnt] {
|
||||
auto srdr = io.file_reader(path);
|
||||
auto rdr = new_reader(srdr, path, codemap.new_filemap(path, 0u));
|
||||
let vec[cmnt] comments = vec();
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ tag file_type {
|
|||
state type parser =
|
||||
state obj {
|
||||
fn peek() -> token.token;
|
||||
impure fn bump();
|
||||
impure fn err(str s);
|
||||
impure fn restrict(restriction r);
|
||||
fn bump();
|
||||
fn err(str s);
|
||||
fn restrict(restriction r);
|
||||
fn get_restriction() -> restriction;
|
||||
fn get_file_type() -> file_type;
|
||||
fn get_env() -> eval.env;
|
||||
|
|
@ -43,7 +43,7 @@ state type parser =
|
|||
fn get_chpos() -> uint;
|
||||
};
|
||||
|
||||
impure fn new_parser(session.session sess,
|
||||
fn new_parser(session.session sess,
|
||||
eval.env env,
|
||||
ast.def_id initial_def,
|
||||
str path, uint pos) -> parser {
|
||||
|
|
@ -63,7 +63,7 @@ impure fn new_parser(session.session sess,
|
|||
ret tok;
|
||||
}
|
||||
|
||||
impure fn bump() {
|
||||
fn bump() {
|
||||
// log rdr.get_filename()
|
||||
// + ":" + common.istr(lo.line as int);
|
||||
tok = lexer.next_token(rdr);
|
||||
|
|
@ -71,11 +71,11 @@ impure fn new_parser(session.session sess,
|
|||
hi = rdr.get_chpos();
|
||||
}
|
||||
|
||||
impure fn err(str m) {
|
||||
fn err(str m) {
|
||||
sess.span_err(rec(lo=lo, hi=hi), m);
|
||||
}
|
||||
|
||||
impure fn restrict(restriction r) {
|
||||
fn restrict(restriction r) {
|
||||
res = r;
|
||||
}
|
||||
|
||||
|
|
@ -134,13 +134,13 @@ impure fn new_parser(session.session sess,
|
|||
rdr, prec_table());
|
||||
}
|
||||
|
||||
impure fn unexpected(parser p, token.token t) {
|
||||
fn unexpected(parser p, token.token t) {
|
||||
let str s = "unexpected token: ";
|
||||
s += token.to_str(t);
|
||||
p.err(s);
|
||||
}
|
||||
|
||||
impure fn expect(parser p, token.token t) {
|
||||
fn expect(parser p, token.token t) {
|
||||
if (p.peek() == t) {
|
||||
p.bump();
|
||||
} else {
|
||||
|
|
@ -156,7 +156,7 @@ fn spanned[T](uint lo, uint hi, &T node) -> ast.spanned[T] {
|
|||
ret rec(node=node, span=rec(lo=lo, hi=hi));
|
||||
}
|
||||
|
||||
impure fn parse_ident(parser p) -> ast.ident {
|
||||
fn parse_ident(parser p) -> ast.ident {
|
||||
alt (p.peek()) {
|
||||
case (token.IDENT(?i)) { p.bump(); ret i; }
|
||||
case (_) {
|
||||
|
|
@ -172,7 +172,7 @@ impure fn parse_ident(parser p) -> ast.ident {
|
|||
* lexical sytnax-extension or something similar. For now we just imitate
|
||||
* rustboot.
|
||||
*/
|
||||
impure fn parse_str_lit_or_env_ident(parser p) -> ast.ident {
|
||||
fn parse_str_lit_or_env_ident(parser p) -> ast.ident {
|
||||
alt (p.peek()) {
|
||||
case (token.LIT_STR(?s)) { p.bump(); ret s; }
|
||||
case (token.IDENT(?i)) {
|
||||
|
|
@ -192,9 +192,9 @@ impure fn parse_str_lit_or_env_ident(parser p) -> ast.ident {
|
|||
}
|
||||
|
||||
|
||||
impure fn parse_ty_fn(ast.effect eff, ast.proto proto, parser p, uint lo)
|
||||
fn parse_ty_fn(ast.proto proto, parser p, uint lo)
|
||||
-> ast.ty_ {
|
||||
impure fn parse_fn_input_ty(parser p) -> rec(ast.mode mode, @ast.ty ty) {
|
||||
fn parse_fn_input_ty(parser p) -> rec(ast.mode mode, @ast.ty ty) {
|
||||
auto mode;
|
||||
if (p.peek() == token.BINOP(token.AND)) {
|
||||
p.bump();
|
||||
|
|
@ -236,10 +236,10 @@ impure fn parse_ty_fn(ast.effect eff, ast.proto proto, parser p, uint lo)
|
|||
output = @spanned(lo, inputs.span.hi, ast.ty_nil);
|
||||
}
|
||||
|
||||
ret ast.ty_fn(eff, proto, inputs.node, output);
|
||||
ret ast.ty_fn(proto, inputs.node, output);
|
||||
}
|
||||
|
||||
impure fn parse_proto(parser p) -> ast.proto {
|
||||
fn parse_proto(parser p) -> ast.proto {
|
||||
alt (p.peek()) {
|
||||
case (token.ITER) { p.bump(); ret ast.proto_iter; }
|
||||
case (token.FN) { p.bump(); ret ast.proto_fn; }
|
||||
|
|
@ -248,19 +248,18 @@ impure fn parse_proto(parser p) -> ast.proto {
|
|||
fail;
|
||||
}
|
||||
|
||||
impure fn parse_ty_obj(parser p, &mutable uint hi) -> ast.ty_ {
|
||||
fn parse_ty_obj(parser p, &mutable uint hi) -> ast.ty_ {
|
||||
expect(p, token.OBJ);
|
||||
impure fn parse_method_sig(parser p) -> ast.ty_method {
|
||||
fn parse_method_sig(parser p) -> ast.ty_method {
|
||||
auto flo = p.get_lo_pos();
|
||||
|
||||
let ast.effect eff = parse_effect(p);
|
||||
let ast.proto proto = parse_proto(p);
|
||||
auto ident = parse_ident(p);
|
||||
auto f = parse_ty_fn(eff, proto, p, flo);
|
||||
auto f = parse_ty_fn(proto, p, flo);
|
||||
expect(p, token.SEMI);
|
||||
alt (f) {
|
||||
case (ast.ty_fn(?eff, ?proto, ?inputs, ?output)) {
|
||||
ret rec(effect=eff, proto=proto, ident=ident,
|
||||
case (ast.ty_fn(?proto, ?inputs, ?output)) {
|
||||
ret rec(proto=proto, ident=ident,
|
||||
inputs=inputs, output=output);
|
||||
}
|
||||
}
|
||||
|
|
@ -276,19 +275,19 @@ impure fn parse_ty_obj(parser p, &mutable uint hi) -> ast.ty_ {
|
|||
ret ast.ty_obj(meths.node);
|
||||
}
|
||||
|
||||
impure fn parse_mt(parser p) -> ast.mt {
|
||||
fn parse_mt(parser p) -> ast.mt {
|
||||
auto mut = parse_mutability(p);
|
||||
auto t = parse_ty(p);
|
||||
ret rec(ty=t, mut=mut);
|
||||
}
|
||||
|
||||
impure fn parse_ty_field(parser p) -> ast.ty_field {
|
||||
fn parse_ty_field(parser p) -> ast.ty_field {
|
||||
auto mt = parse_mt(p);
|
||||
auto id = parse_ident(p);
|
||||
ret rec(ident=id, mt=mt);
|
||||
}
|
||||
|
||||
impure fn parse_constr_arg(parser p) -> @ast.constr_arg {
|
||||
fn parse_constr_arg(parser p) -> @ast.constr_arg {
|
||||
auto sp = p.get_span();
|
||||
auto carg = ast.carg_base;
|
||||
if (p.peek() == token.BINOP(token.STAR)) {
|
||||
|
|
@ -299,7 +298,7 @@ impure fn parse_constr_arg(parser p) -> @ast.constr_arg {
|
|||
ret @rec(node=carg, span=sp);
|
||||
}
|
||||
|
||||
impure fn parse_ty_constr(parser p) -> @ast.constr {
|
||||
fn parse_ty_constr(parser p) -> @ast.constr {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto path = parse_path(p, GREEDY);
|
||||
auto pf = parse_constr_arg;
|
||||
|
|
@ -309,7 +308,7 @@ impure fn parse_ty_constr(parser p) -> @ast.constr {
|
|||
ret @spanned(lo, args.span.hi, rec(path=path, args=args.node));
|
||||
}
|
||||
|
||||
impure fn parse_constrs(parser p) -> common.spanned[vec[@ast.constr]] {
|
||||
fn parse_constrs(parser p) -> common.spanned[vec[@ast.constr]] {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto hi = p.get_hi_pos();
|
||||
let vec[@ast.constr] constrs = vec();
|
||||
|
|
@ -334,7 +333,7 @@ impure fn parse_constrs(parser p) -> common.spanned[vec[@ast.constr]] {
|
|||
ret spanned(lo, hi, constrs);
|
||||
}
|
||||
|
||||
impure fn parse_ty_constrs(@ast.ty t, parser p) -> @ast.ty {
|
||||
fn parse_ty_constrs(@ast.ty t, parser p) -> @ast.ty {
|
||||
if (p.peek() == token.COLON) {
|
||||
auto constrs = parse_constrs(p);
|
||||
ret @spanned(t.span.lo, constrs.span.hi,
|
||||
|
|
@ -343,13 +342,11 @@ impure fn parse_ty_constrs(@ast.ty t, parser p) -> @ast.ty {
|
|||
ret t;
|
||||
}
|
||||
|
||||
impure fn parse_ty(parser p) -> @ast.ty {
|
||||
fn parse_ty(parser p) -> @ast.ty {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto hi = lo;
|
||||
let ast.ty_ t;
|
||||
|
||||
// FIXME: make sure these are only used when valid
|
||||
let ast.effect eff = parse_effect(p);
|
||||
// FIXME: do something with this
|
||||
let ast.layer lyr = parse_layer(p);
|
||||
|
||||
|
|
@ -418,9 +415,9 @@ impure fn parse_ty(parser p) -> @ast.ty {
|
|||
case (token.FN) {
|
||||
auto flo = p.get_lo_pos();
|
||||
p.bump();
|
||||
t = parse_ty_fn(eff, ast.proto_fn, p, flo);
|
||||
t = parse_ty_fn(ast.proto_fn, p, flo);
|
||||
alt (t) {
|
||||
case (ast.ty_fn(_, _, _, ?out)) {
|
||||
case (ast.ty_fn(_, _, ?out)) {
|
||||
hi = out.span.hi;
|
||||
}
|
||||
}
|
||||
|
|
@ -429,9 +426,9 @@ impure fn parse_ty(parser p) -> @ast.ty {
|
|||
case (token.ITER) {
|
||||
auto flo = p.get_lo_pos();
|
||||
p.bump();
|
||||
t = parse_ty_fn(eff, ast.proto_iter, p, flo);
|
||||
t = parse_ty_fn(ast.proto_iter, p, flo);
|
||||
alt (t) {
|
||||
case (ast.ty_fn(_, _, _, ?out)) {
|
||||
case (ast.ty_fn(_, _, ?out)) {
|
||||
hi = out.span.hi;
|
||||
}
|
||||
}
|
||||
|
|
@ -482,7 +479,7 @@ impure fn parse_ty(parser p) -> @ast.ty {
|
|||
ret parse_ty_constrs(@spanned(lo, hi, t), p);
|
||||
}
|
||||
|
||||
impure fn parse_arg(parser p) -> ast.arg {
|
||||
fn parse_arg(parser p) -> ast.arg {
|
||||
let ast.mode m = ast.val;
|
||||
if (p.peek() == token.BINOP(token.AND)) {
|
||||
m = ast.alias;
|
||||
|
|
@ -498,9 +495,9 @@ impure fn parse_arg(parser p) -> ast.arg {
|
|||
ret rec(mode=m, ty=t, ident=i, id=p.next_def_id());
|
||||
}
|
||||
|
||||
impure fn parse_seq_to_end[T](token.token ket,
|
||||
fn parse_seq_to_end[T](token.token ket,
|
||||
option.t[token.token] sep,
|
||||
(impure fn(parser) -> T) f,
|
||||
(fn(parser) -> T) f,
|
||||
mutable uint hi,
|
||||
parser p) -> vec[T] {
|
||||
let bool first = true;
|
||||
|
|
@ -526,10 +523,10 @@ impure fn parse_seq_to_end[T](token.token ket,
|
|||
ret v;
|
||||
}
|
||||
|
||||
impure fn parse_seq[T](token.token bra,
|
||||
fn parse_seq[T](token.token bra,
|
||||
token.token ket,
|
||||
option.t[token.token] sep,
|
||||
(impure fn(parser) -> T) f,
|
||||
(fn(parser) -> T) f,
|
||||
parser p) -> util.common.spanned[vec[T]] {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto hi = p.get_hi_pos();
|
||||
|
|
@ -538,7 +535,7 @@ impure fn parse_seq[T](token.token bra,
|
|||
ret spanned(lo, hi, result);
|
||||
}
|
||||
|
||||
impure fn parse_lit(parser p) -> ast.lit {
|
||||
fn parse_lit(parser p) -> ast.lit {
|
||||
auto sp = p.get_span();
|
||||
let ast.lit_ lit = ast.lit_nil;
|
||||
alt (p.peek()) {
|
||||
|
|
@ -594,7 +591,7 @@ tag greed {
|
|||
MINIMAL;
|
||||
}
|
||||
|
||||
impure fn parse_ty_args(parser p, uint hi) ->
|
||||
fn parse_ty_args(parser p, uint hi) ->
|
||||
util.common.spanned[vec[@ast.ty]] {
|
||||
|
||||
if (p.peek() == token.LBRACKET) {
|
||||
|
|
@ -609,7 +606,7 @@ impure fn parse_ty_args(parser p, uint hi) ->
|
|||
ret spanned(hi, hi, v);
|
||||
}
|
||||
|
||||
impure fn parse_path(parser p, greed g) -> ast.path {
|
||||
fn parse_path(parser p, greed g) -> ast.path {
|
||||
|
||||
auto lo = p.get_lo_pos();
|
||||
auto hi = lo;
|
||||
|
|
@ -643,7 +640,7 @@ impure fn parse_path(parser p, greed g) -> ast.path {
|
|||
ret spanned(lo, tys.span.hi, rec(idents=ids, types=tys.node));
|
||||
}
|
||||
|
||||
impure fn parse_mutability(parser p) -> ast.mutability {
|
||||
fn parse_mutability(parser p) -> ast.mutability {
|
||||
if (p.peek() == token.MUTABLE) {
|
||||
p.bump();
|
||||
if (p.peek() == token.QUES) {
|
||||
|
|
@ -655,7 +652,7 @@ impure fn parse_mutability(parser p) -> ast.mutability {
|
|||
ret ast.imm;
|
||||
}
|
||||
|
||||
impure fn parse_field(parser p) -> ast.field {
|
||||
fn parse_field(parser p) -> ast.field {
|
||||
auto m = parse_mutability(p);
|
||||
auto i = parse_ident(p);
|
||||
expect(p, token.EQ);
|
||||
|
|
@ -663,7 +660,7 @@ impure fn parse_field(parser p) -> ast.field {
|
|||
ret rec(mut=m, ident=i, expr=e);
|
||||
}
|
||||
|
||||
impure fn parse_bottom_expr(parser p) -> @ast.expr {
|
||||
fn parse_bottom_expr(parser p) -> @ast.expr {
|
||||
|
||||
auto lo = p.get_lo_pos();
|
||||
auto hi = p.get_hi_pos();
|
||||
|
|
@ -701,7 +698,7 @@ impure fn parse_bottom_expr(parser p) -> @ast.expr {
|
|||
|
||||
case (token.TUP) {
|
||||
p.bump();
|
||||
impure fn parse_elt(parser p) -> ast.elt {
|
||||
fn parse_elt(parser p) -> ast.elt {
|
||||
auto m = parse_mutability(p);
|
||||
auto e = parse_expr(p);
|
||||
ret rec(mut=m, expr=e);
|
||||
|
|
@ -767,7 +764,7 @@ impure fn parse_bottom_expr(parser p) -> @ast.expr {
|
|||
case (token.BIND) {
|
||||
p.bump();
|
||||
auto e = parse_expr_res(p, RESTRICT_NO_CALL_EXPRS);
|
||||
impure fn parse_expr_opt(parser p) -> option.t[@ast.expr] {
|
||||
fn parse_expr_opt(parser p) -> option.t[@ast.expr] {
|
||||
alt (p.peek()) {
|
||||
case (token.UNDERSCORE) {
|
||||
p.bump();
|
||||
|
|
@ -937,7 +934,7 @@ impure fn parse_bottom_expr(parser p) -> @ast.expr {
|
|||
* rust crates. At the moment we have neither.
|
||||
*/
|
||||
|
||||
impure fn expand_syntax_ext(parser p, ast.span sp,
|
||||
fn expand_syntax_ext(parser p, ast.span sp,
|
||||
&ast.path path, vec[@ast.expr] args,
|
||||
option.t[@ast.expr] body) -> ast.expr_ {
|
||||
|
||||
|
|
@ -956,7 +953,7 @@ impure fn expand_syntax_ext(parser p, ast.span sp,
|
|||
}
|
||||
}
|
||||
|
||||
impure fn extend_expr_by_ident(parser p, uint lo, uint hi,
|
||||
fn extend_expr_by_ident(parser p, uint lo, uint hi,
|
||||
@ast.expr e, ast.ident i) -> @ast.expr {
|
||||
auto e_ = e.node;
|
||||
alt (e.node) {
|
||||
|
|
@ -981,14 +978,14 @@ impure fn extend_expr_by_ident(parser p, uint lo, uint hi,
|
|||
ret @spanned(lo, hi, e_);
|
||||
}
|
||||
|
||||
impure fn parse_self_method(parser p) -> @ast.expr {
|
||||
fn parse_self_method(parser p) -> @ast.expr {
|
||||
auto sp = p.get_span();
|
||||
let ast.ident f_name = parse_ident(p);
|
||||
auto hi = p.get_span();
|
||||
ret @rec(node=ast.expr_self_method(f_name, ast.ann_none), span=sp);
|
||||
}
|
||||
|
||||
impure fn parse_dot_or_call_expr(parser p) -> @ast.expr {
|
||||
fn parse_dot_or_call_expr(parser p) -> @ast.expr {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto e = parse_bottom_expr(p);
|
||||
auto hi = e.span.hi;
|
||||
|
|
@ -1043,7 +1040,7 @@ impure fn parse_dot_or_call_expr(parser p) -> @ast.expr {
|
|||
ret e;
|
||||
}
|
||||
|
||||
impure fn parse_prefix_expr(parser p) -> @ast.expr {
|
||||
fn parse_prefix_expr(parser p) -> @ast.expr {
|
||||
|
||||
if (p.peek() == token.MUTABLE) {
|
||||
p.bump();
|
||||
|
|
@ -1140,11 +1137,11 @@ fn prec_table() -> vec[op_spec] {
|
|||
rec(tok=token.OROR, op=ast.or, prec=1));
|
||||
}
|
||||
|
||||
impure fn parse_binops(parser p) -> @ast.expr {
|
||||
fn parse_binops(parser p) -> @ast.expr {
|
||||
ret parse_more_binops(p, parse_prefix_expr(p), 0);
|
||||
}
|
||||
|
||||
impure fn parse_more_binops(parser p, @ast.expr lhs, int min_prec)
|
||||
fn parse_more_binops(parser p, @ast.expr lhs, int min_prec)
|
||||
-> @ast.expr {
|
||||
// Magic nonsense to work around rustboot bug
|
||||
fn op_eq(token.token a, token.token b) -> bool {
|
||||
|
|
@ -1176,7 +1173,7 @@ impure fn parse_more_binops(parser p, @ast.expr lhs, int min_prec)
|
|||
ret lhs;
|
||||
}
|
||||
|
||||
impure fn parse_assign_expr(parser p) -> @ast.expr {
|
||||
fn parse_assign_expr(parser p) -> @ast.expr {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto lhs = parse_binops(p);
|
||||
alt (p.peek()) {
|
||||
|
|
@ -1223,7 +1220,7 @@ impure fn parse_assign_expr(parser p) -> @ast.expr {
|
|||
ret lhs;
|
||||
}
|
||||
|
||||
impure fn parse_if_expr(parser p) -> @ast.expr {
|
||||
fn parse_if_expr(parser p) -> @ast.expr {
|
||||
auto lo = p.get_lo_pos();
|
||||
|
||||
expect(p, token.IF);
|
||||
|
|
@ -1245,7 +1242,7 @@ impure fn parse_if_expr(parser p) -> @ast.expr {
|
|||
ret @spanned(lo, hi, ast.expr_if(cond, thn, els, ast.ann_none));
|
||||
}
|
||||
|
||||
impure fn parse_else_expr(parser p) -> @ast.expr {
|
||||
fn parse_else_expr(parser p) -> @ast.expr {
|
||||
expect(p, token.ELSE);
|
||||
alt (p.peek()) {
|
||||
case (token.IF) {
|
||||
|
|
@ -1259,7 +1256,7 @@ impure fn parse_else_expr(parser p) -> @ast.expr {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn parse_head_local(parser p) -> @ast.decl {
|
||||
fn parse_head_local(parser p) -> @ast.decl {
|
||||
auto lo = p.get_lo_pos();
|
||||
let @ast.local local;
|
||||
if (p.peek() == token.AUTO) {
|
||||
|
|
@ -1272,7 +1269,7 @@ impure fn parse_head_local(parser p) -> @ast.decl {
|
|||
|
||||
|
||||
|
||||
impure fn parse_for_expr(parser p) -> @ast.expr {
|
||||
fn parse_for_expr(parser p) -> @ast.expr {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto is_each = false;
|
||||
|
||||
|
|
@ -1301,7 +1298,7 @@ impure fn parse_for_expr(parser p) -> @ast.expr {
|
|||
}
|
||||
|
||||
|
||||
impure fn parse_while_expr(parser p) -> @ast.expr {
|
||||
fn parse_while_expr(parser p) -> @ast.expr {
|
||||
auto lo = p.get_lo_pos();
|
||||
|
||||
expect(p, token.WHILE);
|
||||
|
|
@ -1313,7 +1310,7 @@ impure fn parse_while_expr(parser p) -> @ast.expr {
|
|||
ret @spanned(lo, hi, ast.expr_while(cond, body, ast.ann_none));
|
||||
}
|
||||
|
||||
impure fn parse_do_while_expr(parser p) -> @ast.expr {
|
||||
fn parse_do_while_expr(parser p) -> @ast.expr {
|
||||
auto lo = p.get_lo_pos();
|
||||
|
||||
expect(p, token.DO);
|
||||
|
|
@ -1326,7 +1323,7 @@ impure fn parse_do_while_expr(parser p) -> @ast.expr {
|
|||
ret @spanned(lo, hi, ast.expr_do_while(body, cond, ast.ann_none));
|
||||
}
|
||||
|
||||
impure fn parse_alt_expr(parser p) -> @ast.expr {
|
||||
fn parse_alt_expr(parser p) -> @ast.expr {
|
||||
auto lo = p.get_lo_pos();
|
||||
expect(p, token.ALT);
|
||||
expect(p, token.LPAREN);
|
||||
|
|
@ -1377,7 +1374,7 @@ impure fn parse_alt_expr(parser p) -> @ast.expr {
|
|||
ret @spanned(lo, hi, expr);
|
||||
}
|
||||
|
||||
impure fn parse_spawn_expr(parser p) -> @ast.expr {
|
||||
fn parse_spawn_expr(parser p) -> @ast.expr {
|
||||
auto lo = p.get_lo_pos();
|
||||
expect(p, token.SPAWN);
|
||||
|
||||
|
|
@ -1398,11 +1395,11 @@ impure fn parse_spawn_expr(parser p) -> @ast.expr {
|
|||
ret @spanned(lo, hi, spawn_expr);
|
||||
}
|
||||
|
||||
impure fn parse_expr(parser p) -> @ast.expr {
|
||||
fn parse_expr(parser p) -> @ast.expr {
|
||||
ret parse_expr_res(p, UNRESTRICTED);
|
||||
}
|
||||
|
||||
impure fn parse_expr_res(parser p, restriction r) -> @ast.expr {
|
||||
fn parse_expr_res(parser p, restriction r) -> @ast.expr {
|
||||
auto old = p.get_restriction();
|
||||
p.restrict(r);
|
||||
auto e = parse_expr_inner(p);
|
||||
|
|
@ -1410,7 +1407,7 @@ impure fn parse_expr_res(parser p, restriction r) -> @ast.expr {
|
|||
ret e;
|
||||
}
|
||||
|
||||
impure fn parse_expr_inner(parser p) -> @ast.expr {
|
||||
fn parse_expr_inner(parser p) -> @ast.expr {
|
||||
alt (p.peek()) {
|
||||
case (token.LBRACE) {
|
||||
auto blk = parse_block(p);
|
||||
|
|
@ -1442,7 +1439,7 @@ impure fn parse_expr_inner(parser p) -> @ast.expr {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn parse_initializer(parser p) -> option.t[ast.initializer] {
|
||||
fn parse_initializer(parser p) -> option.t[ast.initializer] {
|
||||
alt (p.peek()) {
|
||||
case (token.EQ) {
|
||||
p.bump();
|
||||
|
|
@ -1460,7 +1457,7 @@ impure fn parse_initializer(parser p) -> option.t[ast.initializer] {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn parse_pat(parser p) -> @ast.pat {
|
||||
fn parse_pat(parser p) -> @ast.pat {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto hi = p.get_hi_pos();
|
||||
auto pat;
|
||||
|
|
@ -1514,7 +1511,7 @@ impure fn parse_pat(parser p) -> @ast.pat {
|
|||
ret @spanned(lo, hi, pat);
|
||||
}
|
||||
|
||||
impure fn parse_local_full(&option.t[@ast.ty] tyopt,
|
||||
fn parse_local_full(&option.t[@ast.ty] tyopt,
|
||||
parser p) -> @ast.local {
|
||||
auto ident = parse_ident(p);
|
||||
auto init = parse_initializer(p);
|
||||
|
|
@ -1526,30 +1523,30 @@ impure fn parse_local_full(&option.t[@ast.ty] tyopt,
|
|||
ann = ast.ann_none);
|
||||
}
|
||||
|
||||
impure fn parse_typed_local(parser p) -> @ast.local {
|
||||
fn parse_typed_local(parser p) -> @ast.local {
|
||||
auto ty = parse_ty(p);
|
||||
ret parse_local_full(some(ty), p);
|
||||
}
|
||||
|
||||
impure fn parse_auto_local(parser p) -> @ast.local {
|
||||
fn parse_auto_local(parser p) -> @ast.local {
|
||||
ret parse_local_full(none[@ast.ty], p);
|
||||
}
|
||||
|
||||
impure fn parse_let(parser p) -> @ast.decl {
|
||||
fn parse_let(parser p) -> @ast.decl {
|
||||
auto lo = p.get_lo_pos();
|
||||
expect(p, token.LET);
|
||||
auto local = parse_typed_local(p);
|
||||
ret @spanned(lo, p.get_hi_pos(), ast.decl_local(local));
|
||||
}
|
||||
|
||||
impure fn parse_auto(parser p) -> @ast.decl {
|
||||
fn parse_auto(parser p) -> @ast.decl {
|
||||
auto lo = p.get_lo_pos();
|
||||
expect(p, token.AUTO);
|
||||
auto local = parse_auto_local(p);
|
||||
ret @spanned(lo, p.get_hi_pos(), ast.decl_local(local));
|
||||
}
|
||||
|
||||
impure fn parse_stmt(parser p) -> @ast.stmt {
|
||||
fn parse_stmt(parser p) -> @ast.stmt {
|
||||
if (p.get_file_type() == SOURCE_FILE) {
|
||||
ret parse_source_stmt(p);
|
||||
} else {
|
||||
|
|
@ -1557,13 +1554,13 @@ impure fn parse_stmt(parser p) -> @ast.stmt {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn parse_crate_stmt(parser p) -> @ast.stmt {
|
||||
fn parse_crate_stmt(parser p) -> @ast.stmt {
|
||||
auto cdir = parse_crate_directive(p);
|
||||
ret @spanned(cdir.span.lo, cdir.span.hi,
|
||||
ast.stmt_crate_directive(@cdir));
|
||||
}
|
||||
|
||||
impure fn parse_source_stmt(parser p) -> @ast.stmt {
|
||||
fn parse_source_stmt(parser p) -> @ast.stmt {
|
||||
auto lo = p.get_lo_pos();
|
||||
alt (p.peek()) {
|
||||
|
||||
|
|
@ -1685,7 +1682,7 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn parse_block(parser p) -> ast.block {
|
||||
fn parse_block(parser p) -> ast.block {
|
||||
auto lo = p.get_lo_pos();
|
||||
|
||||
let vec[@ast.stmt] stmts = vec();
|
||||
|
|
@ -1746,11 +1743,11 @@ impure fn parse_block(parser p) -> ast.block {
|
|||
ret spanned[ast.block_](lo, hi, bloc);
|
||||
}
|
||||
|
||||
impure fn parse_ty_param(parser p) -> ast.ty_param {
|
||||
fn parse_ty_param(parser p) -> ast.ty_param {
|
||||
ret parse_ident(p);
|
||||
}
|
||||
|
||||
impure fn parse_ty_params(parser p) -> vec[ast.ty_param] {
|
||||
fn parse_ty_params(parser p) -> vec[ast.ty_param] {
|
||||
let vec[ast.ty_param] ty_params = vec();
|
||||
if (p.peek() == token.LBRACKET) {
|
||||
auto f = parse_ty_param; // FIXME: pass as lval directly
|
||||
|
|
@ -1760,7 +1757,7 @@ impure fn parse_ty_params(parser p) -> vec[ast.ty_param] {
|
|||
ret ty_params;
|
||||
}
|
||||
|
||||
impure fn parse_fn_decl(parser p, ast.effect eff) -> ast.fn_decl {
|
||||
fn parse_fn_decl(parser p) -> ast.fn_decl {
|
||||
auto pf = parse_arg;
|
||||
let util.common.spanned[vec[ast.arg]] inputs =
|
||||
// FIXME: passing parse_arg as an lval doesn't work at the
|
||||
|
|
@ -1783,61 +1780,59 @@ impure fn parse_fn_decl(parser p, ast.effect eff) -> ast.fn_decl {
|
|||
} else {
|
||||
output = @spanned(inputs.span.lo, inputs.span.hi, ast.ty_nil);
|
||||
}
|
||||
ret rec(effect=eff, inputs=inputs.node, output=output);
|
||||
ret rec(inputs=inputs.node, output=output);
|
||||
}
|
||||
|
||||
impure fn parse_fn(parser p, ast.effect eff, ast.proto proto) -> ast._fn {
|
||||
auto decl = parse_fn_decl(p, eff);
|
||||
fn parse_fn(parser p, ast.proto proto) -> ast._fn {
|
||||
auto decl = parse_fn_decl(p);
|
||||
auto body = parse_block(p);
|
||||
ret rec(decl = decl,
|
||||
proto = proto,
|
||||
body = body);
|
||||
}
|
||||
|
||||
impure fn parse_fn_header(parser p)
|
||||
fn parse_fn_header(parser p)
|
||||
-> tup(ast.ident, vec[ast.ty_param]) {
|
||||
auto id = parse_ident(p);
|
||||
auto ty_params = parse_ty_params(p);
|
||||
ret tup(id, ty_params);
|
||||
}
|
||||
|
||||
impure fn parse_item_fn_or_iter(parser p, ast.effect eff) -> @ast.item {
|
||||
fn parse_item_fn_or_iter(parser p) -> @ast.item {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto proto = parse_proto(p);
|
||||
auto t = parse_fn_header(p);
|
||||
auto f = parse_fn(p, eff, proto);
|
||||
auto f = parse_fn(p, proto);
|
||||
auto item = ast.item_fn(t._0, f, t._1,
|
||||
p.next_def_id(), ast.ann_none);
|
||||
ret @spanned(lo, f.body.span.hi, item);
|
||||
}
|
||||
|
||||
|
||||
impure fn parse_obj_field(parser p) -> ast.obj_field {
|
||||
fn parse_obj_field(parser p) -> ast.obj_field {
|
||||
auto mut = parse_mutability(p); // TODO: store this, use it in typeck
|
||||
auto ty = parse_ty(p);
|
||||
auto ident = parse_ident(p);
|
||||
ret rec(ty=ty, ident=ident, id=p.next_def_id(), ann=ast.ann_none);
|
||||
}
|
||||
|
||||
impure fn parse_method(parser p) -> @ast.method {
|
||||
fn parse_method(parser p) -> @ast.method {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto eff = parse_effect(p);
|
||||
auto proto = parse_proto(p);
|
||||
auto ident = parse_ident(p);
|
||||
auto f = parse_fn(p, eff, proto);
|
||||
auto f = parse_fn(p, proto);
|
||||
auto meth = rec(ident=ident, meth=f,
|
||||
id=p.next_def_id(), ann=ast.ann_none);
|
||||
ret @spanned(lo, f.body.span.hi, meth);
|
||||
}
|
||||
|
||||
impure fn parse_dtor(parser p) -> @ast.method {
|
||||
fn parse_dtor(parser p) -> @ast.method {
|
||||
auto lo = p.get_lo_pos();
|
||||
expect(p, token.DROP);
|
||||
let ast.block b = parse_block(p);
|
||||
let vec[ast.arg] inputs = vec();
|
||||
let @ast.ty output = @spanned(lo, lo, ast.ty_nil);
|
||||
let ast.fn_decl d = rec(effect=ast.eff_pure,
|
||||
inputs=inputs,
|
||||
let ast.fn_decl d = rec(inputs=inputs,
|
||||
output=output);
|
||||
let ast._fn f = rec(decl = d,
|
||||
proto = ast.proto_fn,
|
||||
|
|
@ -1849,7 +1844,7 @@ impure fn parse_dtor(parser p) -> @ast.method {
|
|||
ret @spanned(lo, f.body.span.hi, m);
|
||||
}
|
||||
|
||||
impure fn parse_item_obj(parser p, ast.layer lyr) -> @ast.item {
|
||||
fn parse_item_obj(parser p, ast.layer lyr) -> @ast.item {
|
||||
auto lo = p.get_lo_pos();
|
||||
expect(p, token.OBJ);
|
||||
auto ident = parse_ident(p);
|
||||
|
|
@ -1890,7 +1885,7 @@ impure fn parse_item_obj(parser p, ast.layer lyr) -> @ast.item {
|
|||
ret @spanned(lo, hi, item);
|
||||
}
|
||||
|
||||
impure fn parse_mod_items(parser p, token.token term) -> ast._mod {
|
||||
fn parse_mod_items(parser p, token.token term) -> ast._mod {
|
||||
auto index = new_str_hash[ast.mod_index_entry]();
|
||||
auto view_items = parse_view(p, index);
|
||||
let vec[@ast.item] items = vec();
|
||||
|
|
@ -1904,7 +1899,7 @@ impure fn parse_mod_items(parser p, token.token term) -> ast._mod {
|
|||
ret rec(view_items=view_items, items=items, index=index);
|
||||
}
|
||||
|
||||
impure fn parse_item_const(parser p) -> @ast.item {
|
||||
fn parse_item_const(parser p) -> @ast.item {
|
||||
auto lo = p.get_lo_pos();
|
||||
expect(p, token.CONST);
|
||||
auto ty = parse_ty(p);
|
||||
|
|
@ -1917,7 +1912,7 @@ impure fn parse_item_const(parser p) -> @ast.item {
|
|||
ret @spanned(lo, hi, item);
|
||||
}
|
||||
|
||||
impure fn parse_item_mod(parser p) -> @ast.item {
|
||||
fn parse_item_mod(parser p) -> @ast.item {
|
||||
auto lo = p.get_lo_pos();
|
||||
expect(p, token.MOD);
|
||||
auto id = parse_ident(p);
|
||||
|
|
@ -1929,7 +1924,7 @@ impure fn parse_item_mod(parser p) -> @ast.item {
|
|||
ret @spanned(lo, hi, item);
|
||||
}
|
||||
|
||||
impure fn parse_item_native_type(parser p) -> @ast.native_item {
|
||||
fn parse_item_native_type(parser p) -> @ast.native_item {
|
||||
auto t = parse_type_decl(p);
|
||||
auto hi = p.get_hi_pos();
|
||||
expect(p, token.SEMI);
|
||||
|
|
@ -1937,11 +1932,11 @@ impure fn parse_item_native_type(parser p) -> @ast.native_item {
|
|||
ret @spanned(t._0, hi, item);
|
||||
}
|
||||
|
||||
impure fn parse_item_native_fn(parser p, ast.effect eff) -> @ast.native_item {
|
||||
fn parse_item_native_fn(parser p) -> @ast.native_item {
|
||||
auto lo = p.get_lo_pos();
|
||||
expect(p, token.FN);
|
||||
auto t = parse_fn_header(p);
|
||||
auto decl = parse_fn_decl(p, eff);
|
||||
auto decl = parse_fn_decl(p);
|
||||
auto link_name = none[str];
|
||||
if (p.peek() == token.EQ) {
|
||||
p.bump();
|
||||
|
|
@ -1955,8 +1950,7 @@ impure fn parse_item_native_fn(parser p, ast.effect eff) -> @ast.native_item {
|
|||
ret @spanned(lo, hi, item);
|
||||
}
|
||||
|
||||
impure fn parse_native_item(parser p) -> @ast.native_item {
|
||||
let ast.effect eff = parse_effect(p);
|
||||
fn parse_native_item(parser p) -> @ast.native_item {
|
||||
let ast.opacity opa = parse_opacity(p);
|
||||
let ast.layer lyr = parse_layer(p);
|
||||
alt (p.peek()) {
|
||||
|
|
@ -1964,7 +1958,7 @@ impure fn parse_native_item(parser p) -> @ast.native_item {
|
|||
ret parse_item_native_type(p);
|
||||
}
|
||||
case (token.FN) {
|
||||
ret parse_item_native_fn(p, eff);
|
||||
ret parse_item_native_fn(p);
|
||||
}
|
||||
case (?t) {
|
||||
unexpected(p, t);
|
||||
|
|
@ -1973,7 +1967,7 @@ impure fn parse_native_item(parser p) -> @ast.native_item {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn parse_native_mod_items(parser p,
|
||||
fn parse_native_mod_items(parser p,
|
||||
str native_name,
|
||||
ast.native_abi abi) -> ast.native_mod {
|
||||
auto index = new_str_hash[ast.native_mod_index_entry]();
|
||||
|
|
@ -2008,7 +2002,7 @@ fn default_native_name(session.session sess, str id) -> str {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn parse_item_native_mod(parser p) -> @ast.item {
|
||||
fn parse_item_native_mod(parser p) -> @ast.item {
|
||||
auto lo = p.get_lo_pos();
|
||||
expect(p, token.NATIVE);
|
||||
auto abi = ast.native_abi_cdecl;
|
||||
|
|
@ -2041,14 +2035,14 @@ impure fn parse_item_native_mod(parser p) -> @ast.item {
|
|||
ret @spanned(lo, hi, item);
|
||||
}
|
||||
|
||||
impure fn parse_type_decl(parser p) -> tup(uint, ast.ident) {
|
||||
fn parse_type_decl(parser p) -> tup(uint, ast.ident) {
|
||||
auto lo = p.get_lo_pos();
|
||||
expect(p, token.TYPE);
|
||||
auto id = parse_ident(p);
|
||||
ret tup(lo, id);
|
||||
}
|
||||
|
||||
impure fn parse_item_type(parser p) -> @ast.item {
|
||||
fn parse_item_type(parser p) -> @ast.item {
|
||||
auto t = parse_type_decl(p);
|
||||
auto tps = parse_ty_params(p);
|
||||
|
||||
|
|
@ -2060,7 +2054,7 @@ impure fn parse_item_type(parser p) -> @ast.item {
|
|||
ret @spanned(t._0, hi, item);
|
||||
}
|
||||
|
||||
impure fn parse_item_tag(parser p) -> @ast.item {
|
||||
fn parse_item_tag(parser p) -> @ast.item {
|
||||
auto lo = p.get_lo_pos();
|
||||
expect(p, token.TAG);
|
||||
auto id = parse_ident(p);
|
||||
|
|
@ -2112,7 +2106,7 @@ impure fn parse_item_tag(parser p) -> @ast.item {
|
|||
ret @spanned(lo, hi, item);
|
||||
}
|
||||
|
||||
impure fn parse_opacity(parser p) -> ast.opacity {
|
||||
fn parse_opacity(parser p) -> ast.opacity {
|
||||
alt (p.peek()) {
|
||||
case (token.ABS) {
|
||||
p.bump();
|
||||
|
|
@ -2125,7 +2119,7 @@ impure fn parse_opacity(parser p) -> ast.opacity {
|
|||
fail;
|
||||
}
|
||||
|
||||
impure fn parse_layer(parser p) -> ast.layer {
|
||||
fn parse_layer(parser p) -> ast.layer {
|
||||
alt (p.peek()) {
|
||||
case (token.STATE) {
|
||||
p.bump();
|
||||
|
|
@ -2143,18 +2137,14 @@ impure fn parse_layer(parser p) -> ast.layer {
|
|||
}
|
||||
|
||||
|
||||
impure fn parse_effect(parser p) -> ast.effect {
|
||||
fn parse_auth(parser p) -> ast._auth {
|
||||
alt (p.peek()) {
|
||||
case (token.IMPURE) {
|
||||
p.bump();
|
||||
ret ast.eff_impure;
|
||||
}
|
||||
case (token.UNSAFE) {
|
||||
p.bump();
|
||||
ret ast.eff_unsafe;
|
||||
ret ast.auth_unsafe;
|
||||
}
|
||||
case (_) {
|
||||
ret ast.eff_pure;
|
||||
case (?t) {
|
||||
unexpected(p, t);
|
||||
}
|
||||
}
|
||||
fail;
|
||||
|
|
@ -2164,8 +2154,6 @@ fn peeking_at_item(parser p) -> bool {
|
|||
alt (p.peek()) {
|
||||
case (token.STATE) { ret true; }
|
||||
case (token.GC) { ret true; }
|
||||
case (token.IMPURE) { ret true; }
|
||||
case (token.UNSAFE) { ret true; }
|
||||
case (token.CONST) { ret true; }
|
||||
case (token.FN) { ret true; }
|
||||
case (token.ITER) { ret true; }
|
||||
|
|
@ -2178,46 +2166,39 @@ fn peeking_at_item(parser p) -> bool {
|
|||
ret false;
|
||||
}
|
||||
|
||||
impure fn parse_item(parser p) -> @ast.item {
|
||||
let ast.effect eff = parse_effect(p);
|
||||
fn parse_item(parser p) -> @ast.item {
|
||||
let ast.opacity opa = parse_opacity(p);
|
||||
let ast.layer lyr = parse_layer(p);
|
||||
|
||||
alt (p.peek()) {
|
||||
case (token.CONST) {
|
||||
check (eff == ast.eff_pure);
|
||||
check (lyr == ast.layer_value);
|
||||
ret parse_item_const(p);
|
||||
}
|
||||
|
||||
case (token.FN) {
|
||||
check (lyr == ast.layer_value);
|
||||
ret parse_item_fn_or_iter(p, eff);
|
||||
ret parse_item_fn_or_iter(p);
|
||||
}
|
||||
case (token.ITER) {
|
||||
check (lyr == ast.layer_value);
|
||||
ret parse_item_fn_or_iter(p, eff);
|
||||
ret parse_item_fn_or_iter(p);
|
||||
}
|
||||
case (token.MOD) {
|
||||
check (eff == ast.eff_pure);
|
||||
check (lyr == ast.layer_value);
|
||||
ret parse_item_mod(p);
|
||||
}
|
||||
case (token.NATIVE) {
|
||||
check (eff == ast.eff_pure);
|
||||
check (lyr == ast.layer_value);
|
||||
ret parse_item_native_mod(p);
|
||||
}
|
||||
case (token.TYPE) {
|
||||
check (eff == ast.eff_pure);
|
||||
ret parse_item_type(p);
|
||||
}
|
||||
case (token.TAG) {
|
||||
check (eff == ast.eff_pure);
|
||||
ret parse_item_tag(p);
|
||||
}
|
||||
case (token.OBJ) {
|
||||
check (eff == ast.eff_pure);
|
||||
ret parse_item_obj(p, lyr);
|
||||
}
|
||||
case (?t) {
|
||||
|
|
@ -2227,7 +2208,7 @@ impure fn parse_item(parser p) -> @ast.item {
|
|||
fail;
|
||||
}
|
||||
|
||||
impure fn parse_meta_item(parser p) -> @ast.meta_item {
|
||||
fn parse_meta_item(parser p) -> @ast.meta_item {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto ident = parse_ident(p);
|
||||
expect(p, token.EQ);
|
||||
|
|
@ -2244,13 +2225,13 @@ impure fn parse_meta_item(parser p) -> @ast.meta_item {
|
|||
fail;
|
||||
}
|
||||
|
||||
impure fn parse_meta(parser p) -> vec[@ast.meta_item] {
|
||||
fn parse_meta(parser p) -> vec[@ast.meta_item] {
|
||||
auto pf = parse_meta_item;
|
||||
ret parse_seq[@ast.meta_item](token.LPAREN, token.RPAREN,
|
||||
some(token.COMMA), pf, p).node;
|
||||
}
|
||||
|
||||
impure fn parse_optional_meta(parser p) -> vec[@ast.meta_item] {
|
||||
fn parse_optional_meta(parser p) -> vec[@ast.meta_item] {
|
||||
alt (p.peek()) {
|
||||
case (token.LPAREN) {
|
||||
ret parse_meta(p);
|
||||
|
|
@ -2262,7 +2243,7 @@ impure fn parse_optional_meta(parser p) -> vec[@ast.meta_item] {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn parse_use(parser p) -> @ast.view_item {
|
||||
fn parse_use(parser p) -> @ast.view_item {
|
||||
auto lo = p.get_lo_pos();
|
||||
expect(p, token.USE);
|
||||
auto ident = parse_ident(p);
|
||||
|
|
@ -2274,7 +2255,7 @@ impure fn parse_use(parser p) -> @ast.view_item {
|
|||
ret @spanned(lo, hi, use_decl);
|
||||
}
|
||||
|
||||
impure fn parse_rest_import_name(parser p, ast.ident first,
|
||||
fn parse_rest_import_name(parser p, ast.ident first,
|
||||
option.t[ast.ident] def_ident)
|
||||
-> @ast.view_item {
|
||||
auto lo = p.get_lo_pos();
|
||||
|
|
@ -2302,7 +2283,7 @@ impure fn parse_rest_import_name(parser p, ast.ident first,
|
|||
ret @spanned(lo, hi, import_decl);
|
||||
}
|
||||
|
||||
impure fn parse_full_import_name(parser p, ast.ident def_ident)
|
||||
fn parse_full_import_name(parser p, ast.ident def_ident)
|
||||
-> @ast.view_item {
|
||||
alt (p.peek()) {
|
||||
case (token.IDENT(?ident)) {
|
||||
|
|
@ -2316,7 +2297,7 @@ impure fn parse_full_import_name(parser p, ast.ident def_ident)
|
|||
fail;
|
||||
}
|
||||
|
||||
impure fn parse_import(parser p) -> @ast.view_item {
|
||||
fn parse_import(parser p) -> @ast.view_item {
|
||||
expect(p, token.IMPORT);
|
||||
alt (p.peek()) {
|
||||
case (token.IDENT(?ident)) {
|
||||
|
|
@ -2338,7 +2319,7 @@ impure fn parse_import(parser p) -> @ast.view_item {
|
|||
fail;
|
||||
}
|
||||
|
||||
impure fn parse_export(parser p) -> @ast.view_item {
|
||||
fn parse_export(parser p) -> @ast.view_item {
|
||||
auto lo = p.get_lo_pos();
|
||||
expect(p, token.EXPORT);
|
||||
auto id = parse_ident(p);
|
||||
|
|
@ -2347,7 +2328,7 @@ impure fn parse_export(parser p) -> @ast.view_item {
|
|||
ret @spanned(lo, hi, ast.view_item_export(id));
|
||||
}
|
||||
|
||||
impure fn parse_view_item(parser p) -> @ast.view_item {
|
||||
fn parse_view_item(parser p) -> @ast.view_item {
|
||||
alt (p.peek()) {
|
||||
case (token.USE) {
|
||||
ret parse_use(p);
|
||||
|
|
@ -2371,7 +2352,7 @@ fn is_view_item(token.token t) -> bool {
|
|||
ret false;
|
||||
}
|
||||
|
||||
impure fn parse_view(parser p, ast.mod_index index) -> vec[@ast.view_item] {
|
||||
fn parse_view(parser p, ast.mod_index index) -> vec[@ast.view_item] {
|
||||
let vec[@ast.view_item] items = vec();
|
||||
while (is_view_item(p.peek())) {
|
||||
auto item = parse_view_item(p);
|
||||
|
|
@ -2382,7 +2363,7 @@ impure fn parse_view(parser p, ast.mod_index index) -> vec[@ast.view_item] {
|
|||
ret items;
|
||||
}
|
||||
|
||||
impure fn parse_native_view(parser p, ast.native_mod_index index)
|
||||
fn parse_native_view(parser p, ast.native_mod_index index)
|
||||
-> vec[@ast.view_item] {
|
||||
let vec[@ast.view_item] items = vec();
|
||||
while (is_view_item(p.peek())) {
|
||||
|
|
@ -2395,7 +2376,7 @@ impure fn parse_native_view(parser p, ast.native_mod_index index)
|
|||
}
|
||||
|
||||
|
||||
impure fn parse_crate_from_source_file(parser p) -> @ast.crate {
|
||||
fn parse_crate_from_source_file(parser p) -> @ast.crate {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto m = parse_mod_items(p, token.EOF);
|
||||
let vec[@ast.crate_directive] cdirs = vec();
|
||||
|
|
@ -2409,7 +2390,7 @@ impure fn parse_crate_from_source_file(parser p) -> @ast.crate {
|
|||
//
|
||||
// Each directive imperatively extends its environment with 0 or more items.
|
||||
|
||||
impure fn parse_crate_directive(parser p) -> ast.crate_directive
|
||||
fn parse_crate_directive(parser p) -> ast.crate_directive
|
||||
{
|
||||
auto lo = p.get_lo_pos();
|
||||
alt (p.peek()) {
|
||||
|
|
@ -2417,10 +2398,10 @@ impure fn parse_crate_directive(parser p) -> ast.crate_directive
|
|||
p.bump();
|
||||
auto n = parse_path(p, GREEDY);
|
||||
expect(p, token.EQ);
|
||||
auto e = parse_effect(p);
|
||||
auto a = parse_auth(p);
|
||||
auto hi = p.get_hi_pos();
|
||||
expect(p, token.SEMI);
|
||||
ret spanned(lo, hi, ast.cdir_auth(n, e));
|
||||
ret spanned(lo, hi, ast.cdir_auth(n, a));
|
||||
}
|
||||
|
||||
case (token.META) {
|
||||
|
|
@ -2510,7 +2491,7 @@ impure fn parse_crate_directive(parser p) -> ast.crate_directive
|
|||
}
|
||||
|
||||
|
||||
impure fn parse_crate_directives(parser p, token.token term)
|
||||
fn parse_crate_directives(parser p, token.token term)
|
||||
-> vec[@ast.crate_directive] {
|
||||
|
||||
let vec[@ast.crate_directive] cdirs = vec();
|
||||
|
|
@ -2523,7 +2504,7 @@ impure fn parse_crate_directives(parser p, token.token term)
|
|||
ret cdirs;
|
||||
}
|
||||
|
||||
impure fn parse_crate_from_crate_file(parser p) -> @ast.crate {
|
||||
fn parse_crate_from_crate_file(parser p) -> @ast.crate {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto prefix = std.fs.dirname(p.get_filemap().name);
|
||||
auto cdirs = parse_crate_directives(p, token.EOF);
|
||||
|
|
|
|||
|
|
@ -100,8 +100,7 @@ tag token {
|
|||
STATE;
|
||||
GC;
|
||||
|
||||
/* Effect keywords */
|
||||
IMPURE;
|
||||
/* Unsafe-block keyword */
|
||||
UNSAFE;
|
||||
|
||||
/* Type qualifiers */
|
||||
|
|
@ -273,8 +272,7 @@ fn to_str(token t) -> str {
|
|||
case (STATE) { ret "state"; }
|
||||
case (GC) { ret "gc"; }
|
||||
|
||||
/* Effect keywords */
|
||||
case (IMPURE) { ret "impure"; }
|
||||
/* Unsafe-block keyword */
|
||||
case (UNSAFE) { ret "unsafe"; }
|
||||
|
||||
/* Type qualifiers */
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ type ast_fold[ENV] =
|
|||
vec[ast.ty_method] meths) -> @ty) fold_ty_obj,
|
||||
|
||||
(fn(&ENV e, &span sp,
|
||||
ast.effect eff,
|
||||
ast.proto proto,
|
||||
vec[rec(ast.mode mode, @ty ty)] inputs,
|
||||
@ty output) -> @ty) fold_ty_fn,
|
||||
|
|
@ -299,7 +298,7 @@ type ast_fold[ENV] =
|
|||
ast.proto proto,
|
||||
&block body) -> ast._fn) fold_fn,
|
||||
|
||||
(fn(&ENV e, ast.effect effect,
|
||||
(fn(&ENV e,
|
||||
vec[arg] inputs,
|
||||
@ty output) -> ast.fn_decl) fold_fn_decl,
|
||||
|
||||
|
|
@ -398,12 +397,12 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty {
|
|||
case (ast.ty_obj(?meths)) {
|
||||
let vec[ast.ty_method] meths_ = vec();
|
||||
for (ast.ty_method m in meths) {
|
||||
auto tfn = fold_ty_fn(env_, fld, t.span, m.effect, m.proto,
|
||||
auto tfn = fold_ty_fn(env_, fld, t.span, m.proto,
|
||||
m.inputs, m.output);
|
||||
alt (tfn.node) {
|
||||
case (ast.ty_fn(?eff, ?p, ?ins, ?out)) {
|
||||
case (ast.ty_fn(?p, ?ins, ?out)) {
|
||||
_vec.push[ast.ty_method]
|
||||
(meths_, rec(effect=eff, proto=p, inputs=ins,
|
||||
(meths_, rec(proto=p, inputs=ins,
|
||||
output=out with m));
|
||||
}
|
||||
}
|
||||
|
|
@ -416,8 +415,8 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty {
|
|||
ret fld.fold_ty_path(env_, t.span, pth_, ref_opt);
|
||||
}
|
||||
|
||||
case (ast.ty_fn(?eff, ?proto, ?inputs, ?output)) {
|
||||
ret fold_ty_fn(env_, fld, t.span, eff, proto, inputs, output);
|
||||
case (ast.ty_fn(?proto, ?inputs, ?output)) {
|
||||
ret fold_ty_fn(env_, fld, t.span, proto, inputs, output);
|
||||
}
|
||||
|
||||
case (ast.ty_chan(?ty)) {
|
||||
|
|
@ -433,7 +432,7 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty {
|
|||
}
|
||||
|
||||
fn fold_ty_fn[ENV](&ENV env, ast_fold[ENV] fld, &span sp,
|
||||
ast.effect eff, ast.proto proto,
|
||||
ast.proto proto,
|
||||
vec[rec(ast.mode mode, @ty ty)] inputs,
|
||||
@ty output) -> @ty {
|
||||
auto output_ = fold_ty(env, fld, output);
|
||||
|
|
@ -443,7 +442,7 @@ fn fold_ty_fn[ENV](&ENV env, ast_fold[ENV] fld, &span sp,
|
|||
auto input_ = rec(ty=ty_ with input);
|
||||
inputs_ += vec(input_);
|
||||
}
|
||||
ret fld.fold_ty_fn(env, sp, eff, proto, inputs_, output_);
|
||||
ret fld.fold_ty_fn(env, sp, proto, inputs_, output_);
|
||||
}
|
||||
|
||||
fn fold_decl[ENV](&ENV env, ast_fold[ENV] fld, @decl d) -> @decl {
|
||||
|
|
@ -894,7 +893,7 @@ fn fold_fn_decl[ENV](&ENV env, ast_fold[ENV] fld,
|
|||
inputs += vec(fold_arg(env, fld, a));
|
||||
}
|
||||
auto output = fold_ty[ENV](env, fld, decl.output);
|
||||
ret fld.fold_fn_decl(env, decl.effect, inputs, output);
|
||||
ret fld.fold_fn_decl(env, inputs, output);
|
||||
}
|
||||
|
||||
fn fold_fn[ENV](&ENV env, ast_fold[ENV] fld, &ast._fn f) -> ast._fn {
|
||||
|
|
@ -1187,10 +1186,10 @@ fn identity_fold_ty_obj[ENV](&ENV env, &span sp,
|
|||
}
|
||||
|
||||
fn identity_fold_ty_fn[ENV](&ENV env, &span sp,
|
||||
ast.effect eff, ast.proto proto,
|
||||
ast.proto proto,
|
||||
vec[rec(ast.mode mode, @ty ty)] inputs,
|
||||
@ty output) -> @ty {
|
||||
ret @respan(sp, ast.ty_fn(eff, proto, inputs, output));
|
||||
ret @respan(sp, ast.ty_fn(proto, inputs, output));
|
||||
}
|
||||
|
||||
fn identity_fold_ty_path[ENV](&ENV env, &span sp, ast.path p,
|
||||
|
|
@ -1530,10 +1529,9 @@ fn identity_fold_block[ENV](&ENV e, &span sp, &ast.block_ blk) -> block {
|
|||
}
|
||||
|
||||
fn identity_fold_fn_decl[ENV](&ENV e,
|
||||
ast.effect effect,
|
||||
vec[arg] inputs,
|
||||
@ty output) -> ast.fn_decl {
|
||||
ret rec(effect=effect, inputs=inputs, output=output);
|
||||
ret rec(inputs=inputs, output=output);
|
||||
}
|
||||
|
||||
fn identity_fold_fn[ENV](&ENV e,
|
||||
|
|
@ -1638,7 +1636,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
|
|||
fold_ty_tup = bind identity_fold_ty_tup[ENV](_,_,_),
|
||||
fold_ty_rec = bind identity_fold_ty_rec[ENV](_,_,_),
|
||||
fold_ty_obj = bind identity_fold_ty_obj[ENV](_,_,_),
|
||||
fold_ty_fn = bind identity_fold_ty_fn[ENV](_,_,_,_,_,_),
|
||||
fold_ty_fn = bind identity_fold_ty_fn[ENV](_,_,_,_,_),
|
||||
fold_ty_path = bind identity_fold_ty_path[ENV](_,_,_,_),
|
||||
fold_ty_chan = bind identity_fold_ty_chan[ENV](_,_,_),
|
||||
fold_ty_port = bind identity_fold_ty_port[ENV](_,_,_),
|
||||
|
|
@ -1708,7 +1706,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
|
|||
bind identity_fold_native_item_ty[ENV](_,_,_,_),
|
||||
fold_item_tag = bind identity_fold_item_tag[ENV](_,_,_,_,_,_,_),
|
||||
fold_item_obj = bind identity_fold_item_obj[ENV](_,_,_,_,_,_,_),
|
||||
|
||||
|
||||
fold_view_item_use =
|
||||
bind identity_fold_view_item_use[ENV](_,_,_,_,_,_),
|
||||
fold_view_item_import =
|
||||
|
|
@ -1720,7 +1718,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
|
|||
|
||||
fold_block = bind identity_fold_block[ENV](_,_,_),
|
||||
fold_fn = bind identity_fold_fn[ENV](_,_,_,_),
|
||||
fold_fn_decl = bind identity_fold_fn_decl[ENV](_,_,_,_),
|
||||
fold_fn_decl = bind identity_fold_fn_decl[ENV](_,_,_),
|
||||
fold_mod = bind identity_fold_mod[ENV](_,_),
|
||||
fold_native_mod = bind identity_fold_native_mod[ENV](_,_),
|
||||
fold_crate = bind identity_fold_crate[ENV](_,_,_,_),
|
||||
|
|
|
|||
|
|
@ -521,8 +521,8 @@ fn create_index[T](vec[tup(T, uint)] index, fn(&T) -> uint hash_fn)
|
|||
ret buckets;
|
||||
}
|
||||
|
||||
impure fn encode_index[T](&ebml.writer ebml_w, vec[vec[tup(T, uint)]] buckets,
|
||||
impure fn(io.writer, &T) write_fn) {
|
||||
fn encode_index[T](&ebml.writer ebml_w, vec[vec[tup(T, uint)]] buckets,
|
||||
fn(io.writer, &T) write_fn) {
|
||||
auto writer = io.new_writer_(ebml_w.writer);
|
||||
|
||||
ebml.start_tag(ebml_w, tag_index);
|
||||
|
|
@ -553,16 +553,16 @@ impure fn encode_index[T](&ebml.writer ebml_w, vec[vec[tup(T, uint)]] buckets,
|
|||
}
|
||||
|
||||
|
||||
impure fn write_str(io.writer writer, &str s) {
|
||||
fn write_str(io.writer writer, &str s) {
|
||||
writer.write_str(s);
|
||||
}
|
||||
|
||||
impure fn write_int(io.writer writer, &int n) {
|
||||
fn write_int(io.writer writer, &int n) {
|
||||
writer.write_be_uint(n as uint, 4u);
|
||||
}
|
||||
|
||||
|
||||
impure fn encode_metadata(@trans.crate_ctxt cx, @ast.crate crate)
|
||||
fn encode_metadata(@trans.crate_ctxt cx, @ast.crate crate)
|
||||
-> ValueRef {
|
||||
auto string_w = io.string_writer();
|
||||
auto buf_w = string_w.get_writer().get_buf_writer();
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@ tag sty {
|
|||
ty_task;
|
||||
ty_tup(vec[mt]);
|
||||
ty_rec(vec[field]);
|
||||
ty_fn(ast.proto, vec[arg], @t); // TODO: effect
|
||||
ty_native_fn(ast.native_abi, vec[arg], @t); // TODO: effect
|
||||
ty_fn(ast.proto, vec[arg], @t);
|
||||
ty_native_fn(ast.native_abi, vec[arg], @t);
|
||||
ty_obj(vec[method]);
|
||||
ty_var(int); // ephemeral type var
|
||||
ty_local(ast.def_id); // type of a local var
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ fn ast_ty_to_ty(ty_getter getter, &@ast.ty ast_ty) -> @ty.t {
|
|||
sty = ty.ty_rec(flds);
|
||||
}
|
||||
|
||||
case (ast.ty_fn(_, ?proto, ?inputs, ?output)) {
|
||||
case (ast.ty_fn(?proto, ?inputs, ?output)) {
|
||||
auto f = bind ast_arg_to_arg(getter, _);
|
||||
auto i = _vec.map[ast.ty_arg, arg](f, inputs);
|
||||
sty = ty.ty_fn(proto, i, ast_ty_to_ty(getter, output));
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ fn mk_fn_info(_fn f) -> fn_info {
|
|||
ret res;
|
||||
}
|
||||
|
||||
/* extends mk_fn_info to an item, side-effecting the map fi from
|
||||
/* extends mk_fn_info to an item, side-effecting the map fi from
|
||||
function IDs to fn_info maps */
|
||||
fn mk_fn_info_item_fn(&_fn_info_map fi, &span sp, ident i, &ast._fn f,
|
||||
vec[ast.ty_param] ty_params, def_id id, ann a) -> @item {
|
||||
|
|
@ -888,14 +888,14 @@ fn find_pre_post_expr(&_fn_info_map fm, &fn_info enclosing, &expr e) -> () {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn gen(&fn_info enclosing, &ann a, def_id id) -> bool {
|
||||
fn gen(&fn_info enclosing, &ann a, def_id id) -> bool {
|
||||
check(enclosing.contains_key(id));
|
||||
let uint i = (enclosing.get(id))._0;
|
||||
|
||||
ret set_in_postcond(i, (ann_to_ts_ann_fail_more(a)).conditions);
|
||||
}
|
||||
|
||||
impure fn gen_poststate(&fn_info enclosing, &ann a, def_id id) -> bool {
|
||||
fn gen_poststate(&fn_info enclosing, &ann a, def_id id) -> bool {
|
||||
check(enclosing.contains_key(id));
|
||||
let uint i = (enclosing.get(id))._0;
|
||||
|
||||
|
|
@ -976,7 +976,7 @@ fn find_pre_post_state_item(_fn_info_map fm, @item i) -> bool {
|
|||
fail;
|
||||
}
|
||||
|
||||
impure fn set_prestate_ann(ann a, prestate pre) -> bool {
|
||||
fn set_prestate_ann(ann a, prestate pre) -> bool {
|
||||
alt (a) {
|
||||
case (ann_type(_,_,?ts_a)) {
|
||||
check (! is_none[@ts_ann](ts_a));
|
||||
|
|
@ -990,7 +990,7 @@ impure fn set_prestate_ann(ann a, prestate pre) -> bool {
|
|||
}
|
||||
|
||||
|
||||
impure fn extend_prestate_ann(ann a, prestate pre) -> bool {
|
||||
fn extend_prestate_ann(ann a, prestate pre) -> bool {
|
||||
alt (a) {
|
||||
case (ann_type(_,_,?ts_a)) {
|
||||
check (! is_none[@ts_ann](ts_a));
|
||||
|
|
@ -1003,7 +1003,7 @@ impure fn extend_prestate_ann(ann a, prestate pre) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn set_poststate_ann(ann a, poststate post) -> bool {
|
||||
fn set_poststate_ann(ann a, poststate post) -> bool {
|
||||
alt (a) {
|
||||
case (ann_type(_,_,?ts_a)) {
|
||||
check (! is_none[@ts_ann](ts_a));
|
||||
|
|
@ -1016,7 +1016,7 @@ impure fn set_poststate_ann(ann a, poststate post) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn extend_poststate_ann(ann a, poststate post) -> bool {
|
||||
fn extend_poststate_ann(ann a, poststate post) -> bool {
|
||||
alt (a) {
|
||||
case (ann_type(_,_,?ts_a)) {
|
||||
check (! is_none[@ts_ann](ts_a));
|
||||
|
|
@ -1029,7 +1029,7 @@ impure fn extend_poststate_ann(ann a, poststate post) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn set_pre_and_post(&ann a, pre_and_post pp) -> () {
|
||||
fn set_pre_and_post(&ann a, pre_and_post pp) -> () {
|
||||
alt (a) {
|
||||
case (ann_type(_,_,?ts_a)) {
|
||||
check (! is_none[@ts_ann](ts_a));
|
||||
|
|
@ -1068,7 +1068,7 @@ fn find_pre_post_state_exprs(&_fn_info_map fm,
|
|||
ret changed;
|
||||
}
|
||||
|
||||
impure fn pure_exp(&ann a, &prestate p) -> bool {
|
||||
fn pure_exp(&ann a, &prestate p) -> bool {
|
||||
auto changed = false;
|
||||
changed = extend_prestate_ann(a, p) || changed;
|
||||
changed = extend_poststate_ann(a, p) || changed;
|
||||
|
|
@ -1363,7 +1363,7 @@ fn fixed_point_states(_fn_info_map fm, fn_info f_info,
|
|||
}
|
||||
}
|
||||
|
||||
impure fn check_states_expr(fn_info enclosing, &expr e) -> () {
|
||||
fn check_states_expr(fn_info enclosing, &expr e) -> () {
|
||||
let precond prec = expr_precond(e);
|
||||
let prestate pres = expr_prestate(e);
|
||||
|
||||
|
|
|
|||
|
|
@ -48,14 +48,14 @@ fn mkstate(io.writer out, uint width) -> ps {
|
|||
mutable potential_brk=false);
|
||||
}
|
||||
|
||||
impure fn write_spaces(ps p, uint i) {
|
||||
fn write_spaces(ps p, uint i) {
|
||||
while (i > 0u) {
|
||||
i -= 1u;
|
||||
p.out.write_str(" ");
|
||||
}
|
||||
}
|
||||
|
||||
impure fn push_context(ps p, contexttype tp, uint indent) {
|
||||
fn push_context(ps p, contexttype tp, uint indent) {
|
||||
before_print(p, false);
|
||||
_vec.push[context](p.context, rec(tp=tp, indent=indent));
|
||||
p.start_of_box = true;
|
||||
|
|
@ -65,13 +65,13 @@ fn pop_context(ps p) {
|
|||
_vec.pop[context](p.context);
|
||||
}
|
||||
|
||||
impure fn add_token(ps p, token tok) {
|
||||
fn add_token(ps p, token tok) {
|
||||
if (p.width == 0u) {direct_token(p, tok);}
|
||||
else if (p.scanning == scan_none) {do_token(p, tok);}
|
||||
else {buffer_token(p, tok);}
|
||||
}
|
||||
|
||||
impure fn direct_token(ps p, token tok) {
|
||||
fn direct_token(ps p, token tok) {
|
||||
alt (tok) {
|
||||
case (brk(?sz)) {write_spaces(p, sz);}
|
||||
case (word(?w)) {p.out.write_str(w);}
|
||||
|
|
@ -80,7 +80,7 @@ impure fn direct_token(ps p, token tok) {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn buffer_token(ps p, token tok) {
|
||||
fn buffer_token(ps p, token tok) {
|
||||
p.buffered += vec(tok);
|
||||
auto col = p.scancol;
|
||||
p.scancol = col + token_size(tok);
|
||||
|
|
@ -114,14 +114,14 @@ impure fn buffer_token(ps p, token tok) {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn check_potential_brk(ps p) {
|
||||
fn check_potential_brk(ps p) {
|
||||
for (boxtype tp in p.scandepth) {
|
||||
if (tp != box_h) {ret;}
|
||||
}
|
||||
p.potential_brk = true;
|
||||
}
|
||||
|
||||
impure fn finish_scan(ps p, bool fits) {
|
||||
fn finish_scan(ps p, bool fits) {
|
||||
auto buf = p.buffered;
|
||||
auto front = _vec.shift[token](buf);
|
||||
auto chosen_tp = cx_h;
|
||||
|
|
@ -145,7 +145,7 @@ impure fn finish_scan(ps p, bool fits) {
|
|||
for (token t in buf) { add_token(p, t); }
|
||||
}
|
||||
|
||||
impure fn start_scan(ps p, token tok, scantype tp) {
|
||||
fn start_scan(ps p, token tok, scantype tp) {
|
||||
p.buffered = vec();
|
||||
p.scancol = p.col;
|
||||
p.scanning = tp;
|
||||
|
|
@ -174,7 +174,7 @@ fn box_is(boxtype a, boxtype b) -> bool {
|
|||
else {ret false;}
|
||||
}
|
||||
|
||||
impure fn do_token(ps p, token tok) {
|
||||
fn do_token(ps p, token tok) {
|
||||
auto start_of_box = p.start_of_box;
|
||||
p.start_of_box = false;
|
||||
alt (tok) {
|
||||
|
|
@ -223,14 +223,14 @@ impure fn do_token(ps p, token tok) {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn line_break(ps p) {
|
||||
fn line_break(ps p) {
|
||||
p.out.write_str("\n");
|
||||
p.col = 0u;
|
||||
p.spaces = cur_context(p).indent;
|
||||
p.start_of_line = true;
|
||||
}
|
||||
|
||||
impure fn before_print(ps p, bool closing) {
|
||||
fn before_print(ps p, bool closing) {
|
||||
if (p.start_of_line) {
|
||||
p.start_of_line = false;
|
||||
if (closing) {p.spaces = base_indent(p);}
|
||||
|
|
@ -254,14 +254,14 @@ fn token_size(token tok) -> uint {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn box(ps p, uint indent) {add_token(p, open(box_hv, indent));}
|
||||
impure fn abox(ps p) {add_token(p, open(box_align, 0u));}
|
||||
impure fn vbox(ps p, uint indent) {add_token(p, open(box_v, indent));}
|
||||
impure fn hbox(ps p, uint indent) {add_token(p, open(box_h, indent));}
|
||||
impure fn end(ps p) {add_token(p, close);}
|
||||
impure fn wrd(ps p, str wrd) {add_token(p, word(wrd));}
|
||||
impure fn cwrd(ps p, str wrd) {add_token(p, cword(wrd));}
|
||||
impure fn space(ps p) {add_token(p, brk(1u));}
|
||||
impure fn spaces(ps p, uint n) {add_token(p, brk(n));}
|
||||
impure fn line(ps p) {add_token(p, brk(0u));}
|
||||
impure fn hardbreak(ps p) {add_token(p, hardbrk);}
|
||||
fn box(ps p, uint indent) {add_token(p, open(box_hv, indent));}
|
||||
fn abox(ps p) {add_token(p, open(box_align, 0u));}
|
||||
fn vbox(ps p, uint indent) {add_token(p, open(box_v, indent));}
|
||||
fn hbox(ps p, uint indent) {add_token(p, open(box_h, indent));}
|
||||
fn end(ps p) {add_token(p, close);}
|
||||
fn wrd(ps p, str wrd) {add_token(p, word(wrd));}
|
||||
fn cwrd(ps p, str wrd) {add_token(p, cword(wrd));}
|
||||
fn space(ps p) {add_token(p, brk(1u));}
|
||||
fn spaces(ps p, uint n) {add_token(p, brk(n));}
|
||||
fn line(ps p) {add_token(p, brk(0u));}
|
||||
fn hardbreak(ps p) {add_token(p, hardbrk);}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ type ps = @rec(pp.ps s,
|
|||
option.t[vec[lexer.cmnt]] comments,
|
||||
mutable uint cur_cmnt);
|
||||
|
||||
impure fn print_file(ast._mod _mod, str filename, io.writer out) {
|
||||
fn print_file(ast._mod _mod, str filename, io.writer out) {
|
||||
auto cmnts = lexer.gather_comments(filename);
|
||||
auto s = @rec(s=pp.mkstate(out, default_columns),
|
||||
comments=option.some[vec[lexer.cmnt]](cmnts),
|
||||
|
|
@ -59,39 +59,39 @@ fn pat_to_str(&@ast.pat p) -> str {
|
|||
ret writer.get_str();
|
||||
}
|
||||
|
||||
impure fn hbox(ps s) {
|
||||
fn hbox(ps s) {
|
||||
pp.hbox(s.s, indent_unit);
|
||||
}
|
||||
impure fn wrd1(ps s, str word) {
|
||||
fn wrd1(ps s, str word) {
|
||||
wrd(s.s, word);
|
||||
space(s.s);
|
||||
}
|
||||
impure fn popen(ps s) {
|
||||
fn popen(ps s) {
|
||||
wrd(s.s, "(");
|
||||
pp.abox(s.s);
|
||||
}
|
||||
impure fn popen_h(ps s) {
|
||||
fn popen_h(ps s) {
|
||||
wrd(s.s, "(");
|
||||
pp.hbox(s.s, 0u);
|
||||
}
|
||||
impure fn pclose(ps s) {
|
||||
fn pclose(ps s) {
|
||||
end(s.s);
|
||||
wrd(s.s, ")");
|
||||
}
|
||||
impure fn bopen(ps s) {
|
||||
fn bopen(ps s) {
|
||||
wrd(s.s, "{");
|
||||
pp.vbox(s.s, indent_unit);
|
||||
line(s.s);
|
||||
}
|
||||
impure fn bclose(ps s) {
|
||||
fn bclose(ps s) {
|
||||
end(s.s);
|
||||
pp.cwrd(s.s, "}");
|
||||
}
|
||||
impure fn bclose_c(ps s, common.span span) {
|
||||
fn bclose_c(ps s, common.span span) {
|
||||
maybe_print_comment(s, span.hi);
|
||||
bclose(s);
|
||||
}
|
||||
impure fn commasep[IN](ps s, vec[IN] elts, impure fn(ps, &IN) op) {
|
||||
fn commasep[IN](ps s, vec[IN] elts, fn(ps, &IN) op) {
|
||||
auto first = true;
|
||||
for (IN elt in elts) {
|
||||
if (first) {first = false;}
|
||||
|
|
@ -99,7 +99,7 @@ impure fn commasep[IN](ps s, vec[IN] elts, impure fn(ps, &IN) op) {
|
|||
op(s, elt);
|
||||
}
|
||||
}
|
||||
impure fn commasep_cmnt[IN](ps s, vec[IN] elts, impure fn(ps, &IN) op,
|
||||
fn commasep_cmnt[IN](ps s, vec[IN] elts, fn(ps, &IN) op,
|
||||
fn(&IN) -> common.span get_span) {
|
||||
auto len = _vec.len[IN](elts);
|
||||
auto i = 0u;
|
||||
|
|
@ -112,21 +112,21 @@ impure fn commasep_cmnt[IN](ps s, vec[IN] elts, impure fn(ps, &IN) op,
|
|||
}
|
||||
}
|
||||
}
|
||||
impure fn commasep_exprs(ps s, vec[@ast.expr] exprs) {
|
||||
fn commasep_exprs(ps s, vec[@ast.expr] exprs) {
|
||||
fn expr_span(&@ast.expr expr) -> common.span {ret expr.span;}
|
||||
auto f = print_expr;
|
||||
auto gs = expr_span;
|
||||
commasep_cmnt[@ast.expr](s, exprs, f, gs);
|
||||
}
|
||||
|
||||
impure fn print_mod(ps s, ast._mod _mod) {
|
||||
fn print_mod(ps s, ast._mod _mod) {
|
||||
for (@ast.view_item vitem in _mod.view_items) {print_view_item(s, vitem);}
|
||||
line(s.s);
|
||||
for (@ast.item item in _mod.items) {print_item(s, item);}
|
||||
print_remaining_comments(s);
|
||||
}
|
||||
|
||||
impure fn print_type(ps s, &@ast.ty ty) {
|
||||
fn print_type(ps s, &@ast.ty ty) {
|
||||
maybe_print_comment(s, ty.span.lo);
|
||||
hbox(s);
|
||||
alt (ty.node) {
|
||||
|
|
@ -159,7 +159,7 @@ impure fn print_type(ps s, &@ast.ty ty) {
|
|||
case (ast.ty_rec(?fields)) {
|
||||
wrd(s.s, "rec");
|
||||
popen(s);
|
||||
impure fn print_field(ps s, &ast.ty_field f) {
|
||||
fn print_field(ps s, &ast.ty_field f) {
|
||||
hbox(s);
|
||||
print_mt(s, f.mt);
|
||||
space(s.s);
|
||||
|
|
@ -182,7 +182,7 @@ impure fn print_type(ps s, &@ast.ty ty) {
|
|||
bopen(s);
|
||||
for (ast.ty_method m in methods) {
|
||||
hbox(s);
|
||||
print_ty_fn(s, m.effect, m.proto, option.some[str](m.ident),
|
||||
print_ty_fn(s, m.proto, option.some[str](m.ident),
|
||||
m.inputs, m.output);
|
||||
wrd(s.s, ";");
|
||||
end(s.s);
|
||||
|
|
@ -190,8 +190,8 @@ impure fn print_type(ps s, &@ast.ty ty) {
|
|||
}
|
||||
bclose_c(s, ty.span);
|
||||
}
|
||||
case (ast.ty_fn(?eff, ?proto,?inputs,?output)) {
|
||||
print_ty_fn(s, eff, proto, option.none[str], inputs, output);
|
||||
case (ast.ty_fn(?proto,?inputs,?output)) {
|
||||
print_ty_fn(s, proto, option.none[str], inputs, output);
|
||||
}
|
||||
case (ast.ty_path(?path,_)) {
|
||||
print_path(s, path);
|
||||
|
|
@ -200,7 +200,7 @@ impure fn print_type(ps s, &@ast.ty ty) {
|
|||
end(s.s);
|
||||
}
|
||||
|
||||
impure fn print_item(ps s, @ast.item item) {
|
||||
fn print_item(ps s, @ast.item item) {
|
||||
maybe_print_comment(s, item.span.lo);
|
||||
hbox(s);
|
||||
alt (item.node) {
|
||||
|
|
@ -278,7 +278,7 @@ impure fn print_item(ps s, @ast.item item) {
|
|||
wrd(s.s, v.node.name);
|
||||
if (_vec.len[ast.variant_arg](v.node.args) > 0u) {
|
||||
popen(s);
|
||||
impure fn print_variant_arg(ps s, &ast.variant_arg arg) {
|
||||
fn print_variant_arg(ps s, &ast.variant_arg arg) {
|
||||
print_type(s, arg.ty);
|
||||
}
|
||||
auto f = print_variant_arg;
|
||||
|
|
@ -295,7 +295,7 @@ impure fn print_item(ps s, @ast.item item) {
|
|||
wrd(s.s, id);
|
||||
print_type_params(s, params);
|
||||
popen(s);
|
||||
impure fn print_field(ps s, &ast.obj_field field) {
|
||||
fn print_field(ps s, &ast.obj_field field) {
|
||||
hbox(s);
|
||||
print_type(s, field.ty);
|
||||
space(s.s);
|
||||
|
|
@ -337,7 +337,7 @@ impure fn print_item(ps s, @ast.item item) {
|
|||
line(s.s);
|
||||
}
|
||||
|
||||
impure fn print_block(ps s, ast.block blk) {
|
||||
fn print_block(ps s, ast.block blk) {
|
||||
maybe_print_comment(s, blk.span.lo);
|
||||
bopen(s);
|
||||
for (@ast.stmt st in blk.node.stmts) {
|
||||
|
|
@ -359,7 +359,7 @@ impure fn print_block(ps s, ast.block blk) {
|
|||
bclose_c(s, blk.span);
|
||||
}
|
||||
|
||||
impure fn print_literal(ps s, @ast.lit lit) {
|
||||
fn print_literal(ps s, @ast.lit lit) {
|
||||
maybe_print_comment(s, lit.span.lo);
|
||||
alt (lit.node) {
|
||||
case (ast.lit_str(?st)) {print_string(s, st);}
|
||||
|
|
@ -392,7 +392,7 @@ impure fn print_literal(ps s, @ast.lit lit) {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn print_expr(ps s, &@ast.expr expr) {
|
||||
fn print_expr(ps s, &@ast.expr expr) {
|
||||
maybe_print_comment(s, expr.span.lo);
|
||||
hbox(s);
|
||||
alt (expr.node) {
|
||||
|
|
@ -406,7 +406,7 @@ impure fn print_expr(ps s, &@ast.expr expr) {
|
|||
pclose(s);
|
||||
}
|
||||
case (ast.expr_tup(?exprs,_)) {
|
||||
impure fn printElt(ps s, &ast.elt elt) {
|
||||
fn printElt(ps s, &ast.elt elt) {
|
||||
hbox(s);
|
||||
if (elt.mut == ast.mut) {wrd1(s, "mutable");}
|
||||
print_expr(s, elt.expr);
|
||||
|
|
@ -421,7 +421,7 @@ impure fn print_expr(ps s, &@ast.expr expr) {
|
|||
pclose(s);
|
||||
}
|
||||
case (ast.expr_rec(?fields,?wth,_)) {
|
||||
impure fn print_field(ps s, &ast.field field) {
|
||||
fn print_field(ps s, &ast.field field) {
|
||||
hbox(s);
|
||||
if (field.mut == ast.mut) {wrd1(s, "mutable");}
|
||||
wrd(s.s, field.ident);
|
||||
|
|
@ -460,7 +460,7 @@ impure fn print_expr(ps s, &@ast.expr expr) {
|
|||
print_ident(s, ident);
|
||||
}
|
||||
case (ast.expr_bind(?func,?args,_)) {
|
||||
impure fn print_opt(ps s, &option.t[@ast.expr] expr) {
|
||||
fn print_opt(ps s, &option.t[@ast.expr] expr) {
|
||||
alt (expr) {
|
||||
case (option.some[@ast.expr](?expr)) {
|
||||
print_expr(s, expr);
|
||||
|
|
@ -685,7 +685,7 @@ impure fn print_expr(ps s, &@ast.expr expr) {
|
|||
end(s.s);
|
||||
}
|
||||
|
||||
impure fn print_decl(ps s, @ast.decl decl) {
|
||||
fn print_decl(ps s, @ast.decl decl) {
|
||||
maybe_print_comment(s, decl.span.lo);
|
||||
hbox(s);
|
||||
alt (decl.node) {
|
||||
|
|
@ -724,11 +724,11 @@ impure fn print_decl(ps s, @ast.decl decl) {
|
|||
end(s.s);
|
||||
}
|
||||
|
||||
impure fn print_ident(ps s, ast.ident ident) {
|
||||
fn print_ident(ps s, ast.ident ident) {
|
||||
wrd(s.s, ident);
|
||||
}
|
||||
|
||||
impure fn print_for_decl(ps s, @ast.decl decl) {
|
||||
fn print_for_decl(ps s, @ast.decl decl) {
|
||||
alt (decl.node) {
|
||||
case (ast.decl_local(?loc)) {
|
||||
print_type(s, option.get[@ast.ty](loc.ty));
|
||||
|
|
@ -738,7 +738,7 @@ impure fn print_for_decl(ps s, @ast.decl decl) {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn print_path(ps s, ast.path path) {
|
||||
fn print_path(ps s, ast.path path) {
|
||||
maybe_print_comment(s, path.span.lo);
|
||||
auto first = true;
|
||||
for (str id in path.node.idents) {
|
||||
|
|
@ -754,7 +754,7 @@ impure fn print_path(ps s, ast.path path) {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn print_pat(ps s, &@ast.pat pat) {
|
||||
fn print_pat(ps s, &@ast.pat pat) {
|
||||
maybe_print_comment(s, pat.span.lo);
|
||||
alt (pat.node) {
|
||||
case (ast.pat_wild(_)) {wrd(s.s, "_");}
|
||||
|
|
@ -772,18 +772,13 @@ impure fn print_pat(ps s, &@ast.pat pat) {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn print_fn(ps s, ast.fn_decl decl, str name,
|
||||
fn print_fn(ps s, ast.fn_decl decl, str name,
|
||||
vec[ast.ty_param] typarams) {
|
||||
alt (decl.effect) {
|
||||
case (ast.eff_impure) {wrd1(s, "impure");}
|
||||
case (ast.eff_unsafe) {wrd1(s, "unsafe");}
|
||||
case (_) {}
|
||||
}
|
||||
wrd1(s, "fn");
|
||||
wrd(s.s, name);
|
||||
print_type_params(s, typarams);
|
||||
popen(s);
|
||||
impure fn print_arg(ps s, &ast.arg x) {
|
||||
fn print_arg(ps s, &ast.arg x) {
|
||||
hbox(s);
|
||||
if (x.mode == ast.alias) {wrd(s.s, "&");}
|
||||
print_type(s, x.ty);
|
||||
|
|
@ -804,10 +799,10 @@ impure fn print_fn(ps s, ast.fn_decl decl, str name,
|
|||
}
|
||||
}
|
||||
|
||||
impure fn print_type_params(ps s, vec[ast.ty_param] params) {
|
||||
fn print_type_params(ps s, vec[ast.ty_param] params) {
|
||||
if (_vec.len[ast.ty_param](params) > 0u) {
|
||||
wrd(s.s, "[");
|
||||
impure fn printParam(ps s, &ast.ty_param param) {
|
||||
fn printParam(ps s, &ast.ty_param param) {
|
||||
wrd(s.s, param);
|
||||
}
|
||||
auto f = printParam;
|
||||
|
|
@ -816,7 +811,7 @@ impure fn print_type_params(ps s, vec[ast.ty_param] params) {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn print_view_item(ps s, @ast.view_item item) {
|
||||
fn print_view_item(ps s, @ast.view_item item) {
|
||||
maybe_print_comment(s, item.span.lo);
|
||||
hbox(s);
|
||||
alt (item.node) {
|
||||
|
|
@ -825,7 +820,7 @@ impure fn print_view_item(ps s, @ast.view_item item) {
|
|||
wrd(s.s, id);
|
||||
if (_vec.len[@ast.meta_item](mta) > 0u) {
|
||||
popen(s);
|
||||
impure fn print_meta(ps s, &@ast.meta_item item) {
|
||||
fn print_meta(ps s, &@ast.meta_item item) {
|
||||
hbox(s);
|
||||
wrd1(s, item.node.name);
|
||||
wrd1(s, "=");
|
||||
|
|
@ -869,7 +864,7 @@ fn operator_prec(ast.binop op) -> int {
|
|||
fail;
|
||||
}
|
||||
|
||||
impure fn print_maybe_parens(ps s, @ast.expr expr, int outer_prec) {
|
||||
fn print_maybe_parens(ps s, @ast.expr expr, int outer_prec) {
|
||||
auto add_them;
|
||||
alt (expr.node) {
|
||||
case (ast.expr_binary(?op,_,_,_)) {
|
||||
|
|
@ -907,7 +902,7 @@ fn escape_str(str st, char to_escape) -> str {
|
|||
ret out;
|
||||
}
|
||||
|
||||
impure fn print_mt(ps s, &ast.mt mt) {
|
||||
fn print_mt(ps s, &ast.mt mt) {
|
||||
alt (mt.mut) {
|
||||
case (ast.mut) { wrd1(s, "mutable"); }
|
||||
case (ast.maybe_mut) { wrd1(s, "mutable?"); }
|
||||
|
|
@ -916,17 +911,12 @@ impure fn print_mt(ps s, &ast.mt mt) {
|
|||
print_type(s, mt.ty);
|
||||
}
|
||||
|
||||
impure fn print_string(ps s, str st) {
|
||||
fn print_string(ps s, str st) {
|
||||
wrd(s.s, "\""); wrd(s.s, escape_str(st, '"')); wrd(s.s, "\"");
|
||||
}
|
||||
|
||||
impure fn print_ty_fn(ps s, ast.effect eff, ast.proto proto, option.t[str] id,
|
||||
vec[ast.ty_arg] inputs, @ast.ty output) {
|
||||
alt (eff) {
|
||||
case (ast.eff_impure) {wrd1(s, "impure");}
|
||||
case (ast.eff_unsafe) {wrd1(s, "unsafe");}
|
||||
case (_) {}
|
||||
}
|
||||
fn print_ty_fn(ps s, ast.proto proto, option.t[str] id,
|
||||
vec[ast.ty_arg] inputs, @ast.ty output) {
|
||||
if (proto == ast.proto_fn) {wrd(s.s, "fn");}
|
||||
else {wrd(s.s, "iter");}
|
||||
alt (id) {
|
||||
|
|
@ -934,7 +924,7 @@ impure fn print_ty_fn(ps s, ast.effect eff, ast.proto proto, option.t[str] id,
|
|||
case (_) {}
|
||||
}
|
||||
popen_h(s);
|
||||
impure fn print_arg(ps s, &ast.ty_arg input) {
|
||||
fn print_arg(ps s, &ast.ty_arg input) {
|
||||
if (middle.ty.mode_is_alias(input.mode)) {wrd(s.s, "&");}
|
||||
print_type(s, input.ty);
|
||||
}
|
||||
|
|
@ -962,7 +952,7 @@ fn next_comment(ps s) -> option.t[lexer.cmnt] {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn maybe_print_comment(ps s, uint pos) {
|
||||
fn maybe_print_comment(ps s, uint pos) {
|
||||
while (true) {
|
||||
alt (next_comment(s)) {
|
||||
case (option.some[lexer.cmnt](?cmnt)) {
|
||||
|
|
@ -977,7 +967,7 @@ impure fn maybe_print_comment(ps s, uint pos) {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn maybe_print_line_comment(ps s, common.span span) -> bool {
|
||||
fn maybe_print_line_comment(ps s, common.span span) -> bool {
|
||||
alt (next_comment(s)) {
|
||||
case (option.some[lexer.cmnt](?cmnt)) {
|
||||
if (span.hi + 4u >= cmnt.pos) {
|
||||
|
|
@ -992,7 +982,7 @@ impure fn maybe_print_line_comment(ps s, common.span span) -> bool {
|
|||
ret false;
|
||||
}
|
||||
|
||||
impure fn print_remaining_comments(ps s) {
|
||||
fn print_remaining_comments(ps s) {
|
||||
while (true) {
|
||||
alt (next_comment(s)) {
|
||||
case (option.some[lexer.cmnt](?cmnt)) {
|
||||
|
|
@ -1005,7 +995,7 @@ impure fn print_remaining_comments(ps s) {
|
|||
}
|
||||
}
|
||||
|
||||
impure fn print_comment(ps s, lexer.cmnt_ cmnt) {
|
||||
fn print_comment(ps s, lexer.cmnt_ cmnt) {
|
||||
alt (cmnt) {
|
||||
case (lexer.cmnt_line(?val)) {
|
||||
wrd(s.s, "// " + val);
|
||||
|
|
|
|||
|
|
@ -45,37 +45,11 @@ mod util {
|
|||
mod typestate_ann;
|
||||
}
|
||||
|
||||
auth driver.rustc.main = impure;
|
||||
auth front.creader.parse_ty_str = impure;
|
||||
auth front.creader.load_crate = unsafe;
|
||||
auth front.creader.get_metadata_section = unsafe;
|
||||
auth front.creader.lookup_def = impure;
|
||||
auth front.creader.get_type = impure;
|
||||
auth front.creader.get_symbol = impure;
|
||||
auth front.creader.get_tag_variants = impure;
|
||||
auth front.creader.impure_no_op = impure;
|
||||
auth middle.metadata = unsafe;
|
||||
auth middle.metadata.encode_index = impure;
|
||||
auth middle.metadata.encode_metadata = impure;
|
||||
auth middle.trans = unsafe;
|
||||
auth middle.trans.copy_any_self_to_alloca = impure;
|
||||
auth middle.trans.copy_args_to_allocas = impure;
|
||||
auth middle.trans.trans_block = impure;
|
||||
auth middle.trans.alloc_ty = impure;
|
||||
auth middle.typestate_check.log_expr = impure;
|
||||
auth lib.llvm = unsafe;
|
||||
auth pretty.pprust = impure;
|
||||
auth middle.typestate_check.find_pre_post_block = impure;
|
||||
auth middle.typestate_check.find_pre_post_state_block = impure;
|
||||
auth middle.typestate_check.find_pre_post_state_stmt = impure;
|
||||
auth middle.typestate_check.find_pre_post_state_expr = impure;
|
||||
auth middle.typestate_check.find_pre_post_state_exprs = impure;
|
||||
auth middle.typestate_check.find_pre_post_expr = impure;
|
||||
auth middle.typestate_check.find_pre_post_stmt = impure;
|
||||
auth middle.typestate_check.check_states_against_conditions = impure;
|
||||
auth middle.typestate_check.check_states_stmt = impure;
|
||||
auth middle.typestate_check.log_stmt = impure;
|
||||
auth util.typestate_ann.implies = impure;
|
||||
|
||||
mod lib {
|
||||
alt (target_os) {
|
||||
|
|
|
|||
|
|
@ -85,20 +85,20 @@ fn pps_len(&pre_and_post p) -> uint {
|
|||
ret p.precondition.nbits;
|
||||
}
|
||||
|
||||
impure fn require_and_preserve(uint i, &pre_and_post p) -> () {
|
||||
fn require_and_preserve(uint i, &pre_and_post p) -> () {
|
||||
// sets the ith bit in p's pre and post
|
||||
bitv.set(p.precondition, i, true);
|
||||
bitv.set(p.postcondition, i, true);
|
||||
}
|
||||
|
||||
impure fn set_in_postcond(uint i, &pre_and_post p) -> bool {
|
||||
fn set_in_postcond(uint i, &pre_and_post p) -> bool {
|
||||
// sets the ith bit in p's post
|
||||
auto was_set = bitv.get(p.postcondition, i);
|
||||
bitv.set(p.postcondition, i, true);
|
||||
ret !was_set;
|
||||
}
|
||||
|
||||
impure fn set_in_poststate(uint i, &pre_and_post_state s) -> bool {
|
||||
fn set_in_poststate(uint i, &pre_and_post_state s) -> bool {
|
||||
// sets the ith bit in p's post
|
||||
auto was_set = bitv.get(s.poststate, i);
|
||||
bitv.set(s.poststate, i, true);
|
||||
|
|
@ -107,35 +107,35 @@ impure fn set_in_poststate(uint i, &pre_and_post_state s) -> bool {
|
|||
|
||||
// Sets all the bits in a's precondition to equal the
|
||||
// corresponding bit in p's precondition.
|
||||
impure fn set_precondition(&ts_ann a, &precond p) -> () {
|
||||
fn set_precondition(&ts_ann a, &precond p) -> () {
|
||||
bitv.copy(a.conditions.precondition, p);
|
||||
}
|
||||
|
||||
// Sets all the bits in a's postcondition to equal the
|
||||
// corresponding bit in p's postcondition.
|
||||
impure fn set_postcondition(&ts_ann a, &postcond p) -> () {
|
||||
fn set_postcondition(&ts_ann a, &postcond p) -> () {
|
||||
bitv.copy(a.conditions.postcondition, p);
|
||||
}
|
||||
|
||||
// Sets all the bits in a's prestate to equal the
|
||||
// corresponding bit in p's prestate.
|
||||
impure fn set_prestate(&ts_ann a, &prestate p) -> bool {
|
||||
fn set_prestate(&ts_ann a, &prestate p) -> bool {
|
||||
ret bitv.copy(a.states.prestate, p);
|
||||
}
|
||||
|
||||
// Sets all the bits in a's postcondition to equal the
|
||||
// corresponding bit in p's postcondition.
|
||||
impure fn set_poststate(&ts_ann a, &poststate p) -> bool {
|
||||
fn set_poststate(&ts_ann a, &poststate p) -> bool {
|
||||
ret bitv.copy(a.states.poststate, p);
|
||||
}
|
||||
|
||||
// Set all the bits in p that are set in new
|
||||
impure fn extend_prestate(&prestate p, &poststate new) -> bool {
|
||||
fn extend_prestate(&prestate p, &poststate new) -> bool {
|
||||
ret bitv.union(p, new);
|
||||
}
|
||||
|
||||
// Set all the bits in p that are set in new
|
||||
impure fn extend_poststate(&poststate p, &poststate new) -> bool {
|
||||
fn extend_poststate(&poststate p, &poststate new) -> bool {
|
||||
ret bitv.union(p, new);
|
||||
}
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ fn ann_prestate(&ts_ann a) -> prestate {
|
|||
// returns true if a implies b
|
||||
// that is, returns true except if for some bits c and d,
|
||||
// c = 1 and d = 0
|
||||
impure fn implies(bitv.t a, bitv.t b) -> bool {
|
||||
fn implies(bitv.t a, bitv.t b) -> bool {
|
||||
auto tmp = bitv.clone(b);
|
||||
bitv.difference(tmp, a);
|
||||
ret bitv.is_false(tmp);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue