fix export star module exports, shiftify

This commit is contained in:
dcode 2019-04-18 20:36:51 +02:00
parent 2b0a165e7f
commit 2dec52976a
11 changed files with 192 additions and 159 deletions

View File

@ -687,6 +687,9 @@ export abstract class Node {
range.source.normalizedPath
);
} else { // absolute
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) {
normalizedPath = LIBRARY_PREFIX + normalizedPath;
}
stmt.normalizedPath = normalizedPath;
}
stmt.internalPath = mangleInternalPath(stmt.normalizedPath);
@ -782,10 +785,18 @@ export abstract class Node {
stmt.declarations = null;
stmt.namespaceName = identifier;
stmt.path = path;
var normalizedPath = normalizePath(path.value);
if (path.value.startsWith(".")) {
stmt.normalizedPath = resolvePath(
normalizePath(path.value),
normalizedPath,
range.source.normalizedPath
);
} else {
if (!normalizedPath.startsWith(LIBRARY_PREFIX)) {
normalizedPath = LIBRARY_PREFIX + normalizedPath;
}
stmt.normalizedPath = normalizedPath;
}
stmt.internalPath = mangleInternalPath(stmt.normalizedPath);
return stmt;
}

View File

@ -716,7 +716,12 @@ export class Compiler extends DiagnosticEmitter {
var exports = file.exports;
if (exports) for (let element of exports.values()) this.compileElement(element);
var exportsStar = file.exportsStar;
if (exportsStar) for (let exportStar of exportsStar) this.compileFile(exportStar);
if (exportsStar) {
for (let exportStar of exportsStar) {
this.compileFile(exportStar);
this.compileExports(exportStar);
}
}
}
// files

View File

