Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d43f60e5
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,发现更多精彩内容 >>
提交
d43f60e5
编写于
6月 01, 2011
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rustc: Fold --pretty and --typed-pretty into a single option with an optional argument
上级
8c3809af
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
39 addition
and
17 deletion
+39
-17
src/comp/driver/rustc.rs
src/comp/driver/rustc.rs
+39
-17
未找到文件。
src/comp/driver/rustc.rs
浏览文件 @
d43f60e5
...
...
@@ -29,10 +29,16 @@
import
std
::
getopts
::
optopt
;
import
std
::
getopts
::
optmulti
;
import
std
::
getopts
::
optflag
;
import
std
::
getopts
::
optflagopt
;
import
std
::
getopts
::
opt_present
;
import
back
::
link
::
output_type
;
tag
pp_mode
{
ppm_normal
;
ppm_typed
;
}
fn
default_environment
(
session
::
session
sess
,
str
argv0
,
str
input
)
->
eval
::
env
{
...
...
@@ -112,19 +118,20 @@ fn compile_input(session::session sess,
}
fn
pretty_print_input
(
session
::
session
sess
,
eval
::
env
env
,
str
input
,
bool
typed
)
{
pp_mode
ppm
)
{
auto
def
=
tup
(
ast
::
local_crate
,
0
);
auto
p
=
front
::
parser
::
new_parser
(
sess
,
env
,
def
,
input
,
0u
,
0u
);
auto
crate
=
front
::
parser
::
parse_crate_from_source_file
(
p
);
auto
mode
;
if
(
typed
)
{
alt
(
ppm
)
{
case
(
ppm_typed
)
{
auto
def_map
=
resolve
::
resolve_crate
(
sess
,
crate
);
auto
ty_cx
=
ty
::
mk_ctxt
(
sess
,
def_map
);
typeck
::
check_crate
(
ty_cx
,
crate
);
mode
=
pprust
::
mo_typed
(
ty_cx
);
}
else
{
mode
=
pprust
::
mo_untyped
;
}
case
(
ppm_normal
)
{
mode
=
pprust
::
mo_untyped
;
}
}
pprust
::
print_file
(
sess
,
crate
.node.module
,
input
,
std
::
io
::
stdout
(),
...
...
@@ -150,8 +157,7 @@ fn usage(str argv0) {
-o <filename> write output to <filename>
--glue generate glue.bc file
--shared compile a shared-library crate
--pretty pretty-print the input instead of compiling
--typed-pretty pretty-print the input with types instead of compiling
--pretty [type] pretty-print the input instead of compiling
--ls list the symbols defined by a crate file
-L <path> add a directory to the library search path
--noverify suppress LLVM verification step (slight speedup)
...
...
@@ -304,12 +310,20 @@ fn build_session(@session::options sopts) -> session::session {
ret
sess
;
}
fn
parse_pretty
(
session
::
session
sess
,
&
str
name
)
->
pp_mode
{
if
(
str
::
eq
(
name
,
"normal"
))
{
ret
ppm_normal
;
}
else
if
(
str
::
eq
(
name
,
"typed"
))
{
ret
ppm_typed
;
}
else
{
sess
.err
(
"argument to `pretty` must be either `normal` or `typed`"
);
}
}
fn
main
(
vec
[
str
]
args
)
{
auto
opts
=
[
optflag
(
"h"
),
optflag
(
"help"
),
optflag
(
"v"
),
optflag
(
"version"
),
optflag
(
"glue"
),
optflag
(
"emit-llvm"
),
optflag
(
"pretty"
),
optflag
(
"typed-
pretty"
),
optflag
opt
(
"
pretty"
),
optflag
(
"ls"
),
optflag
(
"parse-only"
),
optflag
(
"O"
),
optopt
(
"OptLevel"
),
optflag
(
"shared"
),
optmulti
(
"L"
),
...
...
@@ -365,13 +379,19 @@ fn main(vec[str] args) {
auto
ifile
=
match
.free
.
(
0
);
let
str
saved_out_filename
=
""
;
auto
env
=
default_environment
(
sess
,
binary
,
ifile
);
auto
pretty
=
opt
_present
(
match
,
"pretty"
);
auto
typed_pretty
=
opt_present
(
match
,
"typed-pretty"
);
auto
pretty
=
opt
ion
::
map
[
str
,
pp_mode
](
bind
parse_pretty
(
sess
,
_
),
getopts
::
opt_default
(
match
,
"pretty"
,
"normal"
)
);
auto
ls
=
opt_present
(
match
,
"ls"
);
if
(
pretty
||
typed_pretty
)
{
pretty_print_input
(
sess
,
env
,
ifile
,
typed_pretty
);
alt
(
pretty
)
{
case
(
some
[
pp_mode
](
?
ppm
))
{
pretty_print_input
(
sess
,
env
,
ifile
,
ppm
);
ret
;
}
else
if
(
ls
)
{
}
case
(
none
[
pp_mode
])
{
/* continue */
}
}
if
(
ls
)
{
front
::
creader
::
list_file_metadata
(
ifile
,
std
::
io
::
stdout
());
ret
;
}
else
{
...
...
@@ -401,6 +421,8 @@ fn main(vec[str] args) {
// If the user wants an exe generated we need to invoke
// gcc to link the object file with some libs
//
// TODO: Factor this out of main.
if
(
sopts
.output_type
==
link
::
output_type_exe
)
{
//FIXME: Should we make the 'stage3's variable here?
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录