assemblyscript
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -27,3 +27,3 @@ /** | ||
/** A 1-bit unsigned integer. */ | ||
declare type bool = boolean; | ||
declare type bool = any; // as required for logical '&&' / '||' | ||
/** A 32-bit float. */ | ||
@@ -70,8 +70,14 @@ declare type float = number; | ||
declare abstract class Disposable implements IDisposable { | ||
dispose(): void; | ||
} | ||
// Arrays | ||
/** A fixed-size array. */ | ||
declare class Array<T> implements IDisposable { | ||
/** Number of array elements. */ | ||
readonly length: int; | ||
declare class Array<T> extends Disposable { | ||
/** Maximum number of elements this array can hold without resizing. */ | ||
readonly capacity: int; | ||
/** Number of elements this array currently holds. */ | ||
length: int; | ||
@@ -89,5 +95,4 @@ /** Constructs a new array with the specified number of elements. */ | ||
reverse(): this; | ||
// implemented | ||
dispose(): void; | ||
/** Grows the array to the specified new capacity, frees the current reference (unsafe) and returns the new reference. Traps if `newCapacity` is less than or equal the current capacity. */ | ||
// unsafeGrow(newCapacity: int): this; | ||
} | ||
@@ -128,5 +133,19 @@ | ||
/** Determines whether the string ends with the specified value. */ | ||
endsWidth(value: string): bool; | ||
endsWith(value: string): bool; | ||
} | ||
// Console | ||
/** Console bindings. */ | ||
declare class console { | ||
/** Logs a message to console. */ | ||
static log(message: string): void; | ||
/** Logs an informative message to console. */ | ||
static info(message: string): void; | ||
/** Logs a warning message to console. */ | ||
static warn(message: string): void; | ||
/** Logs an error message to console. */ | ||
static error(message: string): void; | ||
} | ||
// Builtins | ||
@@ -133,0 +152,0 @@ |
@@ -10,6 +10,12 @@ var fs = require("fs"); | ||
var isDev = fs.existsSync(__dirname + "/../src/index.ts") && path.basename(path.join(__dirname, "..", "..")) !== "node_modules"; | ||
var isOut = false; | ||
if (isDev) { | ||
require("ts-node/register"); | ||
assemblyscript = require("../src"); | ||
if (fs.existsSync(__dirname + "/../out/index.js")) { | ||
assemblyscript = require("../out"); | ||
isOut = true; | ||
} else { | ||
require("ts-node/register"); | ||
assemblyscript = require("../src"); | ||
} | ||
} else | ||
@@ -78,3 +84,3 @@ assemblyscript = require("../dist/assemblyscript"); | ||
(argv.help ? process.stdout : process.stderr).write([ | ||
"Version " + pkg.version + (isDev ? "-dev" : ""), | ||
"Version " + pkg.version + (isDev ? "-dev" + (isOut ? " (out)" : "") : ""), | ||
"Syntax: "+ chalk.reset.cyan.bold("asc") + " [options] entryFile", | ||
@@ -160,9 +166,8 @@ "", | ||
if (format === "linear" || format === "stack") { | ||
if (!assemblyscript.wabt.available) { | ||
if (!argv.quiet) | ||
process.stderr.write("\n" + assemblyscript.wabt.ENOTAVAILABLE + "\n"); | ||
if (!assemblyscript.util.wabt) { | ||
process.stderr.write("\nwabt.js not found\n"); | ||
return callback(EFAILURE); | ||
} | ||
var binary = wasmModule.ascCurrentBinary || (wasmModule.ascCurrentBinary = wasmModule.emitBinary()); // reuse | ||
output.write(assemblyscript.wabt.wasmToWast(binary, { readDebugNames: true }), "utf8", end); | ||
output.write(assemblyscript.util.wasmToWast(binary, { readDebugNames: true }), "utf8", end); | ||
} else | ||
@@ -169,0 +174,0 @@ output.write(wasmModule.emitText(), "utf8", end); |
{ | ||
"name": "assemblyscript", | ||
"description": "A subset of TypeScript that compiles to WebAssembly.", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"author": "Daniel Wirtz <dcode+assemblyscript@dcode.io>", | ||
@@ -26,9 +26,11 @@ "license": "Apache-2.0", | ||
"scripts": { | ||
"build:malloc": "node scripts/build-malloc", | ||
"build:runtime": "node scripts/build-runtime", | ||
"build:typescript": "tsc -P lib/typescript && echo export = ts; >> lib/typescript/build/index.d.ts", | ||
"build:alldeps": "node scripts/build-check && npm run build:malloc && npm run build:typescript", | ||
"build:alldeps": "node scripts/build-check && npm run build:runtime && npm run build:typescript", | ||
"build:diagnostics": "node scripts/build-diagnostics", | ||
"build:library": "node scripts/build-library", | ||
"build:bundle-loader": "node scripts/build-bundle-loader", | ||
"build:bundle": "tsc -P src && node scripts/build-bundle", | ||
"build": "npm run lint && npm run build:library && npm run build:bundle && npm run build:bundle-loader", | ||
"build": "npm run build:diagnostics && npm run lint && npm run build:library && npm run build:bundle && npm run build:bundle-loader", | ||
"clean": "node scripts/clean", | ||
"lint": "tslint --config tslint.json src/**/*.ts cli/**/*.ts assembly.d.ts", | ||
@@ -42,4 +44,4 @@ "test": "ts-node tests", | ||
"dependencies": { | ||
"binaryen": "1.37.14", | ||
"chalk": "^1.1.3", | ||
"binaryen": "1.37.16-nightly.20170719", | ||
"chalk": "^2.0.1", | ||
"minimist": "^1.2.0", | ||
@@ -54,3 +56,3 @@ "wabt": "0.0.13-nightly.20170628" | ||
"@types/minimist": "^1.2.0", | ||
"@types/node": "^8.0.2", | ||
"@types/node": "^8.0.17", | ||
"@types/rimraf": "0.0.28", | ||
@@ -60,5 +62,5 @@ "@types/tape": "^4.2.30", | ||
"browserify": "^14.4.0", | ||
"diff": "^3.2.0", | ||
"diff": "^3.3.0", | ||
"dts-bundle": "^0.7.3", | ||
"gulp-header": "^1.8.8", | ||
"gulp-header": "^1.8.9", | ||
"gulp-sourcemaps": "^2.6.0", | ||
@@ -71,7 +73,7 @@ "gulp-uglify": "^3.0.0", | ||
"tape": "^4.7.0", | ||
"ts-node": "^3.1.0", | ||
"tslint": "^5.4.3", | ||
"typedoc": "^0.7.1", | ||
"typedoc-plugin-external-module-name": "^1.0.9", | ||
"typescript": "^2.4.1", | ||
"ts-node": "^3.3.0", | ||
"tslint": "^5.5.0", | ||
"typedoc": "^0.8.0", | ||
"typedoc-plugin-external-module-name": "github:dcodeIO/typedoc-plugin-external-module-name", | ||
"typescript": "^2.4.2", | ||
"vinyl-buffer": "^1.0.0", | ||
@@ -78,0 +80,0 @@ "vinyl-fs": "^2.4.4", |
@@ -8,3 +8,3 @@ ![AssemblyScript](https://raw.githubusercontent.com/dcodeIO/AssemblyScript/master/logo.png) | ||
[![npm](https://img.shields.io/npm/v/assemblyscript.svg)](https://www.npmjs.com/package/assemblyscript) [![Build Status](https://travis-ci.org/dcodeIO/AssemblyScript.svg?branch=master)](https://travis-ci.org/dcodeIO/AssemblyScript) [![npm](https://img.shields.io/npm/dm/assemblyscript.svg)](https://www.npmjs.com/package/assemblyscript) | ||
[![npm](https://img.shields.io/npm/v/assemblyscript.svg)](https://www.npmjs.com/package/assemblyscript) [![Build Status](https://travis-ci.org/dcodeIO/AssemblyScript.svg?branch=master)](https://travis-ci.org/dcodeIO/AssemblyScript) [![npm](https://img.shields.io/npm/dm/assemblyscript.svg)](https://www.npmjs.com/package/assemblyscript) <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=dcode%40dcode.io&item_name=Open%20Source%20Software%20Donation&item_number=dcodeIO%2Fprotobuf.js"><img alt="donate ❤" src="https://img.shields.io/badge/donate-❤-ff2244.svg"></a> | ||
@@ -45,3 +45,3 @@ Contents | ||
The compiler is able to produce WebAssembly binaries (.wasm) as well as their corresponding text format (.wast). Both Binaryen's s-expression format and, with a little help of [WABT](https://github.com/WebAssembly/wabt), official linear text format are supported. See also: [CLI](#command-line) | ||
The compiler is able to produce WebAssembly binaries (.wasm) as well as their corresponding text format. Both Binaryen's s-expression format (.wast) and, with a little help of [WABT](https://github.com/WebAssembly/wabt), official linear text format (.wat) are supported. See also: [CLI](#command-line) | ||
@@ -52,8 +52,8 @@ What to expect | ||
<details><p> | ||
The most prominent difference of JavaScript and any strictly typed language is that, in TypeScript/JavaScript, a variable can reference a value of any type. This implies that a JavaScript VM has to conduct additional book-keeping of a value's type in addition to its value and that it has to perform additional checks whenever a variable is accessed. Modern JavaScript VMs shortcut the overhead introduced by this and similar dynamic features by generating case-specific code based on statistical information collected just in time, effectively reducing the amount of checks to perform implicitly and thus speeding up execution significantly. Similarily, developers shortcut the overhead of remembering each variable's type by using TypeScript. The combination of both also makes a good match because it potentially aids the JIT compiler. | ||
The most prominent difference of JavaScript and any strictly typed language is that, in JavaScript, a variable can reference a value of any type. This implies that a JavaScript execution environment has to emit additional runtime checks whenever a variable is accessed. Modern JavaScript VMs shortcut the overhead introduced by this and similar dynamic features by generating case-specific code based on statistical information collected just in time (JIT), speeding up execution significantly. Similarily, developers shortcut the overhead of remembering each variable's type by using TypeScript. The combination of both also makes for a good match because it potentially aids the JIT compiler. | ||
Nonetheless, TypeScript isn't a *strictly* typed language after all because it allows specific constructs to resort to JavaScript's dynamic features. For example, TypeScript allows annotating function parameters as omittable (i.e. `someParameter?: number`), effectively resulting in a union type `number | undefined` at runtime, just like it also allows declaring union types explicitly. Conceptionally, these constructs are incompatible with a strict, AOT-compiled type system unless relatively expensive workarounds are introduced. Hence... | ||
Because it has the ability to fall back to dynamic JavaScript features, TypeScript isn't a *strictly* typed language after all. For example, TypeScript supports omittable (i.e. `someParameter?: number`) function parameters resulting in a union type `number | undefined` at runtime, just like it also allows declaring union types explicitly. These constructs are incompatible with a strict, ahead of time (AOT) compiled type system unless additional runtime checks are emitted that'd usually execute slower than similar code running in a VM that has the ability to perform optimizations at runtime. Hence... | ||
</p><summary><strong>TL;DR</strong></summary></details> | ||
Instead of trying to mimic TypeScript/JavaScript as closely as possible at the expense of performance (recap that: slower than similar code running in a JIT-compiling VM), AssemblyScript tries to support TypeScript features as closely as reasonable, not supporting certain JavaScript-specific dynamic constructs intentionally: | ||
Instead of reimplementing TypeScript *as closely as possible* at the expense of performance, AssemblyScript tries to support its features *as closely as reasonable* while not supporting certain dynamic constructs intentionally: | ||
@@ -60,0 +60,0 @@ * All types must be annotated to avoid possibly unwanted implicit type conversions |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
6647
0
6308926
+ Addedansi-styles@3.2.1(transitive)
+ Addedbinaryen@1.37.16-nightly.20170719(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedsupports-color@5.5.0(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedbinaryen@1.37.14(transitive)
- Removedchalk@1.1.3(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.0(transitive)
Updatedchalk@^2.0.1