Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1e654f5f
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,发现更多精彩内容 >>
提交
1e654f5f
编写于
12月 18, 2013
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
librustc: De-`@mut` `CrateContext::externs`
上级
519db347
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
15 deletion
+35
-15
src/librustc/middle/trans/base.rs
src/librustc/middle/trans/base.rs
+23
-11
src/librustc/middle/trans/context.rs
src/librustc/middle/trans/context.rs
+2
-2
src/librustc/middle/trans/foreign.rs
src/librustc/middle/trans/foreign.rs
+10
-2
未找到文件。
src/librustc/middle/trans/base.rs
浏览文件 @
1e654f5f
...
@@ -205,15 +205,21 @@ pub fn get_extern_fn(externs: &mut ExternMap, llmod: ModuleRef, name: &str,
...
@@ -205,15 +205,21 @@ pub fn get_extern_fn(externs: &mut ExternMap, llmod: ModuleRef, name: &str,
fn
get_extern_rust_fn
(
ccx
:
&
mut
CrateContext
,
inputs
:
&
[
ty
::
t
],
output
:
ty
::
t
,
fn
get_extern_rust_fn
(
ccx
:
&
mut
CrateContext
,
inputs
:
&
[
ty
::
t
],
output
:
ty
::
t
,
name
:
&
str
,
did
:
ast
::
DefId
)
->
ValueRef
{
name
:
&
str
,
did
:
ast
::
DefId
)
->
ValueRef
{
match
ccx
.externs
.find_equiv
(
&
name
)
{
{
Some
(
n
)
=>
return
*
n
,
let
externs
=
ccx
.externs
.borrow
();
None
=>
()
match
externs
.get
()
.find_equiv
(
&
name
)
{
Some
(
n
)
=>
return
*
n
,
None
=>
()
}
}
}
let
f
=
decl_rust_fn
(
ccx
,
inputs
,
output
,
name
);
let
f
=
decl_rust_fn
(
ccx
,
inputs
,
output
,
name
);
csearch
::
get_item_attrs
(
ccx
.tcx.cstore
,
did
,
|
meta_items
|
{
csearch
::
get_item_attrs
(
ccx
.tcx.cstore
,
did
,
|
meta_items
|
{
set_llvm_fn_attrs
(
meta_items
.iter
()
.map
(|
&
x
|
attr
::
mk_attr
(
x
))
.to_owned_vec
(),
f
)
set_llvm_fn_attrs
(
meta_items
.iter
()
.map
(|
&
x
|
attr
::
mk_attr
(
x
))
.to_owned_vec
(),
f
)
});
});
ccx
.externs
.insert
(
name
.to_owned
(),
f
);
let
mut
externs
=
ccx
.externs
.borrow_mut
();
externs
.get
()
.insert
(
name
.to_owned
(),
f
);
f
f
}
}
...
@@ -559,11 +565,15 @@ pub fn get_res_dtor(ccx: @mut CrateContext,
...
@@ -559,11 +565,15 @@ pub fn get_res_dtor(ccx: @mut CrateContext,
None
,
None
,
ty
::
lookup_item_type
(
tcx
,
parent_id
)
.ty
);
ty
::
lookup_item_type
(
tcx
,
parent_id
)
.ty
);
let
llty
=
type_of_dtor
(
ccx
,
class_ty
);
let
llty
=
type_of_dtor
(
ccx
,
class_ty
);
get_extern_fn
(
&
mut
ccx
.externs
,
ccx
.llmod
,
{
name
,
let
mut
externs
=
ccx
.externs
.borrow_mut
();
lib
::
llvm
::
CCallConv
,
get_extern_fn
(
externs
.get
(),
llty
)
ccx
.llmod
,
name
,
lib
::
llvm
::
CCallConv
,
llty
)
}
}
}
}
}
...
@@ -865,7 +875,8 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) ->
...
@@ -865,7 +875,8 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) ->
let
c
=
foreign
::
llvm_calling_convention
(
ccx
,
fn_ty
.abis
);
let
c
=
foreign
::
llvm_calling_convention
(
ccx
,
fn_ty
.abis
);
let
cconv
=
c
.unwrap_or
(
lib
::
llvm
::
CCallConv
);
let
cconv
=
c
.unwrap_or
(
lib
::
llvm
::
CCallConv
);
let
llty
=
type_of_fn_from_ty
(
ccx
,
t
);
let
llty
=
type_of_fn_from_ty
(
ccx
,
t
);
get_extern_fn
(
&
mut
ccx
.externs
,
ccx
.llmod
,
name
,
cconv
,
llty
)
let
mut
externs
=
ccx
.externs
.borrow_mut
();
get_extern_fn
(
externs
.get
(),
ccx
.llmod
,
name
,
cconv
,
llty
)
}
}
}
}
}
}
...
@@ -874,7 +885,8 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) ->
...
@@ -874,7 +885,8 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) ->
}
}
_
=>
{
_
=>
{
let
llty
=
type_of
(
ccx
,
t
);
let
llty
=
type_of
(
ccx
,
t
);
get_extern_const
(
&
mut
ccx
.externs
,
ccx
.llmod
,
name
,
llty
)
let
mut
externs
=
ccx
.externs
.borrow_mut
();
get_extern_const
(
externs
.get
(),
ccx
.llmod
,
name
,
llty
)
}
}
}
}
}
}
...
...
src/librustc/middle/trans/context.rs
浏览文件 @
1e654f5f
...
@@ -45,7 +45,7 @@ pub struct CrateContext {
...
@@ -45,7 +45,7 @@ pub struct CrateContext {
metadata_llmod
:
ModuleRef
,
metadata_llmod
:
ModuleRef
,
td
:
TargetData
,
td
:
TargetData
,
tn
:
TypeNames
,
tn
:
TypeNames
,
externs
:
ExternMap
,
externs
:
RefCell
<
ExternMap
>
,
intrinsics
:
HashMap
<&
'static
str
,
ValueRef
>
,
intrinsics
:
HashMap
<&
'static
str
,
ValueRef
>
,
item_vals
:
RefCell
<
HashMap
<
ast
::
NodeId
,
ValueRef
>>
,
item_vals
:
RefCell
<
HashMap
<
ast
::
NodeId
,
ValueRef
>>
,
exp_map2
:
resolve
::
ExportMap2
,
exp_map2
:
resolve
::
ExportMap2
,
...
@@ -181,7 +181,7 @@ pub fn new(sess: session::Session,
...
@@ -181,7 +181,7 @@ pub fn new(sess: session::Session,
metadata_llmod
:
metadata_llmod
,
metadata_llmod
:
metadata_llmod
,
td
:
td
,
td
:
td
,
tn
:
tn
,
tn
:
tn
,
externs
:
HashMap
::
new
(
),
externs
:
RefCell
::
new
(
HashMap
::
new
()
),
intrinsics
:
intrinsics
,
intrinsics
:
intrinsics
,
item_vals
:
RefCell
::
new
(
HashMap
::
new
()),
item_vals
:
RefCell
::
new
(
HashMap
::
new
()),
exp_map2
:
emap2
,
exp_map2
:
emap2
,
...
...
src/librustc/middle/trans/foreign.rs
浏览文件 @
1e654f5f
...
@@ -146,8 +146,16 @@ pub fn register_foreign_item_fn(ccx: @mut CrateContext,
...
@@ -146,8 +146,16 @@ pub fn register_foreign_item_fn(ccx: @mut CrateContext,
// Create the LLVM value for the C extern fn
// Create the LLVM value for the C extern fn
let
llfn_ty
=
lltype_for_fn_from_foreign_types
(
&
tys
);
let
llfn_ty
=
lltype_for_fn_from_foreign_types
(
&
tys
);
let
llfn
=
base
::
get_extern_fn
(
&
mut
ccx
.externs
,
ccx
.llmod
,
lname
,
cc
,
llfn_ty
);
let
llfn
;
{
let
mut
externs
=
ccx
.externs
.borrow_mut
();
llfn
=
base
::
get_extern_fn
(
externs
.get
(),
ccx
.llmod
,
lname
,
cc
,
llfn_ty
);
};
add_argument_attributes
(
&
tys
,
llfn
);
add_argument_attributes
(
&
tys
,
llfn
);
return
llfn
;
return
llfn
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录