forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
58 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 2018 Ryan Dahl <[email protected]> | ||
// All rights reserved. MIT License. | ||
package main | ||
|
||
import ( | ||
"github.com/ry/deno" | ||
) | ||
|
||
func main() { | ||
deno.Init() | ||
deno.Eval("deno_main.js", "denoMain()") | ||
deno.Loop() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright 2018 Ryan Dahl <[email protected]> | ||
// All rights reserved. MIT License. | ||
package main | ||
package deno | ||
|
||
import ( | ||
"crypto/md5" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright 2018 Ryan Dahl <[email protected]> | ||
// All rights reserved. MIT License. | ||
package main | ||
package deno | ||
|
||
import ( | ||
"io/ioutil" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
// Copyright 2018 Ryan Dahl <[email protected]> | ||
// All rights reserved. MIT License. | ||
package main | ||
package deno | ||
|
||
import ( | ||
"github.com/golang/protobuf/proto" | ||
"github.com/ry/v8worker2" | ||
"sync" | ||
) | ||
|
||
|
@@ -20,19 +19,10 @@ var stats struct { | |
v8workerBytesRecv int | ||
} | ||
|
||
// There is a single global worker for this process. | ||
// This file should be the only part of deno that directly access it, so that | ||
// all interaction with V8 can go through a single point. | ||
var worker *v8worker2.Worker | ||
|
||
var channels = make(map[string][]Subscriber) | ||
|
||
type Subscriber func(payload []byte) []byte | ||
|
||
func createWorker() { | ||
worker = v8worker2.New(recv) | ||
} | ||
|
||
func recv(buf []byte) (response []byte) { | ||
stats.v8workerRecv++ | ||
stats.v8workerBytesRecv += len(buf) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright 2018 Ryan Dahl <[email protected]> | ||
// All rights reserved. MIT License. | ||
package main | ||
package deno | ||
|
||
// For testing | ||
func InitEcho() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright 2018 Ryan Dahl <[email protected]> | ||
// All rights reserved. MIT License. | ||
package main | ||
package deno | ||
|
||
import ( | ||
"github.com/golang/protobuf/proto" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright 2018 Ryan Dahl <[email protected]> | ||
// All rights reserved. MIT License. | ||
package main | ||
package deno | ||
|
||
import ( | ||
"bytes" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright 2018 Ryan Dahl <[email protected]> | ||
// All rights reserved. MIT License. | ||
package main | ||
package deno | ||
|
||
import ( | ||
"flag" | ||
|
@@ -34,8 +34,16 @@ func FlagsParse() []string { | |
return args | ||
} | ||
|
||
func main() { | ||
args := FlagsParse() | ||
// There is a single global worker for this process. | ||
// This file should be the only part of deno that directly access it, so that | ||
// all interaction with V8 can go through a single point. | ||
var worker *v8worker2.Worker | ||
var workerArgs []string | ||
var main_js string | ||
var main_map string | ||
|
||
func Init() { | ||
workerArgs = FlagsParse() | ||
|
||
// Maybe start Golang CPU profiler. | ||
// Use --prof for profiling JS. | ||
|
@@ -49,33 +57,36 @@ func main() { | |
} | ||
|
||
createDirs() | ||
createWorker() | ||
|
||
InitOS() | ||
InitEcho() | ||
InitTimers() | ||
InitFetch() | ||
|
||
main_js := stringAsset("main.js") | ||
worker = v8worker2.New(recv) | ||
|
||
main_js = stringAsset("main.js") | ||
err := worker.Load("/main.js", main_js) | ||
exitOnError(err) | ||
main_map := stringAsset("main.map") | ||
|
||
cwd, err := os.Getwd() | ||
check(err) | ||
main_map = stringAsset("main.map") | ||
} | ||
|
||
err = worker.Load("deno_main.js", "denoMain()") | ||
// It's up to library users to call | ||
// deno.Eval("deno_main.js", "denoMain()") | ||
func Eval(filename string, code string) { | ||
err := worker.Load(filename, code) | ||
exitOnError(err) | ||
} | ||
|
||
var command = Msg_START // TODO use proto3 | ||
func Loop() { | ||
cwd, err := os.Getwd() | ||
check(err) | ||
PubMsg("start", &Msg{ | ||
Command: command, | ||
Command: Msg_START, | ||
StartCwd: cwd, | ||
StartArgv: args, | ||
StartArgv: workerArgs, | ||
StartDebugFlag: *flagDebug, | ||
StartMainJs: main_js, | ||
StartMainMap: main_map, | ||
}) | ||
|
||
DispatchLoop() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,5 +47,4 @@ let startCalled = false; | |
const mod = runtime.resolveModule(inputFn, `${cwd}/`); | ||
mod.compileAndRun(); | ||
}); | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright 2018 Ryan Dahl <[email protected]> | ||
// All rights reserved. MIT License. | ||
package main | ||
package deno | ||
|
||
import ( | ||
"github.com/golang/protobuf/proto" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright 2018 Ryan Dahl <[email protected]> | ||
// All rights reserved. MIT License. | ||
package main | ||
package deno | ||
|
||
import ( | ||
"path" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright 2018 Ryan Dahl <[email protected]> | ||
// All rights reserved. MIT License. | ||
package main | ||
package deno | ||
|
||
import ( | ||
"github.com/golang/protobuf/proto" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Copyright 2018 Ryan Dahl <[email protected]> | ||
// All rights reserved. MIT License. | ||
package main | ||
package deno | ||
|
||
import ( | ||
"fmt" | ||
|