Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
b079e1ad
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,发现更多精彩内容 >>
提交
b079e1ad
编写于
8月 05, 2011
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Parse "inline". Also write it into metadata.
上级
c6bb04ab
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
13 deletion
+33
-13
src/comp/metadata/common.rs
src/comp/metadata/common.rs
+2
-0
src/comp/metadata/encoder.rs
src/comp/metadata/encoder.rs
+11
-0
src/comp/syntax/parse/parser.rs
src/comp/syntax/parse/parser.rs
+20
-13
未找到文件。
src/comp/metadata/common.rs
浏览文件 @
b079e1ad
...
...
@@ -62,6 +62,8 @@
// A single crate dependency
const
tag_crate_dep
:
uint
=
0x26u
;
const
tag_items_data_item_inlineness
:
uint
=
0x27u
;
// djb's cdb hashes.
fn
hash_node_id
(
node_id
:
&
int
)
->
uint
{
ret
177573u
^
(
node_id
as
uint
);
}
...
...
src/comp/metadata/encoder.rs
浏览文件 @
b079e1ad
...
...
@@ -166,6 +166,12 @@ fn encode_family(ebml_w: &ebmlivec::writer, c: u8) {
ebmlivec
::
end_tag
(
ebml_w
);
}
fn
encode_inlineness
(
ebml_w
:
&
ebmlivec
::
writer
,
c
:
u8
)
{
ebmlivec
::
start_tag
(
ebml_w
,
tag_items_data_item_inlineness
);
ebml_w
.writer
.write
(
~
[
c
]);
ebmlivec
::
end_tag
(
ebml_w
);
}
fn
def_to_str
(
did
:
&
def_id
)
->
str
{
ret
#
fmt
(
"%d:%d"
,
did
.crate
,
did
.node
);
}
fn
encode_type_param_kinds
(
ebml_w
:
&
ebmlivec
::
writer
,
tps
:
&
ty_param
[])
{
...
...
@@ -256,6 +262,11 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: &ebmlivec::writer,
encode_family
(
ebml_w
,
alt
fd
.decl.purity
{
pure_fn
.
{
'p'
}
impure_fn
.
{
'f'
}
}
as
u8
);
encode_inlineness
(
ebml_w
,
alt
fd
.decl.il
{
il_normal
.
{
'n'
}
il_inline
.
{
'i'
}
}
as
u8
);
encode_type_param_kinds
(
ebml_w
,
tps
);
encode_type
(
ecx
,
ebml_w
,
node_id_to_monotype
(
ecx
.ccx.tcx
,
item
.id
));
encode_symbol
(
ecx
,
ebml_w
,
item
.id
);
...
...
src/comp/syntax/parse/parser.rs
浏览文件 @
b079e1ad
...
...
@@ -1285,7 +1285,7 @@ fn parse_if_expr(p: &parser) -> @ast::expr {
fn
parse_fn_expr
(
p
:
&
parser
,
proto
:
ast
::
proto
)
->
@
ast
::
expr
{
let
lo
=
p
.get_last_lo_pos
();
let
decl
=
parse_fn_decl
(
p
,
ast
::
impure_fn
);
let
decl
=
parse_fn_decl
(
p
,
ast
::
impure_fn
,
ast
::
il_normal
);
let
body
=
parse_block
(
p
);
let
_
fn
=
{
decl
:
decl
,
proto
:
proto
,
body
:
body
};
ret
mk_expr
(
p
,
lo
,
body
.span.hi
,
ast
::
expr_fn
(
_
fn
));
...
...
@@ -1706,7 +1706,8 @@ fn parse_ty_params(p: &parser) -> ast::ty_param[] {
ret
ty_params
;
}
fn
parse_fn_decl
(
p
:
&
parser
,
purity
:
ast
::
purity
)
->
ast
::
fn_decl
{
fn
parse_fn_decl
(
p
:
&
parser
,
purity
:
ast
::
purity
,
il
:
ast
::
inlineness
)
->
ast
::
fn_decl
{
let
inputs
:
ast
::
spanned
[
ast
::
arg
[]]
=
parse_seq
(
token
::
LPAREN
,
token
::
RPAREN
,
some
(
token
::
COMMA
),
parse_arg
,
p
);
...
...
@@ -1730,7 +1731,7 @@ fn parse_fn_decl(p: &parser, purity: ast::purity) -> ast::fn_decl {
ret
{
inputs
:
inputs
.node
,
output
:
t
,
purity
:
purity
,
il
:
ast
::
il_norma
l
,
il
:
i
l
,
cf
:
ast
::
return
,
constraints
:
constrs
};
}
...
...
@@ -1738,15 +1739,16 @@ fn parse_fn_decl(p: &parser, purity: ast::purity) -> ast::fn_decl {
ret
{
inputs
:
inputs
.node
,
output
:
@
spanned
(
p
.get_lo_pos
(),
p
.get_hi_pos
(),
ast
::
ty_bot
),
purity
:
purity
,
il
:
ast
::
il_norma
l
,
il
:
i
l
,
cf
:
ast
::
noreturn
,
constraints
:
constrs
};
}
}
}
fn
parse_fn
(
p
:
&
parser
,
proto
:
ast
::
proto
,
purity
:
ast
::
purity
)
->
ast
::
_
fn
{
let
decl
=
parse_fn_decl
(
p
,
purity
);
fn
parse_fn
(
p
:
&
parser
,
proto
:
ast
::
proto
,
purity
:
ast
::
purity
,
il
:
ast
::
inlineness
)
->
ast
::
_
fn
{
let
decl
=
parse_fn_decl
(
p
,
purity
,
il
);
let
body
=
parse_block
(
p
);
ret
{
decl
:
decl
,
proto
:
proto
,
body
:
body
};
}
...
...
@@ -1767,10 +1769,11 @@ fn mk_item(p: &parser, lo: uint, hi: uint, ident: &ast::ident,
}
fn
parse_item_fn_or_iter
(
p
:
&
parser
,
purity
:
ast
::
purity
,
proto
:
ast
::
proto
,
attrs
:
&
ast
::
attribute
[])
->
@
ast
::
item
{
attrs
:
&
ast
::
attribute
[],
il
:
ast
::
inlineness
)
->
@
ast
::
item
{
let
lo
=
p
.get_last_lo_pos
();
let
t
=
parse_fn_header
(
p
);
let
f
=
parse_fn
(
p
,
proto
,
purity
);
let
f
=
parse_fn
(
p
,
proto
,
purity
,
il
);
ret
mk_item
(
p
,
lo
,
f
.body.span.hi
,
t
.ident
,
ast
::
item_fn
(
f
,
t
.tps
),
attrs
);
}
...
...
@@ -1797,7 +1800,7 @@ fn parse_method(p: &parser) -> @ast::method {
let
lo
=
p
.get_lo_pos
();
let
proto
=
parse_proto
(
p
);
let
ident
=
parse_value_ident
(
p
);
let
f
=
parse_fn
(
p
,
proto
,
ast
::
impure_fn
);
let
f
=
parse_fn
(
p
,
proto
,
ast
::
impure_fn
,
ast
::
il_normal
);
let
meth
=
{
ident
:
ident
,
meth
:
f
,
id
:
p
.get_id
()};
ret
@
spanned
(
lo
,
f
.body.span.hi
,
meth
);
}
...
...
@@ -1910,7 +1913,7 @@ fn parse_item_native_fn(p: &parser, attrs: &ast::attribute[]) ->
@
ast
::
native_item
{
let
lo
=
p
.get_last_lo_pos
();
let
t
=
parse_fn_header
(
p
);
let
decl
=
parse_fn_decl
(
p
,
ast
::
impure_fn
);
let
decl
=
parse_fn_decl
(
p
,
ast
::
impure_fn
,
ast
::
il_normal
);
let
link_name
=
none
;
if
p
.peek
()
==
token
::
EQ
{
p
.bump
();
link_name
=
some
(
parse_str
(
p
));
}
let
hi
=
p
.get_hi_pos
();
...
...
@@ -2071,16 +2074,20 @@ fn parse_auth(p: &parser) -> ast::_auth {
fn
parse_item
(
p
:
&
parser
,
attrs
:
&
ast
::
attribute
[])
->
option
::
t
[
@
ast
::
item
]
{
if
eat_word
(
p
,
"const"
)
{
ret
some
(
parse_item_const
(
p
,
attrs
));
}
else
if
(
eat_word
(
p
,
"inline"
))
{
expect_word
(
p
,
"fn"
);
ret
some
(
parse_item_fn_or_iter
(
p
,
ast
::
impure_fn
,
ast
::
proto_fn
,
attrs
,
ast
::
il_inline
));
}
else
if
(
is_word
(
p
,
"fn"
)
&&
p
.look_ahead
(
1u
)
!=
token
::
LPAREN
)
{
p
.bump
();
ret
some
(
parse_item_fn_or_iter
(
p
,
ast
::
impure_fn
,
ast
::
proto_fn
,
attrs
));
attrs
,
ast
::
il_normal
));
}
else
if
(
eat_word
(
p
,
"pred"
))
{
ret
some
(
parse_item_fn_or_iter
(
p
,
ast
::
pure_fn
,
ast
::
proto_fn
,
attrs
));
attrs
,
ast
::
il_normal
));
}
else
if
(
eat_word
(
p
,
"iter"
))
{
ret
some
(
parse_item_fn_or_iter
(
p
,
ast
::
impure_fn
,
ast
::
proto_iter
,
attrs
));
attrs
,
ast
::
il_normal
));
}
else
if
(
eat_word
(
p
,
"mod"
))
{
ret
some
(
parse_item_mod
(
p
,
attrs
));
}
else
if
(
eat_word
(
p
,
"native"
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录