porffor 0.55.32 → 0.55.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,168 +18,7 @@ import type {} from './porffor.d.ts';
18
18
  // enumerable - 0b0100
19
19
  // writable - 0b1000
20
20
 
21
- export const __Porffor_object_isObject = (arg: any): boolean => {
22
- const t: i32 = Porffor.wasm`local.get ${arg+1}`;
23
- return Porffor.fastAnd(
24
- arg != 0, // null
25
- t > 0x05,
26
- t != Porffor.TYPES.string,
27
- t != Porffor.TYPES.bytestring
28
- );
29
- };
30
-
31
- export const __Porffor_object_isObjectOrNull = (arg: any): boolean => {
32
- const t: i32 = Porffor.wasm`local.get ${arg+1}`;
33
- return Porffor.fastAnd(
34
- t > 0x05,
35
- t != Porffor.TYPES.string,
36
- t != Porffor.TYPES.bytestring
37
- );
38
- };
39
-
40
- export const __Porffor_object_isObjectOrSymbol = (arg: any): boolean => {
41
- const t: i32 = Porffor.wasm`local.get ${arg+1}`;
42
- return Porffor.fastAnd(
43
- arg != 0, // null
44
- t > 0x04,
45
- t != Porffor.TYPES.string,
46
- t != Porffor.TYPES.bytestring
47
- );
48
- };
49
-
50
-
51
- export const __Porffor_object_preventExtensions = (obj: any): void => {
52
- if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
53
- obj = __Porffor_object_underlying(obj);
54
- if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) return;
55
- }
56
-
57
- Porffor.wasm.i32.store8(obj, Porffor.wasm.i32.load8_u(obj, 0, 2) | 0b0001, 0, 2);
58
- };
59
-
60
- export const __Porffor_object_isInextensible = (obj: any): boolean => {
61
- if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
62
- obj = __Porffor_object_underlying(obj);
63
- if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) return false;
64
- }
65
-
66
- return (Porffor.wasm.i32.load8_u(obj, 0, 2) & 0b0001) as boolean;
67
- };
68
-
69
- export const __Porffor_object_setPrototype = (obj: any, proto: any): void => {
70
- if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
71
- obj = __Porffor_object_underlying(obj);
72
- if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) return;
73
- }
74
-
75
- if (__Porffor_object_isObjectOrNull(proto)) {
76
- Porffor.wasm.i32.store(obj, proto, 0, 4);
77
- Porffor.wasm.i32.store8(obj, Porffor.rawType(proto), 0, 3);
78
- }
79
- };
80
-
81
- export const __Porffor_object_getPrototype = (obj: any): any => {
82
- if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
83
- obj = __Porffor_object_underlying(obj);
84
- if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
85
- // return empty
86
- Porffor.wasm`
87
- i32.const 0
88
- i32.const 0
89
- return`;
90
- }
91
- }
92
-
93
- Porffor.wasm`
94
- local.get ${obj}
95
- i32.load 0 4
96
- local.get ${obj}
97
- i32.load8_u 0 3
98
- return`;
99
- };
100
-
101
-
102
- export const __Porffor_object_overrideAllFlags = (obj: any, overrideOr: i32, overrideAnd: i32): void => {
103
- if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
104
- obj = __Porffor_object_underlying(obj);
105
- if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) return;
106
- }
107
-
108
- let ptr: i32 = Porffor.wasm`local.get ${obj}`;
109
-
110
- const size: i32 = Porffor.wasm.i32.load16_u(obj, 0, 0);
111
- const endPtr: i32 = ptr + size * 18;
112
-
113
- for (; ptr < endPtr; ptr += 18) {
114
- let flags: i32 = Porffor.wasm.i32.load8_u(ptr, 0, 24);
115
- flags = (flags | overrideOr) & overrideAnd;
116
- Porffor.wasm.i32.store8(ptr, flags, 0, 24);
117
- }
118
- };
119
-
120
- export const __Porffor_object_checkAllFlags = (obj: any, dataAnd: i32, accessorAnd: i32, dataExpected: i32, accessorExpected: i32): boolean => {
121
- if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
122
- obj = __Porffor_object_underlying(obj);
123
- if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) return false;
124
- }
125
-
126
- let ptr: i32 = Porffor.wasm`local.get ${obj}`;
127
-
128
- const size: i32 = Porffor.wasm.i32.load16_u(obj, 0, 0);
129
- const endPtr: i32 = ptr + size * 18;
130
-
131
- for (; ptr < endPtr; ptr += 18) {
132
- const flags: i32 = Porffor.wasm.i32.load8_u(ptr, 0, 24);
133
- if (flags & 0b0001) {
134
- // accessor
135
- if ((flags & accessorAnd) != accessorExpected) return false;
136
- } else {
137
- // data
138
- if ((flags & dataAnd) != dataExpected) return false;
139
- }
140
-
141
- }
142
-
143
- return true;
144
- };
145
-
146
- export const __Porffor_object_packAccessor = (get: any, set: any): f64 => {
147
- // pack i32s get & set into a single f64 (reinterpreted u64)
148
- Porffor.wasm`
149
- local.get ${set}
150
- i64.extend_i32_u
151
- i64.const 32
152
- i64.shl
153
- local.get ${get}
154
- i64.extend_i32_u
155
- i64.or
156
- f64.reinterpret_i64
157
- return`;
158
- };
159
-
160
- export const __Porffor_object_accessorGet = (entryPtr: i32): Function|undefined => {
161
- const out: Function = Porffor.wasm.i32.load(entryPtr, 0, 8);
162
-
163
- // no getter, return undefined
164
- if (Porffor.wasm`local.get ${out}` == 0) {
165
- return undefined;
166
- }
167
-
168
- return out;
169
- };
170
-
171
- export const __Porffor_object_accessorSet = (entryPtr: i32): Function|undefined => {
172
- const out: Function = Porffor.wasm.i32.load(entryPtr, 0, 12);
173
-
174
- // no setter, return undefined
175
- if (Porffor.wasm`local.get ${out}` == 0) {
176
- return undefined;
177
- }
178
-
179
- return out;
180
- };
181
-
182
-
21
+ // hash key for hashmap
183
22
  export const __Porffor_object_hash = (key: any): i32 => {
184
23
  if (Porffor.wasm`local.get ${key+1}` == Porffor.TYPES.symbol) {
185
24
  // symbol, hash is unused so just return 0
@@ -362,6 +201,318 @@ local.set ${hash}`;
362
201
  return hash;
363
202
  };
364
203
 
204
+ export const __Porffor_object_writeKey = (ptr: i32, key: any, hash: i32): void => {
205
+ // write hash to ptr
206
+ Porffor.wasm.i32.store(ptr, hash, 0, 0);
207
+
208
+ // encode key type
209
+ let keyEnc: i32 = Porffor.wasm`local.get ${key}`;
210
+
211
+ // set MSB 1 if regular string
212
+ if (Porffor.wasm`local.get ${key+1}` == Porffor.TYPES.string) keyEnc |= 0x80000000;
213
+ // set MSB 1&2 if symbol
214
+ else if (Porffor.wasm`local.get ${key+1}` == Porffor.TYPES.symbol) keyEnc |= 0xc0000000;
215
+
216
+ // write encoded key to ptr + 4
217
+ Porffor.wasm.i32.store(ptr, keyEnc, 0, 4);
218
+ };
219
+
220
+ export const __Porffor_object_fastAdd = (obj: any, key: any, value: any, flags: i32): void => {
221
+ // add new entry
222
+ // bump size +1
223
+ const size: i32 = Porffor.wasm.i32.load16_u(obj, 0, 0);
224
+ Porffor.wasm.i32.store16(obj, size + 1, 0, 0);
225
+
226
+ // entryPtr = current end of object
227
+ const entryPtr: i32 = Porffor.wasm`local.get ${obj}` + 8 + size * 18;
228
+ __Porffor_object_writeKey(entryPtr, key, __Porffor_object_hash(key));
229
+
230
+ // write new value value
231
+ Porffor.wasm.f64.store(entryPtr, value, 0, 8);
232
+
233
+ // write new tail (value type + flags)
234
+ Porffor.wasm.i32.store16(entryPtr,
235
+ flags + (Porffor.wasm`local.get ${value+1}` << 8),
236
+ 0, 16);
237
+ };
238
+
239
+ // store underlying (real) objects for hidden types
240
+ let underlyingStore: i32 = 0;
241
+ export const __Porffor_object_underlying = (_obj: any): any => {
242
+ if (Porffor.type(_obj) == Porffor.TYPES.object) {
243
+ Porffor.wasm`
244
+ local.get ${_obj}
245
+ i32.trunc_sat_f64_u
246
+ i32.const 7 ;; object
247
+ return`;
248
+ }
249
+
250
+ if (Porffor.fastAnd(
251
+ Porffor.type(_obj) >= Porffor.TYPES.error,
252
+ Porffor.type(_obj) < 0x40
253
+ )) {
254
+ Porffor.wasm`
255
+ local.get ${_obj}
256
+ i32.trunc_sat_f64_u
257
+ i32.const 7 ;; object
258
+ return`;
259
+ }
260
+
261
+ if (Porffor.fastAnd(
262
+ Porffor.type(_obj) > 0x05,
263
+ Porffor.type(_obj) != Porffor.TYPES.undefined
264
+ )) {
265
+ if (underlyingStore == 0) underlyingStore = Porffor.allocate();
266
+
267
+ // check if underlying object already exists for obj
268
+ const underlyingLength: i32 = Porffor.wasm.i32.load(underlyingStore, 0, 0);
269
+ const end: i32 = underlyingLength * 12;
270
+ for (let i: i32 = 0; i < end; i += 12) {
271
+ if (Porffor.wasm.f64.eq(Porffor.wasm.f64.load(underlyingStore + i, 0, 4), _obj))
272
+ return Porffor.wasm.i32.load(underlyingStore + i, 0, 12) as object;
273
+ }
274
+
275
+ let obj;
276
+ Porffor.wasm`
277
+ local.get ${_obj}
278
+ i32.trunc_sat_f64_u
279
+ local.set ${obj}`;
280
+
281
+ // it does not, make it
282
+ const underlying: object = {};
283
+ if (Porffor.type(_obj) == Porffor.TYPES.function) {
284
+ if (ecma262.IsConstructor(_obj)) { // constructor
285
+ // set prototype and prototype.constructor if function and constructor
286
+ const proto: object = {};
287
+ __Porffor_object_fastAdd(underlying, 'prototype', proto, 0b1000);
288
+ __Porffor_object_fastAdd(proto, 'constructor', _obj, 0b1010);
289
+ }
290
+
291
+ __Porffor_object_fastAdd(underlying, 'name', __Porffor_funcLut_name(obj), 0b0010);
292
+ __Porffor_object_fastAdd(underlying, 'length', __Porffor_funcLut_length(obj), 0b0010);
293
+ }
294
+
295
+ if (Porffor.type(_obj) == Porffor.TYPES.array) {
296
+ const len: i32 = Porffor.wasm.i32.load(obj, 0, 0);
297
+ __Porffor_object_fastAdd(underlying, 'length', len, 0b1000);
298
+
299
+ // todo: this should somehow be kept in sync?
300
+ for (let i: i32 = 0; i < len; i++) {
301
+ let ptr: i32 = obj + i * 9;
302
+ Porffor.wasm`
303
+ local x f64
304
+ local x#type i32
305
+ local.get ${ptr}
306
+ f64.load 0 4
307
+ local.set x
308
+
309
+ local.get ${ptr}
310
+ i32.load8_u 0 12
311
+ local.set x#type`;
312
+ __Porffor_object_fastAdd(underlying, __Number_prototype_toString(i), x, 0b1110);
313
+ }
314
+ }
315
+
316
+ if (Porffor.fastOr(
317
+ Porffor.type(_obj) == Porffor.TYPES.string,
318
+ Porffor.type(_obj) == Porffor.TYPES.stringobject)
319
+ ) {
320
+ const len: i32 = (obj as string).length;
321
+ __Porffor_object_fastAdd(underlying, 'length', len, 0b0000);
322
+
323
+ for (let i: i32 = 0; i < len; i++) {
324
+ __Porffor_object_fastAdd(underlying, __Number_prototype_toString(i), (obj as string)[i], 0b0100);
325
+ }
326
+
327
+ if (Porffor.type(_obj) == Porffor.TYPES.string) Porffor.wasm.i32.store8(obj, 0b0001, 0, 2); // make inextensible
328
+ }
329
+
330
+ if (Porffor.type(_obj) == Porffor.TYPES.bytestring) {
331
+ const len: i32 = (obj as bytestring).length;
332
+ __Porffor_object_fastAdd(underlying, 'length', len, 0b0000);
333
+
334
+ for (let i: i32 = 0; i < len; i++) {
335
+ __Porffor_object_fastAdd(underlying, __Number_prototype_toString(i), (obj as bytestring)[i], 0b0100);
336
+ }
337
+
338
+ Porffor.wasm.i32.store8(obj, 0b0001, 0, 2); // make inextensible
339
+ }
340
+
341
+ // store new underlying obj
342
+ Porffor.wasm.i32.store(underlyingStore, underlyingLength + 1, 0, 0);
343
+ Porffor.wasm.f64.store(underlyingStore + underlyingLength * 12, _obj, 0, 4);
344
+ Porffor.wasm.i32.store(underlyingStore + underlyingLength * 12, underlying, 0, 12);
345
+ return underlying;
346
+ }
347
+
348
+ Porffor.wasm`
349
+ local.get ${_obj}
350
+ i32.trunc_sat_f64_u
351
+ local.get ${_obj+1}
352
+ return`;
353
+ };
354
+
355
+ export const __Porffor_object_isObject = (arg: any): boolean => {
356
+ const t: i32 = Porffor.wasm`local.get ${arg+1}`;
357
+ return Porffor.fastAnd(
358
+ arg != 0, // null
359
+ t > 0x05,
360
+ t != Porffor.TYPES.string,
361
+ t != Porffor.TYPES.bytestring
362
+ );
363
+ };
364
+
365
+ export const __Porffor_object_isObjectOrNull = (arg: any): boolean => {
366
+ const t: i32 = Porffor.wasm`local.get ${arg+1}`;
367
+ return Porffor.fastAnd(
368
+ t > 0x05,
369
+ t != Porffor.TYPES.string,
370
+ t != Porffor.TYPES.bytestring
371
+ );
372
+ };
373
+
374
+ export const __Porffor_object_isObjectOrSymbol = (arg: any): boolean => {
375
+ const t: i32 = Porffor.wasm`local.get ${arg+1}`;
376
+ return Porffor.fastAnd(
377
+ arg != 0, // null
378
+ t > 0x04,
379
+ t != Porffor.TYPES.string,
380
+ t != Porffor.TYPES.bytestring
381
+ );
382
+ };
383
+
384
+
385
+ export const __Porffor_object_preventExtensions = (obj: any): void => {
386
+ if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
387
+ obj = __Porffor_object_underlying(obj);
388
+ if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) return;
389
+ }
390
+
391
+ Porffor.wasm.i32.store8(obj, Porffor.wasm.i32.load8_u(obj, 0, 2) | 0b0001, 0, 2);
392
+ };
393
+
394
+ export const __Porffor_object_isInextensible = (obj: any): boolean => {
395
+ if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
396
+ obj = __Porffor_object_underlying(obj);
397
+ if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) return false;
398
+ }
399
+
400
+ return (Porffor.wasm.i32.load8_u(obj, 0, 2) & 0b0001) as boolean;
401
+ };
402
+
403
+ export const __Porffor_object_setPrototype = (obj: any, proto: any): void => {
404
+ if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
405
+ obj = __Porffor_object_underlying(obj);
406
+ if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) return;
407
+ }
408
+
409
+ if (__Porffor_object_isObjectOrNull(proto)) {
410
+ Porffor.wasm.i32.store(obj, proto, 0, 4);
411
+ Porffor.wasm.i32.store8(obj, Porffor.type(proto), 0, 3);
412
+ }
413
+ };
414
+
415
+ export const __Porffor_object_getPrototype = (obj: any): any => {
416
+ if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
417
+ obj = __Porffor_object_underlying(obj);
418
+ if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
419
+ // return empty
420
+ Porffor.wasm`
421
+ i32.const 0
422
+ i32.const 0
423
+ return`;
424
+ }
425
+ }
426
+
427
+ Porffor.wasm`
428
+ local.get ${obj}
429
+ i32.load 0 4
430
+ local.get ${obj}
431
+ i32.load8_u 0 3
432
+ return`;
433
+ };
434
+
435
+
436
+ export const __Porffor_object_overrideAllFlags = (obj: any, overrideOr: i32, overrideAnd: i32): void => {
437
+ if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
438
+ obj = __Porffor_object_underlying(obj);
439
+ if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) return;
440
+ }
441
+
442
+ let ptr: i32 = Porffor.wasm`local.get ${obj}`;
443
+
444
+ const size: i32 = Porffor.wasm.i32.load16_u(obj, 0, 0);
445
+ const endPtr: i32 = ptr + size * 18;
446
+
447
+ for (; ptr < endPtr; ptr += 18) {
448
+ let flags: i32 = Porffor.wasm.i32.load8_u(ptr, 0, 24);
449
+ flags = (flags | overrideOr) & overrideAnd;
450
+ Porffor.wasm.i32.store8(ptr, flags, 0, 24);
451
+ }
452
+ };
453
+
454
+ export const __Porffor_object_checkAllFlags = (obj: any, dataAnd: i32, accessorAnd: i32, dataExpected: i32, accessorExpected: i32): boolean => {
455
+ if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
456
+ obj = __Porffor_object_underlying(obj);
457
+ if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) return false;
458
+ }
459
+
460
+ let ptr: i32 = Porffor.wasm`local.get ${obj}`;
461
+
462
+ const size: i32 = Porffor.wasm.i32.load16_u(obj, 0, 0);
463
+ const endPtr: i32 = ptr + size * 18;
464
+
465
+ for (; ptr < endPtr; ptr += 18) {
466
+ const flags: i32 = Porffor.wasm.i32.load8_u(ptr, 0, 24);
467
+ if (flags & 0b0001) {
468
+ // accessor
469
+ if ((flags & accessorAnd) != accessorExpected) return false;
470
+ } else {
471
+ // data
472
+ if ((flags & dataAnd) != dataExpected) return false;
473
+ }
474
+
475
+ }
476
+
477
+ return true;
478
+ };
479
+
480
+ export const __Porffor_object_packAccessor = (get: any, set: any): f64 => {
481
+ // pack i32s get & set into a single f64 (reinterpreted u64)
482
+ Porffor.wasm`
483
+ local.get ${set}
484
+ i64.extend_i32_u
485
+ i64.const 32
486
+ i64.shl
487
+ local.get ${get}
488
+ i64.extend_i32_u
489
+ i64.or
490
+ f64.reinterpret_i64
491
+ return`;
492
+ };
493
+
494
+ export const __Porffor_object_accessorGet = (entryPtr: i32): Function|undefined => {
495
+ const out: Function = Porffor.wasm.i32.load(entryPtr, 0, 8);
496
+
497
+ // no getter, return undefined
498
+ if (Porffor.wasm`local.get ${out}` == 0) {
499
+ return undefined;
500
+ }
501
+
502
+ return out;
503
+ };
504
+
505
+ export const __Porffor_object_accessorSet = (entryPtr: i32): Function|undefined => {
506
+ const out: Function = Porffor.wasm.i32.load(entryPtr, 0, 12);
507
+
508
+ // no setter, return undefined
509
+ if (Porffor.wasm`local.get ${out}` == 0) {
510
+ return undefined;
511
+ }
512
+
513
+ return out;
514
+ };
515
+
365
516
  export const __Porffor_object_lookup = (obj: any, target: any, targetHash: i32): i32 => {
366
517
  if (Porffor.wasm`local.get ${obj}` == 0) return -1;
367
518
  if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
@@ -489,22 +640,6 @@ i32.shr_u
489
640
  return`;
490
641
  };
491
642
 
492
- export const __Porffor_object_writeKey = (ptr: i32, key: any, hash: i32 = __Porffor_object_hash(key)): void => {
493
- // write hash to ptr
494
- Porffor.wasm.i32.store(ptr, hash, 0, 0);
495
-
496
- // encode key type
497
- let keyEnc: i32 = Porffor.wasm`local.get ${key}`;
498
-
499
- // set MSB 1 if regular string
500
- if (Porffor.wasm`local.get ${key+1}` == Porffor.TYPES.string) keyEnc |= 0x80000000;
501
- // set MSB 1&2 if symbol
502
- else if (Porffor.wasm`local.get ${key+1}` == Porffor.TYPES.symbol) keyEnc |= 0xc0000000;
503
-
504
- // write encoded key to ptr + 4
505
- Porffor.wasm.i32.store(ptr, keyEnc, 0, 4);
506
- };
507
-
508
643
  export const __Porffor_object_set = (obj: any, key: any, value: any): any => {
509
644
  if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) {
510
645
  obj = __Porffor_object_underlying(obj);
@@ -519,13 +654,7 @@ export const __Porffor_object_set = (obj: any, key: any, value: any): any => {
519
654
  if (entryPtr == -1) {
520
655
  if (hash == -406948493) if (key == '__proto__') {
521
656
  // set prototype
522
- Porffor.wasm`
523
- local.get ${obj}
524
- local.get ${obj+1}
525
- local.get ${value}
526
- i32.trunc_sat_f64_u
527
- local.get ${value+1}
528
- call __Porffor_object_setPrototype`;
657
+ __Porffor_object_setPrototype(obj, value);
529
658
  return value;
530
659
  }
531
660
 
@@ -629,13 +758,7 @@ export const __Porffor_object_setStrict = (obj: any, key: any, value: any): any
629
758
  if (entryPtr == -1) {
630
759
  if (hash == -406948493) if (key == '__proto__') {
631
760
  // set prototype
632
- Porffor.wasm`
633
- local.get ${obj}
634
- local.get ${obj+1}
635
- local.get ${value}
636
- i32.trunc_sat_f64_u
637
- local.get ${value+1}
638
- call __Porffor_object_setPrototype`;
761
+ __Porffor_object_setPrototype(obj, value);
639
762
  return value;
640
763
  }
641
764
 
@@ -908,15 +1031,9 @@ export const __Porffor_object_expr_init = (obj: any, key: any, value: any): void
908
1031
  const hash: i32 = __Porffor_object_hash(key);
909
1032
  let entryPtr: i32 = __Porffor_object_lookup(obj, key, hash);
910
1033
  if (entryPtr == -1) {
911
- if (key == '__proto__') {
1034
+ if (hash == -406948493) if (key == '__proto__') {
912
1035
  // set prototype
913
- Porffor.wasm`
914
- local.get ${obj}
915
- local.get ${obj+1}
916
- local.get ${value}
917
- i32.trunc_sat_f64_u
918
- local.get ${value+1}
919
- call __Porffor_object_setPrototype`;
1036
+ __Porffor_object_setPrototype(obj, value);
920
1037
  return value;
921
1038
  }
922
1039
 
@@ -940,43 +1057,6 @@ call __Porffor_object_setPrototype`;
940
1057
  0, 16);
