Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
e3b2205e
D
deno
项目概览
张重言
/
deno
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
deno
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e3b2205e
编写于
6月 07, 2019
作者:
K
Kitson Kelly
提交者:
Ryan Dahl
6月 06, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup compiler API (#2466)
上级
cbcb78f1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
31 deletion
+12
-31
cli/compiler.rs
cli/compiler.rs
+11
-30
cli/state.rs
cli/state.rs
+1
-1
未找到文件。
cli/compiler.rs
浏览文件 @
e3b2205e
...
...
@@ -84,21 +84,19 @@ pub fn get_compiler_config(
pub
fn
compile_async
(
state
:
ThreadSafeState
,
specifier
:
&
str
,
referrer
:
&
str
,
module_meta_data
:
&
ModuleMetaData
,
)
->
impl
Future
<
Item
=
ModuleMetaData
,
Error
=
Diagnostic
>
{
let
module_name
=
module_meta_data
.module_name
.clone
();
debug!
(
"Running rust part of compile_sync.
specifier: {}, referrer
: {}"
,
&
specifier
,
&
referrer
"Running rust part of compile_sync.
module_name
: {}"
,
&
module_name
);
let
root_names
=
vec!
[
module_
meta_data
.module_
name
.clone
()];
let
root_names
=
vec!
[
module_name
.clone
()];
let
compiler_config
=
get_compiler_config
(
&
state
,
"typescript"
);
let
req_msg
=
req
(
root_names
,
compiler_config
);
let
module_meta_data_
=
module_meta_data
.clone
();
// Count how many times we start the compiler worker.
state
.metrics.compiler_starts
.fetch_add
(
1
,
Ordering
::
SeqCst
);
...
...
@@ -113,9 +111,7 @@ pub fn compile_async(
js_check
(
worker
.execute
(
"workerMain()"
));
js_check
(
worker
.execute
(
"compilerMain()"
));
let
compiling_job
=
state
.progress
.add
(
format!
(
"Compiling {}"
,
module_meta_data_
.module_name
));
let
compiling_job
=
state
.progress
.add
(
format!
(
"Compiling {}"
,
module_name
));
let
resource
=
worker
.state.resource
.clone
();
let
compiler_rid
=
resource
.rid
;
...
...
@@ -146,12 +142,9 @@ pub fn compile_async(
}
}
let
r
=
state
.dir
.fetch_module_meta_data
(
&
module_meta_data_
.module_name
,
"."
,
true
,
true
,
);
let
r
=
state
.dir
.fetch_module_meta_data
(
&
module_name
,
"."
,
true
,
true
);
let
module_meta_data_after_compile
=
r
.unwrap
();
// Explicit drop to keep reference alive until future completes.
...
...
@@ -167,16 +160,9 @@ pub fn compile_async(
pub
fn
compile_sync
(
state
:
ThreadSafeState
,
specifier
:
&
str
,
referrer
:
&
str
,
module_meta_data
:
&
ModuleMetaData
,
)
->
Result
<
ModuleMetaData
,
Diagnostic
>
{
tokio_util
::
block_on
(
compile_async
(
state
,
specifier
,
referrer
,
module_meta_data
,
))
tokio_util
::
block_on
(
compile_async
(
state
,
module_meta_data
))
}
#[cfg(test)]
...
...
@@ -186,11 +172,7 @@ mod tests {
#[test]
fn
test_compile_sync
()
{
tokio_util
::
init
(||
{
let
cwd
=
std
::
env
::
current_dir
()
.unwrap
();
let
cwd_string
=
cwd
.to_str
()
.unwrap
()
.to_owned
();
let
specifier
=
"./tests/002_hello.ts"
;
let
referrer
=
cwd_string
+
"/"
;
use
crate
::
worker
;
let
module_name
=
worker
::
root_specifier_to_url
(
specifier
)
.unwrap
()
...
...
@@ -208,8 +190,7 @@ mod tests {
maybe_source_map
:
None
,
};
out
=
compile_sync
(
ThreadSafeState
::
mock
(),
specifier
,
&
referrer
,
&
out
)
.unwrap
();
out
=
compile_sync
(
ThreadSafeState
::
mock
(),
&
out
)
.unwrap
();
assert
!
(
out
.maybe_output_code
...
...
cli/state.rs
浏览文件 @
e3b2205e
...
...
@@ -127,7 +127,7 @@ fn fetch_module_meta_data_and_maybe_compile_async(
{
debug!
(
">>>>> compile_sync START"
);
Either
::
A
(
compile_async
(
state_
.clone
(),
&
specifier
,
&
referrer
,
&
out
)
compile_async
(
state_
.clone
(),
&
out
)
.map_err
(|
e
|
{
debug!
(
"compiler error exiting!"
);
eprintln!
(
"
\n
{}"
,
e
.to_string
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录