Skip to content
/ ts-llvm Public
forked from emlai/ts-llvm

Work-in-progress TypeScript to LLVM compiler

License

Notifications You must be signed in to change notification settings

Kingwl/ts-llvm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ts-llvm

ts-llvm is a compiler for TypeScript that generates LLVM code, which can then be optimized using all existing LLVM optimizations, and converted further into e.g. native code, WebAssembly, or JavaScript (using emscripten).

It uses the TypeScript Compiler API to parse and typecheck the input TypeScript code. The resulting TypeScript AST is transformed into LLVM IR using the llvm-node bindings. ts-llvm also provides a runtime library written in C++ that implements native replacements for built-in TypeScript APIs such as console.log.

ts-llvm is still in very early stages of development. For example, it cannot yet compile most TypeScript programs and it doesn't yet do any garbage collection. If you're willing to contribute, any help will be greatly appreciated. For questions you can create a GitHub issue or ask on the ts-llvm Slack.

Building from source

  1. You need to have LLVM installed on your system.
  2. Run npm install to install other dependencies. If llvm-config is not on your PATH, you may need to tell llvm-node where to find LLVM on your system, e.g. by running npm config set cmake_LLVM_DIR $(path-to-llvm/bin/llvm-config --cmakedir) before npm install.
  3. If you want ts-llvm to generate native code, you need to have llc and cc (any C++ compiler) on your PATH. llc will not be required once llvm-node gains support for the LLVM legacy PassManager and addPassesToEmitFile APIs. cc will not be required once ts-llvm learns to detect the system C++ compiler on its own.

Once everything above is set up, you can use the following commands:

  • npm run build will build the ts-llvm compiler in the build directory.
  • npm start will run the ts-llvm compiler. You can pass arguments to the compiler after two consecutive hyphens: e.g. npm start -- --help will print the compiler's usage information.
  • npm test will run the test suite.

License

ts-llvm is licensed under the MIT license.

About

Work-in-progress TypeScript to LLVM compiler

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 74.0%
  • LLVM 20.3%
  • C++ 5.7%