@harmoniclabs/pebble 0.1.5 → 0.1.7
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.
- package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.d.ts +0 -1
- package/dist/IR/toUPLC/subRoutines/replaceNatives/nativeToIR.js +19 -8
- package/dist/compiler/TirCompiler/expressify/expressifyVars.js +14 -0
- package/dist/compiler/tir/types/utils/canCastTo.js +2 -4
- package/dist/compiler/tir/types/utils/getListTypeArg.js +3 -0
- package/package.json +1 -1
|
@@ -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(
|
|
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");
|
|
@@ -43,6 +43,8 @@ import { TirArrayLikeDeconstr } from "../../tir/statements/TirVarDecl/TirArrayLi
|
|
|
43
43
|
import { TirNamedDeconstructVarDecl } from "../../tir/statements/TirVarDecl/TirNamedDeconstructVarDecl.js";
|
|
44
44
|
import { TirSimpleVarDecl } from "../../tir/statements/TirVarDecl/TirSimpleVarDecl.js";
|
|
45
45
|
import { TirAliasType } from "../../tir/types/TirAliasType.js";
|
|
46
|
+
import { TirBytesT } from "../../tir/types/TirNativeType/native/bytes.js";
|
|
47
|
+
import { TirStringT } from "../../tir/types/TirNativeType/native/string.js";
|
|
46
48
|
import { TirFuncT, TirListT, TirPairDataT } from "../../tir/types/TirNativeType/index.js";
|
|
47
49
|
import { TirLinearMapT } from "../../tir/types/TirNativeType/native/linearMap.js";
|
|
48
50
|
import { TirLinearMapEntryT } from "../../tir/types/TirNativeType/native/linearMapEntry.js";
|
|
@@ -471,6 +473,18 @@ function expressifyMethodCall(ctx, methodCall) {
|
|
|
471
473
|
if (result)
|
|
472
474
|
return result;
|
|
473
475
|
}
|
|
476
|
+
if (objectType instanceof TirBytesT || objectType instanceof TirStringT) {
|
|
477
|
+
const exprRange = SourceRange.join(methodIdentifierProp.range, methodCall.range.atEnd());
|
|
478
|
+
if (methodName === "length") {
|
|
479
|
+
return new TirCallExpr(TirNativeFunc.lengthOfByteString, [objectExpr], int_t, exprRange);
|
|
480
|
+
}
|
|
481
|
+
if (methodName === "subByteString" || methodName === "slice") {
|
|
482
|
+
return new TirCallExpr(TirNativeFunc.sliceByteString, [methodCall.args[0], methodCall.args[1], objectExpr], bytes_t, exprRange);
|
|
483
|
+
}
|
|
484
|
+
if (methodName === "prepend") {
|
|
485
|
+
return new TirCallExpr(TirNativeFunc.consByteString, [methodCall.args[0], objectExpr], bytes_t, exprRange);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
474
488
|
throw new Error(`not implemented::expressifyMethodCall for type '${objectType.toString()}' (method name: '${methodName}')`);
|
|
475
489
|
// const tsEnsureExhautstiveCheck: never = objectType;
|
|
476
490
|
throw new Error(`Cannot call method '${methodName}' on non-struct type '${objectType.toString()}'`);
|
|
@@ -67,10 +67,8 @@ export function canCastTo(a, b) {
|
|
|
67
67
|
return true;
|
|
68
68
|
if (a instanceof TirStringT)
|
|
69
69
|
return true; // string -> bytes // decode utf8
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// we have no idea of the size of ints
|
|
73
|
-
// if( a instanceof TirIntT ) return true;
|
|
70
|
+
if (a instanceof TirIntT)
|
|
71
|
+
return true; // int -> bytes // big endian encoding
|
|
74
72
|
return false;
|
|
75
73
|
}
|
|
76
74
|
if (b instanceof TirStringT) {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { TirAliasType } from "../TirAliasType.js";
|
|
2
2
|
import { TirLinearMapT } from "../TirNativeType/native/linearMap.js";
|
|
3
|
+
import { TirLinearMapEntryT } from "../TirNativeType/native/linearMapEntry.js";
|
|
3
4
|
import { TirListT } from "../TirNativeType/native/list.js";
|
|
4
5
|
export function getListTypeArg(list_t) {
|
|
5
6
|
while (list_t instanceof TirAliasType)
|
|
6
7
|
list_t = list_t.aliased;
|
|
7
8
|
if (list_t instanceof TirListT)
|
|
8
9
|
return list_t.typeArg;
|
|
10
|
+
if (list_t instanceof TirLinearMapT)
|
|
11
|
+
return new TirLinearMapEntryT(list_t.keyTypeArg, list_t.valTypeArg);
|
|
9
12
|
return undefined;
|
|
10
13
|
}
|
|
11
14
|
export function getLinearMapTypeArgs(map_t) {
|
package/package.json
CHANGED