941
1058
  };
942
1059
 
943
- export const __Porffor_object_expr_initWithFlags = (obj: any, key: any, value: any, flags: i32): void => {
944
- if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) obj = __Porffor_object_underlying(obj);
945
-
946
- const hash: i32 = __Porffor_object_hash(key);
947
- let entryPtr: i32 = __Porffor_object_lookup(obj, key, hash);
948
- if (entryPtr == -1) {
949
- if (key == '__proto__') {
950
- // set prototype
951
- Porffor.wasm`
952
- local.get ${obj}
953
- local.get ${obj+1}
954
- local.get ${value}
955
- i32.trunc_sat_f64_u
956
- local.get ${value+1}
957
- call __Porffor_object_setPrototype`;
958
- return value;
959
- }
960
-
961
- // add new entry
962
- // bump size +1
963
- const size: i32 = Porffor.wasm.i32.load16_u(obj, 0, 0);
964
- Porffor.wasm.i32.store16(obj, size + 1, 0, 0);
965
-
966
- // entryPtr = current end of object
967
- entryPtr = Porffor.wasm`local.get ${obj}` + 8 + size * 18;
968
- __Porffor_object_writeKey(entryPtr, key, hash);
969
- }
970
-
971
- // write new value value
972
- Porffor.wasm.f64.store(entryPtr, value, 0, 8);
973
-
974
- // write new tail (value type + flags)
975
- Porffor.wasm.i32.store16(entryPtr,
976
- flags + (Porffor.wasm`local.get ${value+1}` << 8),
977
- 0, 16);
978
- };
979
-
980
1060
  // used for { get foo() {} }
