Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f164d777
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,发现更多精彩内容 >>
提交
f164d777
编写于
7月 06, 2011
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Move AST constraints to interior vectors
上级
c83782f5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
16 deletion
+17
-16
src/comp/syntax/ast.rs
src/comp/syntax/ast.rs
+4
-4
src/comp/syntax/fold.rs
src/comp/syntax/fold.rs
+5
-4
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+6
-6
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+2
-2
未找到文件。
src/comp/syntax/ast.rs
浏览文件 @
f164d777
...
...
@@ -337,7 +337,7 @@ fn is_path(&@expr e) -> bool {
ty_arg
[]
inputs
,
@
ty
output
,
controlflow
cf
,
vec
[
@
constr
]
constrs
);
(
@
constr
)[
]
constrs
);
type
ty_field
=
spanned
[
ty_field_
];
...
...
@@ -403,11 +403,11 @@ fn ty_mach_to_str(ty_mach tm) -> str {
ty_chan
(
@
ty
);
ty_tup
(
mt
[]);
ty_rec
(
ty_field
[]);
ty_fn
(
proto
,
ty_arg
[],
@
ty
,
controlflow
,
vec
[
@
constr
]);
ty_fn
(
proto
,
ty_arg
[],
@
ty
,
controlflow
,
(
@
constr
)[
]);
ty_obj
(
ty_method
[]);
ty_path
(
path
,
node_id
);
ty_type
;
ty_constr
(
@
ty
,
vec
[
@
constr
]);
ty_constr
(
@
ty
,
(
@
constr
)[
]);
}
...
...
@@ -442,7 +442,7 @@ fn ty_mach_to_str(ty_mach tm) -> str {
@
ty
output
,
purity
purity
,
controlflow
cf
,
vec
[
@
constr
]
constraints
);
(
@
constr
)[
]
constraints
);
tag
purity
{
pure_fn
;
// declared with "pred"
...
...
src/comp/syntax/fold.rs
浏览文件 @
f164d777
...
...
@@ -175,8 +175,8 @@ fn noop_fold_native_item(&@native_item ni, ast_fold fld) -> @native_item {
rec
(
inputs
=
map
(
fold_arg
,
fdec
.inputs
),
output
=
fld
.fold_ty
(
fdec
.output
),
purity
=
fdec
.purity
,
cf
=
fdec
.cf
,
constraints
=
map
(
fld
.fold_constr
,
fdec
.constraints
)),
constraints
=
ivec
::
map
(
fld
.fold_constr
,
fdec
.constraints
)),
typms
)
}
},
...
...
@@ -450,11 +450,12 @@ fn noop_fold_constr(&constr_ c, ast_fold fld) -> constr_ {
fn
noop_fold_fn
(
&
_
fn
f
,
ast_fold
fld
)
->
_
fn
{
auto
fold_arg
=
bind
fold_arg_
(
_
,
fld
);
ret
rec
(
decl
=
rec
(
inputs
=
map
(
fold_arg
,
f
.decl.inputs
),
ret
rec
(
decl
=
rec
(
inputs
=
vec
::
map
(
fold_arg
,
f
.decl.inputs
),
output
=
fld
.fold_ty
(
f
.decl.output
),
purity
=
f
.decl.purity
,
cf
=
f
.decl.cf
,
constraints
=
map
(
fld
.fold_constr
,
f
.decl.constraints
)),
constraints
=
ivec
::
map
(
fld
.fold_constr
,
f
.decl.constraints
)),
proto
=
f
.proto
,
body
=
fld
.fold_block
(
f
.body
));
}
...
...
src/comp/syntax/parse/parser.rs
浏览文件 @
f164d777
...
...
@@ -363,17 +363,17 @@ fn parse_ty_constr(&vec[ast::arg] fn_args, &parser p) -> @ast::constr {
// Use the args list to translate each bound variable
// mentioned in a constraint to an arg index.
// Seems weird to do this in the parser, but I'm not sure how else to.
fn
parse_constrs
(
&
vec
[
ast
::
arg
]
args
,
&
parser
p
)
->
ast
::
spanned
[
vec
[
@
ast
::
constr
]]
{
fn
parse_constrs
(
&
vec
[
ast
::
arg
]
args
,
&
parser
p
)
->
ast
::
spanned
[(
@
ast
::
constr
)[
]]
{
auto
lo
=
p
.get_lo_pos
();
auto
hi
=
p
.get_hi_pos
();
let
vec
[
@
ast
::
constr
]
constrs
=
[];
let
(
@
ast
::
constr
)[]
constrs
=
~
[];
if
(
p
.peek
()
==
token
::
COLON
)
{
p
.bump
();
while
(
true
)
{
auto
constr
=
parse_ty_constr
(
args
,
p
);
hi
=
constr
.span.hi
;
vec
::
push
(
constrs
,
constr
)
;
constrs
+=
~
[
constr
]
;
if
(
p
.peek
()
==
token
::
COMMA
)
{
p
.bump
();
}
else
{
break
;
}
}
}
...
...
@@ -1799,7 +1799,7 @@ fn parse_dtor(&parser p) -> @ast::method {
cf
=
ast
::
return
,
// I guess dtors can't have constraints?
constraints
=
[]);
constraints
=
~
[]);
let
ast
::
_
fn
f
=
rec
(
decl
=
d
,
proto
=
ast
::
proto_fn
,
body
=
b
);
let
ast
::
method_
m
=
rec
(
ident
=
"drop"
,
meth
=
f
,
id
=
p
.get_id
());
...
...
@@ -1844,7 +1844,7 @@ fn parse_item_res(&parser p, ast::layer lyr, &ast::attribute[] attrs) ->
output
=@
spanned
(
lo
,
lo
,
ast
::
ty_nil
),
purity
=
ast
::
impure_fn
,
cf
=
ast
::
return
,
constraints
=
[]);
constraints
=
~
[]);
auto
f
=
rec
(
decl
=
decl
,
proto
=
ast
::
proto_fn
,
body
=
dtor
);
ret
mk_item
(
p
,
lo
,
dtor
.span.hi
,
ident
,
ast
::
item_res
(
f
,
p
.get_id
(),
ty_params
,
p
.get_id
()),
attrs
);
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
f164d777
...
...
@@ -1235,7 +1235,7 @@ fn print_mt(&ps s, &ast::mt mt) {
fn
print_ty_fn
(
&
ps
s
,
&
ast
::
proto
proto
,
&
option
::
t
[
str
]
id
,
&
ast
::
ty_arg
[]
inputs
,
&@
ast
::
ty
output
,
&
ast
::
controlflow
cf
,
&
vec
[
@
ast
::
constr
]
constrs
)
{
&
ast
::
controlflow
cf
,
&
(
@
ast
::
constr
)[
]
constrs
)
{
ibox
(
s
,
indent_unit
);
if
(
proto
==
ast
::
proto_fn
)
{
word
(
s
.s
,
"fn"
);
...
...
@@ -1488,7 +1488,7 @@ fn ast_constr_to_str(&@ast::constr c) -> str {
constr_args_to_str
(
uint_to_str
,
cag_ivec
);
}
fn
ast_constrs_str
(
&
vec
[
@
ast
::
constr
]
constrs
)
->
str
{
fn
ast_constrs_str
(
&
(
@
ast
::
constr
)[
]
constrs
)
->
str
{
auto
s
=
""
;
auto
colon
=
true
;
for
(
@
ast
::
constr
c
in
constrs
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录