thinscript

所属分类:编程语言基础
开发工具:C
文件大小:0KB
下载次数:0
上传日期:2016-05-11 17:12:56
上 传 者sh-1993
说明:  受TypeScript启发的低级编程语言
(A low-level programming language inspired by TypeScript)

文件列表:
.npmignore (145, 2016-04-23)
build.js (3641, 2016-04-23)
lib/ (0, 2016-04-23)
lib/thinc.c (3259, 2016-04-23)
lib/thinc.js (1740, 2016-04-23)
out/ (0, 2016-04-23)
out/benchmark.html (4793, 2016-04-23)
out/benchmark.thin (527218, 2016-04-23)
out/common.js (6484, 2016-04-23)
out/compiled.c (465683, 2016-04-23)
out/compiled.h (1133, 2016-04-23)
out/compiled.js (238752, 2016-04-23)
out/compiled.wasm (108521, 2016-04-23)
out/index.html (14731, 2016-04-23)
package.json (169, 2016-04-23)
src/ (0, 2016-04-23)
src/bytearray.thin (4123, 2016-04-23)
src/c.thin (24324, 2016-04-23)
src/checker.thin (54613, 2016-04-23)
src/compiler.thin (4523, 2016-04-23)
src/imports.thin (396, 2016-04-23)
src/js.thin (20647, 2016-04-23)
src/lexer.thin (19296, 2016-04-23)
src/library.thin (12543, 2016-04-23)
src/log.thin (4887, 2016-04-23)
src/main.thin (6116, 2016-04-23)
src/node.thin (23288, 2016-04-23)
src/parser.thin (37923, 2016-04-23)
src/preprocessor.thin (12444, 2016-04-23)
src/scope.thin (2296, 2016-04-23)
src/shaking.thin (1794, 2016-04-23)
src/stringbuilder.thin (3803, 2016-04-23)
src/symbol.thin (3902, 2016-04-23)
src/type.thin (2507, 2016-04-23)
src/wasm.thin (39027, 2016-04-23)

# ThinScript ThinScript is an experimental programming language that compiles to JavaScript, WebAssembly, and C. It's meant to be a thin layer on top of WebAssembly that makes it easier to work with: no dependencies and fast compile times. The syntax is inspired by TypeScript and the compiler is open source and bootstrapped (it can compile itself). This is still an experiment and isn't intended for real use yet. The biggest issue is that the generated code currently doesn't delete anything (garbage collection is planned but not yet implemented). Also the WebAssembly specification is still being developed and the current binary format will stop working when WebAssembly is officially released. ## Demo An interactive compiler demo is available online at http://evanw.github.io/thinscript/. Here's some example code to demonstrate the language (documentation will be written at some point): ```TypeScript declare function print(text: string): void; class Link { value: int; next: Link; } class List { first: Link; last: Link; append(value: int): void { var link = new Link(); link.value = value; // Append the new link to the end of the chain if (this.first == null) this.first = link; else this.last.next = link; this.last = link; } } extern function main(): int { var list = new List(); list.append(1); list.append(2); list.append(3); var total = 0; var link = list.first; while (link != null) { total = total + link.value; link = link.next; } #if JS print("Hello from JavaScript"); #elif WASM print("Hello from WebAssembly"); #elif C print("Hello from C"); #else print("Unknown target"); #endif return total; } ``` # Building Run `node build.js` to build the compiler using itself. This generates updated versions of `out/compiled.js`, `out/compiled.wasm`, and `out/compiled.c`. If you have a C compiler installed, this also builds a native version of the compiler by compiling `out/compiled.c` and `lib/thinc.c` together into the `out/thinc` binary.

近期下载者

相关文件


收藏者