Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6bcdb48e
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,发现更多精彩内容 >>
提交
6bcdb48e
编写于
7月 25, 2011
作者:
M
Michael Sullivan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Disallow block as a variable name in preparation for it becoming a keyword.
上级
01675f34
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
48 addition
and
47 deletion
+48
-47
src/comp/middle/alias.rs
src/comp/middle/alias.rs
+8
-8
src/comp/middle/trans_dps.rs
src/comp/middle/trans_dps.rs
+4
-4
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+7
-7
src/comp/syntax/fold.rs
src/comp/syntax/fold.rs
+10
-10
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+3
-2
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+16
-16
未找到文件。
src/comp/middle/alias.rs
浏览文件 @
6bcdb48e
...
...
@@ -103,11 +103,11 @@ fn visit_expr(&@ctx cx, &@ast::expr ex, &scope sc, &vt[scope] v) {
case
(
_
)
{
}
}
}
ast
::
expr_for_each
(
?
decl
,
?
call
,
?
bl
oc
k
)
{
check_for_each
(
*
cx
,
decl
,
call
,
bl
oc
k
,
sc
,
v
);
ast
::
expr_for_each
(
?
decl
,
?
call
,
?
blk
)
{
check_for_each
(
*
cx
,
decl
,
call
,
blk
,
sc
,
v
);
}
ast
::
expr_for
(
?
decl
,
?
seq
,
?
bl
oc
k
)
{
check_for
(
*
cx
,
decl
,
seq
,
bl
oc
k
,
sc
,
v
);
ast
::
expr_for
(
?
decl
,
?
seq
,
?
blk
)
{
check_for
(
*
cx
,
decl
,
seq
,
blk
,
sc
,
v
);
}
ast
::
expr_path
(
?
pt
)
{
check_var
(
*
cx
,
ex
,
pt
,
ex
.id
,
false
,
sc
);
...
...
@@ -326,7 +326,7 @@ fn walk_pat(&mutable node_id[] found, &@ast::pat p) {
}
fn
check_for_each
(
&
ctx
cx
,
&@
ast
::
local
local
,
&@
ast
::
expr
call
,
&
ast
::
block
bl
oc
k
,
&
scope
sc
,
&
vt
[
scope
]
v
)
{
&
ast
::
block
blk
,
&
scope
sc
,
&
vt
[
scope
]
v
)
{
visit
::
visit_expr
(
call
,
sc
,
v
);
alt
(
call
.node
)
{
case
(
ast
::
expr_call
(
?
f
,
?
args
))
{
...
...
@@ -339,12 +339,12 @@ fn check_for_each(&ctx cx, &@ast::local local, &@ast::expr call,
tys
=
data
.unsafe_ts
,
depends_on
=
deps
(
sc
,
data
.root_vars
),
mutable
ok
=
valid
);
visit
::
visit_block
(
bl
oc
k
,
@
(
*
sc
+
~
[
new_sc
]),
v
);
visit
::
visit_block
(
blk
,
@
(
*
sc
+
~
[
new_sc
]),
v
);
}
}
}
fn
check_for
(
&
ctx
cx
,
&@
ast
::
local
local
,
&@
ast
::
expr
seq
,
&
ast
::
block
bl
oc
k
,
fn
check_for
(
&
ctx
cx
,
&@
ast
::
local
local
,
&@
ast
::
expr
seq
,
&
ast
::
block
blk
,
&
scope
sc
,
&
vt
[
scope
]
v
)
{
visit
::
visit_expr
(
seq
,
sc
,
v
);
auto
defnum
=
local
.node.id
;
...
...
@@ -374,7 +374,7 @@ fn check_for(&ctx cx, &@ast::local local, &@ast::expr seq, &ast::block block,
tys
=
unsafe
,
depends_on
=
deps
(
sc
,
root_def
),
mutable
ok
=
valid
);
visit
::
visit_block
(
bl
oc
k
,
@
(
*
sc
+
~
[
new_sc
]),
v
);
visit
::
visit_block
(
blk
,
@
(
*
sc
+
~
[
new_sc
]),
v
);
}
fn
check_var
(
&
ctx
cx
,
&@
ast
::
expr
ex
,
&
ast
::
path
p
,
ast
::
node_id
id
,
...
...
src/comp/middle/trans_dps.rs
浏览文件 @
6bcdb48e
...
...
@@ -446,14 +446,14 @@ fn trans_recv(&@block_ctxt bcx, &dest dest, &@ast::expr expr) -> @block_ctxt {
ret
bcx
;
// TODO
}
fn
trans_block
(
&@
block_ctxt
cx
,
&
dest
dest
,
&
ast
::
block
bl
oc
k
)
fn
trans_block
(
&@
block_ctxt
cx
,
&
dest
dest
,
&
ast
::
block
blk
)
->
@
block_ctxt
{
auto
bcx
=
cx
;
for
each
(
@
ast
::
local
local
in
trans
::
block_locals
(
bl
oc
k
))
{
for
each
(
@
ast
::
local
local
in
trans
::
block_locals
(
blk
))
{
bcx
=
trans
::
alloc_local
(
bcx
,
local
)
.bcx
;
}
for
(
@
ast
::
stmt
stmt
in
bl
oc
k
.node.stmts
)
{
for
(
@
ast
::
stmt
stmt
in
blk
.node.stmts
)
{
bcx
=
trans_stmt
(
bcx
,
stmt
);
// If we hit a terminator, control won't go any further so
...
...
@@ -461,7 +461,7 @@ fn trans_block(&@block_ctxt cx, &dest dest, &ast::block block)
if
trans
::
is_terminated
(
bcx
)
{
ret
bcx
;
}
}
alt
(
bl
oc
k
.node.expr
)
{
alt
(
blk
.node.expr
)
{
some
(
?
e
)
{
bcx
=
trans_expr
(
bcx
,
dest
,
e
);
}
none
{
/* no-op */
}
}
...
...
src/comp/middle/typeck.rs
浏览文件 @
6bcdb48e
...
...
@@ -1147,7 +1147,7 @@ fn visit_fn_post(@wb_ctxt wbcx, &ast::_fn f,
}
fn
keep_going
(
@
wb_ctxt
wbcx
)
->
bool
{
!
wbcx
.ignore
&&
wbcx
.success
}
fn
resolve_type_vars_in_block
(
&@
fn_ctxt
fcx
,
&
ast
::
block
bl
oc
k
)
->
bool
{
fn
resolve_type_vars_in_block
(
&@
fn_ctxt
fcx
,
&
ast
::
block
blk
)
->
bool
{
auto
wbcx
=
@
rec
(
fcx
=
fcx
,
mutable
ignore
=
false
,
mutable
success
=
true
);
...
...
@@ -1163,7 +1163,7 @@ fn resolve_type_vars_in_block(&@fn_ctxt fcx, &ast::block block) -> bool {
visit_pat_pre
=
bind
visit_pat_pre
(
wbcx
,
_
),
visit_local_pre
=
bind
visit_local_pre
(
wbcx
,
_
)
with
walk
::
default_visitor
());
walk
::
walk_block
(
visit
,
bl
oc
k
);
walk
::
walk_block
(
visit
,
blk
);
ret
wbcx
.success
;
}
}
...
...
@@ -2598,14 +2598,14 @@ fn check_stmt(&@fn_ctxt fcx, &@ast::stmt stmt) {
write
::
nil_ty
(
fcx
.ccx.tcx
,
node_id
);
}
fn
check_block
(
&@
fn_ctxt
fcx
,
&
ast
::
block
bl
oc
k
)
{
for
(
@
ast
::
stmt
s
in
bl
oc
k
.node.stmts
)
{
check_stmt
(
fcx
,
s
);
}
alt
(
bl
oc
k
.node.expr
)
{
case
(
none
)
{
write
::
nil_ty
(
fcx
.ccx.tcx
,
bl
oc
k
.node.id
);
}
fn
check_block
(
&@
fn_ctxt
fcx
,
&
ast
::
block
blk
)
{
for
(
@
ast
::
stmt
s
in
blk
.node.stmts
)
{
check_stmt
(
fcx
,
s
);
}
alt
(
blk
.node.expr
)
{
case
(
none
)
{
write
::
nil_ty
(
fcx
.ccx.tcx
,
blk
.node.id
);
}
case
(
some
(
?
e
))
{
check_expr
(
fcx
,
e
);
auto
ety
=
expr_ty
(
fcx
.ccx.tcx
,
e
);
write
::
ty_only_fixup
(
fcx
,
bl
oc
k
.node.id
,
ety
);
write
::
ty_only_fixup
(
fcx
,
blk
.node.id
,
ety
);
}
}
}
...
...
src/comp/syntax/fold.rs
浏览文件 @
6bcdb48e
...
...
@@ -138,8 +138,8 @@ fn fold_mac_(&mac m, ast_fold fld) -> mac {
case
(
mac_embed_type
(
?
ty
))
{
mac_embed_type
(
fld
.fold_ty
(
ty
))
}
case
(
mac_embed_block
(
?
bl
oc
k
))
{
mac_embed_block
(
fld
.fold_block
(
bl
oc
k
))
case
(
mac_embed_block
(
?
blk
))
{
mac_embed_block
(
fld
.fold_block
(
blk
))
}
case
(
mac_ellipsis
)
{
mac_ellipsis
}
},
...
...
@@ -388,16 +388,16 @@ fn fold_anon_obj_field_(&anon_obj_field aof, ast_fold fld)
case
(
expr_while
(
?
cond
,
?
body
))
{
expr_while
(
fld
.fold_expr
(
cond
),
fld
.fold_block
(
body
))
}
case
(
expr_for
(
?
decl
,
?
expr
,
?
bl
oc
k
))
{
case
(
expr_for
(
?
decl
,
?
expr
,
?
blk
))
{
expr_for
(
fld
.fold_local
(
decl
),
fld
.fold_expr
(
expr
),
fld
.fold_block
(
bl
oc
k
))
fld
.fold_block
(
blk
))
}
case
(
expr_for_each
(
?
decl
,
?
expr
,
?
bl
oc
k
))
{
case
(
expr_for_each
(
?
decl
,
?
expr
,
?
blk
))
{
expr_for_each
(
fld
.fold_local
(
decl
),
fld
.fold_expr
(
expr
),
fld
.fold_block
(
bl
oc
k
))
fld
.fold_block
(
blk
))
}
case
(
expr_do_while
(
?
bl
oc
k
,
?
expr
))
{
expr_do_while
(
fld
.fold_block
(
bl
oc
k
),
fld
.fold_expr
(
expr
))
case
(
expr_do_while
(
?
blk
,
?
expr
))
{
expr_do_while
(
fld
.fold_block
(
blk
),
fld
.fold_expr
(
expr
))
}
case
(
expr_alt
(
?
expr
,
?
arms
))
{
expr_alt
(
fld
.fold_expr
(
expr
),
ivec
::
map
(
fld
.fold_arm
,
arms
))
...
...
@@ -405,8 +405,8 @@ fn fold_anon_obj_field_(&anon_obj_field aof, ast_fold fld)
case
(
expr_fn
(
?
f
))
{
expr_fn
(
fld
.fold_fn
(
f
))
}
case
(
expr_block
(
?
bl
oc
k
))
{
expr_block
(
fld
.fold_block
(
bl
oc
k
))
case
(
expr_block
(
?
blk
))
{
expr_block
(
fld
.fold_block
(
blk
))
}
case
(
expr_move
(
?
el
,
?
er
))
{
expr_move
(
fld
.fold_expr
(
el
),
fld
.fold_expr
(
er
))
...
...
src/comp/syntax/parse/parser.rs
浏览文件 @
6bcdb48e
...
...
@@ -174,6 +174,7 @@ fn bad_expr_word_table() -> hashmap[str, ()] {
words
.insert
(
"fn"
,
());
words
.insert
(
"pred"
,
());
words
.insert
(
"iter"
,
());
words
.insert
(
"block"
,
());
words
.insert
(
"import"
,
());
words
.insert
(
"export"
,
());
words
.insert
(
"let"
,
());
...
...
@@ -1407,8 +1408,8 @@ fn parse_alt_expr(&parser p) -> @ast::expr {
if
(
p
.peek
()
==
token
::
LPAREN
)
{
parens
=
true
;
p
.bump
();
}
auto
pats
=
parse_pats
(
p
);
if
(
parens
)
{
expect
(
p
,
token
::
RPAREN
);
}
auto
bl
oc
k
=
parse_block
(
p
);
arms
+=
~
[
rec
(
pats
=
pats
,
block
=
bl
oc
k
)];
auto
blk
=
parse_block
(
p
);
arms
+=
~
[
rec
(
pats
=
pats
,
block
=
blk
)];
}
auto
hi
=
p
.get_hi_pos
();
p
.bump
();
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
6bcdb48e
...
...
@@ -601,7 +601,7 @@ fn print_possibly_embedded_block(&ps s, &ast::block blk, bool embedded,
s
.ann
.post
(
ann_node
);
}
fn
print_if
(
&
ps
s
,
&@
ast
::
expr
test
,
&
ast
::
block
bl
oc
k
,
fn
print_if
(
&
ps
s
,
&@
ast
::
expr
test
,
&
ast
::
block
blk
,
&
option
::
t
[
@
ast
::
expr
]
elseopt
,
bool
chk
)
{
head
(
s
,
"if"
);
if
(
chk
)
{
...
...
@@ -609,7 +609,7 @@ fn print_if(&ps s, &@ast::expr test, &ast::block block,
}
print_expr
(
s
,
test
);
space
(
s
.s
);
print_block
(
s
,
bl
oc
k
);
print_block
(
s
,
blk
);
fn
do_else
(
&
ps
s
,
option
::
t
[
@
ast
::
expr
]
els
)
{
alt
(
els
)
{
case
(
some
(
?
_
else
))
{
...
...
@@ -773,11 +773,11 @@ fn print_opt(&ps s, &option::t[@ast::expr] expr) {
word_space
(
s
,
"as"
);
print_type
(
s
,
*
ty
);
}
case
(
ast
::
expr_if
(
?
test
,
?
bl
oc
k
,
?
elseopt
))
{
print_if
(
s
,
test
,
bl
oc
k
,
elseopt
,
false
);
case
(
ast
::
expr_if
(
?
test
,
?
blk
,
?
elseopt
))
{
print_if
(
s
,
test
,
blk
,
elseopt
,
false
);
}
case
(
ast
::
expr_if_check
(
?
test
,
?
bl
oc
k
,
?
elseopt
))
{
print_if
(
s
,
test
,
bl
oc
k
,
elseopt
,
true
);
case
(
ast
::
expr_if_check
(
?
test
,
?
blk
,
?
elseopt
))
{
print_if
(
s
,
test
,
blk
,
elseopt
,
true
);
}
case
(
ast
::
expr_ternary
(
?
test
,
?
then
,
?
els
))
{
print_expr
(
s
,
test
);
...
...
@@ -788,13 +788,13 @@ fn print_opt(&ps s, &option::t[@ast::expr] expr) {
word_space
(
s
,
":"
);
print_expr
(
s
,
els
);
}
case
(
ast
::
expr_while
(
?
test
,
?
bl
oc
k
))
{
case
(
ast
::
expr_while
(
?
test
,
?
blk
))
{
head
(
s
,
"while"
);
print_expr
(
s
,
test
);
space
(
s
.s
);
print_block
(
s
,
bl
oc
k
);
print_block
(
s
,
blk
);
}
case
(
ast
::
expr_for
(
?
decl
,
?
expr
,
?
bl
oc
k
))
{
case
(
ast
::
expr_for
(
?
decl
,
?
expr
,
?
blk
))
{
head
(
s
,
"for"
);
popen
(
s
);
print_for_decl
(
s
,
decl
);
...
...
@@ -803,9 +803,9 @@ fn print_opt(&ps s, &option::t[@ast::expr] expr) {
print_expr
(
s
,
expr
);
pclose
(
s
);
space
(
s
.s
);
print_block
(
s
,
bl
oc
k
);
print_block
(
s
,
blk
);
}
case
(
ast
::
expr_for_each
(
?
decl
,
?
expr
,
?
bl
oc
k
))
{
case
(
ast
::
expr_for_each
(
?
decl
,
?
expr
,
?
blk
))
{
head
(
s
,
"for each"
);
popen
(
s
);
print_for_decl
(
s
,
decl
);
...
...
@@ -814,12 +814,12 @@ fn print_opt(&ps s, &option::t[@ast::expr] expr) {
print_expr
(
s
,
expr
);
pclose
(
s
);
space
(
s
.s
);
print_block
(
s
,
bl
oc
k
);
print_block
(
s
,
blk
);
}
case
(
ast
::
expr_do_while
(
?
bl
oc
k
,
?
expr
))
{
case
(
ast
::
expr_do_while
(
?
blk
,
?
expr
))
{
head
(
s
,
"do"
);
space
(
s
.s
);
print_block
(
s
,
bl
oc
k
);
print_block
(
s
,
blk
);
space
(
s
.s
);
word_space
(
s
,
"while"
);
print_expr
(
s
,
expr
);
...
...
@@ -853,14 +853,14 @@ fn print_opt(&ps s, &option::t[@ast::expr] expr) {
space
(
s
.s
);
print_block
(
s
,
f
.body
);
}
case
(
ast
::
expr_block
(
?
bl
oc
k
))
{
case
(
ast
::
expr_block
(
?
blk
))
{
// containing cbox, will be closed by print-block at }
cbox
(
s
,
indent_unit
);
// head-box, will be closed by print-block after {
ibox
(
s
,
0u
);
print_block
(
s
,
bl
oc
k
);
print_block
(
s
,
blk
);
}
case
(
ast
::
expr_move
(
?
lhs
,
?
rhs
))
{
print_expr
(
s
,
lhs
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录