Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
1869306a
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,发现更多精彩内容 >>
提交
1869306a
编写于
12月 13, 2011
作者:
N
Niko Matsakis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change syntax from lambda[send] to sendfn
上级
f512e67f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
15 addition
and
82 deletion
+15
-82
src/comp/front/test.rs
src/comp/front/test.rs
+0
-1
src/comp/syntax/ast.rs
src/comp/syntax/ast.rs
+0
-1
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+14
-79
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+1
-1
未找到文件。
src/comp/front/test.rs
浏览文件 @
1869306a
...
...
@@ -349,7 +349,6 @@ fn mk_test_wrapper(cx: test_ctxt,
let
wrapper_capture
:
@
ast
::
capture
=
@
{
node
:
{
is_send
:
false
,
copies
:
[],
moves
:
[]
},
...
...
src/comp/syntax/ast.rs
浏览文件 @
1869306a
...
...
@@ -255,7 +255,6 @@
// At the moment, one can only capture local variables.
type
capture_
=
{
is_send
:
bool
,
copies
:
[
spanned
<
ident
>
],
moves
:
[
spanned
<
ident
>
]
};
...
...
src/comp/syntax/parse/parser.rs
浏览文件 @
1869306a
...
...
@@ -14,13 +14,6 @@
tag
file_type
{
CRATE_FILE
;
SOURCE_FILE
;
}
tag
fn_kw
{
fn_kw_fn
;
fn_kw_fn_at
;
fn_kw_lambda
;
fn_kw_block
;
}
type
parse_sess
=
@
{
cm
:
codemap
::
codemap
,
mutable
next_id
:
node_id
};
fn
next_node_id
(
sess
:
parse_sess
)
->
node_id
{
...
...
@@ -544,13 +537,9 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
}
else
if
eat_word
(
p
,
"block"
)
{
t
=
parse_ty_fn
(
ast
::
proto_block
,
p
);
}
else
if
eat_word
(
p
,
"lambda"
)
{
if
eat
(
p
,
token
::
LBRACKET
)
{
// lambda[send](...)
expect_word
(
p
,
"send"
);
expect
(
p
,
token
::
RBRACKET
);
t
=
parse_ty_fn
(
ast
::
proto_send
,
p
);
}
else
{
// lambda(...)
t
=
parse_ty_fn
(
ast
::
proto_shared
(
ast
::
sugar_sexy
),
p
);
}
t
=
parse_ty_fn
(
ast
::
proto_shared
(
ast
::
sugar_sexy
),
p
);
}
else
if
eat_word
(
p
,
"sendfn"
)
{
t
=
parse_ty_fn
(
ast
::
proto_send
,
p
);
}
else
if
eat_word
(
p
,
"obj"
)
{
t
=
parse_ty_obj
(
p
);
}
else
if
p
.peek
()
==
token
::
MOD_SEP
||
is_ident
(
p
.peek
())
{
...
...
@@ -844,12 +833,14 @@ fn parse_bottom_expr(p: parser) -> @ast::expr {
ret parse_spawn_expr(p);
*/
}
else
if
eat_word
(
p
,
"fn"
)
{
let
kw
=
parse_fn_anon_kw
(
p
);
ret
parse_fn_expr
(
p
,
kw
);
let
proto
=
parse_fn_ty_proto
(
p
);
ret
parse_fn_expr
(
p
,
proto
);
}
else
if
eat_word
(
p
,
"block"
)
{
ret
parse_fn_expr
(
p
,
fn_kw
_block
);
ret
parse_fn_expr
(
p
,
ast
::
proto
_block
);
}
else
if
eat_word
(
p
,
"lambda"
)
{
ret
parse_fn_expr
(
p
,
fn_kw_lambda
);
ret
parse_fn_expr
(
p
,
ast
::
proto_shared
(
ast
::
sugar_sexy
));
}
else
if
eat_word
(
p
,
"sendfn"
)
{
ret
parse_fn_expr
(
p
,
ast
::
proto_send
);
}
else
if
eat_word
(
p
,
"unchecked"
)
{
ret
parse_block_expr
(
p
,
lo
,
ast
::
unchecked_blk
);
}
else
if
eat_word
(
p
,
"unsafe"
)
{
...
...
@@ -1290,7 +1281,7 @@ fn parse_if_expr(p: parser) -> @ast::expr {
// Parses:
//
// CC := [
send;
copy ID*; move ID*]
// CC := [copy ID*; move ID*]
//
// where any part is optional and trailing ; is permitted.
fn
parse_capture_clause
(
p
:
parser
)
->
@
ast
::
capture
{
...
...
@@ -1322,17 +1313,13 @@ fn eat_ident_list(p: parser) -> [ast::spanned<ast::ident>] {
std
::
util
::
unreachable
();
}
let
is_send
=
false
;
let
copies
=
[];
let
moves
=
[];
let
lo
=
p
.get_lo_pos
();
if
eat
(
p
,
token
::
LBRACKET
)
{
while
!
eat
(
p
,
token
::
RBRACKET
)
{
if
eat_word
(
p
,
"send"
)
{
is_send
=
true
;
expect_opt_trailing_semi
(
p
);
}
else
if
eat_word
(
p
,
"copy"
)
{
if
eat_word
(
p
,
"copy"
)
{
copies
+=
eat_ident_list
(
p
);
expect_opt_trailing_semi
(
p
);
}
else
if
eat_word
(
p
,
"move"
)
{
...
...
@@ -1346,68 +1333,25 @@ fn eat_ident_list(p: parser) -> [ast::spanned<ast::ident>] {
}
let
hi
=
p
.get_last_hi_pos
();
ret
@
spanned
(
lo
,
hi
,
{
is_send
:
is_send
,
copies
:
copies
,
moves
:
moves
});
ret
@
spanned
(
lo
,
hi
,
{
copies
:
copies
,
moves
:
moves
});
}
fn
select_proto
(
p
:
parser
,
kw
:
fn_kw
,
is_send
:
bool
)
->
ast
::
proto
{
ret
alt
(
kw
,
is_send
)
{
(
fn_kw_fn
.
,
true
)
{
ast
::
proto_bare
}
(
fn_kw_fn_at
.
,
true
)
{
ast
::
proto_send
}
(
fn_kw_lambda
.
,
true
)
{
ast
::
proto_send
}
(
fn_kw_block
.
,
true
)
{
p
.fatal
(
"block cannot be declared sendable"
)
}
(
fn_kw_fn
.
,
false
)
{
ast
::
proto_bare
}
(
fn_kw_fn_at
.
,
false
)
{
ast
::
proto_shared
(
ast
::
sugar_normal
)
}
(
fn_kw_lambda
.
,
false
)
{
ast
::
proto_shared
(
ast
::
sugar_sexy
)
}
(
fn_kw_block
.
,
false
)
{
ast
::
proto_block
}
};
}
fn
parse_fn_expr
(
p
:
parser
,
kw
:
fn_kw
)
->
@
ast
::
expr
{
fn
parse_fn_expr
(
p
:
parser
,
proto
:
ast
::
proto
)
->
@
ast
::
expr
{
let
lo
=
p
.get_last_lo_pos
();
let
captures
=
parse_capture_clause
(
p
);
let
is_send
=
captures
.node.is_send
;
let
proto
=
select_proto
(
p
,
kw
,
is_send
);
let
decl
=
parse_fn_decl
(
p
,
ast
::
impure_fn
,
ast
::
il_normal
);
let
body
=
parse_block
(
p
);
let
_
fn
=
{
decl
:
decl
,
proto
:
proto
,
body
:
body
};
ret
mk_expr
(
p
,
lo
,
body
.span.hi
,
ast
::
expr_fn
(
_
fn
,
captures
));
}
/*
** This version triggers an LLVM bug: **
fn parse_fn_expr(p: parser, kw: fn_kw) -> @ast::expr {
let lo = p.get_last_lo_pos();
let captures = parse_capture_clause(p);
let is_send = captures.node.is_send;
//let proto = select_proto(p, kw, is_send);
log_err (kw, captures, is_send);
let proto = alt (kw, is_send) {
(fn_kw_fn., true) { ast::proto_bare }
(fn_kw_fn_at., true) { ast::proto_send }
(fn_kw_lambda., true) { ast::proto_send }
(fn_kw_block., true) { p.fatal("block cannot be declared sendable") }
(fn_kw_fn., false) { ast::proto_bare }
(fn_kw_fn_at., false) { ast::proto_shared(ast::sugar_normal) }
(fn_kw_lambda., false) { ast::proto_shared(ast::sugar_sexy) }
(fn_kw_block., false) { ast::proto_block }
};
fail "foo";
//let decl = parse_fn_decl(p, ast::impure_fn, ast::il_normal);
//let body = parse_block(p);
//let _fn = {decl: decl, proto: proto, body: body};
//ret mk_expr(p, lo, body.span.hi, ast::expr_fn(_fn, captures));
}
*/
fn
parse_fn_block_expr
(
p
:
parser
)
->
@
ast
::
expr
{
let
lo
=
p
.get_last_lo_pos
();
let
decl
=
parse_fn_block_decl
(
p
);
let
mid
=
p
.get_last_hi_pos
();
let
body
=
parse_block_tail
(
p
,
lo
,
ast
::
default_blk
);
let
_
fn
=
{
decl
:
decl
,
proto
:
ast
::
proto_block
,
body
:
body
};
let
captures
=
@
spanned
(
lo
,
mid
,
{
is_send
:
false
,
copies
:
[],
moves
:
[]});
let
captures
=
@
spanned
(
lo
,
mid
,
{
copies
:
[],
moves
:
[]});
ret
mk_expr
(
p
,
lo
,
body
.span.hi
,
ast
::
expr_fn
(
_
fn
,
captures
));
}
...
...
@@ -2191,15 +2135,6 @@ fn parse_fn_ty_proto(p: parser) -> ast::proto {
}
}
fn
parse_fn_anon_kw
(
p
:
parser
)
->
fn_kw
{
if
p
.peek
()
==
token
::
AT
{
p
.bump
();
fn_kw_fn_at
}
else
{
fn_kw_fn
}
}
fn
parse_method_proto
(
p
:
parser
)
->
ast
::
proto
{
if
eat_word
(
p
,
"fn"
)
{
ret
ast
::
proto_bare
;
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
1869306a
...
...
@@ -1600,7 +1600,7 @@ fn proto_to_str(p: ast::proto) -> str {
ret
alt
p
{
ast
::
proto_bare
.
{
"fn"
}
ast
::
proto_block
.
{
"block"
}
ast
::
proto_send
.
{
"
lambda[send]
"
}
ast
::
proto_send
.
{
"
sendfn
"
}
ast
::
proto_shared
(
ast
::
sugar_normal
.
)
{
"fn@"
}
ast
::
proto_shared
(
ast
::
sugar_sexy
.
)
{
"lambda"
}
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录