@harmoniclabs/pebble 0.1.1 → 0.1.2
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.
|
@@ -8,15 +8,18 @@ import { IRRecursive } from "../../../IRNodes/IRRecursive.js";
|
|
|
8
8
|
import { IRSelfCall } from "../../../IRNodes/IRSelfCall.js";
|
|
9
9
|
import { IRVar } from "../../../IRNodes/IRVar.js";
|
|
10
10
|
import { _modifyChildFromTo } from "../../_internal/_modifyChildFromTo.js";
|
|
11
|
-
import { isDebugUplcOptimizations } from "../../CompilerOptions.js";
|
|
12
11
|
import { expandFuncsAndReturnRoot } from "./expandFuncsAndReturnRoot.js";
|
|
13
12
|
import { getApplicationTerms } from "../../utils/getApplicationTerms.js";
|
|
14
13
|
import { getUnboundedVars } from "../handleLetted/groupByScope.js";
|
|
15
14
|
export function performUplcOptimizationsAndReturnRoot(root, options) {
|
|
16
|
-
const opts = options.uplcOptimizations;
|
|
17
|
-
if
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
// const opts = options.uplcOptimizations;
|
|
16
|
+
// if( isDebugUplcOptimizations( opts ) ) return root;
|
|
17
|
+
// const {
|
|
18
|
+
// groupApplications,
|
|
19
|
+
// inlineSingleUse: shouldInlineSingleUse,
|
|
20
|
+
// simplifyWrappedPartialFuncApps,
|
|
21
|
+
// removeForceDelay
|
|
22
|
+
// } = opts;
|
|
20
23
|
root = expandFuncsAndReturnRoot(root);
|
|
21
24
|
const stack = [root];
|
|
22
25
|
let t = root;
|
|
@@ -40,6 +43,23 @@ export function performUplcOptimizationsAndReturnRoot(root, options) {
|
|
|
40
43
|
stack.push(nextBody);
|
|
41
44
|
continue;
|
|
42
45
|
}
|
|
46
|
+
// group 3 or more consecutive applications into a case
|
|
47
|
+
const consecutiveAppTerms = getApplicationTerms(t);
|
|
48
|
+
if (consecutiveAppTerms) {
|
|
49
|
+
const { func, args } = consecutiveAppTerms;
|
|
50
|
+
if (args.length > 2) {
|
|
51
|
+
const newTerm = new IRCase(new IRConstr(0, args), [func]);
|
|
52
|
+
if (t.parent)
|
|
53
|
+
_modifyChildFromTo(t.parent, t, newTerm);
|
|
54
|
+
else
|
|
55
|
+
root = newTerm;
|
|
56
|
+
stack.push(...args, func);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
// else normal application traversing
|
|
60
|
+
stack.push(...args, func);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
43
63
|
if (t instanceof IRRecursive ||
|
|
44
64
|
t instanceof IRHoisted ||
|
|
45
65
|
t instanceof IRLetted ||
|
package/package.json
CHANGED