Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
6720ea76
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,发现更多精彩内容 >>
提交
6720ea76
编写于
7月 01, 2011
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Change methods in ty::t to use interior vectors
上级
172c5633
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
43 deletion
+48
-43
src/comp/metadata/tydecode.rs
src/comp/metadata/tydecode.rs
+7
-7
src/comp/middle/ty.rs
src/comp/middle/ty.rs
+22
-22
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+16
-11
src/comp/pretty/ppaux.rs
src/comp/pretty/ppaux.rs
+3
-3
未找到文件。
src/comp/metadata/tydecode.rs
浏览文件 @
6720ea76
...
@@ -230,7 +230,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
...
@@ -230,7 +230,7 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
}
}
case
(
'O'
)
{
case
(
'O'
)
{
assert
(
next
(
st
)
as
char
==
'['
);
assert
(
next
(
st
)
as
char
==
'['
);
let
vec
[
ty
::
method
]
methods
=
[];
let
ty
::
method
[]
methods
=
~
[];
while
(
peek
(
st
)
as
char
!=
']'
)
{
while
(
peek
(
st
)
as
char
!=
']'
)
{
auto
proto
;
auto
proto
;
alt
(
next
(
st
)
as
char
)
{
alt
(
next
(
st
)
as
char
)
{
...
@@ -243,12 +243,12 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
...
@@ -243,12 +243,12 @@ fn parse_ty(@pstate st, str_def sd) -> ty::t {
}
}
auto
func
=
parse_ty_fn
(
st
,
sd
);
auto
func
=
parse_ty_fn
(
st
,
sd
);
methods
+=
methods
+=
[
rec
(
proto
=
proto
,
~
[
rec
(
proto
=
proto
,
ident
=
name
,
ident
=
name
,
inputs
=
func
._0
,
inputs
=
func
._0
,
output
=
func
._1
,
output
=
func
._1
,
cf
=
func
._2
,
cf
=
func
._2
,
constrs
=
func
._3
)];
constrs
=
func
._3
)];
}
}
st
.pos
+=
1u
;
st
.pos
+=
1u
;
ret
ty
::
mk_obj
(
st
.tcx
,
methods
);
ret
ty
::
mk_obj
(
st
.tcx
,
methods
);
...
...
src/comp/middle/ty.rs
浏览文件 @
6720ea76
...
@@ -268,7 +268,7 @@ fn method_ty_to_fn_ty(&ctxt cx, method m) -> t {
...
@@ -268,7 +268,7 @@ fn method_ty_to_fn_ty(&ctxt cx, method m) -> t {
ty_rec
(
field
[]);
ty_rec
(
field
[]);
ty_fn
(
ast
::
proto
,
arg
[],
t
,
controlflow
,
vec
[
@
constr_def
]);
ty_fn
(
ast
::
proto
,
arg
[],
t
,
controlflow
,
vec
[
@
constr_def
]);
ty_native_fn
(
ast
::
native_abi
,
arg
[],
t
);
ty_native_fn
(
ast
::
native_abi
,
arg
[],
t
);
ty_obj
(
vec
[
method
]);
ty_obj
(
method
[
]);
ty_res
(
def_id
,
t
,
vec
[
t
]);
ty_res
(
def_id
,
t
,
vec
[
t
]);
ty_var
(
int
);
// type variable
ty_var
(
int
);
// type variable
ty_param
(
uint
);
// fn/tag type param
ty_param
(
uint
);
// fn/tag type param
...
@@ -603,7 +603,7 @@ fn mk_native_fn(&ctxt cx, &ast::native_abi abi, &arg[] args, &t ty) -> t {
...
@@ -603,7 +603,7 @@ fn mk_native_fn(&ctxt cx, &ast::native_abi abi, &arg[] args, &t ty) -> t {
ret
gen_ty
(
cx
,
ty_native_fn
(
abi
,
args
,
ty
));
ret
gen_ty
(
cx
,
ty_native_fn
(
abi
,
args
,
ty
));
}
}
fn
mk_obj
(
&
ctxt
cx
,
&
vec
[
method
]
meths
)
->
t
{
fn
mk_obj
(
&
ctxt
cx
,
&
method
[
]
meths
)
->
t
{
ret
gen_ty
(
cx
,
ty_obj
(
meths
));
ret
gen_ty
(
cx
,
ty_obj
(
meths
));
}
}
...
@@ -811,7 +811,7 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
...
@@ -811,7 +811,7 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
fold_ty
(
cx
,
fld
,
ret_ty
)),
ty
);
fold_ty
(
cx
,
fld
,
ret_ty
)),
ty
);
}
}
case
(
ty_obj
(
?
methods
))
{
case
(
ty_obj
(
?
methods
))
{
let
vec
[
method
]
new_methods
=
[];
let
method
[]
new_methods
=
~
[];
for
(
method
m
in
methods
)
{
for
(
method
m
in
methods
)
{
let
arg
[]
new_args
=
~
[];
let
arg
[]
new_args
=
~
[];
for
(
arg
a
in
m
.inputs
)
{
for
(
arg
a
in
m
.inputs
)
{
...
@@ -819,12 +819,12 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
...
@@ -819,12 +819,12 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
ty
=
fold_ty
(
cx
,
fld
,
a
.ty
))];
ty
=
fold_ty
(
cx
,
fld
,
a
.ty
))];
}
}
new_methods
+=
new_methods
+=
[
rec
(
proto
=
m
.proto
,
~
[
rec
(
proto
=
m
.proto
,
ident
=
m
.ident
,
ident
=
m
.ident
,
inputs
=
new_args
,
inputs
=
new_args
,
output
=
fold_ty
(
cx
,
fld
,
m
.output
),
output
=
fold_ty
(
cx
,
fld
,
m
.output
),
cf
=
m
.cf
,
cf
=
m
.cf
,
constrs
=
m
.constrs
)];
constrs
=
m
.constrs
)];
}
}
ty
=
copy_cname
(
cx
,
mk_obj
(
cx
,
new_methods
),
ty
);
ty
=
copy_cname
(
cx
,
mk_obj
(
cx
,
new_methods
),
ty
);
}
}
...
@@ -1634,8 +1634,8 @@ fn equal_def(&ast::def_id did_a, &ast::def_id did_b) -> bool {
...
@@ -1634,8 +1634,8 @@ fn equal_def(&ast::def_id did_a, &ast::def_id did_b) -> bool {
case
(
ty_obj
(
?
methods_a
))
{
case
(
ty_obj
(
?
methods_a
))
{
alt
(
b
)
{
alt
(
b
)
{
case
(
ty_obj
(
?
methods_b
))
{
case
(
ty_obj
(
?
methods_b
))
{
auto
len
=
vec
::
len
[
method
](
methods_a
);
auto
len
=
i
vec
::
len
[
method
](
methods_a
);
if
(
len
!=
vec
::
len
[
method
](
methods_b
))
{
ret
false
;
}
if
(
len
!=
i
vec
::
len
[
method
](
methods_b
))
{
ret
false
;
}
auto
i
=
0u
;
auto
i
=
0u
;
while
(
i
<
len
)
{
while
(
i
<
len
)
{
auto
m_a
=
methods_a
.
(
i
);
auto
m_a
=
methods_a
.
(
i
);
...
@@ -1947,17 +1947,17 @@ fn field_idx(&session::session sess, &span sp, &ast::ident id,
...
@@ -1947,17 +1947,17 @@ fn field_idx(&session::session sess, &span sp, &ast::ident id,
}
}
fn
method_idx
(
&
session
::
session
sess
,
&
span
sp
,
&
ast
::
ident
id
,
fn
method_idx
(
&
session
::
session
sess
,
&
span
sp
,
&
ast
::
ident
id
,
&
vec
[
method
]
meths
)
->
uint
{
&
method
[
]
meths
)
->
uint
{
let
uint
i
=
0u
;
let
uint
i
=
0u
;
for
(
method
m
in
meths
)
{
if
(
str
::
eq
(
m
.ident
,
id
))
{
ret
i
;
}
i
+=
1u
;
}
for
(
method
m
in
meths
)
{
if
(
str
::
eq
(
m
.ident
,
id
))
{
ret
i
;
}
i
+=
1u
;
}
sess
.span_fatal
(
sp
,
"unknown method '"
+
id
+
"' of obj"
);
sess
.span_fatal
(
sp
,
"unknown method '"
+
id
+
"' of obj"
);
}
}
fn
sort_methods
(
&
vec
[
method
]
meths
)
->
vec
[
method
]
{
fn
sort_methods
(
&
method
[]
meths
)
->
method
[
]
{
fn
method_lteq
(
&
method
a
,
&
method
b
)
->
bool
{
fn
method_lteq
(
&
method
a
,
&
method
b
)
->
bool
{
ret
str
::
lteq
(
a
.ident
,
b
.ident
);
ret
str
::
lteq
(
a
.ident
,
b
.ident
);
}
}
ret
std
::
sort
::
merge_sort
[
method
](
bind
method_lteq
(
_
,
_
),
meths
);
ret
std
::
sort
::
ivector
::
merge_sort
[
method
](
bind
method_lteq
(
_
,
_
),
meths
);
}
}
fn
is_lval
(
&@
ast
::
expr
expr
)
->
bool
{
fn
is_lval
(
&@
ast
::
expr
expr
)
->
bool
{
...
@@ -2197,12 +2197,12 @@ fn unify_native_fn(&@ctxt cx, &ast::native_abi e_abi,
...
@@ -2197,12 +2197,12 @@ fn unify_native_fn(&@ctxt cx, &ast::native_abi e_abi,
}
}
}
}
fn
unify_obj
(
&@
ctxt
cx
,
&
t
expected
,
&
t
actual
,
fn
unify_obj
(
&@
ctxt
cx
,
&
t
expected
,
&
t
actual
,
&
vec
[
method
]
expected_meths
,
&
vec
[
method
]
actual_meths
)
->
&
method
[]
expected_meths
,
&
method
[
]
actual_meths
)
->
result
{
result
{
let
vec
[
method
]
result_meths
=
[];
let
method
[]
result_meths
=
~
[];
let
uint
i
=
0u
;
let
uint
i
=
0u
;
let
uint
expected_len
=
vec
::
len
[
method
](
expected_meths
);
let
uint
expected_len
=
i
vec
::
len
[
method
](
expected_meths
);
let
uint
actual_len
=
vec
::
len
[
method
](
actual_meths
);
let
uint
actual_len
=
i
vec
::
len
[
method
](
actual_meths
);
if
(
expected_len
!=
actual_len
)
{
ret
ures_err
(
terr_meth_count
);
}
if
(
expected_len
!=
actual_len
)
{
ret
ures_err
(
terr_meth_count
);
}
while
(
i
<
expected_len
)
{
while
(
i
<
expected_len
)
{
auto
e_meth
=
expected_meths
.
(
i
);
auto
e_meth
=
expected_meths
.
(
i
);
...
@@ -2220,10 +2220,10 @@ fn unify_obj(&@ctxt cx, &t expected, &t actual,
...
@@ -2220,10 +2220,10 @@ fn unify_obj(&@ctxt cx, &t expected, &t actual,
alt
(
struct
(
cx
.tcx
,
tfn
))
{
alt
(
struct
(
cx
.tcx
,
tfn
))
{
case
(
ty_fn
(
?
proto
,
?
ins
,
?
out
,
?
cf
,
?
constrs
))
{
case
(
ty_fn
(
?
proto
,
?
ins
,
?
out
,
?
cf
,
?
constrs
))
{
result_meths
+=
result_meths
+=
[
rec
(
inputs
=
ins
,
~
[
rec
(
inputs
=
ins
,
output
=
out
,
output
=
out
,
cf
=
cf
,
cf
=
cf
,
constrs
=
constrs
with
e_meth
)];
constrs
=
constrs
with
e_meth
)];
}
}
}
}
}
}
...
...
src/comp/middle/typeck.rs
浏览文件 @
6720ea76
...
@@ -336,7 +336,7 @@ fn instantiate(&ty::ctxt tcx, &span sp, &ty_getter getter,
...
@@ -336,7 +336,7 @@ fn instantiate(&ty::ctxt tcx, &span sp, &ty_getter getter,
cname
=
some
(
path_to_str
(
path
));
cname
=
some
(
path_to_str
(
path
));
}
}
case
(
ast
::
ty_obj
(
?
meths
))
{
case
(
ast
::
ty_obj
(
?
meths
))
{
let
vec
[
ty
::
method
]
tmeths
=
[];
let
ty
::
method
[]
tmeths
=
~
[];
for
(
ast
::
ty_method
m
in
meths
)
{
for
(
ast
::
ty_method
m
in
meths
)
{
auto
ins
=
~
[];
auto
ins
=
~
[];
for
(
ast
::
ty_arg
ta
in
m
.node.inputs
)
{
for
(
ast
::
ty_arg
ta
in
m
.node.inputs
)
{
...
@@ -355,7 +355,7 @@ fn instantiate(&ty::ctxt tcx, &span sp, &ty_getter getter,
...
@@ -355,7 +355,7 @@ fn instantiate(&ty::ctxt tcx, &span sp, &ty_getter getter,
output
=
out
,
output
=
out
,
cf
=
m
.node.cf
,
cf
=
m
.node.cf
,
constrs
=
out_constrs
);
constrs
=
out_constrs
);
vec
::
push
[
ty
::
method
](
tmeths
,
new_m
)
;
tmeths
+=
~
[
new_m
]
;
}
}
typ
=
ty
::
mk_obj
(
tcx
,
ty
::
sort_methods
(
tmeths
));
typ
=
ty
::
mk_obj
(
tcx
,
ty
::
sort_methods
(
tmeths
));
}
}
...
@@ -681,9 +681,12 @@ fn get_tag_variant_types(&@ctxt cx, &ast::def_id tag_id,
...
@@ -681,9 +681,12 @@ fn get_tag_variant_types(&@ctxt cx, &ast::def_id tag_id,
write
::
ty_only
(
cx
.tcx
,
variant
.node.id
,
result_ty
);
write
::
ty_only
(
cx
.tcx
,
variant
.node.id
,
result_ty
);
}
}
}
}
fn
get_obj_method_types
(
&@
ctxt
cx
,
&
ast
::
_
obj
object
)
->
vec
[
ty
::
method
]
{
fn
get_obj_method_types
(
&@
ctxt
cx
,
&
ast
::
_
obj
object
)
->
ty
::
method
[]
{
ret
vec
::
map
[
@
ast
::
method
,
auto
meths
=
~
[];
method
](
bind
ty_of_method
(
cx
,
_
),
object
.methods
);
for
(
@
ast
::
method
am
in
object
.methods
)
{
meths
+=
~
[
ty_of_method
(
cx
,
am
)];
}
ret
meths
;
}
}
fn
convert
(
@
ctxt
cx
,
@
mutable
option
::
t
[
ast
::
native_abi
]
abi
,
fn
convert
(
@
ctxt
cx
,
@
mutable
option
::
t
[
ast
::
native_abi
]
abi
,
&@
ast
::
item
it
)
{
&@
ast
::
item
it
)
{
...
@@ -2069,7 +2072,7 @@ fn check_binop_type_compat(&@fn_ctxt fcx, common::span span,
...
@@ -2069,7 +2072,7 @@ fn check_binop_type_compat(&@fn_ctxt fcx, common::span span,
let
uint
ix
=
let
uint
ix
=
ty
::
method_idx
(
fcx
.ccx.tcx.sess
,
expr
.span
,
field
,
ty
::
method_idx
(
fcx
.ccx.tcx.sess
,
expr
.span
,
field
,
methods
);
methods
);
if
(
ix
>=
vec
::
len
[
ty
::
method
](
methods
))
{
if
(
ix
>=
i
vec
::
len
[
ty
::
method
](
methods
))
{
fcx
.ccx.tcx.sess
.span_fatal
(
expr
.span
,
fcx
.ccx.tcx.sess
.span_fatal
(
expr
.span
,
"bad index on obj"
);
"bad index on obj"
);
}
}
...
@@ -2213,11 +2216,13 @@ fn ty_of_method(@crate_ctxt ccx, &@ast::method m) -> ty::method {
...
@@ -2213,11 +2216,13 @@ fn ty_of_method(@crate_ctxt ccx, &@ast::method m) -> ty::method {
constrs
=
out_constrs
);
constrs
=
out_constrs
);
}
}
fn
get_anon_obj_method_types
(
@
crate_ctxt
ccx
,
fn
get_anon_obj_method_types
(
@
crate_ctxt
ccx
,
&
ast
::
anon_obj
anon_obj
)
->
&
ast
::
anon_obj
anon_obj
)
vec
[
ty
::
method
]
{
->
ty
::
method
[]
{
ret
vec
::
map
[
@
ast
::
method
,
auto
meths
=
~
[];
method
](
bind
ty_of_method
(
ccx
,
_
),
for
(
@
ast
::
method
am
in
anon_obj
.methods
)
{
anon_obj
.methods
);
meths
+=
~
[
ty_of_method
(
ccx
,
am
)];
}
ret
meths
;
}
}
auto
method_types
=
get_anon_obj_method_types
(
fcx
.ccx
,
anon_obj
);
auto
method_types
=
get_anon_obj_method_types
(
fcx
.ccx
,
anon_obj
);
auto
ot
=
ty
::
mk_obj
(
fcx
.ccx.tcx
,
ty
::
sort_methods
(
method_types
));
auto
ot
=
ty
::
mk_obj
(
fcx
.ccx.tcx
,
ty
::
sort_methods
(
method_types
));
...
...
src/comp/pretty/ppaux.rs
浏览文件 @
6720ea76
...
@@ -135,9 +135,9 @@ fn mt_to_str(&ctxt cx, &mt m) -> str {
...
@@ -135,9 +135,9 @@ fn mt_to_str(&ctxt cx, &mt m) -> str {
ast
::
return
,
[]);
ast
::
return
,
[]);
}
}
case
(
ty_obj
(
?
meths
))
{
case
(
ty_obj
(
?
meths
))
{
auto
f
=
bind
method_to_str
(
cx
,
_
)
;
auto
strs
=
[]
;
auto
m
=
vec
::
map
[
method
,
str
](
f
,
meths
);
for
(
method
m
in
meths
)
{
strs
+=
[
method_to_str
(
cx
,
m
)];
}
s
+=
"obj {
\n\t
"
+
str
::
connect
(
m
,
"
\n\t
"
)
+
"
\n
}"
;
s
+=
"obj {
\n\t
"
+
str
::
connect
(
strs
,
"
\n\t
"
)
+
"
\n
}"
;
}
}
case
(
ty_res
(
?
id
,
_
,
_
))
{
case
(
ty_res
(
?
id
,
_
,
_
))
{
s
+=
"<resource#"
+
istr
(
id
._0
)
+
":"
+
istr
(
id
._1
)
+
">"
;
s
+=
"<resource#"
+
istr
(
id
._0
)
+
":"
+
istr
(
id
._1
)
+
">"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录