@thi.ng/shader-ast-optimize 0.4.14 → 0.4.15
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/CHANGELOG.md +1 -1
- package/constant-folding.js +10 -20
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
package/constant-folding.js
CHANGED
|
@@ -98,37 +98,27 @@ const foldNode = defmulti(
|
|
|
98
98
|
const isNumR = isLitNumericConst(r);
|
|
99
99
|
if (isNumL && isNumR) {
|
|
100
100
|
const num = maybeFoldMath(op, l.val, r.val);
|
|
101
|
-
if (num !== void 0)
|
|
102
|
-
return replaceNumericNode(node, num);
|
|
101
|
+
if (num !== void 0) return replaceNumericNode(node, num);
|
|
103
102
|
const bool2 = maybeFoldCompare(op, l.val, r.val);
|
|
104
|
-
if (bool2 !== void 0)
|
|
105
|
-
return replaceBooleanNode(node, bool2);
|
|
103
|
+
if (bool2 !== void 0) return replaceBooleanNode(node, bool2);
|
|
106
104
|
} else if (op === "*") {
|
|
107
105
|
if (isNumL && l.val === 0)
|
|
108
106
|
return replaceWithConst(node, r, FLOAT0);
|
|
109
107
|
if (isNumR && r.val === 0)
|
|
110
108
|
return replaceWithConst(node, l, FLOAT0);
|
|
111
|
-
if (isNumL && l.val === 1)
|
|
112
|
-
|
|
113
|
-
if (isNumR && r.val === 1)
|
|
114
|
-
return replaceNode(node, l);
|
|
109
|
+
if (isNumL && l.val === 1) return replaceNode(node, r);
|
|
110
|
+
if (isNumR && r.val === 1) return replaceNode(node, l);
|
|
115
111
|
} else if (op === "/") {
|
|
116
112
|
if (isNumL && l.val === 0)
|
|
117
113
|
return replaceWithConst(node, r, FLOAT0);
|
|
118
|
-
if (isNumR && r.val === 0)
|
|
119
|
-
|
|
120
|
-
if (isNumR && r.val === 1)
|
|
121
|
-
return replaceNode(node, l);
|
|
114
|
+
if (isNumR && r.val === 0) illegalArgs("division by zero");
|
|
115
|
+
if (isNumR && r.val === 1) return replaceNode(node, l);
|
|
122
116
|
} else if (op === "+") {
|
|
123
|
-
if (isNumL && l.val === 0)
|
|
124
|
-
|
|
125
|
-
if (isNumR && r.val === 0)
|
|
126
|
-
return replaceNode(node, l);
|
|
117
|
+
if (isNumL && l.val === 0) return replaceNode(node, r);
|
|
118
|
+
if (isNumR && r.val === 0) return replaceNode(node, l);
|
|
127
119
|
} else if (op === "-") {
|
|
128
|
-
if (isNumL && l.val === 0)
|
|
129
|
-
|
|
130
|
-
if (isNumR && r.val === 0)
|
|
131
|
-
return replaceNode(node, l);
|
|
120
|
+
if (isNumL && l.val === 0) return replaceNode(node, neg(r));
|
|
121
|
+
if (isNumR && r.val === 0) return replaceNode(node, l);
|
|
132
122
|
}
|
|
133
123
|
},
|
|
134
124
|
call_i: (node) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/shader-ast-optimize",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15",
|
|
4
4
|
"description": "Shader AST code optimization passes/strategies",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -36,18 +36,18 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
40
|
-
"@thi.ng/defmulti": "^3.0.
|
|
41
|
-
"@thi.ng/errors": "^2.5.
|
|
42
|
-
"@thi.ng/logger": "^3.0.
|
|
43
|
-
"@thi.ng/math": "^5.10.
|
|
44
|
-
"@thi.ng/shader-ast": "^0.15.
|
|
39
|
+
"@thi.ng/api": "^8.11.2",
|
|
40
|
+
"@thi.ng/defmulti": "^3.0.39",
|
|
41
|
+
"@thi.ng/errors": "^2.5.7",
|
|
42
|
+
"@thi.ng/logger": "^3.0.12",
|
|
43
|
+
"@thi.ng/math": "^5.10.13",
|
|
44
|
+
"@thi.ng/shader-ast": "^0.15.15"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@microsoft/api-extractor": "^7.43.
|
|
48
|
-
"esbuild": "^0.
|
|
49
|
-
"typedoc": "^0.25.
|
|
50
|
-
"typescript": "^5.4.
|
|
47
|
+
"@microsoft/api-extractor": "^7.43.2",
|
|
48
|
+
"esbuild": "^0.21.1",
|
|
49
|
+
"typedoc": "^0.25.13",
|
|
50
|
+
"typescript": "^5.4.5"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
53
53
|
"typescript"
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"parent": "@thi.ng/shader-ast",
|
|
83
83
|
"year": 2019
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
|
|
86
86
|
}
|