Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
9fb08556
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,发现更多精彩内容 >>
提交
9fb08556
编写于
8月 27, 2011
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert rustc::syntax::ast_util to istrs. Issue #855
上级
cbad23a7
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
63 addition
and
60 deletion
+63
-60
src/comp/front/test.rs
src/comp/front/test.rs
+5
-4
src/comp/middle/alias.rs
src/comp/middle/alias.rs
+5
-3
src/comp/middle/resolve.rs
src/comp/middle/resolve.rs
+1
-1
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+4
-4
src/comp/syntax/ast_util.rs
src/comp/syntax/ast_util.rs
+39
-39
src/comp/syntax/parse/token.rs
src/comp/syntax/parse/token.rs
+2
-2
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+6
-6
src/comp/util/ppaux.rs
src/comp/util/ppaux.rs
+1
-1
未找到文件。
src/comp/front/test.rs
浏览文件 @
9fb08556
...
...
@@ -92,7 +92,8 @@ fn fold_item(cx: &test_ctxt, i: &@ast::item, fld: fold::ast_fold) ->
@
ast
::
item
{
cx
.path
+=
[
i
.ident
];
log
#
fmt
[
"current path: %s"
,
ast_util
::
path_name_i
(
cx
.path
)];
log
#
fmt
[
"current path: %s"
,
istr
::
to_estr
(
ast_util
::
path_name_i
(
cx
.path
))];
if
is_test_fn
(
i
)
{
log
"this is a test function"
;
...
...
@@ -248,11 +249,11 @@ fn mk_test_desc_vec(cx: &test_ctxt) -> @ast::expr {
fn
mk_test_desc_rec
(
cx
:
&
test_ctxt
,
test
:
test
)
->
@
ast
::
expr
{
let
path
=
test
.path
;
log
#
fmt
[
"encoding %s"
,
ast_util
::
path_name_i
(
path
)];
log
#
fmt
[
"encoding %s"
,
istr
::
to_estr
(
ast_util
::
path_name_i
(
path
))];
let
name_lit
:
ast
::
lit
=
nospan
(
ast
::
lit_str
(
istr
::
from_estr
(
ast_util
::
path_name_i
(
path
)),
ast
::
sk_rc
));
nospan
(
ast
::
lit_str
(
ast_util
::
path_name_i
(
path
),
ast
::
sk_rc
));
let
name_expr
:
ast
::
expr
=
{
id
:
cx
.next_node_id
(),
node
:
ast
::
expr_lit
(
@
name_lit
),
...
...
src/comp/middle/alias.rs
浏览文件 @
9fb08556
...
...
@@ -518,16 +518,18 @@ fn test_scope(cx: &ctx, sc: &scope, r: &restrict, p: &ast::path) {
let
msg
=
alt
prob
{
overwritten
(
sp
,
wpt
)
{
{
span
:
sp
,
msg
:
"overwriting "
+
ast_util
::
path_name
(
wpt
)}
{
span
:
sp
,
msg
:
"overwriting "
+
istr
::
to_estr
(
ast_util
::
path_name
(
wpt
))}
}
val_taken
(
sp
,
vpt
)
{
{
span
:
sp
,
msg
:
"taking the value of "
+
ast_util
::
path_name
(
vpt
)}
msg
:
"taking the value of "
+
istr
::
to_estr
(
ast_util
::
path_name
(
vpt
))}
}
};
cx
.tcx.sess
.span_err
(
msg
.span
,
msg
.msg
+
" will invalidate alias "
+
ast_util
::
path_name
(
p
)
+
istr
::
to_estr
(
ast_util
::
path_name
(
p
)
)
+
", which is still used"
);
}
}
...
...
src/comp/middle/resolve.rs
浏览文件 @
9fb08556
...
...
@@ -324,7 +324,7 @@ fn walk_pat(e: &@env, pat: &@ast::pat, sc: &scopes, v: &vt<scopes>) {
_
{
e
.sess
.span_err
(
p
.span
,
"not a tag variant: "
+
ast_util
::
path_name
(
p
));
istr
::
to_estr
(
ast_util
::
path_name
(
p
)
));
}
}
}
...
...
src/comp/middle/typeck.rs
浏览文件 @
9fb08556
...
...
@@ -1792,10 +1792,10 @@ fn check_binop_type_compat(fcx: &@fn_ctxt, span: span, ty: ty::t,
let
binopstr
=
ast_util
::
binop_to_str
(
binop
);
let
t_str
=
ty_to_str
(
fcx
.ccx.tcx
,
resolved_t
);
let
errmsg
=
"binary operation "
+
binopstr
+
" cannot be applied to type `"
+
istr
::
to_estr
(
t_str
)
+
"`"
;
fcx
.ccx.tcx.sess
.span_err
(
span
,
errmsg
);
~
"binary operation "
+
binopstr
+
~
" cannot be applied to type `"
+
t_str
+
~
"`"
;
fcx
.ccx.tcx.sess
.span_err
(
span
,
istr
::
to_estr
(
errmsg
)
);
}
}
...
...
src/comp/syntax/ast_util.rs
浏览文件 @
9fb08556
...
...
@@ -14,10 +14,10 @@ fn mk_sp(lo: uint, hi: uint) -> span {
// make this a const, once the compiler supports it
fn
dummy_sp
()
->
span
{
ret
mk_sp
(
0u
,
0u
);
}
fn
path_name
(
p
:
&
path
)
->
str
{
path_name_i
(
p
.node.idents
)
}
fn
path_name
(
p
:
&
path
)
->
i
str
{
path_name_i
(
p
.node.idents
)
}
fn
path_name_i
(
idents
:
&
[
ident
])
->
str
{
istr
::
to_estr
(
istr
::
connect
(
idents
,
~
"::"
)
)
fn
path_name_i
(
idents
:
&
[
ident
])
->
i
str
{
istr
::
connect
(
idents
,
~
"::"
)
}
fn
local_def
(
id
:
node_id
)
->
def_id
{
ret
{
crate
:
local_crate
,
node
:
id
};
}
...
...
@@ -83,27 +83,27 @@ fn pat_binding_ids(pat: &@pat) -> [node_id] {
ret
found
;
}
fn
binop_to_str
(
op
:
binop
)
->
str
{
fn
binop_to_str
(
op
:
binop
)
->
i
str
{
alt
op
{
add
.
{
ret
"+"
;
}
sub
.
{
ret
"-"
;
}
mul
.
{
ret
"*"
;
}
div
.
{
ret
"/"
;
}
rem
.
{
ret
"%"
;
}
and
.
{
ret
"&&"
;
}
or
.
{
ret
"||"
;
}
bitxor
.
{
ret
"^"
;
}
bitand
.
{
ret
"&"
;
}
bitor
.
{
ret
"|"
;
}
lsl
.
{
ret
"<<"
;
}
lsr
.
{
ret
">>"
;
}
asr
.
{
ret
">>>"
;
}
eq
.
{
ret
"=="
;
}
lt
.
{
ret
"<"
;
}
le
.
{
ret
"<="
;
}
ne
.
{
ret
"!="
;
}
ge
.
{
ret
">="
;
}
gt
.
{
ret
">"
;
}
add
.
{
ret
~
"+"
;
}
sub
.
{
ret
~
"-"
;
}
mul
.
{
ret
~
"*"
;
}
div
.
{
ret
~
"/"
;
}
rem
.
{
ret
~
"%"
;
}
and
.
{
ret
~
"&&"
;
}
or
.
{
ret
~
"||"
;
}
bitxor
.
{
ret
~
"^"
;
}
bitand
.
{
ret
~
"&"
;
}
bitor
.
{
ret
~
"|"
;
}
lsl
.
{
ret
~
"<<"
;
}
lsr
.
{
ret
~
">>"
;
}
asr
.
{
ret
~
">>>"
;
}
eq
.
{
ret
~
"=="
;
}
lt
.
{
ret
~
"<"
;
}
le
.
{
ret
~
"<="
;
}
ne
.
{
ret
~
"!="
;
}
ge
.
{
ret
~
">="
;
}
gt
.
{
ret
~
">"
;
}
}
}
...
...
@@ -111,12 +111,12 @@ fn binop_to_str(op: binop) -> str {
alt
b
{
and
.
{
true
}
or
.
{
true
}
_
{
false
}
}
}
fn
unop_to_str
(
op
:
unop
)
->
str
{
fn
unop_to_str
(
op
:
unop
)
->
i
str
{
alt
op
{
box
(
mt
)
{
if
mt
==
mut
{
ret
"@mutable "
;
}
ret
"@"
;
}
deref
.
{
ret
"*"
;
}
not
.
{
ret
"!"
;
}
neg
.
{
ret
"-"
;
}
box
(
mt
)
{
if
mt
==
mut
{
ret
~
"@mutable "
;
}
ret
~
"@"
;
}
deref
.
{
ret
~
"*"
;
}
not
.
{
ret
~
"!"
;
}
neg
.
{
ret
~
"-"
;
}
}
}
...
...
@@ -124,18 +124,18 @@ fn is_path(e: &@expr) -> bool {
ret
alt
e
.node
{
expr_path
(
_
)
{
true
}
_
{
false
}
};
}
fn
ty_mach_to_str
(
tm
:
ty_mach
)
->
str
{
fn
ty_mach_to_str
(
tm
:
ty_mach
)
->
i
str
{
alt
tm
{
ty_u8
.
{
ret
"u8"
;
}
ty_u16
.
{
ret
"u16"
;
}
ty_u32
.
{
ret
"u32"
;
}
ty_u64
.
{
ret
"u64"
;
}
ty_i8
.
{
ret
"i8"
;
}
ty_i16
.
{
ret
"i16"
;
}
ty_i32
.
{
ret
"i32"
;
}
ty_i64
.
{
ret
"i64"
;
}
ty_f32
.
{
ret
"f32"
;
}
ty_f64
.
{
ret
"f64"
;
}
ty_u8
.
{
ret
~
"u8"
;
}
ty_u16
.
{
ret
~
"u16"
;
}
ty_u32
.
{
ret
~
"u32"
;
}
ty_u64
.
{
ret
~
"u64"
;
}
ty_i8
.
{
ret
~
"i8"
;
}
ty_i16
.
{
ret
~
"i16"
;
}
ty_i32
.
{
ret
~
"i32"
;
}
ty_i64
.
{
ret
~
"i64"
;
}
ty_f32
.
{
ret
~
"f32"
;
}
ty_f64
.
{
ret
~
"f64"
;
}
}
}
...
...
src/comp/syntax/parse/token.rs
浏览文件 @
9fb08556
...
...
@@ -149,12 +149,12 @@ fn to_str(r: lexer::reader, t: token) -> istr {
}
LIT_UINT
(
u
)
{
ret
uint
::
to_str
(
u
,
10u
);
}
LIT_MACH_INT
(
tm
,
i
)
{
ret
int
::
to_str
(
i
,
10u
)
+
~
"_"
+
istr
::
from_estr
(
ty_mach_to_str
(
tm
)
);
ret
int
::
to_str
(
i
,
10u
)
+
~
"_"
+
ty_mach_to_str
(
tm
);
}
LIT_MACH_FLOAT
(
tm
,
s
)
{
ret
interner
::
get
::
<
istr
>
(
*
r
.get_interner
(),
s
)
+
~
"_"
+
istr
::
from_estr
(
ty_mach_to_str
(
tm
)
);
ty_mach_to_str
(
tm
);
}
LIT_FLOAT
(
s
)
{
ret
interner
::
get
::
<
istr
>
(
*
r
.get_interner
(),
s
);
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
9fb08556
...
...
@@ -276,7 +276,7 @@ fn print_type(s: &ps, ty: &@ast::ty) {
ast
::
ty_uint
.
{
word
(
s
.s
,
~
"uint"
);
}
ast
::
ty_float
.
{
word
(
s
.s
,
~
"float"
);
}
ast
::
ty_machine
(
tm
)
{
word
(
s
.s
,
istr
::
from_estr
(
ast_util
::
ty_mach_to_str
(
tm
)
));
word
(
s
.s
,
ast_util
::
ty_mach_to_str
(
tm
));
}
ast
::
ty_char
.
{
word
(
s
.s
,
~
"char"
);
}
ast
::
ty_str
.
{
word
(
s
.s
,
~
"str"
);
}
...
...
@@ -846,11 +846,11 @@ fn print_opt(s: &ps, expr: &option::t<@ast::expr>) {
let
prec
=
operator_prec
(
op
);
print_maybe_parens
(
s
,
lhs
,
prec
);
space
(
s
.s
);
word_space
(
s
,
istr
::
from_estr
(
ast_util
::
binop_to_str
(
op
)
));
word_space
(
s
,
ast_util
::
binop_to_str
(
op
));
print_maybe_parens
(
s
,
rhs
,
prec
+
1
);
}
ast
::
expr_unary
(
op
,
expr
)
{
word
(
s
.s
,
istr
::
from_estr
(
ast_util
::
unop_to_str
(
op
)
));
word
(
s
.s
,
ast_util
::
unop_to_str
(
op
));
print_maybe_parens
(
s
,
expr
,
parse
::
parser
::
unop_prec
);
}
ast
::
expr_lit
(
lit
)
{
print_literal
(
s
,
lit
);
}
...
...
@@ -982,7 +982,7 @@ fn print_opt(s: &ps, expr: &option::t<@ast::expr>) {
ast
::
expr_assign_op
(
op
,
lhs
,
rhs
)
{
print_expr
(
s
,
lhs
);
space
(
s
.s
);
word
(
s
.s
,
istr
::
from_estr
(
ast_util
::
binop_to_str
(
op
)
));
word
(
s
.s
,
ast_util
::
binop_to_str
(
op
));
word_space
(
s
,
~
"="
);
print_expr
(
s
,
rhs
);
}
...
...
@@ -1526,12 +1526,12 @@ fn print_literal(s: &ps, lit: &@ast::lit) {
ast
::
lit_float
(
fstr
)
{
word
(
s
.s
,
fstr
);
}
ast
::
lit_mach_int
(
mach
,
val
)
{
word
(
s
.s
,
int
::
str
(
val
as
int
));
word
(
s
.s
,
istr
::
from_estr
(
ast_util
::
ty_mach_to_str
(
mach
)
));
word
(
s
.s
,
ast_util
::
ty_mach_to_str
(
mach
));
}
ast
::
lit_mach_float
(
mach
,
val
)
{
// val is already a str
word
(
s
.s
,
val
);
word
(
s
.s
,
istr
::
from_estr
(
ast_util
::
ty_mach_to_str
(
mach
)
));
word
(
s
.s
,
ast_util
::
ty_mach_to_str
(
mach
));
}
ast
::
lit_nil
.
{
word
(
s
.s
,
~
"()"
);
}
ast
::
lit_bool
(
val
)
{
...
...
src/comp/util/ppaux.rs
浏览文件 @
9fb08556
...
...
@@ -114,7 +114,7 @@ fn mt_to_str(cx: &ctxt, m: &mt) -> istr {
ty_int
.
{
~
"int"
}
ty_float
.
{
~
"float"
}
ty_uint
.
{
~
"uint"
}
ty_machine
(
tm
)
{
istr
::
from_estr
(
ty_mach_to_str
(
tm
)
)
}
ty_machine
(
tm
)
{
ty_mach_to_str
(
tm
)
}
ty_char
.
{
~
"char"
}
ty_str
.
{
~
"str"
}
ty_istr
.
{
~
"istr"
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录