mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-27 07:52:14 +00:00
refactor
This commit is contained in:
parent
661e239fcb
commit
5c25b0cb72
@ -106,15 +106,13 @@ export function FREE(ref: usize): void {
|
||||
/** ArrayBuffer base class. */
|
||||
export abstract class ArrayBufferBase {
|
||||
get byteLength(): i32 {
|
||||
var header = changetype<HEADER>(changetype<usize>(this) - HEADER_SIZE);
|
||||
return header.payloadSize;
|
||||
return changetype<HEADER>(changetype<usize>(this) - HEADER_SIZE).payloadSize;
|
||||
}
|
||||
}
|
||||
|
||||
/** String base class. */
|
||||
export abstract class StringBase {
|
||||
get length(): i32 {
|
||||
var header = changetype<HEADER>(changetype<usize>(this) - HEADER_SIZE);
|
||||
return header.payloadSize >>> 1;
|
||||
return changetype<HEADER>(changetype<usize>(this) - HEADER_SIZE).payloadSize >> 1;
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
(global $std/runtime/ref3 (mut i32) (i32.const 0))
|
||||
(global $std/runtime/ref4 (mut i32) (i32.const 0))
|
||||
(global $std/runtime/header4 (mut i32) (i32.const 0))
|
||||
(global $std/runtime/ref5 (mut i32) (i32.const 0))
|
||||
(export "memory" (memory $0))
|
||||
(export "table" (table $0))
|
||||
(start $start)
|
||||
@ -2707,7 +2708,7 @@
|
||||
else
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 32
|
||||
i32.const 34
|
||||
i32.const 2
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -2818,7 +2819,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 47
|
||||
i32.const 49
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -2830,7 +2831,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 48
|
||||
i32.const 50
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -2844,7 +2845,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 49
|
||||
i32.const 51
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -2856,7 +2857,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 50
|
||||
i32.const 52
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -2871,7 +2872,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 52
|
||||
i32.const 54
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -2887,7 +2888,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 54
|
||||
i32.const 56
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -2904,7 +2905,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 57
|
||||
i32.const 59
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -2929,7 +2930,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 61
|
||||
i32.const 63
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -2940,7 +2941,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 62
|
||||
i32.const 64
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -2956,7 +2957,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 64
|
||||
i32.const 66
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -2968,7 +2969,40 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 65
|
||||
i32.const 67
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
i32.const 10
|
||||
call $~lib/runtime/index/ALLOC
|
||||
global.set $std/runtime/ref5
|
||||
global.get $std/runtime/ref5
|
||||
i32.const 16
|
||||
i32.sub
|
||||
i32.load offset=4
|
||||
i32.const 10
|
||||
i32.ne
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 70
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
global.get $std/runtime/ref5
|
||||
i32.const 16
|
||||
i32.sub
|
||||
i32.load offset=4
|
||||
i32.const 1
|
||||
i32.shr_u
|
||||
i32.const 5
|
||||
i32.ne
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 71
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
|
@ -16,7 +16,9 @@ import {
|
||||
ALLOC,
|
||||
REALLOC,
|
||||
FREE,
|
||||
REGISTER
|
||||
REGISTER,
|
||||
ArrayBufferBase,
|
||||
StringBase
|
||||
} from "runtime";
|
||||
|
||||
class A {}
|
||||
@ -63,3 +65,7 @@ assert(register_parentRef == ref3);
|
||||
var header4 = changetype<HEADER>(register_ref - HEADER_SIZE);
|
||||
assert(header4.classId == __rt_classid<A>());
|
||||
assert(header4.payloadSize == barrier1);
|
||||
|
||||
var ref5 = ALLOC(10);
|
||||
assert(changetype<ArrayBufferBase>(ref5).byteLength == 10);
|
||||
assert(changetype<StringBase>(ref5).length == 5);
|
||||
|
@ -48,6 +48,7 @@
|
||||
(global $std/runtime/ref3 (mut i32) (i32.const 0))
|
||||
(global $std/runtime/ref4 (mut i32) (i32.const 0))
|
||||
(global $std/runtime/header4 (mut i32) (i32.const 0))
|
||||
(global $std/runtime/ref5 (mut i32) (i32.const 0))
|
||||
(global $~lib/memory/HEAP_BASE i32 (i32.const 208))
|
||||
(export "memory" (memory $0))
|
||||
(export "table" (table $0))
|
||||
@ -3398,7 +3399,21 @@
|
||||
local.get $1
|
||||
global.set $std/runtime/register_parentRef
|
||||
)
|
||||
(func $start:std/runtime (; 32 ;) (type $FUNCSIG$v)
|
||||
(func $~lib/runtime/index/ArrayBufferBase#get:byteLength (; 32 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
|
||||
local.get $0
|
||||
i32.const 16
|
||||
i32.sub
|
||||
i32.load offset=4
|
||||
)
|
||||
(func $~lib/runtime/index/StringBase#get:length (; 33 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
|
||||
local.get $0
|
||||
i32.const 16
|
||||
i32.sub
|
||||
i32.load offset=4
|
||||
i32.const 1
|
||||
i32.shr_u
|
||||
)
|
||||
(func $start:std/runtime (; 34 ;) (type $FUNCSIG$v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
call $start:~lib/allocator/tlsf
|
||||
@ -3409,7 +3424,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 24
|
||||
i32.const 26
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -3422,7 +3437,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 30
|
||||
i32.const 32
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -3443,7 +3458,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 32
|
||||
i32.const 34
|
||||
i32.const 2
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -3546,7 +3561,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 47
|
||||
i32.const 49
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -3559,7 +3574,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 48
|
||||
i32.const 50
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -3573,7 +3588,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 49
|
||||
i32.const 51
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -3586,7 +3601,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 50
|
||||
i32.const 52
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -3602,7 +3617,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 52
|
||||
i32.const 54
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -3619,7 +3634,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 54
|
||||
i32.const 56
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -3636,7 +3651,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 57
|
||||
i32.const 59
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -3664,7 +3679,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 61
|
||||
i32.const 63
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -3676,7 +3691,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 62
|
||||
i32.const 64
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -3693,7 +3708,7 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 64
|
||||
i32.const 66
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
@ -3706,15 +3721,44 @@
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 65
|
||||
i32.const 67
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
i32.const 10
|
||||
call $~lib/runtime/index/ALLOC
|
||||
global.set $std/runtime/ref5
|
||||
global.get $std/runtime/ref5
|
||||
call $~lib/runtime/index/ArrayBufferBase#get:byteLength
|
||||
i32.const 10
|
||||
i32.eq
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 70
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
global.get $std/runtime/ref5
|
||||
call $~lib/runtime/index/StringBase#get:length
|
||||
i32.const 5
|
||||
i32.eq
|
||||
i32.eqz
|
||||
if
|
||||
i32.const 0
|
||||
i32.const 56
|
||||
i32.const 71
|
||||
i32.const 0
|
||||
call $~lib/env/abort
|
||||
unreachable
|
||||
end
|
||||
)
|
||||
(func $start (; 33 ;) (type $FUNCSIG$v)
|
||||
(func $start (; 35 ;) (type $FUNCSIG$v)
|
||||
call $start:std/runtime
|
||||
)
|
||||
(func $null (; 34 ;) (type $FUNCSIG$v)
|
||||
(func $null (; 36 ;) (type $FUNCSIG$v)
|
||||
)
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user