diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2010-11-03 17:10:37 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2010-11-05 11:18:40 -0700 |
| commit | adb1754e4dcbf61abb93ac7604aed4e8bca080a8 (patch) | |
| tree | 037acbf63e189a999291e04a9a9db4e777e9c003 /src/comp | |
| parent | e399926776e0d1ef7ebe6d9f0d7ef6d066eabfa0 (diff) | |
| download | rust-adb1754e4dcbf61abb93ac7604aed4e8bca080a8.tar.gz rust-adb1754e4dcbf61abb93ac7604aed4e8bca080a8.zip | |
Move the option type to its own module
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/driver/rustc.rs | 10 | ||||
| -rw-r--r-- | src/comp/front/ast.rs | 15 | ||||
| -rw-r--r-- | src/comp/front/parser.rs | 14 | ||||
| -rw-r--r-- | src/comp/middle/fold.rs | 22 | ||||
| -rw-r--r-- | src/comp/middle/resolve.rs | 18 | ||||
| -rw-r--r-- | src/comp/middle/trans.rs | 10 |
6 files changed, 44 insertions, 45 deletions
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index 920b47d23c8..154b87cbcf4 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -5,9 +5,9 @@ import front.token; import middle.trans; import middle.resolve; -import std.util.option; -import std.util.some; -import std.util.none; +import std.option; +import std.option.some; +import std.option.none; import std._str; import std._vec; @@ -39,8 +39,8 @@ fn usage(session.session sess, str argv0) { impure fn main(vec[str] args) { auto sess = session.session(); - let option[str] input_file = none[str]; - let option[str] output_file = none[str]; + let option.t[str] input_file = none[str]; + let option.t[str] output_file = none[str]; let bool do_warn = true; auto i = 1u; diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index e635c1191b3..a6cbf1ce793 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -1,7 +1,6 @@ -import util.common.option; import std.map.hashmap; -import std.util.option; +import std.option; import util.common.span; import util.common.spanned; @@ -71,16 +70,16 @@ tag unop { type stmt = spanned[stmt_]; tag stmt_ { stmt_decl(@decl); - stmt_ret(option[@expr]); + stmt_ret(option.t[@expr]); stmt_log(@expr); stmt_check_expr(@expr); stmt_expr(@expr); } -type local = rec(option[@ty] ty, +type local = rec(option.t[@ty] ty, bool infer, ident ident, - option[@expr] init, + option.t[@expr] init, def_id id); type decl = spanned[decl_]; @@ -99,14 +98,14 @@ tag expr_ { expr_unary(unop, @expr, ann); expr_lit(@lit, ann); expr_cast(@expr, @ty, ann); - expr_if(@expr, block, option[block], ann); + expr_if(@expr, block, option.t[block], ann); expr_while(@expr, block, ann); expr_do_while(block, @expr, ann); expr_block(block, ann); expr_assign(@expr /* TODO: @expr|is_lval */, @expr, ann); expr_field(@expr, ident, ann); expr_index(@expr, @expr, ann); - expr_name(name, option[def], ann); + expr_name(name, option.t[def], ann); } type lit = spanned[lit_]; @@ -131,7 +130,7 @@ tag ty_ { ty_box(@ty); ty_vec(@ty); ty_tup(vec[tup(bool /* mutability */, @ty)]); - ty_path(path, option[def]); + ty_path(path, option.t[def]); } tag mode { diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index d42f7b4582c..6eb334ca81f 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -1,7 +1,7 @@ import std._io; -import std.util.option; -import std.util.some; -import std.util.none; +import std.option; +import std.option.some; +import std.option.none; import std.map.hashmap; import driver.session; @@ -157,7 +157,7 @@ impure fn parse_arg(parser p) -> ast.arg { impure fn parse_seq[T](token.token bra, token.token ket, - option[token.token] sep, + option.t[token.token] sep, (impure fn(parser) -> T) f, parser p) -> util.common.spanned[vec[T]] { let bool first = true; @@ -185,7 +185,7 @@ impure fn parse_seq[T](token.token bra, ret spanned(lo, hi, v); } -impure fn parse_lit(parser p) -> option[ast.lit] { +impure fn parse_lit(parser p) -> option.t[ast.lit] { auto lo = p.get_span(); let ast.lit_ lit; alt (p.peek()) { @@ -600,7 +600,7 @@ impure fn parse_if_expr(parser p) -> @ast.expr { auto cond = parse_expr(p); expect(p, token.RPAREN); auto thn = parse_block(p); - let option[ast.block] els = none[ast.block]; + let option.t[ast.block] els = none[ast.block]; hi = thn.span; alt (p.peek()) { case (token.ELSE) { @@ -664,7 +664,7 @@ impure fn parse_expr(parser p) -> @ast.expr { } } -impure fn parse_initializer(parser p) -> option[@ast.expr] { +impure fn parse_initializer(parser p) -> option.t[@ast.expr] { if (p.peek() == token.EQ) { p.bump(); ret some(parse_expr(p)); diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs index 8b38c894c8c..48363437b37 100644 --- a/src/comp/middle/fold.rs +++ b/src/comp/middle/fold.rs @@ -1,7 +1,7 @@ import std.map.hashmap; -import std.util.option; -import std.util.some; -import std.util.none; +import std.option; +import std.option.some; +import std.option.none; import util.common.new_str_hash; import util.common.spanned; @@ -47,7 +47,7 @@ type ast_fold[ENV] = vec[tup(bool, @ty)] elts) -> @ty) fold_ty_tup, (fn(&ENV e, &span sp, ast.path p, - &option[def] d) -> @ty) fold_ty_path, + &option.t[def] d) -> @ty) fold_ty_path, // Expr folds. (fn(&ENV e, &span sp, @@ -79,7 +79,7 @@ type ast_fold[ENV] = (fn(&ENV e, &span sp, @expr cond, &block thn, - &option[block] els, + &option.t[block] els, ann a) -> @expr) fold_expr_if, (fn(&ENV e, &span sp, @@ -107,7 +107,7 @@ type ast_fold[ENV] = (fn(&ENV e, &span sp, &name n, - &option[def] d, + &option.t[def] d, ann a) -> @expr) fold_expr_name, // Decl folds. @@ -123,7 +123,7 @@ type ast_fold[ENV] = @decl decl) -> @stmt) fold_stmt_decl, (fn(&ENV e, &span sp, - &option[@expr] rv) -> @stmt) fold_stmt_ret, + &option.t[@expr] rv) -> @stmt) fold_stmt_ret, (fn(&ENV e, &span sp, @expr e) -> @stmt) fold_stmt_log, @@ -568,7 +568,7 @@ fn identity_fold_ty_tup[ENV](&ENV env, &span sp, vec[tup(bool,@ty)] elts) } fn identity_fold_ty_path[ENV](&ENV env, &span sp, ast.path p, - &option[def] d) -> @ty { + &option.t[def] d) -> @ty { ret @respan(sp, ast.ty_path(p, d)); } @@ -614,7 +614,7 @@ fn identity_fold_expr_lit[ENV](&ENV env, &span sp, @ast.lit lit, fn identity_fold_expr_if[ENV](&ENV env, &span sp, @expr cond, &block thn, - &option[block] els, ann a) -> @expr { + &option.t[block] els, ann a) -> @expr { ret @respan(sp, ast.expr_if(cond, thn, els, a)); } @@ -650,7 +650,7 @@ fn identity_fold_expr_index[ENV](&ENV env, &span sp, } fn identity_fold_expr_name[ENV](&ENV env, &span sp, - &name n, &option[def] d, + &name n, &option.t[def] d, ann a) -> @expr { ret @respan(sp, ast.expr_name(n, d, a)); } @@ -675,7 +675,7 @@ fn identity_fold_stmt_decl[ENV](&ENV env, &span sp, @decl d) -> @stmt { } fn identity_fold_stmt_ret[ENV](&ENV env, &span sp, - &option[@expr] rv) -> @stmt { + &option.t[@expr] rv) -> @stmt { ret @respan(sp, ast.stmt_ret(rv)); } diff --git a/src/comp/middle/resolve.rs b/src/comp/middle/resolve.rs index 5741bac44d6..875996db120 100644 --- a/src/comp/middle/resolve.rs +++ b/src/comp/middle/resolve.rs @@ -8,9 +8,9 @@ import std.map.hashmap; import std.list.list; import std.list.nil; import std.list.cons; -import std.util.option; -import std.util.some; -import std.util.none; +import std.option; +import std.option.some; +import std.option.none; import std._str; tag scope { @@ -22,11 +22,11 @@ tag scope { type env = rec(list[scope] scopes, session.session sess); -fn lookup_name(&env e, ast.ident i) -> option[def] { +fn lookup_name(&env e, ast.ident i) -> option.t[def] { // log "resolving name " + i; - fn found_def_item(@ast.item i) -> option[def] { + fn found_def_item(@ast.item i) -> option.t[def] { alt (i.node) { case (ast.item_fn(_, _, ?id)) { ret some[def](ast.def_fn(id)); @@ -40,7 +40,7 @@ fn lookup_name(&env e, ast.ident i) -> option[def] { } } - fn found_decl_stmt(@ast.stmt s) -> option[def] { + fn found_decl_stmt(@ast.stmt s) -> option.t[def] { alt (s.node) { case (ast.stmt_decl(?d)) { alt (d.node) { @@ -56,7 +56,7 @@ fn lookup_name(&env e, ast.ident i) -> option[def] { ret none[def]; } - fn check_mod(ast.ident i, ast._mod m) -> option[def] { + fn check_mod(ast.ident i, ast._mod m) -> option.t[def] { alt (m.index.find(i)) { case (some[uint](?ix)) { ret found_def_item(m.items.(ix)); @@ -66,7 +66,7 @@ fn lookup_name(&env e, ast.ident i) -> option[def] { } - fn in_scope(ast.ident i, &scope s) -> option[def] { + fn in_scope(ast.ident i, &scope s) -> option.t[def] { alt (s) { case (scope_crate(?c)) { @@ -103,7 +103,7 @@ fn lookup_name(&env e, ast.ident i) -> option[def] { } fn fold_expr_name(&env e, &span sp, &ast.name n, - &option[def] d, ann a) -> @ast.expr { + &option.t[def] d, ann a) -> @ast.expr { auto d_ = lookup_name(e, n.node.ident); diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 1783925e1a6..ba4f5cdfdd4 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -3,9 +3,9 @@ import std._vec; import std._str.rustrt.sbuf; import std._vec.rustrt.vbuf; import std.map.hashmap; -import std.util.option; -import std.util.some; -import std.util.none; +import std.option; +import std.option.some; +import std.option.none; import front.ast; import driver.session; @@ -613,7 +613,7 @@ impure fn trans_binary(@block_ctxt cx, ast.binop op, } impure fn trans_if(@block_ctxt cx, &ast.expr cond, - &ast.block thn, &option[ast.block] els) -> result { + &ast.block thn, &option.t[ast.block] els) -> result { auto cond_res = trans_expr(cx, cond); @@ -868,7 +868,7 @@ impure fn trans_check_expr(@block_ctxt cx, &ast.expr e) -> result { ret res(next_cx, C_nil()); } -impure fn trans_ret(@block_ctxt cx, &option[@ast.expr] e) -> result { +impure fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result { auto r = res(cx, C_nil()); alt (e) { case (some[@ast.expr](?x)) { |
