@harmoniclabs/pebble 0.1.6 → 0.1.8

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.
@@ -2,18 +2,13 @@
2
2
  import { fromHex } from "@harmoniclabs/uint8array-utils";
3
3
  const MAX_SAFE_INTEGER = Number(globalThis.Number?.MAX_SAFE_INTEGER ?? ((2 ** 53) - 1));
4
4
  const MIN_SAFE_INTEGER = Number(globalThis.Number?.MIN_SAFE_INTEGER ?? -MAX_SAFE_INTEGER);
5
- /// @ts-ignore Type 'symbol' does not satisfy the constraint 'object'.
6
- const _sym_to_hash = new WeakMap();
7
- // we cannot store the symbol itself as it would prevent garbage collection
8
- /// @ts-ignore Type 'symbol' does not satisfy the constraint 'object'.
5
+ const _sym_to_hash = new Map();
9
6
  const _hash_to_sym = new Map();
10
7
  let _next_hash = MIN_SAFE_INTEGER;
11
8
  const unusedHashes = [];
12
9
  function _collectUnusedHashes() {
13
10
  for (const [h, s] of _hash_to_sym) {
14
- const newSymbol = s.deref();
15
- if (!newSymbol
16
- || !_sym_to_hash.has(newSymbol)) {
11
+ if (!_sym_to_hash.has(s)) {
17
12
  _hash_to_sym.delete(h);
18
13
  unusedHashes.push(h);
19
14
  }
@@ -34,8 +29,7 @@ export function hashVarSym(s) {
34
29
  throw new Error("ran out of IR hashes");
35
30
  const result_hash = unusedHashes.shift() ?? _next_hash++;
36
31
  _sym_to_hash.set(s, result_hash);
37
- /// @ts-ignore Argument of type 'WeakRef<object>' is not assignable to parameter of type 'WeakRef<symbol>'
38
- _hash_to_sym.set(result_hash, new WeakRef(s));
32
+ _hash_to_sym.set(result_hash, s);
39
33
  return fromHex((BigInt(result_hash) + BigInt(MAX_SAFE_INTEGER))
40
34
  .toString(16)
41
35
  .padStart(16, "0"));
@@ -22,7 +22,6 @@ export declare const hoisted_isMoreThanOrEqualTo4: IRHoisted;
22
22
  export declare const hoisted_sub4: IRHoisted;
23
23
  export declare const hoisted_length: IRHoisted;
24
24
  export declare const hoisted_dropList: IRHoisted;
25
- export declare const hoisted_sizeofPositiveInt: IRHoisted;
26
25
  export declare const hoisted_findSopOptional: IRHoisted;
27
26
  export declare const hoisted_lookupLinearMap: IRHoisted;
28
27
  export declare const hoisted_mkFindDataOptional: IRHoisted;
@@ -99,12 +99,6 @@ const drop_n = Symbol("n");
99
99
  const drop_lst = Symbol("lst");
100
100
  export const hoisted_dropList = new IRHoisted(new IRRecursive(drop_self, new IRFunc([drop_n, drop_lst], _ir_lazyIfThenElse(_ir_apps(hoisted_isMoreThanOrEqualTo4.clone(), new IRVar(drop_n)), _ir_apps(new IRSelfCall(drop_self), _ir_apps(hoisted_sub4.clone(), new IRVar(drop_n)), _ir_apps(hoisted_drop4.clone(), new IRVar(drop_lst))), _ir_lazyIfThenElse(_ir_apps(hoisted_isZero.clone(), new IRVar(drop_n)), new IRVar(drop_lst), _ir_lazyIfThenElse(_ir_apps(hoisted_isOne.clone(), new IRVar(drop_n)), _ir_apps(IRNative.tailList, new IRVar(drop_lst)), _ir_lazyIfThenElse(_ir_apps(hoisted_isTwo.clone(), new IRVar(drop_n)), _ir_apps(hoisted_drop2.clone(), new IRVar(drop_lst)), _ir_apps(hoisted_drop3.clone(), new IRVar(drop_lst)))))))));
101
101
  hoisted_dropList.hash;
102
- const MAX_WORD4 = 0xFFFFFFFF;
103
- // Added missing symbols & refactored hoisted_sizeofPositiveInt if previously numeric
104
- const sizeof_self = Symbol("sizeofPositiveInt_self");
105
- const sizeof_n = Symbol("n");
106
- const sizeof_countWords = Symbol("count_words");
107
- export const hoisted_sizeofPositiveInt = new IRHoisted(_ir_apps(new IRRecursive(sizeof_self, new IRFunc([sizeof_n, sizeof_countWords], new IRForced(_ir_apps(IRNative.strictIfThenElse, _ir_apps(hoisted_isZero.clone(), new IRVar(sizeof_n)), new IRDelayed(new IRForced(_ir_apps(IRNative.strictIfThenElse, _ir_apps(hoisted_isZero.clone(), new IRVar(sizeof_countWords)), new IRDelayed(IRConst.int(4)), new IRDelayed(_ir_apps(IRNative.multiplyInteger, IRConst.int(4), new IRVar(sizeof_countWords)))))), new IRDelayed(_ir_apps(new IRSelfCall(sizeof_self), _ir_apps(hoisted_addOne.clone(), new IRVar(sizeof_countWords)), _ir_apps(IRNative.divideInteger, new IRVar(sizeof_n), IRConst.int(MAX_WORD4)))))))), IRConst.int(0)));
108
102
  const foldl_reduce = Symbol("reduceFunc");
109
103
  const foldl_self = Symbol("foldl_self");
110
104
  const foldl_acc = Symbol("accum");
@@ -229,8 +223,25 @@ hoisted_pairDataFromData.hash;
229
223
  const boolSym = Symbol("bool");
230
224
  export const hoisted_boolToInt = new IRHoisted(new IRFunc([boolSym], _ir_apps(IRNative.strictIfThenElse, new IRVar(boolSym), IRConst.int(1), IRConst.int(0))));
231
225
  hoisted_boolToInt.hash;
232
- const intSym = Symbol("int");
233
- export const hoisted_intToBytesBE = new IRHoisted(new IRFunc([intSym], _ir_apps(IRNative.integerToByteString, IRConst.bool(true), _ir_apps(hoisted_sizeofPositiveInt.clone(), new IRVar(intSym)), new IRVar(intSym))));
226
+ // const intSym = Symbol("int");
227
+ export const hoisted_intToBytesBE = new IRHoisted(
228
+ /*
229
+ new IRFunc(
230
+ [ intSym ],
231
+ _ir_apps(
232
+ IRNative.integerToByteString,
233
+ IRConst.bool( true ),
234
+ _ir_apps(
235
+ hoisted_sizeofPositiveInt.clone(),
236
+ new IRVar( intSym )
237
+ ),
238
+ new IRVar( intSym )
239
+ )
240
+ )
241
+ /*/
242
+ _ir_apps(IRNative.integerToByteString, IRConst.bool(true), IRConst.int(0))
243
+ //*/
244
+ );
234
245
  hoisted_intToBytesBE.hash;
235
246
  // hoisted exponentiateInteger
236
247
  const baseSym = Symbol("base");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harmoniclabs/pebble",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "A simple, yet rock solid, functional language with an imperative bias, targeting UPLC",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",