Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f64e52a7
R
Rust
项目概览
int
/
Rust
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
f64e52a7
编写于
12月 01, 2014
作者:
J
Jorge Aparicio
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tell trans which binops are by value
上级
c3a6d286
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
14 deletion
+20
-14
src/librustc_trans/trans/callee.rs
src/librustc_trans/trans/callee.rs
+6
-5
src/librustc_trans/trans/expr.rs
src/librustc_trans/trans/expr.rs
+14
-9
未找到文件。
src/librustc_trans/trans/callee.rs
浏览文件 @
f64e52a7
...
...
@@ -996,10 +996,11 @@ pub enum CallArgs<'a, 'tcx> {
// value.
ArgVals
(
&
'a
[
ValueRef
]),
// For overloaded operators: `(lhs, Vec(rhs, rhs_id))`. `lhs`
// For overloaded operators: `(lhs, Vec(rhs, rhs_id)
, autoref
)`. `lhs`
// is the left-hand-side and `rhs/rhs_id` is the datum/expr-id of
// the right-hand-side arguments (if any).
ArgOverloadedOp
(
Datum
<
'tcx
,
Expr
>
,
Vec
<
(
Datum
<
'tcx
,
Expr
>
,
ast
::
NodeId
)
>
),
// the right-hand-side arguments (if any). `autoref` indicates whether the `rhs`
// arguments should be auto-referenced
ArgOverloadedOp
(
Datum
<
'tcx
,
Expr
>
,
Vec
<
(
Datum
<
'tcx
,
Expr
>
,
ast
::
NodeId
)
>
,
bool
),
// Supply value of arguments as a list of expressions that must be
// translated, for overloaded call operators.
...
...
@@ -1171,7 +1172,7 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
arg_cleanup_scope
,
ignore_self
)
}
ArgOverloadedOp
(
lhs
,
rhs
)
=>
{
ArgOverloadedOp
(
lhs
,
rhs
,
autoref
)
=>
{
assert
!
(
!
variadic
);
llargs
.push
(
unpack_result!
(
bcx
,
{
...
...
@@ -1185,7 +1186,7 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
llargs
.push
(
unpack_result!
(
bcx
,
{
trans_arg_datum
(
bcx
,
arg_tys
[
1
],
rhs
,
arg_cleanup_scope
,
DoAutorefArg
(
rhs_id
)
)
if
autoref
{
DoAutorefArg
(
rhs_id
)
}
else
{
DontAutorefArg
}
)
}));
}
}
...
...
src/librustc_trans/trans/expr.rs
浏览文件 @
f64e52a7
...
...
@@ -609,7 +609,8 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
method_call
,
base_datum
,
args
,
Some
(
SaveIn
(
scratch
.val
))));
Some
(
SaveIn
(
scratch
.val
)),
true
));
DatumBlock
::
new
(
bcx
,
scratch
.to_expr_datum
())
}
ast
::
ExprBox
(
_
,
ref
contents
)
=>
{
...
...
@@ -762,7 +763,8 @@ fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
method_call
,
base_datum
,
vec!
[(
ix_datum
,
idx
.id
)],
Some
(
SaveIn
(
scratch
.val
))));
Some
(
SaveIn
(
scratch
.val
)),
true
));
let
datum
=
scratch
.to_expr_datum
();
if
ty
::
type_is_sized
(
bcx
.tcx
(),
elt_ty
)
{
Datum
::
new
(
datum
.to_llscalarish
(
bcx
),
elt_ty
,
LvalueExpr
)
...
...
@@ -1092,25 +1094,26 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
callee
::
ArgExprs
(
args
.as_slice
()),
dest
)
}
ast
::
ExprBinary
(
_
,
ref
lhs
,
ref
rhs
)
=>
{
ast
::
ExprBinary
(
op
,
ref
lhs
,
ref
rhs
)
=>
{
// if not overloaded, would be RvalueDatumExpr
let
lhs
=
unpack_datum!
(
bcx
,
trans
(
bcx
,
&**
lhs
));
let
rhs_datum
=
unpack_datum!
(
bcx
,
trans
(
bcx
,
&**
rhs
));
trans_overloaded_op
(
bcx
,
expr
,
MethodCall
::
expr
(
expr
.id
),
lhs
,
vec!
[(
rhs_datum
,
rhs
.id
)],
Some
(
dest
))
.bcx
vec!
[(
rhs_datum
,
rhs
.id
)],
Some
(
dest
),
!
ast_util
::
is_by_value_binop
(
op
))
.bcx
}
ast
::
ExprUnary
(
_
,
ref
subexpr
)
=>
{
// if not overloaded, would be RvalueDatumExpr
let
arg
=
unpack_datum!
(
bcx
,
trans
(
bcx
,
&**
subexpr
));
trans_overloaded_op
(
bcx
,
expr
,
MethodCall
::
expr
(
expr
.id
),
arg
,
Vec
::
new
(),
Some
(
dest
))
.bcx
arg
,
Vec
::
new
(),
Some
(
dest
)
,
true
)
.bcx
}
ast
::
ExprIndex
(
ref
base
,
ref
idx
)
=>
{
// if not overloaded, would be RvalueDatumExpr
let
base
=
unpack_datum!
(
bcx
,
trans
(
bcx
,
&**
base
));
let
idx_datum
=
unpack_datum!
(
bcx
,
trans
(
bcx
,
&**
idx
));
trans_overloaded_op
(
bcx
,
expr
,
MethodCall
::
expr
(
expr
.id
),
base
,
vec!
[(
idx_datum
,
idx
.id
)],
Some
(
dest
))
.bcx
vec!
[(
idx_datum
,
idx
.id
)],
Some
(
dest
)
,
true
)
.bcx
}
ast
::
ExprCast
(
ref
val
,
_
)
=>
{
// DPS output mode means this is a trait cast:
...
...
@@ -1803,7 +1806,8 @@ fn trans_overloaded_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
method_call
:
MethodCall
,
lhs
:
Datum
<
'tcx
,
Expr
>
,
rhs
:
Vec
<
(
Datum
<
'tcx
,
Expr
>
,
ast
::
NodeId
)
>
,
dest
:
Option
<
Dest
>
)
dest
:
Option
<
Dest
>
,
autoref
:
bool
)
->
Result
<
'blk
,
'tcx
>
{
let
method_ty
=
(
*
bcx
.tcx
()
.method_map
.borrow
())[
method_call
]
.ty
;
callee
::
trans_call_inner
(
bcx
,
...
...
@@ -1815,7 +1819,7 @@ fn trans_overloaded_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
None
,
arg_cleanup_scope
)
},
callee
::
ArgOverloadedOp
(
lhs
,
rhs
),
callee
::
ArgOverloadedOp
(
lhs
,
rhs
,
autoref
),
dest
)
}
...
...
@@ -2122,7 +2126,8 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
let
scratch
=
rvalue_scratch_datum
(
bcx
,
ref_ty
,
"overloaded_deref"
);
unpack_result!
(
bcx
,
trans_overloaded_op
(
bcx
,
expr
,
method_call
,
datum
,
Vec
::
new
(),
Some
(
SaveIn
(
scratch
.val
))));
datum
,
Vec
::
new
(),
Some
(
SaveIn
(
scratch
.val
)),
false
));
scratch
.to_expr_datum
()
}
None
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录