Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
55acc737
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,发现更多精彩内容 >>
提交
55acc737
编写于
7月 21, 2011
作者:
L
Lindsey Kuper
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove vestiges of typarams from anon objs.
上级
f3330950
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
35 addition
and
77 deletion
+35
-77
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+22
-59
src/comp/middle/tstate/pre_post_conditions.rs
src/comp/middle/tstate/pre_post_conditions.rs
+1
-1
src/comp/middle/tstate/states.rs
src/comp/middle/tstate/states.rs
+1
-1
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+3
-4
src/comp/syntax/ast.rs
src/comp/syntax/ast.rs
+1
-1
src/comp/syntax/fold.rs
src/comp/syntax/fold.rs
+2
-2
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+2
-5
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+1
-2
src/comp/syntax/visit.rs
src/comp/syntax/visit.rs
+1
-1
src/comp/syntax/walk.rs
src/comp/syntax/walk.rs
+1
-1
未找到文件。
src/comp/middle/trans.rs
浏览文件 @
55acc737
...
...
@@ -5847,8 +5847,8 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ->
case
(
ast
::
expr_spawn
(
?
dom
,
?
name
,
?
func
,
?
args
))
{
ret
trans_spawn
(
cx
,
dom
,
name
,
func
,
args
,
e
.id
);
}
case
(
ast
::
expr_anon_obj
(
?
anon_obj
,
?
tps
))
{
ret
trans_anon_obj
(
cx
,
e
.span
,
anon_obj
,
tps
,
e
.id
);
case
(
ast
::
expr_anon_obj
(
?
anon_obj
))
{
ret
trans_anon_obj
(
cx
,
e
.span
,
anon_obj
,
e
.id
);
}
case
(
_
)
{
// The expression is an lvalue. Fall through.
...
...
@@ -6222,15 +6222,9 @@ fn bar() -> int {
// instead "inlining" the construction of the object and returning the object
// itself.
fn
trans_anon_obj
(
@
block_ctxt
bcx
,
&
span
sp
,
&
ast
::
anon_obj
anon_obj
,
&
ast
::
ty_param
[]
ty_params
,
ast
::
node_id
id
)
->
result
{
ast
::
node_id
id
)
->
result
{
// Right now, we're assuming that anon objs don't take ty params, even
// though the AST supports it. It's nonsensical to write an expression
// like "obj[T](){ ... with ... }", since T is never instantiated;
// nevertheless, such an expression will parse. Idea for the future:
// support typarams.
assert
(
std
::
ivec
::
len
(
ty_params
)
==
0u
);
auto
ccx
=
bcx
.fcx.lcx.ccx
;
// Fields.
...
...
@@ -6286,7 +6280,7 @@ fn anon_obj_field_to_obj_field(&ast::anon_obj_field f)
// is that, since *all* of the methods are "additional", we can
// get away with acting like none of them are.
vtbl
=
create_vtbl
(
bcx
.fcx.lcx
,
sp
,
outer_obj_ty
,
wrapper_obj
,
ty_params
,
none
,
wrapper_obj
,
~
[]
,
none
,
additional_field_tys
);
}
case
(
some
(
?
e
))
{
...
...
@@ -6304,8 +6298,7 @@ fn anon_obj_field_to_obj_field(&ast::anon_obj_field f)
// create a forwarding slot. And, of course, we need to create a
// normal vtable entry for every method being added.
vtbl
=
create_vtbl
(
bcx
.fcx.lcx
,
sp
,
outer_obj_ty
,
wrapper_obj
,
ty_params
,
some
(
with_obj_ty
),
wrapper_obj
,
~
[],
some
(
with_obj_ty
),
additional_field_tys
);
}
}
...
...
@@ -6333,27 +6326,22 @@ fn anon_obj_field_to_obj_field(&ast::anon_obj_field f)
// typarams, fields, and a pointer to our with_obj.
let
TypeRef
llbox_ty
=
T_ptr
(
T_empty_struct
());
if
(
std
::
ivec
::
len
[
ast
::
ty_param
](
ty_params
)
==
0u
&&
std
::
ivec
::
len
[
ast
::
anon_obj_field
](
additional_fields
)
==
0u
&&
if
(
std
::
ivec
::
len
[
ast
::
anon_obj_field
](
additional_fields
)
==
0u
&&
anon_obj
.with_obj
==
none
)
{
// If the object we're translating has no fields
or type parameters
//
and no with_obj,
there's not much to do.
// If the object we're translating has no fields
and no with_obj,
// there's not much to do.
bcx
.build
.Store
(
C_null
(
llbox_ty
),
pair_box
);
}
else
{
// Synthesize a tuple type for fields: [field, ...]
let
ty
::
t
fields_ty
=
ty
::
mk_imm_tup
(
ccx
.tcx
,
additional_field_tys
);
// Tydescs are run-time instantiations of typarams. We're not
// actually supporting typarams for anon objs yet, but let's
// create space for them in case we ever want them.
// Type for tydescs.
let
ty
::
t
tydesc_ty
=
ty
::
mk_type
(
ccx
.tcx
);
let
ty
::
t
[]
tps
=
~
[];
for
(
ast
::
ty_param
tp
in
ty_params
)
{
tps
+=
~
[
tydesc_ty
];
}
// Synthesize a tuple type for typarams: [typaram, ...]
let
ty
::
t
typarams_ty
=
ty
::
mk_imm_tup
(
ccx
.tcx
,
tps
);
// Placeholder for non-existent typarams, since anon objs don't have
// them.
let
ty
::
t
typarams_ty
=
ty
::
mk_imm_tup
(
ccx
.tcx
,
~
[]);
// Tuple type for body:
// [tydesc_ty, [typaram, ...], [field, ...], with_obj]
...
...
@@ -6402,35 +6390,15 @@ fn anon_obj_field_to_obj_field(&ast::anon_obj_field f)
bcx
=
body_td
.bcx
;
bcx
.build
.Store
(
body_td
.val
,
body_tydesc
.val
);
// Copy the object's type parameters and fields into the space we
// allocated for the object body. (This is something like saving the
// lexical environment of a function in its closure: the "captured
// typarams" are any type parameters that are passed to the object
// constructor and are then available to the object's methods.
// Likewise for the object's fields.)
// Copy typarams into captured typarams.
auto
body_typarams
=
GEP_tup_like
(
bcx
,
body_ty
,
body
.val
,
~
[
0
,
abi
::
obj_body_elt_typarams
]);
bcx
=
body_typarams
.bcx
;
let
int
i
=
0
;
for
(
ast
::
ty_param
tp
in
ty_params
)
{
auto
typaram
=
bcx
.fcx.lltydescs
.
(
i
);
auto
capture
=
GEP_tup_like
(
bcx
,
typarams_ty
,
body_typarams
.val
,
~
[
0
,
i
]);
bcx
=
capture
.bcx
;
bcx
=
copy_val
(
bcx
,
INIT
,
capture
.val
,
typaram
,
tydesc_ty
)
.bcx
;
i
+=
1
;
}
// Copy additional fields into the object's body.
// Copy the object's fields into the space we allocated for the object
// body. (This is something like saving the lexical environment of a
// function in its closure: the fields were passed to the object
// constructor and are now available to the object's methods.
auto
body_fields
=
GEP_tup_like
(
bcx
,
body_ty
,
body
.val
,
~
[
0
,
abi
::
obj_body_elt_fields
]);
bcx
=
body_fields
.bcx
;
i
=
0
;
let
int
i
=
0
;
for
(
ast
::
anon_obj_field
f
in
additional_fields
)
{
// FIXME (part of issue #538): make this work eventually, when we
// have additional field exprs in the AST.
...
...
@@ -7182,16 +7150,11 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
// Synthesize a tuple type for fields: [field, ...]
let
ty
::
t
fields_ty
=
ty
::
mk_imm_tup
(
cx
.ccx.tcx
,
additional_field_tys
);
// Tydescs are run-time instantiations of typarams. We're not
// actually supporting typarams for anon objs yet, but let's
// create space for them in case we ever want them.
// Type for tydescs.
let
ty
::
t
tydesc_ty
=
ty
::
mk_type
(
cx
.ccx.tcx
);
let
ty
::
t
[]
tps
=
~
[];
for
(
ast
::
ty_param
tp
in
ty_params
)
{
tps
+=
~
[
tydesc_ty
];
}
// Synthesize a tuple type for typarams: [typaram, ...]
let
ty
::
t
typarams_ty
=
ty
::
mk_imm_tup
(
cx
.ccx.tcx
,
tps
);
// Placeholder for non-existent typarams, since anon objs don't have them.
let
ty
::
t
typarams_ty
=
ty
::
mk_imm_tup
(
cx
.ccx.tcx
,
~
[]);
// Tuple type for body:
// [tydesc_ty, [typaram, ...], [field, ...], with_obj]
...
...
src/comp/middle/tstate/pre_post_conditions.rs
浏览文件 @
55acc737
...
...
@@ -567,7 +567,7 @@ fn combine_pp(pre_and_post antec, fn_ctxt fcx, &pre_and_post pp,
case
(
expr_mac
(
_
))
{
fcx
.ccx.tcx.sess
.bug
(
"unexpanded macro"
);
}
case
(
expr_anon_obj
(
?
anon_obj
,
_
))
{
case
(
expr_anon_obj
(
?
anon_obj
))
{
alt
(
anon_obj
.with_obj
)
{
case
(
some
(
?
ex
))
{
find_pre_post_expr
(
fcx
,
ex
);
...
...
src/comp/middle/tstate/states.rs
浏览文件 @
55acc737
...
...
@@ -564,7 +564,7 @@ fn find_pre_post_state_expr(&fn_ctxt fcx, &prestate pres, @expr e) -> bool {
case
(
expr_cont
)
{
ret
pure_exp
(
fcx
.ccx
,
e
.id
,
pres
);
}
case
(
expr_port
(
_
))
{
ret
pure_exp
(
fcx
.ccx
,
e
.id
,
pres
);
}
case
(
expr_self_method
(
_
))
{
ret
pure_exp
(
fcx
.ccx
,
e
.id
,
pres
);
}
case
(
expr_anon_obj
(
?
anon_obj
,
_
))
{
case
(
expr_anon_obj
(
?
anon_obj
))
{
alt
(
anon_obj
.with_obj
)
{
case
(
some
(
?
wt
))
{
ret
find_pre_post_state_sub
(
fcx
,
pres
,
wt
,
e
.id
,
none
);
...
...
src/comp/middle/typeck.rs
浏览文件 @
55acc737
...
...
@@ -2395,7 +2395,7 @@ fn get_node(&spanned[field] f) -> field { f.node }
}
}
}
case
(
ast
::
expr_anon_obj
(
?
ao
,
?
tps
))
{
case
(
ast
::
expr_anon_obj
(
?
ao
))
{
let
ast
::
anon_obj_field
[]
fields
=
~
[];
alt
(
ao
.fields
)
{
...
...
@@ -2432,8 +2432,7 @@ fn ty_of_method(@crate_ctxt ccx, &@ast::method m) -> ty::method {
fn
get_anon_obj_method_types
(
@
fn_ctxt
fcx
,
&
ast
::
anon_obj
ao
,
&
ast
::
anon_obj_field
[]
fields
,
&
ast
::
ty_param
[]
tps
)
&
ast
::
anon_obj_field
[]
fields
)
->
ty
::
method
[]
{
let
ty
::
method
[]
methods
=
~
[];
...
...
@@ -2495,7 +2494,7 @@ fn ao_field_to_o_field(&ast::anon_obj_field f)
}
auto
method_types
=
get_anon_obj_method_types
(
fcx
,
ao
,
fields
,
tps
);
fields
);
auto
ot
=
ty
::
mk_obj
(
fcx
.ccx.tcx
,
ty
::
sort_methods
(
method_types
));
write
::
ty_only_fixup
(
fcx
,
id
,
ot
);
...
...
src/comp/syntax/ast.rs
浏览文件 @
55acc737
...
...
@@ -325,7 +325,7 @@ fn unop_to_str(unop op) -> str {
expr_if_check
(
@
expr
,
block
,
option
::
t
[
@
expr
]);
expr_port
(
option
::
t
[
@
ty
]);
expr_chan
(
@
expr
);
expr_anon_obj
(
anon_obj
,
ty_param
[]
);
expr_anon_obj
(
anon_obj
);
expr_mac
(
mac
);
}
...
...
src/comp/syntax/fold.rs
浏览文件 @
55acc737
...
...
@@ -458,8 +458,8 @@ fn fold_anon_obj_field_(&anon_obj_field aof, ast_fold fld)
})
}
case
(
expr_chan
(
?
e
))
{
expr_chan
(
fld
.fold_expr
(
e
))
}
case
(
expr_anon_obj
(
?
ao
,
?
typms
))
{
expr_anon_obj
(
fold_anon_obj
(
ao
)
,
typms
)
case
(
expr_anon_obj
(
?
ao
))
{
expr_anon_obj
(
fold_anon_obj
(
ao
))
}
case
(
expr_mac
(
?
mac
))
{
expr_mac
(
fold_mac
(
mac
))
...
...
src/comp/syntax/parse/parser.rs
浏览文件 @
55acc737
...
...
@@ -833,9 +833,6 @@ fn parse_elt(&parser p) -> ast::elt {
}
else
if
(
eat_word
(
p
,
"obj"
))
{
// Anonymous object
// FIXME: Can anonymous objects have ty params?
auto
ty_params
=
parse_ty_params
(
p
);
// Only make people type () if they're actually adding new fields
let
option
::
t
[
ast
::
anon_obj_field
[]]
fields
=
none
;
if
(
p
.peek
()
==
token
::
LPAREN
)
{
...
...
@@ -864,7 +861,7 @@ fn parse_elt(&parser p) -> ast::elt {
// "spanned".
let
ast
::
anon_obj
ob
=
rec
(
fields
=
fields
,
methods
=
meths
,
with_obj
=
with_obj
);
ex
=
ast
::
expr_anon_obj
(
ob
,
ty_params
);
ex
=
ast
::
expr_anon_obj
(
ob
);
}
else
if
(
eat_word
(
p
,
"rec"
))
{
expect
(
p
,
token
::
LPAREN
);
auto
fields
=
~
[
parse_field
(
p
)];
...
...
@@ -1686,7 +1683,7 @@ fn stmt_ends_with_semi(&ast::stmt stmt) -> bool {
case
(
ast
::
expr_if_check
(
_
,
_
,
_
))
{
false
}
case
(
ast
::
expr_port
(
_
))
{
true
}
case
(
ast
::
expr_chan
(
_
))
{
true
}
case
(
ast
::
expr_anon_obj
(
_
,
_
))
{
false
}
case
(
ast
::
expr_anon_obj
(
_
))
{
false
}
case
(
ast
::
expr_assert
(
_
))
{
true
}
}
}
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
55acc737
...
...
@@ -986,9 +986,8 @@ fn print_opt(&ps s, &option::t[@ast::expr] expr) {
print_expr
(
s
,
expr
);
pclose
(
s
);
}
case
(
ast
::
expr_anon_obj
(
?
anon_obj
,
?
tps
))
{
case
(
ast
::
expr_anon_obj
(
?
anon_obj
))
{
head
(
s
,
"obj"
);
print_type_params
(
s
,
tps
);
// Fields
popen
(
s
);
...
...
src/comp/syntax/visit.rs
浏览文件 @
55acc737
...
...
@@ -395,7 +395,7 @@ fn visit_expr[E](&@expr ex, &E e, &vt[E] v) {
case
(
expr_assert
(
?
x
))
{
v
.visit_expr
(
x
,
e
,
v
);
}
case
(
expr_port
(
?
t
))
{
visit_ty_opt
(
t
,
e
,
v
);
}
case
(
expr_chan
(
?
x
))
{
v
.visit_expr
(
x
,
e
,
v
);
}
case
(
expr_anon_obj
(
?
anon_obj
,
_
))
{
case
(
expr_anon_obj
(
?
anon_obj
))
{
alt
(
anon_obj
.fields
)
{
case
(
none
)
{
}
case
(
some
(
?
fields
))
{
...
...
src/comp/syntax/walk.rs
浏览文件 @
55acc737
...
...
@@ -388,7 +388,7 @@ fn walk_expr(&ast_visitor v, @ast::expr e) {
case
(
ast
::
expr_assert
(
?
x
))
{
walk_expr
(
v
,
x
);
}
case
(
ast
::
expr_port
(
_
))
{
}
case
(
ast
::
expr_chan
(
?
x
))
{
walk_expr
(
v
,
x
);
}
case
(
ast
::
expr_anon_obj
(
?
anon_obj
,
_
))
{
case
(
ast
::
expr_anon_obj
(
?
anon_obj
))
{
// Fields
alt
(
anon_obj
.fields
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录