Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
01a2e996
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
01a2e996
编写于
5月 22, 2012
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
prepare for gather to gather up multiple maps
上级
d2ec15bc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
16 deletion
+18
-16
src/rustc/middle/borrowck.rs
src/rustc/middle/borrowck.rs
+18
-16
未找到文件。
src/rustc/middle/borrowck.rs
浏览文件 @
01a2e996
...
...
@@ -35,12 +35,12 @@ fn check_crate(tcx: ty::ctxt,
root_map
:
root_map
(),
mutbl_map
:
int_hash
()};
let
req_
loan_map
=
if
msg_level
>
0u
{
let
req_
maps
=
if
msg_level
>
0u
{
gather_loans
(
bccx
,
crate
)
}
else
{
int_hash
()
{
req_loan_map
:
int_hash
()}
};
check_loans
(
bccx
,
req_
loan_map
,
crate
);
check_loans
(
bccx
,
req_
maps
,
crate
);
ret
(
bccx
.root_map
,
bccx
.mutbl_map
);
}
...
...
@@ -189,17 +189,19 @@ fn root_map_key_hash(k: root_map_key) -> uint {
// their associated scopes. In phase two, checking loans, we will then make
// sure that all of these loans are honored.
// Maps a scope to a list of loans that were issued within that scope.
type
req_loan_map
=
hashmap
<
ast
::
node_id
,
@
mut
[
@
const
[
loan
]]
>
;
type
req_maps
=
{
req_loan_map
:
hashmap
<
ast
::
node_id
,
@
mut
[
@
const
[
loan
]]
>
};
enum
gather_loan_ctxt
=
@
{
bccx
:
borrowck_ctxt
,
req_
loan_map
:
req_loan_map
};
enum
gather_loan_ctxt
=
@
{
bccx
:
borrowck_ctxt
,
req_
maps
:
req_maps
};
fn
gather_loans
(
bccx
:
borrowck_ctxt
,
crate
:
@
ast
::
crate
)
->
req_loan_map
{
let
glcx
=
gather_loan_ctxt
(
@
{
bccx
:
bccx
,
req_loan_map
:
int_hash
()});
fn
gather_loans
(
bccx
:
borrowck_ctxt
,
crate
:
@
ast
::
crate
)
->
req_maps
{
let
glcx
=
gather_loan_ctxt
(
@
{
bccx
:
bccx
,
req_maps
:
{
req_loan_map
:
int_hash
()}});
let
v
=
visit
::
mk_vt
(
@
{
visit_expr
:
req_loans_in_expr
with
*
visit
::
default_visitor
()});
visit
::
visit_crate
(
*
crate
,
glcx
,
v
);
ret
glcx
.req_
loan_map
;
ret
glcx
.req_
maps
;
}
fn
req_loans_in_expr
(
ex
:
@
ast
::
expr
,
...
...
@@ -332,12 +334,12 @@ fn guarantee_valid(cmt: cmt,
}
fn
add_loans
(
scope_id
:
ast
::
node_id
,
loans
:
@
const
[
loan
])
{
alt
self
.req_loan_map
.find
(
scope_id
)
{
alt
self
.req_
maps.req_
loan_map
.find
(
scope_id
)
{
some
(
l
)
{
*
l
+=
[
loans
];
}
none
{
self
.req_loan_map
.insert
(
scope_id
,
@
mut
[
loans
]);
self
.req_
maps.req_
loan_map
.insert
(
scope_id
,
@
mut
[
loans
]);
}
}
}
...
...
@@ -467,7 +469,7 @@ fn pat_is_variant(pat: @ast::pat) -> bool {
enum
check_loan_ctxt
=
@
{
bccx
:
borrowck_ctxt
,
req_
loan_map
:
req_loan_map
,
req_
maps
:
req_maps
,
// Keep track of whether we're inside a ctor, so as to
// allow mutating immutable fields in the same class if
...
...
@@ -478,10 +480,10 @@ enum check_loan_ctxt = @{
};
fn
check_loans
(
bccx
:
borrowck_ctxt
,
req_
loan_map
:
req_loan_map
,
req_
maps
:
req_maps
,
crate
:
@
ast
::
crate
)
{
let
clcx
=
check_loan_ctxt
(
@
{
bccx
:
bccx
,
req_
loan_map
:
req_loan_map
,
req_
maps
:
req_maps
,
mut
in_ctor
:
false
,
mut
is_pure
:
false
});
let
vt
=
visit
::
mk_vt
(
@
{
visit_expr
:
check_loans_in_expr
,
...
...
@@ -514,7 +516,7 @@ fn walk_loans(scope_id: ast::node_id,
f
:
fn
(
loan
)
->
bool
)
{
let
mut
scope_id
=
scope_id
;
let
region_map
=
self
.tcx
()
.region_map
;
let
req_loan_map
=
self
.req_loan_map
;
let
req_loan_map
=
self
.req_
maps.req_
loan_map
;
loop
{
for
req_loan_map
.find
(
scope_id
)
.each
{
|
loanss
|
...
...
@@ -613,7 +615,7 @@ fn check_pure(expr: @ast::expr) {
}
fn
check_for_conflicting_loans
(
scope_id
:
ast
::
node_id
)
{
let
new_loanss
=
alt
self
.req_loan_map
.find
(
scope_id
)
{
let
new_loanss
=
alt
self
.req_
maps.req_
loan_map
.find
(
scope_id
)
{
none
{
ret
;
}
some
(
loanss
)
{
loanss
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录