Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
deno
提交
3afc0b84
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,发现更多精彩内容 >>
提交
3afc0b84
编写于
9月 09, 2018
作者:
R
Ryan Dahl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fbs_util.ts -> dispatch.ts
And send() -> sendSync()
上级
e2a285b8
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
28 addition
and
31 deletion
+28
-31
BUILD.gn
BUILD.gn
+2
-2
js/dispatch.ts
js/dispatch.ts
+1
-4
js/fetch.ts
js/fetch.ts
+1
-1
js/main.ts
js/main.ts
+2
-2
js/os.ts
js/os.ts
+18
-18
js/timers.ts
js/timers.ts
+2
-2
tests/error_004_missing_module.ts.out
tests/error_004_missing_module.ts.out
+1
-1
tests/error_005_missing_dynamic_import.ts.out
tests/error_005_missing_dynamic_import.ts.out
+1
-1
未找到文件。
BUILD.gn
浏览文件 @
3afc0b84
...
...
@@ -190,8 +190,8 @@ run_node("gen_declarations") {
"js/compiler.ts",
"js/console.ts",
"js/deno.ts",
"js/dispatch.ts",
"js/errors.ts",
"js/fbs_util.ts",
"js/fetch.ts",
"js/global-eval.ts",
"js/globals.ts",
...
...
@@ -226,8 +226,8 @@ run_node("bundle") {
"js/assets.ts",
"js/compiler.ts",
"js/console.ts",
"js/dispatch.ts",
"js/errors.ts",
"js/fbs_util.ts",
"js/fetch.ts",
"js/fetch_types.d.ts",
"js/globals.ts",
...
...
js/
fbs_util
.ts
→
js/
dispatch
.ts
浏览文件 @
3afc0b84
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
// TODO Rename this file to //js/dispatch.ts
import
{
libdeno
}
from
"
./libdeno
"
;
import
{
flatbuffers
}
from
"
flatbuffers
"
;
import
*
as
fbs
from
"
gen/msg_generated
"
;
...
...
@@ -12,7 +11,6 @@ const promiseTable = new Map<number, util.Resolvable<fbs.Base>>();
export
function
handleAsyncMsgFromRust
(
ui8
:
Uint8Array
)
{
const
bb
=
new
flatbuffers
.
ByteBuffer
(
ui8
);
const
base
=
fbs
.
Base
.
getRootAsBase
(
bb
);
const
cmdId
=
base
.
cmdId
();
const
promise
=
promiseTable
.
get
(
cmdId
);
util
.
assert
(
promise
!=
null
,
`Expecting promise in table.
${
cmdId
}
`
);
...
...
@@ -38,9 +36,8 @@ export function sendAsync(
return
promise
;
}
// TODO Rename to sendSync
// @internal
export
function
send
(
export
function
send
Sync
(
builder
:
flatbuffers
.
Builder
,
msgType
:
fbs
.
Any
,
msg
:
flatbuffers
.
Offset
...
...
js/fetch.ts
浏览文件 @
3afc0b84
...
...
@@ -8,7 +8,7 @@ import {
notImplemented
}
from
"
./util
"
;
import
{
flatbuffers
}
from
"
flatbuffers
"
;
import
{
sendAsync
}
from
"
./
fbs_util
"
;
import
{
sendAsync
}
from
"
./
dispatch
"
;
import
*
as
fbs
from
"
gen/msg_generated
"
;
import
{
Headers
,
...
...
js/main.ts
浏览文件 @
3afc0b84
...
...
@@ -6,13 +6,13 @@ import * as os from "./os";
import
{
DenoCompiler
}
from
"
./compiler
"
;
import
{
libdeno
}
from
"
./libdeno
"
;
import
{
argv
}
from
"
./deno
"
;
import
{
send
,
handleAsyncMsgFromRust
}
from
"
./fbs_util
"
;
import
{
send
Sync
,
handleAsyncMsgFromRust
}
from
"
./dispatch
"
;
function
sendStart
():
fbs
.
StartRes
{
const
builder
=
new
flatbuffers
.
Builder
();
fbs
.
Start
.
startStart
(
builder
);
const
startOffset
=
fbs
.
Start
.
endStart
(
builder
);
const
baseRes
=
send
(
builder
,
fbs
.
Any
.
Start
,
startOffset
);
const
baseRes
=
send
Sync
(
builder
,
fbs
.
Any
.
Start
,
startOffset
);
assert
(
baseRes
!=
null
);
assert
(
fbs
.
Any
.
StartRes
===
baseRes
!
.
msgType
());
const
startRes
=
new
fbs
.
StartRes
();
...
...
js/os.ts
浏览文件 @
3afc0b84
...
...
@@ -4,14 +4,14 @@ import * as fbs from "gen/msg_generated";
import
{
assert
}
from
"
./util
"
;
import
*
as
util
from
"
./util
"
;
import
{
flatbuffers
}
from
"
flatbuffers
"
;
import
{
send
}
from
"
./fbs_util
"
;
import
{
send
Sync
}
from
"
./dispatch
"
;
export
function
exit
(
exitCode
=
0
):
never
{
const
builder
=
new
flatbuffers
.
Builder
();
fbs
.
Exit
.
startExit
(
builder
);
fbs
.
Exit
.
addCode
(
builder
,
exitCode
);
const
msg
=
fbs
.
Exit
.
endExit
(
builder
);
send
(
builder
,
fbs
.
Any
.
Exit
,
msg
);
send
Sync
(
builder
,
fbs
.
Any
.
Exit
,
msg
);
return
util
.
unreachable
();
}
...
...
@@ -28,7 +28,7 @@ export function codeFetch(
fbs
.
CodeFetch
.
addModuleSpecifier
(
builder
,
moduleSpecifier_
);
fbs
.
CodeFetch
.
addContainingFile
(
builder
,
containingFile_
);
const
msg
=
fbs
.
CodeFetch
.
endCodeFetch
(
builder
);
const
baseRes
=
send
(
builder
,
fbs
.
Any
.
CodeFetch
,
msg
);
const
baseRes
=
send
Sync
(
builder
,
fbs
.
Any
.
CodeFetch
,
msg
);
assert
(
baseRes
!=
null
);
assert
(
fbs
.
Any
.
CodeFetchRes
===
baseRes
!
.
msgType
(),
...
...
@@ -59,7 +59,7 @@ export function codeCache(
fbs
.
CodeCache
.
addSourceCode
(
builder
,
sourceCode_
);
fbs
.
CodeCache
.
addOutputCode
(
builder
,
outputCode_
);
const
msg
=
fbs
.
CodeCache
.
endCodeCache
(
builder
);
const
baseRes
=
send
(
builder
,
fbs
.
Any
.
CodeCache
,
msg
);
const
baseRes
=
send
Sync
(
builder
,
fbs
.
Any
.
CodeCache
,
msg
);
assert
(
baseRes
==
null
);
// Expect null or error.
}
...
...
@@ -97,7 +97,7 @@ export function makeTempDirSync({
fbs
.
MakeTempDir
.
addSuffix
(
builder
,
fbSuffix
);
}
const
msg
=
fbs
.
MakeTempDir
.
endMakeTempDir
(
builder
);
const
baseRes
=
send
(
builder
,
fbs
.
Any
.
MakeTempDir
,
msg
);
const
baseRes
=
send
Sync
(
builder
,
fbs
.
Any
.
MakeTempDir
,
msg
);
assert
(
baseRes
!=
null
);
assert
(
fbs
.
Any
.
MakeTempDirRes
===
baseRes
!
.
msgType
());
const
res
=
new
fbs
.
MakeTempDirRes
();
...
...
@@ -111,7 +111,7 @@ export function makeTempDirSync({
// and permission bits (before umask).
export
function
mkdirSync
(
path
:
string
,
mode
=
0o777
):
void
{
/* Ideally we could write:
const res = send({
const res = send
Sync
({
command: fbs.Command.MKDIR_SYNC,
mkdirSyncPath: path,
mkdirSyncMode: mode,
...
...
@@ -123,7 +123,7 @@ export function mkdirSync(path: string, mode = 0o777): void {
fbs
.
MkdirSync
.
addPath
(
builder
,
path_
);
fbs
.
MkdirSync
.
addMode
(
builder
,
mode
);
const
msg
=
fbs
.
MkdirSync
.
endMkdirSync
(
builder
);
send
(
builder
,
fbs
.
Any
.
MkdirSync
,
msg
);
send
Sync
(
builder
,
fbs
.
Any
.
MkdirSync
,
msg
);
}
/**
...
...
@@ -136,7 +136,7 @@ export function mkdirSync(path: string, mode = 0o777): void {
*/
export
function
readFileSync
(
filename
:
string
):
Uint8Array
{
/* Ideally we could write
const res = send({
const res = send
Sync
({
command: fbs.Command.READ_FILE_SYNC,
readFileSyncFilename: filename
});
...
...
@@ -147,7 +147,7 @@ export function readFileSync(filename: string): Uint8Array {
fbs
.
ReadFileSync
.
startReadFileSync
(
builder
);
fbs
.
ReadFileSync
.
addFilename
(
builder
,
filename_
);
const
msg
=
fbs
.
ReadFileSync
.
endReadFileSync
(
builder
);
const
baseRes
=
send
(
builder
,
fbs
.
Any
.
ReadFileSync
,
msg
);
const
baseRes
=
send
Sync
(
builder
,
fbs
.
Any
.
ReadFileSync
,
msg
);
assert
(
baseRes
!=
null
);
assert
(
fbs
.
Any
.
ReadFileSyncRes
===
baseRes
!
.
msgType
());
const
res
=
new
fbs
.
ReadFileSyncRes
();
...
...
@@ -182,7 +182,7 @@ function setEnv(key: string, value: string): void {
fbs
.
SetEnv
.
addKey
(
builder
,
_key
);
fbs
.
SetEnv
.
addValue
(
builder
,
_value
);
const
msg
=
fbs
.
SetEnv
.
endSetEnv
(
builder
);
send
(
builder
,
fbs
.
Any
.
SetEnv
,
msg
);
send
Sync
(
builder
,
fbs
.
Any
.
SetEnv
,
msg
);
}
/**
...
...
@@ -200,14 +200,14 @@ function setEnv(key: string, value: string): void {
*/
export
function
env
():
{
[
index
:
string
]:
string
}
{
/* Ideally we could write
const res = send({
const res = send
Sync
({
command: fbs.Command.ENV,
});
*/
const
builder
=
new
flatbuffers
.
Builder
();
fbs
.
Environ
.
startEnviron
(
builder
);
const
msg
=
fbs
.
Environ
.
endEnviron
(
builder
);
const
baseRes
=
send
(
builder
,
fbs
.
Any
.
Environ
,
msg
)
!
;
const
baseRes
=
send
Sync
(
builder
,
fbs
.
Any
.
Environ
,
msg
)
!
;
assert
(
fbs
.
Any
.
EnvironRes
===
baseRes
.
msgType
());
const
res
=
new
fbs
.
EnvironRes
();
assert
(
baseRes
.
msg
(
res
)
!=
null
);
...
...
@@ -303,7 +303,7 @@ export function statSync(filename: string): FileInfo {
function
statSyncInner
(
filename
:
string
,
lstat
:
boolean
):
FileInfo
{
/* Ideally we could write
const res = send({
const res = send
Sync
({
command: fbs.Command.STAT_FILE_SYNC,
StatFilename: filename,
StatLStat: lstat,
...
...
@@ -316,7 +316,7 @@ function statSyncInner(filename: string, lstat: boolean): FileInfo {
fbs
.
StatSync
.
addFilename
(
builder
,
filename_
);
fbs
.
StatSync
.
addLstat
(
builder
,
lstat
);
const
msg
=
fbs
.
StatSync
.
endStatSync
(
builder
);
const
baseRes
=
send
(
builder
,
fbs
.
Any
.
StatSync
,
msg
);
const
baseRes
=
send
Sync
(
builder
,
fbs
.
Any
.
StatSync
,
msg
);
assert
(
baseRes
!=
null
);
assert
(
fbs
.
Any
.
StatSyncRes
===
baseRes
!
.
msgType
());
const
res
=
new
fbs
.
StatSyncRes
();
...
...
@@ -338,7 +338,7 @@ export function writeFileSync(
perm
=
0o666
):
void
{
/* Ideally we could write:
const res = send({
const res = send
Sync
({
command: fbs.Command.WRITE_FILE_SYNC,
writeFileSyncFilename: filename,
writeFileSyncData: data,
...
...
@@ -353,7 +353,7 @@ export function writeFileSync(
fbs
.
WriteFileSync
.
addData
(
builder
,
dataOffset
);
fbs
.
WriteFileSync
.
addPerm
(
builder
,
perm
);
const
msg
=
fbs
.
WriteFileSync
.
endWriteFileSync
(
builder
);
send
(
builder
,
fbs
.
Any
.
WriteFileSync
,
msg
);
send
Sync
(
builder
,
fbs
.
Any
.
WriteFileSync
,
msg
);
}
/**
...
...
@@ -366,7 +366,7 @@ export function writeFileSync(
*/
export
function
renameSync
(
oldpath
:
string
,
newpath
:
string
):
void
{
/* Ideally we could write:
const res = send({
const res = send
Sync
({
command: fbs.Command.RENAME_SYNC,
renameOldPath: oldpath,
renameNewPath: newpath
...
...
@@ -379,5 +379,5 @@ export function renameSync(oldpath: string, newpath: string): void {
fbs
.
RenameSync
.
addOldpath
(
builder
,
_oldpath
);
fbs
.
RenameSync
.
addNewpath
(
builder
,
_newpath
);
const
msg
=
fbs
.
RenameSync
.
endRenameSync
(
builder
);
send
(
builder
,
fbs
.
Any
.
RenameSync
,
msg
);
send
Sync
(
builder
,
fbs
.
Any
.
RenameSync
,
msg
);
}
js/timers.ts
浏览文件 @
3afc0b84
...
...
@@ -3,7 +3,7 @@ import { assert } from "./util";
import
*
as
util
from
"
./util
"
;
import
*
as
fbs
from
"
gen/msg_generated
"
;
import
{
flatbuffers
}
from
"
flatbuffers
"
;
import
{
send
,
sendAsync
}
from
"
./fbs_util
"
;
import
{
send
Sync
,
sendAsync
}
from
"
./dispatch
"
;
let
nextTimerId
=
1
;
...
...
@@ -93,6 +93,6 @@ export function clearTimer(id: number) {
fbs
.
TimerClear
.
startTimerClear
(
builder
);
fbs
.
TimerClear
.
addId
(
builder
,
id
);
const
msg
=
fbs
.
TimerClear
.
endTimerClear
(
builder
);
const
res
=
send
(
builder
,
fbs
.
Any
.
TimerClear
,
msg
);
const
res
=
send
Sync
(
builder
,
fbs
.
Any
.
TimerClear
,
msg
);
assert
(
res
==
null
);
}
tests/error_004_missing_module.ts.out
浏览文件 @
3afc0b84
NotFound: Cannot resolve module "bad-module.ts" from "[WILDCARD]/tests/error_004_missing_module.ts"
at maybeError (deno/js/errors.ts:[WILDCARD])
at maybeThrowError (deno/js/errors.ts:[WILDCARD])
at send
(deno/js/fbs_util
.ts:[WILDCARD])
at send
Sync (deno/js/dispatch
.ts:[WILDCARD])
at Object.codeFetch (deno/js/os.ts:[WILDCARD])
at DenoCompiler.resolveModule (deno/js/compiler.ts:[WILDCARD])
at DenoCompiler._resolveModuleName (deno/js/compiler.ts:[WILDCARD])
...
...
tests/error_005_missing_dynamic_import.ts.out
浏览文件 @
3afc0b84
NotFound: Cannot resolve module "bad-module.ts" from "[WILDCARD]deno/tests/error_005_missing_dynamic_import.ts"
at maybeError (deno/js/errors.ts:[WILDCARD])
at maybeThrowError (deno/js/errors.ts:[WILDCARD])
at send
(deno/js/fbs_util
.ts:[WILDCARD])
at send
Sync (deno/js/dispatch
.ts:[WILDCARD])
at Object.codeFetch (deno/js/os.ts:[WILDCARD])
at DenoCompiler.resolveModule (deno/js/compiler.ts:[WILDCARD])
at DenoCompiler._resolveModuleName (deno/js/compiler.ts:[WILDCARD])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录