Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
378c0087
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,发现更多精彩内容 >>
提交
378c0087
编写于
1月 30, 2011
作者:
B
Brian Anderson
提交者:
Graydon Hoare
2月 10, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Parse 'be' statement. Pass tailcall tests. No actual tailcalls yet.
上级
c0f997be
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
48 addition
and
0 deletion
+48
-0
src/Makefile
src/Makefile
+3
-0
src/comp/front/ast.rs
src/comp/front/ast.rs
+1
-0
src/comp/front/parser.rs
src/comp/front/parser.rs
+7
-0
src/comp/middle/fold.rs
src/comp/middle/fold.rs
+13
-0
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+9
-0
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+15
-0
未找到文件。
src/Makefile
浏览文件 @
378c0087
...
...
@@ -517,6 +517,9 @@ TEST_XFAILS_RUSTC := $(filter-out \
simple-obj.rs
\
stateful-obj.rs
\
str-idx.rs
\
tail-call-arg-leak.rs
\
tail-cps.rs
\
tail-direct.rs
\
type-in-nested-module.rs
\
type-param.rs
\
tup.rs
\
...
...
src/comp/front/ast.rs
浏览文件 @
378c0087
...
...
@@ -116,6 +116,7 @@
tag
stmt_
{
stmt_decl
(
@
decl
);
stmt_ret
(
option
.t
[
@
expr
]);
stmt_be
(
@
expr
);
stmt_log
(
@
expr
);
stmt_check_expr
(
@
expr
);
stmt_fail
;
...
...
src/comp/front/parser.rs
浏览文件 @
378c0087
...
...
@@ -1200,6 +1200,12 @@ fn is_ident(token.token t) -> bool {
}
}
case
(
token
.BE
)
{
p
.bump
();
auto
e
=
parse_expr
(
p
);
ret
@
spanned
(
lo
,
e
.span
,
ast
.stmt_be
(
e
));
}
case
(
token
.LET
)
{
auto
decl
=
parse_let
(
p
);
auto
hi
=
p
.get_span
();
...
...
@@ -1340,6 +1346,7 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool {
}
}
case
(
ast
.stmt_ret
(
_
))
{
ret
true
;
}
case
(
ast
.stmt_be
(
_
))
{
ret
true
;
}
case
(
ast
.stmt_log
(
_
))
{
ret
true
;
}
case
(
ast
.stmt_check_expr
(
_
))
{
ret
true
;
}
case
(
ast
.stmt_fail
)
{
ret
true
;
}
...
...
src/comp/middle/fold.rs
浏览文件 @
378c0087
...
...
@@ -176,6 +176,9 @@
(
fn
(
&
ENV
e
,
&
span
sp
,
&
option
.t
[
@
expr
]
rv
)
->
@
stmt
)
fold_stmt_ret
,
(
fn
(
&
ENV
e
,
&
span
sp
,
@
expr
e
)
->
@
stmt
)
fold_stmt_be
,
(
fn
(
&
ENV
e
,
&
span
sp
,
@
expr
e
)
->
@
stmt
)
fold_stmt_log
,
...
...
@@ -636,6 +639,11 @@ fn fold_stmt[ENV](&ENV env, ast_fold[ENV] fld, &@stmt s) -> @stmt {
ret
fld
.fold_stmt_ret
(
env_
,
s
.span
,
oee
);
}
case
(
ast
.stmt_be
(
?
e
))
{
auto
ee
=
fold_expr
(
env_
,
fld
,
e
);
ret
fld
.fold_stmt_be
(
env_
,
s
.span
,
ee
);
}
case
(
ast
.stmt_log
(
?
e
))
{
auto
ee
=
fold_expr
(
env_
,
fld
,
e
);
ret
fld
.fold_stmt_log
(
env_
,
s
.span
,
ee
);
...
...
@@ -1136,6 +1144,10 @@ fn identity_fold_stmt_ret[ENV](&ENV env, &span sp,
ret
@
respan
(
sp
,
ast
.stmt_ret
(
rv
));
}
fn
identity_fold_stmt_be
[
ENV
](
&
ENV
env
,
&
span
sp
,
@
expr
x
)
->
@
stmt
{
ret
@
respan
(
sp
,
ast
.stmt_be
(
x
));
}
fn
identity_fold_stmt_log
[
ENV
](
&
ENV
e
,
&
span
sp
,
@
expr
x
)
->
@
stmt
{
ret
@
respan
(
sp
,
ast
.stmt_log
(
x
));
}
...
...
@@ -1366,6 +1378,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
fold_stmt_decl
=
bind
identity_fold_stmt_decl
[
ENV
](
_
,
_
,
_
),
fold_stmt_ret
=
bind
identity_fold_stmt_ret
[
ENV
](
_
,
_
,
_
),
fold_stmt_be
=
bind
identity_fold_stmt_be
[
ENV
](
_
,
_
,
_
),
fold_stmt_log
=
bind
identity_fold_stmt_log
[
ENV
](
_
,
_
,
_
),
fold_stmt_check_expr
=
bind
identity_fold_stmt_check_expr
[
ENV
](
_
,
_
,
_
),
...
...
src/comp/middle/trans.rs
浏览文件 @
378c0087
...
...
@@ -3128,6 +3128,11 @@ fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result {
ret
res
(
bcx
,
C_nil
());
}
fn
trans_be
(
@
block_ctxt
cx
,
@
ast
.expr
e
)
->
result
{
// FIXME: So this isn't actually a tail call
ret
trans_ret
(
cx
,
some
(
e
));
}
fn
init_local
(
@
block_ctxt
cx
,
@
ast
.local
local
)
->
result
{
// Make a note to drop this slot on the way out.
...
...
@@ -3178,6 +3183,10 @@ fn trans_stmt(@block_ctxt cx, &ast.stmt s) -> result {
bcx
=
trans_ret
(
cx
,
e
)
.bcx
;
}
case
(
ast
.stmt_be
(
?
e
))
{
bcx
=
trans_be
(
cx
,
e
)
.bcx
;
}
case
(
ast
.stmt_expr
(
?
e
))
{
bcx
=
trans_expr
(
cx
,
e
)
.bcx
;
}
...
...
src/comp/middle/typeck.rs
浏览文件 @
378c0087
...
...
@@ -1719,6 +1719,21 @@ fn check_stmt(&@fn_ctxt fcx, &@ast.stmt stmt) -> @ast.stmt {
}
}
case
(
ast
.stmt_be
(
?
expr
))
{
alt
(
expr
.node
)
{
case
(
ast
.expr_call
(
_
,
_
,
_
))
{
auto
expr_0
=
check_expr
(
fcx
,
expr
);
auto
expr_1
=
demand_expr
(
fcx
,
fcx
.ret_ty
,
expr_0
);
ret
@
fold
.respan
[
ast
.stmt_
](
stmt
.span
,
ast
.stmt_be
(
expr_1
));
}
case
(
_
)
{
fcx
.ccx.sess
.err
(
"Non-call expression in tail call"
);
fail
;
}
}
}
case
(
ast
.stmt_log
(
?
expr
))
{
auto
expr_t
=
check_expr
(
fcx
,
expr
);
ret
@
fold
.respan
[
ast
.stmt_
](
stmt
.span
,
ast
.stmt_log
(
expr_t
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录