Skip to content

Instantly share code, notes, and snippets.

@RyosukeCla
Last active February 6, 2019 10:06
Show Gist options
  • Save RyosukeCla/5228f50d91209716f8a9918a96887930 to your computer and use it in GitHub Desktop.
Save RyosukeCla/5228f50d91209716f8a9918a96887930 to your computer and use it in GitHub Desktop.
reading-dino

Deno

$ target/debug/deno tests/002_hello.ts

rust

src/main.rs

  1. load env args, and set flags
  2. new isolate
  3. tokio init (async)
  4. isolate execute denoMain(); in js/main.js
  5. isolate execute_mod tests/002_hello.ts
  6. isolate event loop

isolate execute

  1. libdeno::deno_execute (See libdeno/api.cc)

isolate execute_mod

  1. code fetch and maybe compile tests/002_hello.ts
  2. code_fetch
  3. compile_sync
  4. spawn worker compilerMain() in js/compiler.ts 1. compiler.compile
  5. mod_load_deps for loading dependencies in the loaded ts module

mod_load_deps

  1. let len = libdeno::deno_mod_imports_len: the number of dependeicies
  2. for in 0..len
  3. libdeno::deno_mod_imports_get
  4. resolve module
  5. code_fetch_and_maybe_compile
  6. mod_load_deps for recursively loading depedenecy tree.

isolate event loop

  1. while !is_idle: !(ntasks == 0 && deadline)
  2. complete_op
  3. done

complete_op

  1. ntasks_decrement()
  2. respond
  3. libdeno::deno_respond

TS

Compiler implements ts.LanguageServiceHost, ts.FormatDiagnosticsHost

  1. compiler.compile
  2. resolve module
  3. _service: ts.LanguageService getEmitOutput tests/002_hello.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment