Rework resolver (#489)

* Rework IR and resolver to use nested lookup tables
* Integrate types into IR
* Make components prefer IR, slimmed down AST
* Implement `export *`
* Add `@lazy` annotation and remove `--noTreeShaking`
* Add `@start` annotation and remove magic `main`
* Related refactoring, cleanup and docs
This commit is contained in:
Daniel Wirtz
2019-02-21 00:11:22 +01:00
committed by GitHub
parent e623786b42
commit 0c64f21250
234 changed files with 16949 additions and 37871 deletions

View File

@ -1,20 +1,16 @@
(module
(type $ii (func (param i32) (result i32)))
(type $_ (func))
(type $iiii (func (param i32 i32 i32) (result i32)))
(type $iFFF (func (param i32 f64 f64) (result f64)))
(type $_ (func))
(memory $0 0)
(table $0 1 funcref)
(elem (i32.const 0) $null)
(global $~lib/internal/allocator/AL_BITS i32 (i32.const 3))
(global $~lib/internal/allocator/AL_SIZE i32 (i32.const 8))
(global $~lib/internal/allocator/AL_MASK i32 (i32.const 7))
(global $~lib/internal/allocator/MAX_SIZE_32 i32 (i32.const 1073741824))
(global $~lib/allocator/arena/startOffset (mut i32) (i32.const 0))
(global $~lib/allocator/arena/offset (mut i32) (i32.const 0))
(global $optional-typeparameters/tConcrete (mut i32) (i32.const 0))
(global $optional-typeparameters/tDerived (mut i32) (i32.const 0))
(global $HEAP_BASE i32 (i32.const 8))
(global $~lib/memory/HEAP_BASE i32 (i32.const 8))
(export "memory" (memory $0))
(export "table" (table $0))
(start $start)
@ -24,7 +20,19 @@
(func $optional-typeparameters/testDerived<i32,i32> (; 1 ;) (type $ii) (param $0 i32) (result i32)
local.get $0
)
(func $~lib/allocator/arena/__memory_allocate (; 2 ;) (type $ii) (param $0 i32) (result i32)
(func $start:~lib/allocator/arena (; 2 ;) (type $_)
global.get $~lib/memory/HEAP_BASE
i32.const 7
i32.add
i32.const 7
i32.const -1
i32.xor
i32.and
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
)
(func $~lib/allocator/arena/__memory_allocate (; 3 ;) (type $ii) (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
(local $3 i32)
@ -32,7 +40,7 @@
(local $5 i32)
(local $6 i32)
local.get $0
global.get $~lib/internal/allocator/MAX_SIZE_32
i32.const 1073741824
i32.gt_u
if
unreachable
@ -49,9 +57,9 @@
i32.gt_u
select
i32.add
global.get $~lib/internal/allocator/AL_MASK
i32.const 7
i32.add
global.get $~lib/internal/allocator/AL_MASK
i32.const 7
i32.const -1
i32.xor
i32.and
@ -103,12 +111,12 @@
global.set $~lib/allocator/arena/offset
local.get $1
)
(func $~lib/memory/memory.allocate (; 3 ;) (type $ii) (param $0 i32) (result i32)
(func $~lib/memory/memory.allocate (; 4 ;) (type $ii) (param $0 i32) (result i32)
local.get $0
call $~lib/allocator/arena/__memory_allocate
return
)
(func $optional-typeparameters/TestConcrete<i32,i32>#constructor (; 4 ;) (type $ii) (param $0 i32) (result i32)
(func $optional-typeparameters/TestConcrete<i32,i32>#constructor (; 5 ;) (type $ii) (param $0 i32) (result i32)
local.get $0
i32.eqz
if
@ -118,12 +126,12 @@
end
local.get $0
)
(func $optional-typeparameters/TestConcrete<i32,i32>#test<i32> (; 5 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(func $optional-typeparameters/TestConcrete<i32,i32>#test<i32> (; 6 ;) (type $iiii) (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
local.get $1
local.get $2
i32.add
)
(func $optional-typeparameters/TestDerived<f64,f64>#constructor (; 6 ;) (type $ii) (param $0 i32) (result i32)
(func $optional-typeparameters/TestDerived<f64,f64>#constructor (; 7 ;) (type $ii) (param $0 i32) (result i32)
local.get $0
i32.eqz
if
@ -133,28 +141,19 @@
end
local.get $0
)
(func $optional-typeparameters/TestDerived<f64,f64>#test<f64> (; 7 ;) (type $iFFF) (param $0 i32) (param $1 f64) (param $2 f64) (result f64)
(func $optional-typeparameters/TestDerived<f64,f64>#test<f64> (; 8 ;) (type $iFFF) (param $0 i32) (param $1 f64) (param $2 f64) (result f64)
local.get $1
local.get $2
f64.add
)
(func $start (; 8 ;) (type $_)
(func $start:optional-typeparameters (; 9 ;) (type $_)
i32.const 1
call $optional-typeparameters/testConcrete<i32,i32>
drop
i32.const 2
call $optional-typeparameters/testDerived<i32,i32>
drop
global.get $HEAP_BASE
global.get $~lib/internal/allocator/AL_MASK
i32.add
global.get $~lib/internal/allocator/AL_MASK
i32.const -1
i32.xor
i32.and
global.set $~lib/allocator/arena/startOffset
global.get $~lib/allocator/arena/startOffset
global.set $~lib/allocator/arena/offset
call $start:~lib/allocator/arena
i32.const 0
call $optional-typeparameters/TestConcrete<i32,i32>#constructor
global.set $optional-typeparameters/tConcrete
@ -172,6 +171,9 @@
call $optional-typeparameters/TestDerived<f64,f64>#test<f64>
drop
)
(func $null (; 9 ;) (type $_)
(func $start (; 10 ;) (type $_)
call $start:optional-typeparameters
)
(func $null (; 11 ;) (type $_)
)
)