981
1061
  export const __Porffor_object_expr_get = (obj: any, key: any, get: any): void => {
982
1062
  if (Porffor.wasm`local.get ${obj+1}` != Porffor.TYPES.object) obj = __Porffor_object_underlying(obj);
@@ -1,8 +1,8 @@
1
1
  import type {} from './porffor.d.ts';
2
2
 
3
3
  export const __Porffor_compareStrings = (a: any, b: any): boolean => {
4
- let at: i32 = Porffor.rawType(a);
5
- let bt: i32 = Porffor.rawType(b);
4
+ let at: i32 = Porffor.type(a);
5
+ let bt: i32 = Porffor.type(b);
6
6
 
7
7
  if ((at | 0b10000000) != Porffor.TYPES.bytestring) {
8
8
  // a is not string or bytestring
@@ -36,8 +36,8 @@ export const __Porffor_compareStrings = (a: any, b: any): boolean => {
36
36
  };
37
37
 
38
38
  export const __Porffor_concatStrings = (a: any, b: any): any => {
39
- let at: i32 = Porffor.rawType(a);
40
- let bt: i32 = Porffor.rawType(b);
39
+ let at: i32 = Porffor.type(a);
40
+ let bt: i32 = Porffor.type(b);
41
41
 
42
42
  if ((at | 0b10000000) != Porffor.TYPES.bytestring) {
43
43
  // a is not string or bytestring
@@ -1,12 +1,11 @@
1
1
  export default () => {
2
2
  let out = ``;
3
3
  const noArgs = (a0, a1) => out += `
4
- export const __String_prototype_${a0} = (_this: any) => {
5
- const pre: bytestring = '<${a1}>';
6
- const post: bytestring = '</${a1}>';
4
+ export const __String_prototype_${a0} = (_this: any) =>
5
+ Porffor.concatStrings(
6
+ Porffor.concatStrings('<${a1}>', _this),
7
+ '</${a1}>');
7
8
 
8
- return Porffor.concatStrings(Porffor.concatStrings(pre, _this), post);
9
- };
10
9
  export const __ByteString_prototype_${a0} = (_this: any) =>
11
10
  __String_prototype_${a0}(_this);
12
11
  `;
@@ -22,13 +21,15 @@ export const __ByteString_prototype_${a0} = (_this: any) =>
22
21
  noArgs('sup', 'sup');
23
22
 
24
23
  const arg = (name, s1, s2) => out += `
25
- export const __String_prototype_${name} = (_this: any, arg: any) => {
26
- const pre1: bytestring = '<${s1} ${s2}="';
27
- const pre2: bytestring = '">';
28
- const post: bytestring = '</${s1}>';
24
+ export const __String_prototype_${name} = (_this: any, arg: any) =>
25
+ Porffor.concatStrings(
26
+ Porffor.concatStrings(
27
+ Porffor.concatStrings(
28
+ Porffor.concatStrings('<${s1} ${s2}="', arg),
29
+ '">'),
30
+ _this),
31
+ '</${s1}>');
29
32
 
30
- return Porffor.concatStrings(Porffor.concatStrings(Porffor.concatStrings(Porffor.concatStrings(pre1, arg), pre2), _this), post);
31
- };
32
33
  export const __ByteString_prototype_${name} = (_this: any, arg: any) =>
33
34
  __String_prototype_${name}(_this, arg);
34
35
  `;