Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4b06dc57
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,发现更多精彩内容 >>
提交
4b06dc57
编写于
2月 01, 2011
作者:
R
Rafael Ávila de Espíndola
提交者:
Graydon Hoare
2月 01, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add very minimal support for native modules. For now they must be empty.
上级
b3689e7c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
64 addition
and
2 deletion
+64
-2
src/Makefile
src/Makefile
+1
-0
src/comp/front/ast.rs
src/comp/front/ast.rs
+6
-0
src/comp/front/parser.rs
src/comp/front/parser.rs
+19
-0
src/comp/middle/fold.rs
src/comp/middle/fold.rs
+29
-2
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+4
-0
src/test/run-pass/native2.rs
src/test/run-pass/native2.rs
+5
-0
未找到文件。
src/Makefile
浏览文件 @
4b06dc57
...
...
@@ -476,6 +476,7 @@ TEST_XFAILS_RUSTC := $(filter-out \
linear-for-loop.rs
\
multiline-comment.rs
\
mutual-recursion-group.rs
\
native2.rs
\
obj-drop.rs
\
obj-recursion.rs
\
obj-with-vec.rs
\
...
...
src/comp/front/ast.rs
浏览文件 @
4b06dc57
...
...
@@ -227,6 +227,8 @@
vec
[
@
item
]
items
,
mod_index
index
);
type
native_mod
=
rec
(
str
native_name
);
type
variant_arg
=
rec
(
@
ty
ty
,
def_id
id
);
type
variant
=
rec
(
str
name
,
vec
[
variant_arg
]
args
,
def_id
id
,
ann
ann
);
...
...
@@ -241,6 +243,7 @@
item_const
(
ident
,
@
ty
,
@
expr
,
def_id
,
ann
);
item_fn
(
ident
,
_
fn
,
vec
[
ty_param
],
def_id
,
ann
);
item_mod
(
ident
,
_
mod
,
def_id
);
item_native_mod
(
ident
,
native_mod
,
def_id
);
item_ty
(
ident
,
@
ty
,
vec
[
ty_param
],
def_id
,
ann
);
item_tag
(
ident
,
vec
[
variant
],
vec
[
ty_param
],
def_id
);
item_obj
(
ident
,
_
obj
,
vec
[
ty_param
],
def_id
,
ann
);
...
...
@@ -268,6 +271,9 @@ fn index_item(mod_index index, @item it) {
case
(
ast
.item_mod
(
?
id
,
_
,
_
))
{
index
.insert
(
id
,
ast
.mie_item
(
it
));
}
case
(
ast
.item_native_mod
(
?
id
,
_
,
_
))
{
index
.insert
(
id
,
ast
.mie_item
(
it
));
}
case
(
ast
.item_ty
(
?
id
,
_
,
_
,
_
,
_
))
{
index
.insert
(
id
,
ast
.mie_item
(
it
));
}
...
...
src/comp/front/parser.rs
浏览文件 @
4b06dc57
...
...
@@ -1577,6 +1577,20 @@ fn stmt_ends_with_semi(@ast.stmt stmt) -> bool {
ret
@
spanned
(
lo
,
hi
,
item
);
}
impure
fn
parse_item_native_mod
(
parser
p
)
->
@
ast
.item
{
auto
lo
=
p
.get_span
();
expect
(
p
,
token
.NATIVE
);
auto
native_name
=
parse_str_lit
(
p
);
expect
(
p
,
token
.MOD
);
auto
id
=
parse_ident
(
p
);
expect
(
p
,
token
.LBRACE
);
auto
m
=
rec
(
native_name
=
native_name
);
auto
hi
=
p
.get_span
();
expect
(
p
,
token
.RBRACE
);
auto
item
=
ast
.item_native_mod
(
id
,
m
,
p
.next_def_id
());
ret
@
spanned
(
lo
,
hi
,
item
);
}
impure
fn
parse_item_type
(
parser
p
)
->
@
ast
.item
{
auto
lo
=
p
.get_span
();
expect
(
p
,
token
.TYPE
);
...
...
@@ -1717,6 +1731,11 @@ fn peeking_at_item(parser p) -> bool {
check
(
lyr
==
ast
.layer_value
);
ret
parse_item_mod
(
p
);
}
case
(
token
.NATIVE
)
{
check
(
eff
==
ast
.eff_pure
);
check
(
lyr
==
ast
.layer_value
);
ret
parse_item_native_mod
(
p
);
}
case
(
token
.TYPE
)
{
check
(
eff
==
ast
.eff_pure
);
ret
parse_item_type
(
p
);
...
...
src/comp/middle/fold.rs
浏览文件 @
4b06dc57
...
...
@@ -196,6 +196,9 @@
(
fn
(
&
ENV
e
,
&
span
sp
,
ident
ident
,
&
ast
._mod
m
,
def_id
id
)
->
@
item
)
fold_item_mod
,
(
fn
(
&
ENV
e
,
&
span
sp
,
ident
ident
,
&
ast
.native_mod
m
,
def_id
id
)
->
@
item
)
fold_item_native_mod
,
(
fn
(
&
ENV
e
,
&
span
sp
,
ident
ident
,
@
ty
t
,
vec
[
ast
.ty_param
]
ty_params
,
def_id
id
,
ann
a
)
->
@
item
)
fold_item_ty
,
...
...
@@ -229,6 +232,8 @@
(
fn
(
&
ENV
e
,
&
ast
._mod
m
)
->
ast
._mod
)
fold_mod
,
(
fn
(
&
ENV
e
,
&
ast
.native_mod
m
)
->
ast
.native_mod
)
fold_native_mod
,
(
fn
(
&
ENV
e
,
&
span
sp
,
&
ast
._mod
m
)
->
@
ast
.crate
)
fold_crate
,
...
...
@@ -780,6 +785,11 @@ fn fold_item[ENV](&ENV env, ast_fold[ENV] fld, @item i) -> @item {
ret
fld
.fold_item_mod
(
env_
,
i
.span
,
ident
,
mm_
,
id
);
}
case
(
ast
.item_native_mod
(
?
ident
,
?
mm
,
?
id
))
{
let
ast
.native_mod
mm_
=
fold_native_mod
[
ENV
](
env_
,
fld
,
mm
);
ret
fld
.fold_item_native_mod
(
env_
,
i
.span
,
ident
,
mm_
,
id
);
}
case
(
ast
.item_ty
(
?
ident
,
?
ty
,
?
params
,
?
id
,
?
ann
))
{
let
@
ast
.ty
ty_
=
fold_ty
[
ENV
](
env_
,
fld
,
ty
);
ret
fld
.fold_item_ty
(
env_
,
i
.span
,
ident
,
ty_
,
params
,
id
,
ann
);
...
...
@@ -810,7 +820,6 @@ fn fold_item[ENV](&ENV env, ast_fold[ENV] fld, @item i) -> @item {
fail
;
}
fn
fold_mod
[
ENV
](
&
ENV
e
,
ast_fold
[
ENV
]
fld
,
&
ast
._mod
m
)
->
ast
._mod
{
let
vec
[
@
view_item
]
view_items
=
vec
();
...
...
@@ -830,7 +839,12 @@ fn fold_mod[ENV](&ENV e, ast_fold[ENV] fld, &ast._mod m) -> ast._mod {
}
ret
fld
.fold_mod
(
e
,
rec
(
view_items
=
view_items
,
items
=
items
,
index
=
index
));
}
}
fn
fold_native_mod
[
ENV
](
&
ENV
e
,
ast_fold
[
ENV
]
fld
,
&
ast
.native_mod
m
)
->
ast
.native_mod
{
ret
fld
.fold_native_mod
(
e
,
rec
(
native_name
=
m
.native_name
));
}
fn
fold_crate
[
ENV
](
&
ENV
env
,
ast_fold
[
ENV
]
fld
,
@
ast
.crate
c
)
->
@
ast
.crate
{
let
ENV
env_
=
fld
.update_env_for_crate
(
env
,
c
);
...
...
@@ -1105,6 +1119,11 @@ fn identity_fold_item_mod[ENV](&ENV e, &span sp, ident i,
ret
@
respan
(
sp
,
ast
.item_mod
(
i
,
m
,
id
));
}
fn
identity_fold_item_native_mod
[
ENV
](
&
ENV
e
,
&
span
sp
,
ident
i
,
&
ast
.native_mod
m
,
def_id
id
)
->
@
item
{
ret
@
respan
(
sp
,
ast
.item_native_mod
(
i
,
m
,
id
));
}
fn
identity_fold_item_ty
[
ENV
](
&
ENV
e
,
&
span
sp
,
ident
i
,
@
ty
t
,
vec
[
ast
.ty_param
]
ty_params
,
def_id
id
,
ann
a
)
->
@
item
{
...
...
@@ -1159,6 +1178,11 @@ fn identity_fold_mod[ENV](&ENV e, &ast._mod m) -> ast._mod {
ret
m
;
}
fn
identity_fold_native_mod
[
ENV
](
&
ENV
e
,
&
ast
.native_mod
m
)
->
ast
.native_mod
{
ret
m
;
}
fn
identity_fold_crate
[
ENV
](
&
ENV
e
,
&
span
sp
,
&
ast
._mod
m
)
->
@
ast
.crate
{
ret
@
respan
(
sp
,
rec
(
module
=
m
));
}
...
...
@@ -1281,6 +1305,8 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
fold_item_const
=
bind
identity_fold_item_const
[
ENV
](
_
,
_
,
_
,
_
,
_
,
_
,
_
),
fold_item_fn
=
bind
identity_fold_item_fn
[
ENV
](
_
,
_
,
_
,
_
,
_
,
_
,
_
),
fold_item_mod
=
bind
identity_fold_item_mod
[
ENV
](
_
,
_
,
_
,
_
,
_
),
fold_item_native_mod
=
bind
identity_fold_item_native_mod
[
ENV
](
_
,
_
,
_
,
_
,
_
),
fold_item_ty
=
bind
identity_fold_item_ty
[
ENV
](
_
,
_
,
_
,
_
,
_
,
_
,
_
),
fold_item_tag
=
bind
identity_fold_item_tag
[
ENV
](
_
,
_
,
_
,
_
,
_
,
_
),
fold_item_obj
=
bind
identity_fold_item_obj
[
ENV
](
_
,
_
,
_
,
_
,
_
,
_
,
_
),
...
...
@@ -1293,6 +1319,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
fold_block
=
bind
identity_fold_block
[
ENV
](
_
,
_
,
_
),
fold_fn
=
bind
identity_fold_fn
[
ENV
](
_
,
_
,
_
,
_
,
_
,
_
),
fold_mod
=
bind
identity_fold_mod
[
ENV
](
_
,
_
),
fold_native_mod
=
bind
identity_fold_native_mod
[
ENV
](
_
,
_
),
fold_crate
=
bind
identity_fold_crate
[
ENV
](
_
,
_
,
_
),
fold_obj
=
bind
identity_fold_obj
[
ENV
](
_
,
_
,
_
),
...
...
src/comp/middle/typeck.rs
浏览文件 @
4b06dc57
...
...
@@ -376,6 +376,7 @@ fn ty_of_item(@ty_item_table id_to_ty_item,
}
case
(
ast
.item_mod
(
_
,
_
,
_
))
{
fail
;
}
case
(
ast
.item_native_mod
(
_
,
_
,
_
))
{
fail
;
}
}
}
...
...
@@ -455,6 +456,9 @@ fn convert(&@env e, @ast.item i) -> @env {
case
(
ast
.item_mod
(
_
,
_
,
_
))
{
// ignore item_mod, it has no type.
}
case
(
ast
.item_native_mod
(
_
,
_
,
_
))
{
// ignore item_native_mod, it has no type.
}
case
(
_
)
{
// This call populates the ty_table with the converted type of
// the item in passing; we don't need to do anything else.
...
...
src/test/run-pass/native2.rs
0 → 100644
浏览文件 @
4b06dc57
native
"rust"
mod
rustrt
{
}
fn
main
(
vec
[
str
]
args
)
{
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录