Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
f8393cc5
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,发现更多精彩内容 >>
提交
f8393cc5
编写于
3月 28, 2011
作者:
M
Marijn Haverbeke
提交者:
Graydon Hoare
3月 31, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add effect field to ast.ty_fn.
Still not used, except by the pretty-printer.
上级
e7e6f396
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
35 addition
and
31 deletion
+35
-31
src/comp/front/ast.rs
src/comp/front/ast.rs
+2
-3
src/comp/front/parser.rs
src/comp/front/parser.rs
+11
-12
src/comp/middle/fold.rs
src/comp/middle/fold.rs
+12
-11
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+1
-1
src/comp/pretty/pprust.rs
src/comp/pretty/pprust.rs
+9
-4
未找到文件。
src/comp/front/ast.rs
浏览文件 @
f8393cc5
...
...
@@ -305,8 +305,7 @@ fn unop_to_str(unop op) -> str {
type
mt
=
rec
(
@
ty
ty
,
mutability
mut
);
type
ty_field
=
rec
(
ident
ident
,
mt
mt
);
type
ty_arg
=
rec
(
mode
mode
,
@
ty
ty
);
// TODO: effect
type
ty_method
=
rec
(
proto
proto
,
ident
ident
,
type
ty_method
=
rec
(
effect
effect
,
proto
proto
,
ident
ident
,
vec
[
ty_arg
]
inputs
,
@
ty
output
);
type
ty
=
spanned
[
ty_
];
tag
ty_
{
...
...
@@ -324,7 +323,7 @@ fn unop_to_str(unop op) -> str {
ty_chan
(
@
ty
);
ty_tup
(
vec
[
mt
]);
ty_rec
(
vec
[
ty_field
]);
ty_fn
(
proto
,
vec
[
ty_arg
],
@
ty
);
// TODO: effect
ty_fn
(
effect
,
proto
,
vec
[
ty_arg
],
@
ty
);
ty_obj
(
vec
[
ty_method
]);
ty_path
(
path
,
option
.t
[
def
]);
ty_type
;
...
...
src/comp/front/parser.rs
浏览文件 @
f8393cc5
...
...
@@ -184,7 +184,7 @@ fn spanned[T](&span lo, &span hi, &T node) -> ast.spanned[T] {
}
impure
fn
parse_ty_fn
(
ast
.proto
proto
,
parser
p
,
impure
fn
parse_ty_fn
(
ast
.
effect
eff
,
ast
.
proto
proto
,
parser
p
,
ast
.span
lo
)
->
ast
.ty_
{
impure
fn
parse_fn_input_ty
(
parser
p
)
->
rec
(
ast
.mode
mode
,
@
ast
.ty
ty
)
{
auto
mode
;
...
...
@@ -228,7 +228,7 @@ fn spanned[T](&span lo, &span hi, &T node) -> ast.spanned[T] {
output
=
@
spanned
(
lo
,
inputs
.span
,
ast
.ty_nil
);
}
ret
ast
.ty_fn
(
proto
,
inputs
.node
,
output
);
ret
ast
.ty_fn
(
eff
,
proto
,
inputs
.node
,
output
);
}
impure
fn
parse_proto
(
parser
p
)
->
ast
.proto
{
...
...
@@ -245,15 +245,14 @@ fn spanned[T](&span lo, &span hi, &T node) -> ast.spanned[T] {
impure
fn
parse_method_sig
(
parser
p
)
->
ast
.ty_method
{
auto
flo
=
p
.get_span
();
// FIXME: do something with this, currently it's dropped on the floor.
let
ast
.effect
eff
=
parse_effect
(
p
);
let
ast
.proto
proto
=
parse_proto
(
p
);
auto
ident
=
parse_ident
(
p
);
auto
f
=
parse_ty_fn
(
proto
,
p
,
flo
);
auto
f
=
parse_ty_fn
(
eff
,
proto
,
p
,
flo
);
expect
(
p
,
token
.SEMI
);
alt
(
f
)
{
case
(
ast
.ty_fn
(
?
proto
,
?
inputs
,
?
output
))
{
ret
rec
(
proto
=
proto
,
ident
=
ident
,
case
(
ast
.ty_fn
(
?
eff
,
?
proto
,
?
inputs
,
?
output
))
{
ret
rec
(
effect
=
eff
,
proto
=
proto
,
ident
=
ident
,
inputs
=
inputs
,
output
=
output
);
}
}
...
...
@@ -342,9 +341,9 @@ fn spanned[T](&span lo, &span hi, &T node) -> ast.spanned[T] {
auto
hi
=
lo
;
let
ast
.ty_
t
;
// FIXME: do something with these; currently they're
// dropped on the floor.
// FIXME: make sure these are only used when valid
let
ast
.effect
eff
=
parse_effect
(
p
);
// FIXME: do something with this
let
ast
.layer
lyr
=
parse_layer
(
p
);
alt
(
p
.peek
())
{
...
...
@@ -412,9 +411,9 @@ fn spanned[T](&span lo, &span hi, &T node) -> ast.spanned[T] {
case
(
token
.FN
)
{
auto
flo
=
p
.get_span
();
p
.bump
();
t
=
parse_ty_fn
(
ast
.proto_fn
,
p
,
flo
);
t
=
parse_ty_fn
(
eff
,
ast
.proto_fn
,
p
,
flo
);
alt
(
t
)
{
case
(
ast
.ty_fn
(
_
,
_
,
?
out
))
{
case
(
ast
.ty_fn
(
_
,
_
,
_
,
?
out
))
{
hi
=
out
.span
;
}
}
...
...
@@ -423,9 +422,9 @@ fn spanned[T](&span lo, &span hi, &T node) -> ast.spanned[T] {
case
(
token
.ITER
)
{
auto
flo
=
p
.get_span
();
p
.bump
();
t
=
parse_ty_fn
(
ast
.proto_iter
,
p
,
flo
);
t
=
parse_ty_fn
(
eff
,
ast
.proto_iter
,
p
,
flo
);
alt
(
t
)
{
case
(
ast
.ty_fn
(
_
,
_
,
?
out
))
{
case
(
ast
.ty_fn
(
_
,
_
,
_
,
?
out
))
{
hi
=
out
.span
;
}
}
...
...
src/comp/middle/fold.rs
浏览文件 @
f8393cc5
...
...
@@ -60,6 +60,7 @@
vec
[
ast
.ty_method
]
meths
)
->
@
ty
)
fold_ty_obj
,
(
fn
(
&
ENV
e
,
&
span
sp
,
ast
.effect
eff
,
ast
.proto
proto
,
vec
[
rec
(
ast
.mode
mode
,
@
ty
ty
)]
inputs
,
@
ty
output
)
->
@
ty
)
fold_ty_fn
,
...
...
@@ -388,13 +389,13 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty {
case
(
ast
.ty_obj
(
?
meths
))
{
let
vec
[
ast
.ty_method
]
meths_
=
vec
();
for
(
ast
.ty_method
m
in
meths
)
{
auto
tfn
=
fold_ty_fn
(
env_
,
fld
,
t
.span
,
m
.proto
,
auto
tfn
=
fold_ty_fn
(
env_
,
fld
,
t
.span
,
m
.
effect
,
m
.
proto
,
m
.inputs
,
m
.output
);
alt
(
tfn
.node
)
{
case
(
ast
.ty_fn
(
?
p
,
?
ins
,
?
out
))
{
case
(
ast
.ty_fn
(
?
eff
,
?
p
,
?
ins
,
?
out
))
{
_
vec
.push
[
ast
.ty_method
]
(
meths_
,
rec
(
proto
=
p
,
inputs
=
ins
,
output
=
out
with
m
));
(
meths_
,
rec
(
effect
=
eff
,
proto
=
p
,
inputs
=
ins
,
output
=
out
with
m
));
}
}
}
...
...
@@ -406,8 +407,8 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty {
ret
fld
.fold_ty_path
(
env_
,
t
.span
,
pth_
,
ref_opt
);
}
case
(
ast
.ty_fn
(
?
proto
,
?
inputs
,
?
output
))
{
ret
fold_ty_fn
(
env_
,
fld
,
t
.span
,
proto
,
inputs
,
output
);
case
(
ast
.ty_fn
(
?
eff
,
?
proto
,
?
inputs
,
?
output
))
{
ret
fold_ty_fn
(
env_
,
fld
,
t
.span
,
eff
,
proto
,
inputs
,
output
);
}
case
(
ast
.ty_chan
(
?
ty
))
{
...
...
@@ -423,7 +424,7 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty {
}
fn
fold_ty_fn
[
ENV
](
&
ENV
env
,
ast_fold
[
ENV
]
fld
,
&
span
sp
,
ast
.proto
proto
,
ast
.
effect
eff
,
ast
.
proto
proto
,
vec
[
rec
(
ast
.mode
mode
,
@
ty
ty
)]
inputs
,
@
ty
output
)
->
@
ty
{
auto
output_
=
fold_ty
(
env
,
fld
,
output
);
...
...
@@ -433,7 +434,7 @@ fn fold_ty_fn[ENV](&ENV env, ast_fold[ENV] fld, &span sp,
auto
input_
=
rec
(
ty
=
ty_
with
input
);
inputs_
+=
vec
(
input_
);
}
ret
fld
.fold_ty_fn
(
env
,
sp
,
proto
,
inputs_
,
output_
);
ret
fld
.fold_ty_fn
(
env
,
sp
,
eff
,
proto
,
inputs_
,
output_
);
}
fn
fold_decl
[
ENV
](
&
ENV
env
,
ast_fold
[
ENV
]
fld
,
@
decl
d
)
->
@
decl
{
...
...
@@ -1131,10 +1132,10 @@ fn identity_fold_ty_obj[ENV](&ENV env, &span sp,
}
fn
identity_fold_ty_fn
[
ENV
](
&
ENV
env
,
&
span
sp
,
ast
.proto
proto
,
ast
.
effect
eff
,
ast
.
proto
proto
,
vec
[
rec
(
ast
.mode
mode
,
@
ty
ty
)]
inputs
,
@
ty
output
)
->
@
ty
{
ret
@
respan
(
sp
,
ast
.ty_fn
(
proto
,
inputs
,
output
));
ret
@
respan
(
sp
,
ast
.ty_fn
(
eff
,
proto
,
inputs
,
output
));
}
fn
identity_fold_ty_path
[
ENV
](
&
ENV
env
,
&
span
sp
,
ast
.path
p
,
...
...
@@ -1569,7 +1570,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
fold_ty_tup
=
bind
identity_fold_ty_tup
[
ENV
](
_
,
_
,
_
),
fold_ty_rec
=
bind
identity_fold_ty_rec
[
ENV
](
_
,
_
,
_
),
fold_ty_obj
=
bind
identity_fold_ty_obj
[
ENV
](
_
,
_
,
_
),
fold_ty_fn
=
bind
identity_fold_ty_fn
[
ENV
](
_
,
_
,
_
,
_
,
_
),
fold_ty_fn
=
bind
identity_fold_ty_fn
[
ENV
](
_
,
_
,
_
,
_
,
_
,
_
),
fold_ty_path
=
bind
identity_fold_ty_path
[
ENV
](
_
,
_
,
_
,
_
),
fold_ty_chan
=
bind
identity_fold_ty_chan
[
ENV
](
_
,
_
,
_
),
fold_ty_port
=
bind
identity_fold_ty_port
[
ENV
](
_
,
_
,
_
),
...
...
src/comp/middle/typeck.rs
浏览文件 @
f8393cc5
...
...
@@ -337,7 +337,7 @@ fn instantiate(ty_getter getter, ast.def_id id,
sty
=
ty
.ty_rec
(
flds
);
}
case
(
ast
.ty_fn
(
?
proto
,
?
inputs
,
?
output
))
{
case
(
ast
.ty_fn
(
_
,
?
proto
,
?
inputs
,
?
output
))
{
auto
f
=
bind
ast_arg_to_arg
(
getter
,
_
);
auto
i
=
_
vec
.map
[
ast
.ty_arg
,
arg
](
f
,
inputs
);
sty
=
ty
.ty_fn
(
proto
,
i
,
ast_ty_to_ty
(
getter
,
output
));
...
...
src/comp/pretty/pprust.rs
浏览文件 @
f8393cc5
...
...
@@ -127,7 +127,7 @@ fn ty_to_str(&@ast.ty ty) -> str {
bopen
(
s
);
for
(
ast
.ty_method
m
in
methods
)
{
hbox
(
s
);
print_ty_fn
(
s
,
m
.proto
,
option
.some
[
str
](
m
.ident
),
print_ty_fn
(
s
,
m
.
effect
,
m
.
proto
,
option
.some
[
str
](
m
.ident
),
m
.inputs
,
m
.output
);
wrd
(
s
.s
,
";"
);
end
(
s
.s
);
...
...
@@ -135,8 +135,8 @@ fn ty_to_str(&@ast.ty ty) -> str {
}
bclose_c
(
s
,
ty
.span
);
}
case
(
ast
.ty_fn
(
?
proto
,
?
inputs
,
?
output
))
{
print_ty_fn
(
s
,
proto
,
option
.none
[
str
],
inputs
,
output
);
case
(
ast
.ty_fn
(
?
eff
,
?
proto
,
?
inputs
,
?
output
))
{
print_ty_fn
(
s
,
eff
,
proto
,
option
.none
[
str
],
inputs
,
output
);
}
case
(
ast
.ty_path
(
?
path
,
_
))
{
print_path
(
s
,
path
);
...
...
@@ -843,8 +843,13 @@ fn escape_str(str st, char to_escape) -> str {
wrd
(
s
.s
,
"
\"
"
);
wrd
(
s
.s
,
escape_str
(
st
,
'"'
));
wrd
(
s
.s
,
"
\"
"
);
}
impure
fn
print_ty_fn
(
ps
s
,
ast
.proto
proto
,
option
.t
[
str
]
id
,
impure
fn
print_ty_fn
(
ps
s
,
ast
.
effect
eff
,
ast
.
proto
proto
,
option
.t
[
str
]
id
,
vec
[
ast
.ty_arg
]
inputs
,
@
ast
.ty
output
)
{
alt
(
eff
)
{
case
(
ast
.eff_impure
)
{
wrd1
(
s
,
"impure"
);}
case
(
ast
.eff_unsafe
)
{
wrd1
(
s
,
"unsafe"
);}
case
(
_
)
{}
}
if
(
proto
==
ast
.proto_fn
)
{
wrd
(
s
.s
,
"fn"
);}
else
{
wrd
(
s
.s
,
"iter"
);}
alt
(
id
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录