Move the option type to its own module
This commit is contained in:
parent
e399926776
commit
adb1754e4d
14 changed files with 115 additions and 93 deletions
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue