Coder Social home page Coder Social logo

assemblyscript / assemblyscript Goto Github PK

View Code? Open in Web Editor NEW
16.4K 199.0 650.0 160.19 MB

A TypeScript-like language for WebAssembly.

Home Page: https://www.assemblyscript.org

License: Apache License 2.0

JavaScript 1.48% TypeScript 12.54% WebAssembly 85.93% HTML 0.05%
typescript webassembly compiler assemblyscript wasm

assemblyscript's Introduction

AssemblyScript logo

Test status Publish status npm compiler version Discord online #StandWithUkraine

AssemblyScript compiles a variant of TypeScript (basically JavaScript with types) to WebAssembly using Binaryen. It generates lean and mean WebAssembly modules while being just an npm install away.


Contributors

Contributor logos

Thanks to our sponsors!

Most of the maintainers and contributors do this open source work in their free time. If you use AssemblyScript for a serious task or plan to do so, and you'd like us to invest more time on it, please donate to our OpenCollective. By sponsoring this project, your logo will show up below. Thank you so much for your support!

Sponsor logos

Development instructions

A development environment can be set up by cloning the repository:

git clone https://github.com/AssemblyScript/assemblyscript.git
cd assemblyscript
npm install
npm link

The link step is optional and makes the development instance available globally. The full process is documented as part of the repository:

assemblyscript's People

Contributors

alangpierce avatar andy-hanson avatar apsarasx avatar bowenwang1996 avatar countbleck avatar dcodeio avatar dependabot[bot] avatar duncanuszkay1 avatar fgasper avatar floorlamp avatar forcepusher avatar gzuidhof avatar herrcai0907 avatar jayphelps avatar jessecodebones avatar jtenner avatar kazupon avatar liaopeng avatar linusu avatar mattjohnsonpint avatar maxgraey avatar nidin avatar pinkaminadianepie avatar romdotdog avatar saulecabrera avatar surma avatar technohippy avatar torch2424 avatar willemneal avatar yjhmelody avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

assemblyscript's Issues

Support 'this' in static functions

Example:

export class Foo {
  static Boo: i32 = 100;
  static t(): i32 {
    return this.Boo; // not working
    // return Foo.Boo; <- working
  }
}

Propagate constant load/store offsets more efficiently

For example:

const index = 4;
store<i32>(ptr + <usize>index * sizeof<i32>(), value);
// emit as: (i32.store (i32.add (get_local $0) (i32.const 16)) (get_local $2))

Good optimize to this in compile time:

store<i32>(ptr, value, 4 * sizeof<i32>());
// emit as: (i32.store offset=16 (get_local $0) (get_local $2))

So may be this good doing inside load / store buildins.

That do you think?

global const optimization

const A:i32 = 1;
const B:i32 = A + 1;

export function test():i32 {
    return B;
}

output

// module.ts(2,15): warning TS/AS121: Compiling global with unsupported constant initializer expression as mutable.

(module
 (type $i (func (result i32)))
 (type $v (func))
 (global $B (mut i32) (i32.const 0))
 (memory $0 1)
 (export "test" (func $test))
 (export "memory" (memory $0))
 (start $.start)
 (func $test (; 0 ;) (type $i) (result i32)
  (get_global $B)
 )
 (func $.start (; 1 ;) (type $v)
  (set_global $B
   (i32.const 2)
  )
 )
)

Proposal. How about have two modes "typed strict" and "compatibility"?

Assembly Script is superset of typescript that's mean it should have some compatibility with typescript if I right understand one of the main goal. In this case we might easily portable typescript code to AS with minimal changes. In other hand with WebAssembly we have got int64 arithmetics, atomic operations and etc.

For example in typescript parseInt return double with NaN when something wrong, but in AS we can return i64 which make sense, but we loose compatibility.

My propose is make two macro definitions as compile option modes or string hint. One of them is safe compatibility with JS/TS runtime and other produce code with all wasm capabilities.

Thought?

Proposal. Improve "reinterpret<T1, T2>" signature.

Current declaration

declare function reinterpret<T1 = i32 | i64 | f32 | f64, T2 = i32 | i64 | f32 | f64>(value: T1): T2;

Usage

var flt32: f32 = 1.0;
var Int = reinterpret<f32, i32>(flt32);

Proposal declaration

declare function reinterpret<D = i32 | i64 | f32 | f64, S = i32 | i64 | f32 | f64>(value: S): D;

Proposal Usage

var flt32: f32 = 1.0;
var Int = reinterpret<i32>(flt32); // Usual resolving "S" typename by compiler

Reasons

  1. It's simper and less code.
  2. It's clear and alignment to usual casts like var Int = <i32>(flt32). So it less painful refactoring.

PS Also needs verification for equality sizes of source and destination types

How to use std library

sorry, how do I use 'lib' flag?

asc test.ts  --lib /assemblyscript/std/portable/
ERROR TS2304: Cannot find name 'allocate_memory'.
 	var x=new Test()


asc test.ts  --lib /assemblyscript/std/

<--- Last few GCs --->

[32451:0x3d15dd0]    13131 ms: Mark-sweep 1278.0 (1329.7) -> 1278.0 (1339.7) MB, 876.9 / 0.0 ms  allocation failure GC in old space requested
[32451:0x3d15dd0]    14015 ms: Mark-sweep 1278.0 (1339.7) -> 1278.0 (1303.2) MB, 883.4 / 0.0 ms  last resort GC in old space requested
[32451:0x3d15dd0]    14882 ms: Mark-sweep 1278.0 (1303.2) -> 1278.0 (1303.2) MB, 866.8 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x22f669425529 <JSObject>
    1: /* anonymous */ [/opt/wasm/assemblyscript/dist/assemblyscript.js:~1] [pc=0xef89d1a870d](this=0x2181f4708ed1 <t map = 0xaab3fd8be11>,e=0x105a15ac1459 <t map = 0xaab3fd8c809>)
    2: /* anonymous */ [/opt/wasm/assemblyscript/dist/assemblyscript.js:~1] [pc=0xef89d1aaf44](this=0x2181f4708ed1 <t map = 0xaab3fd8be11>,e=0x105a15ac1459 <t map = 0xaab3fd8c809>,t=0x3bf00bf822d1 <undefined>)
    3: ...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [node]
 2: 0x8cea7c [node]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
 5: v8::internal::Factory::NewUninitializedFixedArray(int) [node]
 6: 0xd88283 [node]
 7: v8::internal::Runtime_GrowArrayElements(int, v8::internal::Object**, v8::internal::Isolate*) [node]
 8: 0xef89d0042fd

Unsigned integer addition does not overflow

Hello! So I think I may have found a bug with unsigned addition.

For more context, CTRL+F 0x34, on this file in my repo: https://github.com/torch2424/wasmBoy/blob/master/wasm/cpu/instructions.ts

So, I noticed if you add the constant 1 to a u8 variable, it will not overflow from 0xFF back down to 0x00.

Here are some code samples:

// Incorrect
let badByte: u8 = 0xFF;
badByte += 1; // badByte = 0x100

//Incorrect
let anotherBadByte: u8 = 0xFF;
let badIncrementer: u8 = 1;
anotherBadByte += badIncrementer // anotherBadByte = 0x100;

// Incorrect
let badderByte: u8 = 0xFF;
let badderIncrementer: u8 = 1;
badderByte += <u8>badderIncrementer // badderByte = 0x100;

// Correct
let goodByte: u8 = 0xFF;
let goodIncrementer = 1;
goodByte = <u8>goodByte + <u8>goodIncrementer; // goodByte = 0x00

There are other places where I need to cast variables already declared as their appropriate types in order to do the correct over flow and things. Please let me know if you need more context.

Thanks!

Status / roadmap

I was wondering if you could share any thoughts about the status or roadmap of this development?

The reason I ask is that I am pretty excited about the prospect of TypeScript => WebAssembly compilation (see my recent blog post: http://blog.scottlogic.com/2017/10/30/migrating-d3-force-layout-to-webassembly.html), and I am looking to explore this further.

I've noticed that TurboScript is no longer being maintained, and speedy.js is inactive - which means your project is the only active TypeScript => WebAssembly compiler!

Do you have a rough idea of when v.Next might be released? And are there opportunities for contribution?

This project generated a lot of interest when it was initially picked up by HN/reddit/twitter, but I don't think that has translated to many users. However, I do think there is mileage in the concept, and as WebAssembly itself evolved, allowing for GC, etc ... this approach will become more and more relevant.

Implement a memory manager

Memory management is pretty much a filler currently and consists of a large linear chunk of non-disposable memory.

Ref: std/assembly/heap.ts

API is:

  • allocate_memory(size: usize): usize
    Pretty much like C's malloc.
  • free_memory(ptr: usize): void
    Pretty much like C's free.

Requirements are, in this order:

  • Should be correct
  • Should be efficient
  • Should be small

TLSF seems to be a viable candidate.

Useful resources:

Slack invites

Hi,

This is in the sidebar:

"Slack (invites on request)"

But there is only the option to sign in when clicking on that link. It says to contact the workspace admin but there is no link to that. How does one request an invite?

is graphics rendering possible?

Hi,

I am looking to render graphics in canvas element via WASM, instead of JavaScript. Is this possible with AssemblyScript?

For example, in game of life demo - rendering is done via javascript, is it possible to move it to assembly code?

Importing functions from other files

Hello! I'm currently working on a large project (for fun) in Assembly script.

And I couldn't quite figure out how to split out my code into multiple files, to be imported/exported in an index.ts.

Here is a link to my assemblyscript files in my repo

I know the project is still very new, and if it is not implemented yet, no worries! Thanks for making this awesome project!

P.S I'm hoping I can find time to contribute, because I'm really looking forward to using this in more projects in the future 😄

Optimize NativeMath/NativeMathf to use WASM builtins where beneficial

For example:

  • There are some places where it appears to make sense to use the copysign instruction instead of using a branch (might need a benchmark)
  • JavaScript's Math.round always rounds exact fractions of 0.5 towards +Infinity, even if negative, and the code currently uses a branch for that.
  • Possibly quite a few more things I haven't yet thought of.

See: std/assembly/math.ts

Implement "export/import * from"

So after creating #21

I now realize why I came to the conclusion import did not work.

If you try export * from 'myfile', you will get the following console output:

screen shot 2018-02-10 at 12 44 02 am

And if I remember correctly, imports dont work this way as well.

Thank you!

Complier freezed while parse class constructor

Current example freezed compiler (It seems stack overflow or infinite loop)

import "allocator/arena";
class Vec2 {
   constructor(public x: f32, public y: f32) {
   }
}
new Vec2(1,2);

Debugger catch unresolved exception in current line:

private unsafeNext(preferIdentifier: bool = false, maxTokenLength: i32 = i32.MAX_VALUE): Token {

Debugging Performance

Hello,

Figured I'd ask here instead of Twitter, just so this is archived in some sort.

So, I'm reaching a point where performance is now my bottleneck on my wasmBoy project before moving onto the final major task :)

By using the chrome dev tools profiler, I can see that my main emulation Loop in wasm is on average taking about 14 seconds to run, which means I should probably work on optimizing that if I hope to reach the 16ms for 60fps.

I'm currently building using the following CLI command: npx asc wasm/index.ts -b dist/wasm/index.untouched.wasm -t dist/wasm/index.untouched.wast -O3z --validate --sourceMap --memoryBase 8861696 && echo \"Built Wasm!\".

And here's a screenshot of my profile if that helps at all:

screen shot 2018-03-12 at 2 28 12 am

I know the project is still very young, therefore performance is something that would be focused on much later.

But if you know any tips/tricks/hacks I could use to get this running a bit fast that would be awesome :). Especially any tips on running benchmarks through the source map or something.

No worries if not, I am sure I could manully go through and find things here and there, but yeah. Thanks!

Support for inline functions and constants

Is it possible to add support for inline functions and constants?

An example of code

const pos:i32 = 10;
store<i32>( pos + 10, 10 );

That should be optimized to

store<i32>( 20, 10 );

ABI proposal: rich pointers

I read about the question how to elegantly distinguish

[0, 1].find(el => el == 0) == 0
[0, 1].find(el => el == 2) == undefined

Did you think about using wasm's i64 as 'rich pointers'?
the first 32 bits could be used for types, the second 32 bits for values.
so 'find' would return (for example) :

0x00000000.00000000 == (int,0) 
0xFF000000.00000000 == (undefined,x) 
0xC0000000.00000048 ==  (char,'A') for primitives
0xC000A000.DEADBEEF = pointer to char array
0x10000000.DEADBEEF = pointer to string
0xA0000000.DEADBEEF = pointer to arguments map {order:'irrelevant',year:2018}
etc

Weird Importing Bug I found on WasmBoy

Hello!

So here is that weird importing bug I found. So I made a branch with an exact commit on WasmBoy where I noticed that I am exporting a function from a file (wasm/memory/index.ts) from another file (wasm/memory/load.ts) that exports said function. I then tried to import the function into another random file (wasm/graphics/graphics.ts), and I get the following error:

screen shot 2018-02-15 at 8 11 50 pm

I have no clue what is causing this, but as you mentioned you don't mind looking into it :) Thanks for the help, and sorry if it is something dumb on my end haha!

Classes

Dear AssemblyScript contributors. This is a fascinating project, well done. I've read a great deal of your documentation, tickets and source code and I'm still getting a handle on Binaryen but wondered if I could ask for a little more detail on what "Classes are still wonky when it comes to the details" means at a lower level? I appreciate this comment comes from the "High Level Summary". I've attempted to compile a simple TS class and it fails so I wanted to troubleshoot it a bit. If someone could point me to some existing work on this that would be a great help Just a "start here" would be helpful... I will most certainly share anything that I learn with the community. Many thanks and kind regards.
/W

A problem with npm and some questions

Hey there!

I have tried to create a simple program following the guide

https://github.com/AssemblyScript/assemblyscript/wiki/Hello-World

but for me the installation via npm doesn't work, when I do npm run build, I get the following:

$ npm run build

> [email protected] build D:\study\asc_test
> npm run build:untouched && npm run build:optimized


> [email protected] build:untouched D:\study\asc_test
> asc assembly/module.ts -t module.untouched.wat -b module.untouched.wasm --validate --sourceMap --measure

Error: Cannot find module './assemblyscript'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (D:\study\asc_test\node_modules\assemblyscript\bin\asc.js:23:22)
    at Module._compile (module.js:624:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build:untouched: `asc assembly/module.ts -t module.untouched.wat -b module.untouched.wasm --validate --sourceMap --measure`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build:untouched script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

However, I have tried tried out the alternative way to install the tool

$> git clone https://github.com/AssemblyScript/assemblyscript.git
$> cd assemblyscript
$> npm install
$> npm link

And it compiled successfully.

However, it will be nice, if you fix the installation via npm.

Also, some questions.

  • Is there a way to import Memory in a script? That is to say, how can I get something like (import "js" "mem" (memory 1)) in the .wasm module?

  • Is there any program API besides the CLI API? As here https://www.npmjs.com/package/assemblyscript#api

  • Why do you switch from the Prototype to the NEXT version? Is the NEXT version something completely new? Will be I right, if I say that it's recommended to use the NEXT version, rather than this module
    https://www.npmjs.com/package/assemblyscript
    ?

  • Also, I wonder, do you plan to implement a support for (data ...) expressions? It's a rather useful thing in case when one needs to define a constant array, for example.

  • And Table (of functions) hasn't been supported yet, hasn't it?

On binary operation common type inference

Copying a note here from the compiler sources for discussion:

TODO: Currently, the common type of any binary expression is the first operand's type. This
differs from C and other languages where comparing an int to a long, in this order, upcasts
left to a long before comparison, instead of failing when trying to downcast right to an int.
NOTE that if we change the current behaviour, some examples, tests and wiki pages will have
to be updated, while compound binary operations must retain the previous behavior.

While I like the current behavior because it rather emits an error instead of doing possibly unwanted implicit type-conversions plus how easy it is to annotate the operation's type on the left operand (<i32>left < right guaranteeing i32.lt_s), it certainly is non-standard and there might be valid reasons to do it like C instead. Feel free to discuss.

inline

Is it possible to add support for inline functions and constants?

An example of code

const pos:i32 = 10;
store<i32>( pos + 10, 10 );

That should be optimized to

store<i32>( 20, 10 );

Avoid masking/sign extension between function calls

Booleans, u8, i8, u16 and i16 are optimized poorly it seems. There is a lot of masking going on at the moment that is not necessary.

Consider the following two functions:

export function add16(x: i16, y: i16): i16 {
  return x + y;
}

export function add32(x: i32, y: i32): i32 {
  return x + y;
}

They get compiled down to:

  (func $main/add16 (export "add16") (type $t0) (param $p0 i32) (param $p1 i32) (result i32)
    get_local $p0
    get_local $p1
    i32.add
    i32.const 16
    i32.shl
    i32.const 16
    i32.shr_s
    return)
  (func $main/add32 (export "add32") (type $t0) (param $p0 i32) (param $p1 i32) (result i32)
    get_local $p0
    get_local $p1
    i32.add
    return)

As you can see, the add16 function has a lot of masking operations, while the add32 is just a pure addition. Compare this to the following Rust code:

#[no_mangle]
pub extern fn add16(x: i16, y: i16) -> i16 {
  x + y
}

#[no_mangle]
pub extern fn add32(x: i32, y: i32) -> i32 {
  x + y
}

Which gets compiled down to the following code:

  (func $add16 (export "add16") (type $t0) (param $p0 i32) (param $p1 i32) (result i32)
    get_local $p1
    get_local $p0
    i32.add)
  (func $add32 (export "add32") (type $t0) (param $p0 i32) (param $p1 i32) (result i32)
    get_local $p1
    get_local $p0
    i32.add)

As you can see, they are the same, as adding two i16 values is the same as adding two i32 values, because the upper 16-bits of the 32-bit wide "register" is getting masked away anyway when storing the 16-bit wide value in memory with a i32.store16_u instruction. So there's only very few instructions where actual masking is necessary (like dividing).

Support UTF-8 strings out of the box

currently strings seem to be encoded in something like utf-16.
(data (i32.const 1000) "\03\00\00\00H\00I\00H\00")
would it be possible to use utf-8 instead (as compile flag or default)?

Support type inference?

Hi.

In current time we know that typescript has a great ability to do type inference and we benefit a lot from it, etc:

export function test(i: number) {
    return i++;
}

Typescript will know that the result of test is number.

Lot of my projects are all strictly typed using type inference, but not explicit declaration, they could not pass your type checking.

Not only the typescript, c++, c#, and many modern languages are supporting type inference, and they could be compiled to wasm now or future. So could asc support it?

Thanks.

asm.js

Is it possible to generate asm.js ?

Array.sort don't work properly

For sorting strings we need stable sort like TimSort.
PS Use temporary InsertionSort (which is stable) for references.

Linking

I want to use this to link it against a C program, is there a way to do this so a function in my C code can be called from the WASM ?

import externs

how can one import unresolved externs, like in wast:
(import "console" "log" (func $log_i32 (param i32)))

Random Indexes of Memory get Cleared

Hello!

So I am not entirely sure if this is on my end or yours, even more unsure than #29 , but I'm really stumped on the issue.

So, If I noticed that pieces of memory I have in my wasm memory this.wasmByteMemory = new Uint8Array(this.wasmInstance.exports.memory.buffer), will get reset back to zero.

Like for example, if I'm expecting values in 0xF9A0, 0xF9A1, 0xF9A2, 0xF9A3. Everything will be fine in the game and then randomly, one of the indexes, 0xF9A0 will be cleared. And here's the scary part, I put listeners with a little wasm "consoleLog" I whipped up in front of all of my store<u8>() and store<u16>() calls, and nothing is written at the address, or near the address to clear the data back to zero.

After spending a few hours on this, and realizing I don't have a deep understanding of how wasm memory works, I thought it may be a variable overflowing into the memory buffer itself? It seems highly unlikely, and again it may be on my end. Sometimes it happens when an event happens in the game, and sometimes it doesn't 🤔

Anyways, if you need more context let me know, and thanks again for all of the help!

EDIT: I thought of more context, you can relate too haha! On tetris, whenever you clear a line, the side brick borders, will replace themself with a 0 zero tile. Like what's up with that? haha!

inline 2

Is it possible to add support for inline functions?

export function test(x:i32, y:i32):i32 {
    x = add( x, 1 );
    y = add( y, 1 );
    return add( x, y );
}

inline function add(x:i32, y:i32):i32 {
    return x + y;
}

That should be optimized to

export function test(x:i32, y:i32):i32 {
    x = x + 1;
    y = y + 1;
    return x + y;
}

Integrate with wasm-bindgen?

You've probably seen this already, but Alex Crichton has created a really useful tool for constructing Rust (WebAssembly) <=> JS bindings:

https://github.com/alexcrichton/wasm-bindgen

The tool is designed to be language independent.

I was wondering if it is with exploring using this tool for AssemblyScript? Or do you currently have a solution for creating a richer WASM <=> JS interface?

GC experimentation

The wasm GC spec is making progress, initial experimental implementations are starting to be worked on in VMs, and there is experimentation in AssemblyScript too. It would be great to be able to connect all these things! That is, to know what the earliest testable GC things in VMs are going to be, so that we can emit them from AssemblyScript and then see that code running in a VM. Then we'd be testing the whole toolchain->VM pipeline.

A possible vague plan:

  • Figure out the right GC things to target, that will be testable soon.
  • Implement those things in Binaryen, defining new APIs as needed.
  • Use those new APIs in AssemblyScript.

(Personally I'd love to help out with this, on the Binaryen parts.)

Custom transformers

Is AssemblyScript planning to support TypeScript-like custom transformers?

Skip compilation of unreachable statements

For example, when tree-shaking constant branches, this works:

if (isReference<T>()) return true;
else { ... eliminated if T is a reference ... }

While this doesn't yet:

if (isReference<T>()) return false;
// compilation continues even if T is a reference

Contribution guide(?)

I don't know how the project is running and if you guys need help with anything, but I've noticed that there is some features in TS/JS that we do not have in AssemblyScript like the JSON parser and stringify. Is there some special reason or it's just because no one implemented it yet? I mean, I've read on an issue that you guys don't want to implement Array.push because you don't want to deal with dynamic arrays, etc.

What would be the best approach: Create a PR adding the feature or create a separated lib like a pollyfill?

I'm trying to study the project to understand how could I help, so a contribution guide and a list of what is needed would be nice.

Compiling hangs forever

When I run asc assembly/module.ts -t module.untouched.wat -b module.untouched.wasm --validate --sourceMap --measure, asc pegs my CPU at 100% and doesn't do anything. module.ts is a single ~370 line TypeScript file.

start function optimization

function init():void {
}
init();

output

(module
 (type $v (func))
 (memory $0 1)
 (export "memory" (memory $0))
 (start $.start)
 (func $init (; 0 ;) (type $v)
  (nop)
 )
 (func $.start (; 1 ;) (type $v)
  (call $init)
 )
)

an unnecessary $.start function is created.
most likely this will automatically be corrected if you add inline function support (#12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.