@ -6,7 +6,7 @@ import { ROOT, Block, BLOCK_OVERHEAD, initializeRoot, allocateBlock, reallocateB
// @ts-ignore: decorator
@global @unsafe
function __rt_allocate(size: usize, id: u32): usize {
export function __rt_allocate(size: usize, id: u32): usize {
var root = ROOT;
if (!root) {
initializeRoot();
@ -19,7 +19,7 @@ function __rt_allocate(size: usize, id: u32): usize {
// @ts-ignore: decorator
@global @unsafe
function __rt_reallocate(ref: usize, size: usize): usize {
export function __rt_reallocate(ref: usize, size: usize): usize {
if (DEBUG) assert(ROOT); // must be initialized
assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned
return changetype<usize>(reallocateBlock(ROOT, changetype<Block>(ref - BLOCK_OVERHEAD), size)) + BLOCK_OVERHEAD;
@ -27,7 +27,7 @@ function __rt_reallocate(ref: usize, size: usize): usize {
// @ts-ignore: decorator
@global @unsafe
function __rt_free(ref: usize): void {
export function __rt_free(ref: usize): void {
if (DEBUG) assert(ROOT); // must be initialized
assert(ref != 0 && !(ref & AL_MASK)); // must exist and be aligned
freeBlock(ROOT, changetype<Block>(ref - BLOCK_OVERHEAD));
@ -39,18 +39,20 @@ import { increment, decrement, collectCycles } from "./pure";
// @ts-ignore: decorator
@global @unsafe
function __rt_retain(ref: usize): void {
export function __rt_retain(ref: usize): void {
if (ref) increment(changetype<Block>(ref - BLOCK_OVERHEAD));
}
// @ts-ignore: decorator
@global @unsafe
function __rt_release(ref: usize): void {
export function __rt_release(ref: usize): void {
if (ref) decrement(changetype<Block>(ref - BLOCK_OVERHEAD));
}
// @ts-ignore: decorator
@global @unsafe
function __rt_collect(): void {
export function __rt_collect(): void {
collectCycles();
}
export { __rt_typeinfo };

View File

@ -20,7 +20,7 @@ var offset: usize = startOffset;
// @ts-ignore: decorator
@unsafe @global
function __rt_allocate(size: usize, id: u32): usize {
export function __rt_allocate(size: usize, id: u32): usize {
if (size > BLOCK_MAXSIZE) unreachable();
var ptr = offset + BLOCK_OVERHEAD;
var newPtr = (ptr + max<usize>(size, 1) + AL_MASK) & ~AL_MASK;
@ -41,7 +41,7 @@ function __rt_allocate(size: usize, id: u32): usize {
// @ts-ignore: decorator
@unsafe @global
function __rt_reallocate(ref: usize, size: usize): usize {
export function __rt_reallocate(ref: usize, size: usize): usize {
var block = changetype<CommonBlock>(ref - BLOCK_OVERHEAD);
var oldSize = <usize>block.rtSize;
if (size > oldSize) {
@ -56,12 +56,12 @@ function __rt_reallocate(ref: usize, size: usize): usize {
// @ts-ignore: decorator
@unsafe @global
function __rt_free(ref: usize): void {
export function __rt_free(ref: usize): void {
}
// @ts-ignore: decorator
@unsafe @global
function __rt_reset(): void { // special
export function __rt_reset(): void { // special
offset = startOffset;
}
@ -69,15 +69,17 @@ function __rt_reset(): void { // special
// @ts-ignore: decorator
@global @unsafe
function __rt_retain(ref: usize): void {
export function __rt_retain(ref: usize): void {
}
// @ts-ignore: decorator
@global @unsafe
function __rt_release(ref: usize): void {
export function __rt_release(ref: usize): void {
}
// @ts-ignore: decorator
@global @unsafe
function __rt_collect(): void {
export function __rt_collect(): void {
}
export { __rt_typeinfo };

View File

@ -146,37 +146,60 @@ import { AL_BITS, AL_SIZE, AL_MASK, DEBUG, CommonBlock } from "./common";
/** Gets the second level map of the specified first level. */
// @ts-ignore: decorator
@inline function GETSL(root: Root, fl: usize): u32 {
return load<u32>(changetype<usize>(root) + (fl << alignof<u32>()), SL_START);
return load<u32>(
changetype<usize>(root) + (fl << alignof<u32>()),
SL_START
);
}
/** Sets the second level map of the specified first level. */
// @ts-ignore: decorator
@inline function SETSL(root: Root, fl: usize, slMap: u32): void {
store<u32>(changetype<usize>(root) + (fl << alignof<u32>()), slMap, SL_START);
store<u32>(
changetype<usize>(root) + (fl << alignof<u32>()),
slMap,
SL_START
);
}
/** Gets the head of the free list for the specified combination of first and second level. */
// @ts-ignore: decorator
@inline function GETHEAD(root: Root, fl: usize, sl: u32): Block | null {
return changetype<Block>(load<usize>(changetype<usize>(root) + (fl * SL_SIZE + <usize>sl) * sizeof<usize>(), HL_START));
return changetype<Block>(
load<usize>(
changetype<usize>(root) + (((fl << SL_BITS) + <usize>sl) << alignof<usize>()),
HL_START
)
);
}
/** Sets the head of the free list for the specified combination of first and second level. */
// @ts-ignore: decorator
@inline function SETHEAD(root: Root, fl: usize, sl: u32, head: Block | null): void {
store<usize>(changetype<usize>(root) + (fl * SL_SIZE + <usize>sl) * sizeof<usize>() , changetype<usize>(head), HL_START);
store<usize>(
changetype<usize>(root) + (((fl << SL_BITS) + <usize>sl) << alignof<usize>()),
changetype<usize>(head),
HL_START
);
}
/** Gets the tail block.. */
// @ts-ignore: decorator
@inline function GETTAIL(root: Root): Block {
return load<Block>(changetype<usize>(root), HL_END);
return load<Block>(
changetype<usize>(root),
HL_END
);
}
/** Sets the tail block. */
// @ts-ignore: decorator
@inline function SETTAIL(root: Root, tail: Block): void {
store<Block>(changetype<usize>(root), tail, HL_END);
store<Block>(
changetype<usize>(root),
tail,
HL_END
);
}
/** Inserts a previously used block back into the free list. */
@ -229,7 +252,7 @@ function insertBlock(root: Root, block: Block): void {
var fl: usize, sl: u32;
if (size < SB_SIZE) {
fl = 0;
sl = <u32>(size / AL_SIZE);
sl = <u32>(size >> AL_BITS);
} else {
const inv: usize = sizeof<usize>() * 8 - 1;
fl = inv - clz<usize>(size);
@ -261,7 +284,7 @@ function removeBlock(root: Root, block: Block): void {
var fl: usize, sl: u32;
if (size < SB_SIZE) {
fl = 0;
sl = <u32>(size / AL_SIZE);
sl = <u32>(size >> AL_BITS);
} else {
const inv: usize = sizeof<usize>() * 8 - 1;
fl = inv - clz<usize>(size);
@ -302,7 +325,7 @@ function searchBlock(root: Root, size: usize): Block | null {
var fl: usize, sl: u32;
if (size < SB_SIZE) {
fl = 0;
sl = <u32>(size / AL_SIZE);
sl = <u32>(size >> AL_BITS);
} else {
const halfMaxSize = BLOCK_MAXSIZE >> 1; // don't round last fl
const inv: usize = sizeof<usize>() * 8 - 1;

View File

@ -29,8 +29,8 @@
i32.lt_u
if (result i32)
local.get $2
i32.const 16
i32.div_u
i32.const 4
i32.shr_u
local.set $4
i32.const 0
else
@ -248,8 +248,8 @@
i32.lt_u
if (result i32)
local.get $2
i32.const 16
i32.div_u
i32.const 4
i32.shr_u
local.set $2
i32.const 0
else
@ -497,7 +497,7 @@
if
i32.const 0
i32.const 24
i32.const 427
i32.const 450
i32.const 29
call $~lib/builtins/abort
unreachable
@ -523,8 +523,8 @@
i32.lt_u
if (result i32)
local.get $1
i32.const 16
i32.div_u
i32.const 4
i32.shr_u
local.set $1
i32.const 0
else

View File

@ -41,7 +41,7 @@
if
i32.const 0
i32.const 24
i32.const 256
i32.const 279
i32.const 13
call $~lib/builtins/abort
unreachable
@ -66,7 +66,7 @@
if
i32.const 0
i32.const 24
i32.const 258
i32.const 281
i32.const 13
call $~lib/builtins/abort
unreachable
@ -78,8 +78,8 @@
i32.const 0
local.set $4
local.get $3
i32.const 16
i32.div_u
i32.const 4
i32.shr_u
local.set $5
else
i32.const 31
@ -118,7 +118,7 @@
if
i32.const 0
i32.const 24
i32.const 271
i32.const 294
i32.const 13
call $~lib/builtins/abort
unreachable
@ -151,12 +151,12 @@
local.set $8
local.get $10
local.get $9
i32.const 16
i32.mul
i32.const 4
i32.shl
local.get $8
i32.add
i32.const 4
i32.mul
i32.const 2
i32.shl
i32.add
i32.load offset=96
end
@ -173,12 +173,12 @@
local.set $8
local.get $11
local.get $10
i32.const 16
i32.mul
i32.const 4
i32.shl
local.get $9
i32.add
i32.const 4
i32.mul
i32.const 2
i32.shl
i32.add
local.get $8
i32.store offset=96
@ -256,7 +256,7 @@
if
i32.const 0
i32.const 24
i32.const 184
i32.const 207
i32.const 13
call $~lib/builtins/abort
unreachable
@ -271,7 +271,7 @@
if
i32.const 0
i32.const 24
i32.const 186
i32.const 209
i32.const 13
call $~lib/builtins/abort
unreachable
@ -370,7 +370,7 @@
if
i32.const 0
i32.const 24
i32.const 207
i32.const 230
i32.const 15
call $~lib/builtins/abort
unreachable
@ -433,7 +433,7 @@
if
i32.const 0
i32.const 24
i32.const 222
i32.const 245
i32.const 13
call $~lib/builtins/abort
unreachable
@ -449,7 +449,7 @@
if
i32.const 0
i32.const 24
i32.const 223
i32.const 246
i32.const 13
call $~lib/builtins/abort
unreachable
@ -466,8 +466,8 @@
i32.const 0
local.set $9
local.get $8
i32.const 16
i32.div_u
i32.const 4
i32.shr_u
local.set $10
else
i32.const 31
@ -506,7 +506,7 @@
if
i32.const 0
i32.const 24
i32.const 239
i32.const 262
i32.const 13
call $~lib/builtins/abort
unreachable
@ -520,12 +520,12 @@
local.set $7
local.get $3
local.get $6
i32.const 16
i32.mul
i32.const 4
i32.shl
local.get $7
i32.add
i32.const 4
i32.mul
i32.const 2
i32.shl
i32.add
i32.load offset=96
end
@ -553,12 +553,12 @@
local.set $7
local.get $12
local.get $3
i32.const 16
i32.mul
i32.const 4
i32.shl
local.get $6
i32.add
i32.const 4
i32.mul
i32.const 2
i32.shl
i32.add
local.get $7
i32.store offset=96
@ -629,7 +629,7 @@
if
i32.const 0
i32.const 24
i32.const 365
i32.const 388
i32.const 4
call $~lib/builtins/abort
unreachable
@ -654,7 +654,7 @@
if
i32.const 0
i32.const 24
i32.const 375
i32.const 398
i32.const 15
call $~lib/builtins/abort
unreachable
@ -685,7 +685,7 @@
if
i32.const 0
i32.const 24
i32.const 387
i32.const 410
i32.const 4
call $~lib/builtins/abort
unreachable
@ -862,12 +862,12 @@
local.set $6
local.get $9
local.get $8
i32.const 16
i32.mul
i32.const 4
i32.shl
local.get $7
i32.add
i32.const 4
i32.mul
i32.const 2
i32.shl
i32.add
local.get $6
i32.store offset=96
@ -918,7 +918,7 @@
if
i32.const 0
i32.const 24
i32.const 427
i32.const 450
i32.const 29
call $~lib/builtins/abort
unreachable
@ -954,8 +954,8 @@
i32.const 0
local.set $2
local.get $1
i32.const 16
i32.div_u
i32.const 4
i32.shr_u
local.set $3
else
local.get $1
@ -1012,7 +1012,7 @@
if
i32.const 0
i32.const 24
i32.const 317
i32.const 340
i32.const 13
call $~lib/builtins/abort
unreachable
@ -1077,7 +1077,7 @@
if
i32.const 0
i32.const 24
i32.const 330
i32.const 353
i32.const 17
call $~lib/builtins/abort
unreachable
@ -1092,12 +1092,12 @@
local.set $5
local.get $9
local.get $8
i32.const 16
i32.mul
i32.const 4
i32.shl
local.get $5
i32.add
i32.const 4
i32.mul
i32.const 2
i32.shl
i32.add
i32.load offset=96
end
@ -1114,12 +1114,12 @@
local.set $4
local.get $8
local.get $5
i32.const 16
i32.mul
i32.const 4
i32.shl
local.get $4
i32.add
i32.const 4
i32.mul
i32.const 2
i32.shl
i32.add
i32.load offset=96
end
@ -1195,7 +1195,7 @@
if
i32.const 0
i32.const 24
i32.const 344
i32.const 367
i32.const 13
call $~lib/builtins/abort
unreachable
@ -1306,7 +1306,7 @@
if
i32.const 0
i32.const 24
i32.const 457
i32.const 480
i32.const 15
call $~lib/builtins/abort
unreachable
@ -1324,7 +1324,7 @@
if
i32.const 0
i32.const 24
i32.const 459
i32.const 482
i32.const 13
call $~lib/builtins/abort
unreachable
@ -1388,7 +1388,7 @@
if
i32.const 0
i32.const 24
i32.const 510
i32.const 533
i32.const 2
call $~lib/builtins/abort
unreachable

View File

@ -1,13 +1,3 @@
import "rt";
export {
__rt_allocate,
__rt_reallocate,
__rt_free,
__rt_retain,
__rt_release,
__rt_collect,
__rt_typeinfo
};
export * from "rt";
@start export function main(): void {}

View File

@ -49,8 +49,8 @@
i32.lt_u
if (result i32)
local.get $2
i32.const 16
i32.div_u
i32.const 4
i32.shr_u
local.set $4
i32.const 0
else
@ -268,8 +268,8 @@
i32.lt_u
if (result i32)
local.get $2
i32.const 16
i32.div_u
i32.const 4
i32.shr_u
local.set $2
i32.const 0
else
@ -517,7 +517,7 @@
if
i32.const 0
i32.const 24
i32.const 427
i32.const 450
i32.const 29
call $~lib/builtins/abort
unreachable
@ -543,8 +543,8 @@
i32.lt_u
if (result i32)
local.get $1
i32.const 16
i32.div_u
i32.const 4
i32.shr_u
local.set $1
i32.const 0
else

Binary file not shown.

View File

@ -63,7 +63,7 @@
if
i32.const 0
i32.const 24
i32.const 256
i32.const 279
i32.const 13
call $~lib/builtins/abort
unreachable
@ -88,7 +88,7 @@
if
i32.const 0
i32.const 24
i32.const 258
i32.const 281
i32.const 13
call $~lib/builtins/abort
unreachable
@ -100,8 +100,8 @@
i32.const 0
local.set $4
local.get $3
i32.const 16
i32.div_u
i32.const 4
i32.shr_u
local.set $5
else
i32.const 31
@ -140,7 +140,7 @@
if
i32.const 0
i32.const 24
i32.const 271
i32.const 294
i32.const 13
call $~lib/builtins/abort
unreachable
@ -173,12 +173,12 @@
local.set $8
local.get $10
local.get $9
i32.const 16
i32.mul
i32.const 4
i32.shl
local.get $8
i32.add
i32.const 4
i32.mul
i32.const 2
i32.shl
i32.add
i32.load offset=96
end
@ -195,12 +195,12 @@
local.set $8
local.get $11
local.get $10
i32.const 16
i32.mul
i32.const 4
i32.shl
local.get $9
i32.add
i32.const 4
i32.mul
i32.const 2
i32.shl
i32.add
local.get $8
i32.store offset=96
@ -278,7 +278,7 @@
if
i32.const 0
i32.const 24
i32.const 184
i32.const 207
i32.const 13
call $~lib/builtins/abort
unreachable
@ -293,7 +293,7 @@
if
i32.const 0
i32.const 24
i32.const 186
i32.const 209
i32.const 13
call $~lib/builtins/abort
unreachable
@ -392,7 +392,7 @@
if
i32.const 0
i32.const 24
i32.const 207
i32.const 230
i32.const 15
call $~lib/builtins/abort
unreachable
@ -455,7 +455,7 @@
if
i32.const 0
i32.const 24
i32.const 222
i32.const 245
i32.const 13
call $~lib/builtins/abort
unreachable
@ -471,7 +471,7 @@
if
i32.const 0
i32.const 24
i32.const 223
i32.const 246
i32.const 13
call $~lib/builtins/abort
unreachable
@ -488,8 +488,8 @@
i32.const 0
local.set $9
local.get $8
i32.const 16
i32.div_u
i32.const 4
i32.shr_u
local.set $10
else
i32.const 31
@ -528,7 +528,7 @@
if
i32.const 0
i32.const 24
i32.const 239
i32.const 262
i32.const 13
call $~lib/builtins/abort
unreachable
@ -542,12 +542,12 @@
local.set $7
local.get $3
local.get $6
i32.const 16
i32.mul
i32.const 4
i32.shl
local.get $7
i32.add
i32.const 4
i32.mul
i32.const 2
i32.shl
i32.add
i32.load offset=96
end
@ -575,12 +575,12 @@
local.set $7
local.get $12
local.get $3
i32.const 16
i32.mul
i32.const 4
i32.shl
local.get $6
i32.add
i32.const 4
i32.mul
i32.const 2
i32.shl
i32.add
local.get $7
i32.store offset=96
@ -651,7 +651,7 @@
if
i32.const 0
i32.const 24
i32.const 365
i32.const 388
i32.const 4
call $~lib/builtins/abort
unreachable
@ -676,7 +676,7 @@
if
i32.const 0
i32.const 24
i32.const 375
i32.const 398
i32.const 15
call $~lib/builtins/abort
unreachable
@ -707,7 +707,7 @@
if
i32.const 0
i32.const 24
i32.const 387
i32.const 410
i32.const 4
call $~lib/builtins/abort
unreachable
@ -884,12 +884,12 @@
local.set $6
local.get $9
local.get $8
i32.const 16
i32.mul
i32.const 4
i32.shl
local.get $7
i32.add
i32.const 4
i32.mul
i32.const 2
i32.shl
i32.add
local.get $6
i32.store offset=96
@ -940,7 +940,7 @@
if
i32.const 0
i32.const 24
i32.const 427
i32.const 450
i32.const 29
call $~lib/builtins/abort
unreachable
@ -976,8 +976,8 @@
i32.const 0
local.set $2
local.get $1
i32.const 16
i32.div_u
i32.const 4
i32.shr_u
local.set $3
else
local.get $1
@ -1034,7 +1034,7 @@
if
i32.const 0
i32.const 24
i32.const 317
i32.const 340
i32.const 13
call $~lib/builtins/abort
unreachable
@ -1099,7 +1099,7 @@
if
i32.const 0
i32.const 24
i32.const 330
i32.const 353
i32.const 17
call $~lib/builtins/abort
unreachable
@ -1114,12 +1114,12 @@
local.set $5
local.get $9
local.get $8
i32.const 16
i32.mul
i32.const 4
i32.shl
local.get $5
i32.add
i32.const 4
i32.mul
i32.const 2
i32.shl
i32.add
i32.load offset=96
end
@ -1136,12 +1136,12 @@
local.set $4
local.get $8
local.get $5
i32.const 16
i32.mul
i32.const 4
i32.shl
local.get $4
i32.add
i32.const 4
i32.mul
i32.const 2
i32.shl
i32.add
i32.load offset=96
end
@ -1217,7 +1217,7 @@
if
i32.const 0
i32.const 24
i32.const 344
i32.const 367
i32.const 13
call $~lib/builtins/abort
unreachable
@ -1328,7 +1328,7 @@
if
i32.const 0
i32.const 24
i32.const 457
i32.const 480
i32.const 15
call $~lib/builtins/abort
unreachable
@ -1346,7 +1346,7 @@
if
i32.const 0
i32.const 24
i32.const 459
i32.const 482
i32.const 13
call $~lib/builtins/abort
unreachable
@ -1622,7 +1622,7 @@
if
i32.const 0
i32.const 24
i32.const 472
i32.const 495
i32.const 13
call $~lib/builtins/abort
unreachable
@ -1789,7 +1789,7 @@
if
i32.const 0
i32.const 24
i32.const 510
i32.const 533
i32.const 2
call $~lib/builtins/abort
unreachable