@@ -89,7 +89,7 @@ export function FREE(ref: usize): void {
89
89
}
90
90
91
91
/** Registers a managed object with GC. */
92
- export function REGISTER < T > ( ref : usize ) : void {
92
+ export function REGISTER < T > ( ref : usize , parentRef : usize ) : void {
93
93
var header = UNREF ( ref ) ;
94
94
header . classId = /* TODO: CLASSID<T>() */ 1 ;
95
95
header . reserved2 = 0 ;
@@ -98,49 +98,18 @@ export function REGISTER<T>(ref: usize): void {
98
98
99
99
// === ArrayBuffer ================================================================================
100
100
101
- /** Size of a buffer header, excl. common runtime header. */
102
- @inline export const BUFFER_HEADER_SIZE : usize = ( offsetof < ArrayBuffer > ( ) + AL_MASK ) & ~ AL_MASK ;
103
-
104
- /** Allocates a new ArrayBuffer and returns a pointer to it. */
105
- @inline export function ALLOC_BUFFER ( byteLength : u32 ) : ArrayBuffer {
106
- return changetype < ArrayBuffer > ( ALLOC ( BUFFER_HEADER_SIZE + byteLength ) ) ;
107
- }
108
-
109
- /** Reallocates an ArrayBuffer if necessary. Returns a pointer to it. */
110
- @inline export function REALLOC_BUFFER ( ref : usize , byteLength : u32 ) : ArrayBuffer {
111
- return changetype < ArrayBuffer > ( REALLOC ( ref , BUFFER_HEADER_SIZE + byteLength ) ) ;
112
- }
113
-
114
- /** Loads a value from a backing ArrayBuffer. */
115
- @inline export function LOAD_BUFFER < T , TOut = T > ( buffer : ArrayBuffer , index : i32 , byteOffset : i32 = 0 ) : TOut {
116
- return < TOut > load < T > (
117
- changetype < usize > ( buffer ) + ( < usize > index << alignof < T > ( ) ) + < usize > byteOffset ,
118
- BUFFER_HEADER_SIZE
119
- ) ;
120
- }
121
-
122
- /** Stores a value to a backing ArrayBuffer. */
123
- @inline export function STORE_BUFFER < T , TIn = T > ( buffer : ArrayBuffer , index : i32 , value : TIn , byteOffset : i32 = 0 ) : void {
124
- store < T > (
125
- changetype < usize > ( buffer ) + ( < usize > index << alignof < T > ( ) ) + < usize > byteOffset ,
126
- value ,
127
- BUFFER_HEADER_SIZE
128
- ) ;
101
+ export abstract class ArrayBufferBase {
102
+ get byteLength ( ) : i32 {
103
+ var header = changetype < HEADER > ( changetype < usize > ( this ) - HEADER_SIZE ) ;
104
+ return header . payloadSize ;
105
+ }
129
106
}
130
107
131
108
// === String =====================================================================================
132
109
133
- /** Size of a string header, excl. common runtime header. */
134
- @inline export const STRING_HEADER_SIZE : usize = ( offsetof < String > ( ) + 1 ) & ~ 1 ; // 2 byte aligned
135
-
136
- /** Allocates a new String and returns a pointer to it. */
137
- @inline export function ALLOC_STRING ( length : u32 ) : String {
138
- return changetype < String > ( ALLOC ( STRING_HEADER_SIZE + ( length << 1 ) ) ) ;
139
- }
140
-
141
- /** Reallocates a String if necessary. Returns a pointer to it. */
142
- @inline export function REALLOC_STRING ( ref : usize , length : u32 ) : String {
143
- return changetype < String > ( REALLOC ( ref , STRING_HEADER_SIZE + ( length << 1 ) ) ) ;
110
+ export abstract class StringBase {
111
+ get length ( ) : i32 {
112
+ var header = changetype < HEADER > ( changetype < usize > ( this ) - HEADER_SIZE ) ;
113
+ return header . payloadSize >>> 1 ;
114
+ }
144
115
}
145
-
146
- // ...
0 commit comments