Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
075a094c
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,发现更多精彩内容 >>
提交
075a094c
编写于
7月 21, 2011
作者:
L
Lindsey Kuper
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Now with more type inference.
上级
451e438e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
43 deletion
+42
-43
src/comp/middle/ty.rs
src/comp/middle/ty.rs
+42
-43
未找到文件。
src/comp/middle/ty.rs
浏览文件 @
075a094c
import
std
::
int
;
import
std
::
ivec
;
import
std
::
str
;
...
...
@@ -360,27 +359,27 @@ fn method_ty_to_fn_ty(&ctxt cx, method m) -> t {
@
smallintmap
::
smallintmap
[
ty
::
ty_param_substs_opt_and_ty
];
fn
populate_type_store
(
&
ctxt
cx
)
{
intern
(
cx
,
ty_nil
,
none
[
str
]
);
intern
(
cx
,
ty_bool
,
none
[
str
]
);
intern
(
cx
,
ty_int
,
none
[
str
]
);
intern
(
cx
,
ty_float
,
none
[
str
]
);
intern
(
cx
,
ty_uint
,
none
[
str
]
);
intern
(
cx
,
ty_machine
(
ast
::
ty_i8
),
none
[
str
]
);
intern
(
cx
,
ty_machine
(
ast
::
ty_i16
),
none
[
str
]
);
intern
(
cx
,
ty_machine
(
ast
::
ty_i32
),
none
[
str
]
);
intern
(
cx
,
ty_machine
(
ast
::
ty_i64
),
none
[
str
]
);
intern
(
cx
,
ty_machine
(
ast
::
ty_u8
),
none
[
str
]
);
intern
(
cx
,
ty_machine
(
ast
::
ty_u16
),
none
[
str
]
);
intern
(
cx
,
ty_machine
(
ast
::
ty_u32
),
none
[
str
]
);
intern
(
cx
,
ty_machine
(
ast
::
ty_u64
),
none
[
str
]
);
intern
(
cx
,
ty_machine
(
ast
::
ty_f32
),
none
[
str
]
);
intern
(
cx
,
ty_machine
(
ast
::
ty_f64
),
none
[
str
]
);
intern
(
cx
,
ty_char
,
none
[
str
]
);
intern
(
cx
,
ty_str
,
none
[
str
]
);
intern
(
cx
,
ty_istr
,
none
[
str
]
);
intern
(
cx
,
ty_task
,
none
[
str
]
);
intern
(
cx
,
ty_type
,
none
[
str
]
);
intern
(
cx
,
ty_bot
,
none
[
str
]
);
intern
(
cx
,
ty_nil
,
none
);
intern
(
cx
,
ty_bool
,
none
);
intern
(
cx
,
ty_int
,
none
);
intern
(
cx
,
ty_float
,
none
);
intern
(
cx
,
ty_uint
,
none
);
intern
(
cx
,
ty_machine
(
ast
::
ty_i8
),
none
);
intern
(
cx
,
ty_machine
(
ast
::
ty_i16
),
none
);
intern
(
cx
,
ty_machine
(
ast
::
ty_i32
),
none
);
intern
(
cx
,
ty_machine
(
ast
::
ty_i64
),
none
);
intern
(
cx
,
ty_machine
(
ast
::
ty_u8
),
none
);
intern
(
cx
,
ty_machine
(
ast
::
ty_u16
),
none
);
intern
(
cx
,
ty_machine
(
ast
::
ty_u32
),
none
);
intern
(
cx
,
ty_machine
(
ast
::
ty_u64
),
none
);
intern
(
cx
,
ty_machine
(
ast
::
ty_f32
),
none
);
intern
(
cx
,
ty_machine
(
ast
::
ty_f64
),
none
);
intern
(
cx
,
ty_char
,
none
);
intern
(
cx
,
ty_str
,
none
);
intern
(
cx
,
ty_istr
,
none
);
intern
(
cx
,
ty_task
,
none
);
intern
(
cx
,
ty_type
,
none
);
intern
(
cx
,
ty_bot
,
none
);
assert
(
ivec
::
len
(
cx
.ts.vect
)
==
idx_first_others
);
}
...
...
@@ -530,7 +529,7 @@ fn gen_ty_full(&ctxt cx, &sty st, &option::t[str] cname) -> t {
// These are private constructors to this module. External users should always
// use the mk_foo() functions below.
fn
gen_ty
(
&
ctxt
cx
,
&
sty
st
)
->
t
{
ret
gen_ty_full
(
cx
,
st
,
none
[
str
]
);
}
fn
gen_ty
(
&
ctxt
cx
,
&
sty
st
)
->
t
{
ret
gen_ty_full
(
cx
,
st
,
none
);
}
fn
mk_nil
(
&
ctxt
cx
)
->
t
{
ret
idx_nil
;
}
...
...
@@ -859,7 +858,7 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
// Type utilities
fn
rename
(
&
ctxt
cx
,
t
typ
,
str
new_cname
)
->
t
{
ret
gen_ty_full
(
cx
,
struct
(
cx
,
typ
),
some
[
str
]
(
new_cname
));
ret
gen_ty_full
(
cx
,
struct
(
cx
,
typ
),
some
(
new_cname
));
}
fn
strip_cname
(
&
ctxt
cx
,
t
typ
)
->
t
{
...
...
@@ -1270,10 +1269,10 @@ fn type_owns_heap_mem(&ctxt cx, &t ty) -> bool {
fn
type_param
(
&
ctxt
cx
,
&
t
ty
)
->
option
::
t
[
uint
]
{
alt
(
struct
(
cx
,
ty
))
{
case
(
ty_param
(
?
id
))
{
ret
some
[
uint
]
(
id
);
}
case
(
ty_param
(
?
id
))
{
ret
some
(
id
);
}
case
(
_
)
{
/* fall through */
}
}
ret
none
[
uint
]
;
ret
none
;
}
fn
type_autoderef
(
&
ctxt
cx
,
&
ty
::
t
t
)
->
ty
::
t
{
...
...
@@ -1737,7 +1736,7 @@ fn eq_raw_ty(&@raw_t a, &@raw_t b) -> bool {
alt
(
a
.cname
)
{
case
(
none
)
{
alt
(
b
.cname
)
{
case
(
none
[
str
])
{
/* ok */
}
case
(
none
)
{
/* ok */
}
case
(
_
)
{
ret
false
;
}
}
}
...
...
@@ -2177,10 +2176,10 @@ fn unify_constr(&t base_t, @type_constr expected,
// Unifies two mutability flags.
fn
unify_mut
(
ast
::
mutability
expected
,
ast
::
mutability
actual
)
->
option
::
t
[
ast
::
mutability
]
{
if
(
expected
==
actual
)
{
ret
some
[
ast
::
mutability
]
(
expected
);
}
if
(
expected
==
ast
::
maybe_mut
)
{
ret
some
[
ast
::
mutability
]
(
actual
);
}
if
(
actual
==
ast
::
maybe_mut
)
{
ret
some
[
ast
::
mutability
]
(
expected
);
}
ret
none
[
ast
::
mutability
]
;
if
(
expected
==
actual
)
{
ret
some
(
expected
);
}
if
(
expected
==
ast
::
maybe_mut
)
{
ret
some
(
actual
);
}
if
(
actual
==
ast
::
maybe_mut
)
{
ret
some
(
expected
);
}
ret
none
;
}
tag
fn_common_res
{
fn_common_res_err
(
result
);
...
...
@@ -2332,8 +2331,8 @@ fn resolve_type_structure(&ty_ctxt tcx, &@var_bindings vb, t typ) ->
}
auto
root_id
=
ufindivec
::
find
(
vb
.sets
,
vid
as
uint
);
alt
(
smallintmap
::
find
[
t
](
vb
.types
,
root_id
))
{
case
(
none
[
t
]
)
{
ret
fix_err
(
vid
);
}
case
(
some
[
t
]
(
?
rt
))
{
ret
fix_ok
(
rt
);
}
case
(
none
)
{
ret
fix_err
(
vid
);
}
case
(
some
(
?
rt
))
{
ret
fix_ok
(
rt
);
}
}
}
case
(
_
)
{
ret
fix_ok
(
typ
);
}
...
...
@@ -2778,8 +2777,8 @@ fn dump_var_bindings(ty_ctxt tcx, @var_bindings vb) {
}
auto
typespec
;
alt
(
smallintmap
::
find
[
t
](
vb
.types
,
i
))
{
case
(
none
[
t
]
)
{
typespec
=
""
;
}
case
(
some
[
t
]
(
?
typ
))
{
case
(
none
)
{
typespec
=
""
;
}
case
(
some
(
?
typ
))
{
typespec
=
" ="
+
ty_to_str
(
tcx
,
typ
);
}
}
...
...
@@ -2793,16 +2792,16 @@ fn fixup_vars(ty_ctxt tcx, @var_bindings vb, t typ) -> fixup_result {
fn
subst_vars
(
ty_ctxt
tcx
,
@
var_bindings
vb
,
@
mutable
option
::
t
[
int
]
unresolved
,
int
vid
)
->
t
{
if
(
vid
as
uint
>=
ufindivec
::
set_count
(
vb
.sets
))
{
*
unresolved
=
some
[
int
]
(
vid
);
*
unresolved
=
some
(
vid
);
ret
ty
::
mk_var
(
tcx
,
vid
);
}
auto
root_id
=
ufindivec
::
find
(
vb
.sets
,
vid
as
uint
);
alt
(
smallintmap
::
find
[
t
](
vb
.types
,
root_id
))
{
case
(
none
[
t
]
)
{
*
unresolved
=
some
[
int
]
(
vid
);
case
(
none
)
{
*
unresolved
=
some
(
vid
);
ret
ty
::
mk_var
(
tcx
,
vid
);
}
case
(
some
[
t
]
(
?
rt
))
{
case
(
some
(
?
rt
))
{
ret
fold_ty
(
tcx
,
fm_var
(
bind
subst_vars
(
tcx
,
vb
,
unresolved
,
_
)),
rt
);
...
...
@@ -2815,8 +2814,8 @@ fn subst_vars(ty_ctxt tcx, @var_bindings vb,
typ
);
auto
ur
=
*
unresolved
;
alt
(
ur
)
{
case
(
none
[
int
]
)
{
ret
fix_ok
(
rty
);
}
case
(
some
[
int
]
(
?
var_id
))
{
ret
fix_err
(
var_id
);
}
case
(
none
)
{
ret
fix_ok
(
rty
);
}
case
(
some
(
?
var_id
))
{
ret
fix_err
(
var_id
);
}
}
}
fn
resolve_type_var
(
&
ty_ctxt
tcx
,
&@
var_bindings
vb
,
int
vid
)
->
...
...
@@ -2826,8 +2825,8 @@ fn resolve_type_var(&ty_ctxt tcx, &@var_bindings vb, int vid) ->
}
auto
root_id
=
ufindivec
::
find
(
vb
.sets
,
vid
as
uint
);
alt
(
smallintmap
::
find
[
t
](
vb
.types
,
root_id
))
{
case
(
none
[
t
]
)
{
ret
fix_err
(
vid
);
}
case
(
some
[
t
]
(
?
rt
))
{
ret
fixup_vars
(
tcx
,
vb
,
rt
);
}
case
(
none
)
{
ret
fix_err
(
vid
);
}
case
(
some
(
?
rt
))
{
ret
fixup_vars
(
tcx
,
vb
,
rt
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录