Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
21deb18b
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,发现更多精彩内容 >>
提交
21deb18b
编写于
11月 10, 2015
作者:
S
Simonas Kazlauskas
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[MIR trans] Translate statics
Fixes #29578
上级
05b66b8a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
16 addition
and
15 deletion
+16
-15
src/librustc_trans/trans/common.rs
src/librustc_trans/trans/common.rs
+10
-0
src/librustc_trans/trans/consts.rs
src/librustc_trans/trans/consts.rs
+2
-14
src/librustc_trans/trans/mir/lvalue.rs
src/librustc_trans/trans/mir/lvalue.rs
+4
-1
未找到文件。
src/librustc_trans/trans/common.rs
浏览文件 @
21deb18b
...
@@ -1214,3 +1214,13 @@ pub fn shift_mask_val<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
...
@@ -1214,3 +1214,13 @@ pub fn shift_mask_val<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
}
}
}
}
pub
fn
get_static_val
<
'a
,
'tcx
>
(
ccx
:
&
CrateContext
<
'a
,
'tcx
>
,
did
:
DefId
,
ty
:
Ty
<
'tcx
>
)
->
ValueRef
{
if
let
Some
(
node_id
)
=
ccx
.tcx
()
.map
.as_local_node_id
(
did
)
{
base
::
get_item_val
(
ccx
,
node_id
)
}
else
{
base
::
trans_external_path
(
ccx
,
did
,
ty
)
}
}
src/librustc_trans/trans/consts.rs
浏览文件 @
21deb18b
...
@@ -29,8 +29,8 @@
...
@@ -29,8 +29,8 @@
use
middle
::
def_id
::
DefId
;
use
middle
::
def_id
::
DefId
;
use
trans
::{
adt
,
closure
,
debuginfo
,
expr
,
inline
,
machine
};
use
trans
::{
adt
,
closure
,
debuginfo
,
expr
,
inline
,
machine
};
use
trans
::
base
::{
self
,
push_ctxt
};
use
trans
::
base
::{
self
,
push_ctxt
};
use
trans
::
common
::{
self
,
type_is_sized
,
ExprOrMethodCall
,
node_id_substs
,
C_nil
,
const_get_elt
};
use
trans
::
common
::{
CrateContext
,
C_integral
,
C_floating
,
C_bool
,
C_str_slice
,
C_bytes
,
val_ty
};
use
trans
::
common
::{
CrateContext
,
C_integral
,
C_floating
,
C_bool
,
C_str_slice
,
C_bytes
,
val_ty
};
use
trans
::
common
::{
type_is_sized
,
ExprOrMethodCall
,
node_id_substs
,
C_nil
,
const_get_elt
};
use
trans
::
common
::{
C_struct
,
C_undef
,
const_to_opt_int
,
const_to_opt_uint
,
VariantInfo
,
C_uint
};
use
trans
::
common
::{
C_struct
,
C_undef
,
const_to_opt_int
,
const_to_opt_uint
,
VariantInfo
,
C_uint
};
use
trans
::
common
::{
type_is_fat_ptr
,
Field
,
C_vector
,
C_array
,
C_null
,
ExprId
,
MethodCallKey
};
use
trans
::
common
::{
type_is_fat_ptr
,
Field
,
C_vector
,
C_array
,
C_null
,
ExprId
,
MethodCallKey
};
use
trans
::
declare
;
use
trans
::
declare
;
...
@@ -795,7 +795,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
...
@@ -795,7 +795,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
}
}
let
opt_def
=
cx
.tcx
()
.def_map
.borrow
()
.get
(
&
cur
.id
)
.map
(|
d
|
d
.full_def
());
let
opt_def
=
cx
.tcx
()
.def_map
.borrow
()
.get
(
&
cur
.id
)
.map
(|
d
|
d
.full_def
());
if
let
Some
(
def
::
DefStatic
(
def_id
,
_
))
=
opt_def
{
if
let
Some
(
def
::
DefStatic
(
def_id
,
_
))
=
opt_def
{
get_static_val
(
cx
,
def_id
,
ety
)
common
::
get_static_val
(
cx
,
def_id
,
ety
)
}
else
{
}
else
{
// If this isn't the address of a static, then keep going through
// If this isn't the address of a static, then keep going through
// normal constant evaluation.
// normal constant evaluation.
...
@@ -1075,15 +1075,3 @@ pub fn trans_static(ccx: &CrateContext,
...
@@ -1075,15 +1075,3 @@ pub fn trans_static(ccx: &CrateContext,
Ok
(
g
)
Ok
(
g
)
}
}
}
}
fn
get_static_val
<
'a
,
'tcx
>
(
ccx
:
&
CrateContext
<
'a
,
'tcx
>
,
did
:
DefId
,
ty
:
Ty
<
'tcx
>
)
->
ValueRef
{
if
let
Some
(
node_id
)
=
ccx
.tcx
()
.map
.as_local_node_id
(
did
)
{
base
::
get_item_val
(
ccx
,
node_id
)
}
else
{
base
::
trans_external_path
(
ccx
,
did
,
ty
)
}
}
src/librustc_trans/trans/mir/lvalue.rs
浏览文件 @
21deb18b
...
@@ -65,7 +65,10 @@ pub fn trans_lvalue(&mut self,
...
@@ -65,7 +65,10 @@ pub fn trans_lvalue(&mut self,
tcx
.sess
.bug
(
&
format!
(
"using operand temp {:?} as lvalue"
,
lvalue
)),
tcx
.sess
.bug
(
&
format!
(
"using operand temp {:?} as lvalue"
,
lvalue
)),
},
},
mir
::
Lvalue
::
Arg
(
index
)
=>
self
.args
[
index
as
usize
],
mir
::
Lvalue
::
Arg
(
index
)
=>
self
.args
[
index
as
usize
],
mir
::
Lvalue
::
Static
(
_
def_id
)
=>
unimplemented!
(),
mir
::
Lvalue
::
Static
(
def_id
)
=>
{
let
const_ty
=
self
.mir
.lvalue_ty
(
tcx
,
lvalue
);
LvalueRef
::
new
(
common
::
get_static_val
(
ccx
,
def_id
,
const_ty
.to_ty
(
tcx
)),
const_ty
)
},
mir
::
Lvalue
::
ReturnPointer
=>
{
mir
::
Lvalue
::
ReturnPointer
=>
{
let
return_ty
=
bcx
.monomorphize
(
&
self
.mir.return_ty
);
let
return_ty
=
bcx
.monomorphize
(
&
self
.mir.return_ty
);
let
llval
=
fcx
.get_ret_slot
(
bcx
,
return_ty
,
"return"
);
let
llval
=
fcx
.get_ret_slot
(
bcx
,
return_ty
,
"return"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录