Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ebc4df3c
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,发现更多精彩内容 >>
提交
ebc4df3c
编写于
3月 24, 2011
作者:
B
Brian Anderson
提交者:
Graydon Hoare
3月 25, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement local declarations with receive. Un-XFAIL decl-with-recv.rs.
上级
71f05849
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
51 addition
and
20 deletion
+51
-20
Makefile.in
Makefile.in
+0
-1
src/comp/front/parser.rs
src/comp/front/parser.rs
+14
-6
src/comp/middle/fold.rs
src/comp/middle/fold.rs
+4
-5
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+23
-7
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+10
-1
未找到文件。
Makefile.in
浏览文件 @
ebc4df3c
...
...
@@ -653,7 +653,6 @@ TEST_XFAILS_STAGE0 := $(FLOAT_XFAILS) \
clone-with-exterior.rs
\
comm.rs
\
constrained-type.rs
\
decl-with-recv.rs
\
destructor-ordering.rs
\
iter-ret.rs
\
lazychan.rs
\
...
...
src/comp/front/parser.rs
浏览文件 @
ebc4df3c
...
...
@@ -1365,13 +1365,21 @@ fn op_eq(token.token a, token.token b) -> bool {
}
impure
fn
parse_initializer
(
parser
p
)
->
option
.t
[
ast
.initializer
]
{
if
(
p
.peek
()
==
token
.EQ
)
{
p
.bump
();
ret
some
(
rec
(
op
=
ast
.init_assign
,
expr
=
parse_expr
(
p
)));
alt
(
p
.peek
())
{
case
(
token
.EQ
)
{
p
.bump
();
ret
some
(
rec
(
op
=
ast
.init_assign
,
expr
=
parse_expr
(
p
)));
}
case
(
token
.LARROW
)
{
p
.bump
();
ret
some
(
rec
(
op
=
ast
.init_recv
,
expr
=
parse_expr
(
p
)));
}
case
(
_
)
{
ret
none
[
ast
.initializer
];
}
}
ret
none
[
ast
.initializer
];
}
impure
fn
parse_pat
(
parser
p
)
->
@
ast
.pat
{
...
...
src/comp/middle/fold.rs
浏览文件 @
ebc4df3c
...
...
@@ -437,7 +437,7 @@ fn fold_decl[ENV](&ENV env, ast_fold[ENV] fld, @decl d) -> @decl {
alt
(
d
.node
)
{
case
(
ast
.decl_local
(
?
local
))
{
auto
ty_
=
none
[
@
ast
.ty
];
auto
init
opt
=
none
[
ast
.initializer
];
auto
init
_
=
none
[
ast
.initializer
];
alt
(
local
.ty
)
{
case
(
some
[
@
ast
.ty
](
?
t
))
{
ty_
=
some
[
@
ast
.ty
](
fold_ty
(
env
,
fld
,
t
));
...
...
@@ -446,13 +446,12 @@ fn fold_decl[ENV](&ENV env, ast_fold[ENV] fld, @decl d) -> @decl {
}
alt
(
local
.init
)
{
case
(
some
[
ast
.initializer
](
?
init
))
{
auto
init_
=
rec
(
expr
=
fold_expr
(
env
,
fld
,
init
.expr
)
with
init
);
initopt
=
some
[
ast
.initializer
](
init_
);
auto
e
=
fold_expr
(
env
,
fld
,
init
.expr
);
init_
=
some
[
ast
.initializer
](
rec
(
expr
=
e
with
init
));
}
case
(
_
)
{
/* fall through */
}
}
let
@
ast
.local
local_
=
@
rec
(
ty
=
ty_
,
init
=
init
opt
with
*
local
);
let
@
ast
.local
local_
=
@
rec
(
ty
=
ty_
,
init
=
init
_
with
*
local
);
ret
fld
.fold_decl_local
(
env_
,
d
.span
,
local_
);
}
...
...
src/comp/middle/trans.rs
浏览文件 @
ebc4df3c
...
...
@@ -4839,22 +4839,31 @@ fn trans_recv(@block_ctxt cx, @ast.expr lhs, @ast.expr rhs,
auto
data
=
trans_lval
(
bcx
,
lhs
);
check
(
data
.is_mem
);
bcx
=
data
.res.bcx
;
auto
unit_ty
=
node_ann_type
(
bcx
.fcx.ccx
,
ann
);
// FIXME: calculate copy init-ness in typestate.
ret
recv_val
(
bcx
,
data
.res.val
,
rhs
,
unit_ty
,
DROP_EXISTING
);
}
fn
recv_val
(
@
block_ctxt
cx
,
ValueRef
lhs
,
@
ast
.expr
rhs
,
@
ty
.t
unit_ty
,
copy_action
action
)
->
result
{
auto
bcx
=
cx
;
auto
prt
=
trans_expr
(
bcx
,
rhs
);
bcx
=
prt
.bcx
;
auto
sub
=
trans_upcall
(
bcx
,
"upcall_recv"
,
vec
(
vp2i
(
bcx
,
data
.res.val
),
vec
(
vp2i
(
bcx
,
lhs
),
vp2i
(
bcx
,
prt
.val
)));
bcx
=
sub
.bcx
;
auto
unit_ty
=
node_ann_type
(
cx
.fcx.ccx
,
ann
);
auto
data_load
=
load_scalar_or_boxed
(
bcx
,
data
.res.val
,
unit_ty
);
auto
cp
=
copy_ty
(
bcx
,
DROP_EXISTING
,
data
.res.val
,
data_load
,
unit_ty
);
auto
data_load
=
load_scalar_or_boxed
(
bcx
,
lhs
,
unit_ty
);
auto
cp
=
copy_ty
(
bcx
,
action
,
lhs
,
data_load
,
unit_ty
);
bcx
=
cp
.bcx
;
// TODO: Any cleanup need to be done here?
ret
res
(
bcx
,
data
.res.val
);
ret
res
(
bcx
,
lhs
);
}
fn
init_local
(
@
block_ctxt
cx
,
@
ast
.local
local
)
->
result
{
...
...
@@ -4870,8 +4879,15 @@ fn init_local(@block_ctxt cx, @ast.local local) -> result {
alt
(
local
.init
)
{
case
(
some
[
ast
.initializer
](
?
init
))
{
auto
sub
=
trans_expr
(
bcx
,
init
.expr
);
bcx
=
copy_ty
(
sub
.bcx
,
INIT
,
llptr
,
sub
.val
,
ty
)
.bcx
;
alt
(
init
.op
)
{
case
(
ast
.init_assign
)
{
auto
sub
=
trans_expr
(
bcx
,
init
.expr
);
bcx
=
copy_ty
(
sub
.bcx
,
INIT
,
llptr
,
sub
.val
,
ty
)
.bcx
;
}
case
(
ast
.init_recv
)
{
bcx
=
recv_val
(
bcx
,
llptr
,
init
.expr
,
ty
,
INIT
)
.bcx
;
}
}
}
case
(
_
)
{
if
(
middle
.ty
.type_has_dynamic_size
(
ty
))
{
...
...
src/comp/middle/typeck.rs
浏览文件 @
ebc4df3c
...
...
@@ -2409,7 +2409,16 @@ fn check_decl_local(&@fn_ctxt fcx, &@ast.decl decl) -> @ast.decl {
case
(
some
[
ast
.initializer
](
?
init
))
{
auto
expr_0
=
check_expr
(
fcx
,
init
.expr
);
auto
lty
=
plain_ty
(
ty
.ty_local
(
local
.id
));
auto
expr_1
=
demand_expr
(
fcx
,
lty
,
expr_0
);
auto
expr_1
;
alt
(
init
.op
)
{
case
(
ast
.init_assign
)
{
expr_1
=
demand_expr
(
fcx
,
lty
,
expr_0
);
}
case
(
ast
.init_recv
)
{
auto
port_ty
=
plain_ty
(
ty
.ty_port
(
lty
));
expr_1
=
demand_expr
(
fcx
,
port_ty
,
expr_0
);
}
}
auto
init_0
=
rec
(
expr
=
expr_1
with
init
);
initopt
=
some
[
ast
.initializer
](
init_0
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录