Skip to content

Commit e9bdc31

Browse files
fix: Examples file reference
fix: move `GLKernel.fixIntegerDivisionAccuracy` to `Kernel.fixIntegerDivisionAccuracy` as it has to do with typing fix: FunctionTracer 'ConditionalExpression' needed `ast.test` test: Add test for FunctionTracer 'ConditionalExpression' `ast.test` usage fix: division type handling with `Kernel.fixIntegerDivisionAccuracy` true test: Add test for division handling with and without `Kernel.fixIntegerDivisionAccuracy` true
1 parent 7771b52 commit e9bdc31

File tree

20 files changed

+291
-253
lines changed

20 files changed

+291
-253
lines changed

dist/gpu-browser-core.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* GPU Accelerated JavaScript
66
*
77
* @version 2.0.0-rc.18
8-
* @date Thu Jun 27 2019 13:44:26 GMT-0400 (Eastern Daylight Time)
8+
* @date Sat Jun 29 2019 10:06:59 GMT-0400 (Eastern Daylight Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -2235,6 +2235,7 @@ class FunctionNode {
22352235
this.followingReturnStatement = null;
22362236
this.dynamicOutput = null;
22372237
this.strictTypingChecking = false;
2238+
this.fixIntegerDivisionAccuracy = null;
22382239

22392240
if (settings) {
22402241
for (const p in settings) {
@@ -2554,17 +2555,22 @@ class FunctionNode {
25542555
case 'BinaryExpression':
25552556
switch (ast.operator) {
25562557
case '%':
2557-
return 'Number';
2558-
case '>':
2559-
case '<':
2560-
return 'Boolean';
2561-
case '&':
2562-
case '|':
2563-
case '^':
2564-
case '<<':
2565-
case '>>':
2566-
case '>>>':
2567-
return 'Integer';
2558+
case '/':
2559+
if (this.fixIntegerDivisionAccuracy) {
2560+
return 'Number';
2561+
} else {
2562+
break;
2563+
}
2564+
case '>':
2565+
case '<':
2566+
return 'Boolean';
2567+
case '&':
2568+
case '|':
2569+
case '^':
2570+
case '<<':
2571+
case '>>':
2572+
case '>>>':
2573+
return 'Integer';
25682574
}
25692575
const type = this.getType(ast.left);
25702576
return typeLookupMap[type] || type;
@@ -3663,7 +3669,7 @@ class FunctionTracer {
36633669
this.scan(ast.elements);
36643670
break;
36653671
case 'ConditionalExpression':
3666-
this.scan(ast.consequent);
3672+
this.scan(ast.test);
36673673
this.scan(ast.alternate);
36683674
this.scan(ast.consequent);
36693675
break;
@@ -4222,7 +4228,6 @@ class GLKernel extends Kernel {
42224228
this.renderOutput = null;
42234229
this.renderRawOutput = null;
42244230
this.texSize = null;
4225-
this.fixIntegerDivisionAccuracy = null;
42264231
this.translatedSource = null;
42274232
this.renderStrategy = null;
42284233
this.compiledFragmentShader = null;
@@ -5459,6 +5464,7 @@ class Kernel {
54595464
this.followingReturnStatement = null;
54605465
this.optimizeFloatMemory = null;
54615466
this.strictIntegers = false;
5467+
this.fixIntegerDivisionAccuracy = null;
54625468
}
54635469

54645470
mergeSettings(settings) {
@@ -6130,7 +6136,6 @@ const localPrefix = 'this.';
61306136
class WebGLFunctionNode extends FunctionNode {
61316137
constructor(source, settings) {
61326138
super(source, settings);
6133-
this.fixIntegerDivisionAccuracy = null;
61346139
if (settings && settings.hasOwnProperty('fixIntegerDivisionAccuracy')) {
61356140
this.fixIntegerDivisionAccuracy = settings.fixIntegerDivisionAccuracy;
61366141
}

dist/gpu-browser-core.min.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* GPU Accelerated JavaScript
66
*
77
* @version 2.0.0-rc.18
8-
* @date Thu Jun 27 2019 13:44:28 GMT-0400 (Eastern Daylight Time)
8+
* @date Sat Jun 29 2019 10:07:01 GMT-0400 (Eastern Daylight Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -18,7 +18,7 @@
1818
* GPU Accelerated JavaScript
1919
*
2020
* @version 2.0.0-rc.18
21-
* @date Thu Jun 27 2019 13:44:26 GMT-0400 (Eastern Daylight Time)
21+
* @date Sat Jun 29 2019 10:06:59 GMT-0400 (Eastern Daylight Time)
2222
*
2323
* @license MIT
2424
* The MIT License
@@ -2248,6 +2248,7 @@ class FunctionNode {
22482248
this.followingReturnStatement = null;
22492249
this.dynamicOutput = null;
22502250
this.strictTypingChecking = false;
2251+
this.fixIntegerDivisionAccuracy = null;
22512252

22522253
if (settings) {
22532254
for (const p in settings) {
@@ -2567,17 +2568,22 @@ class FunctionNode {
25672568
case 'BinaryExpression':
25682569
switch (ast.operator) {
25692570
case '%':
2570-
return 'Number';
2571-
case '>':
2572-
case '<':
2573-
return 'Boolean';
2574-
case '&':
2575-
case '|':
2576-
case '^':
2577-
case '<<':
2578-
case '>>':
2579-
case '>>>':
2580-
return 'Integer';
2571+
case '/':
2572+
if (this.fixIntegerDivisionAccuracy) {
2573+
return 'Number';
2574+
} else {
2575+
break;
2576+
}
2577+
case '>':
2578+
case '<':
2579+
return 'Boolean';
2580+
case '&':
2581+
case '|':
2582+
case '^':
2583+
case '<<':
2584+
case '>>':
2585+
case '>>>':
2586+
return 'Integer';
25812587
}
25822588
const type = this.getType(ast.left);
25832589
return typeLookupMap[type] || type;
@@ -3676,7 +3682,7 @@ class FunctionTracer {
36763682
this.scan(ast.elements);
36773683
break;
36783684
case 'ConditionalExpression':
3679-
this.scan(ast.consequent);
3685+
this.scan(ast.test);
36803686
this.scan(ast.alternate);
36813687
this.scan(ast.consequent);
36823688
break;
@@ -4235,7 +4241,6 @@ class GLKernel extends Kernel {
42354241
this.renderOutput = null;
42364242
this.renderRawOutput = null;
42374243
this.texSize = null;
4238-
this.fixIntegerDivisionAccuracy = null;
42394244
this.translatedSource = null;
42404245
this.renderStrategy = null;
42414246
this.compiledFragmentShader = null;
@@ -5472,6 +5477,7 @@ class Kernel {
54725477
this.followingReturnStatement = null;
54735478
this.optimizeFloatMemory = null;
54745479
this.strictIntegers = false;
5480+
this.fixIntegerDivisionAccuracy = null;
54755481
}
54765482

54775483
mergeSettings(settings) {
@@ -6143,7 +6149,6 @@ const localPrefix = 'this.';
61436149
class WebGLFunctionNode extends FunctionNode {
61446150
constructor(source, settings) {
61456151
super(source, settings);
6146-
this.fixIntegerDivisionAccuracy = null;
61476152
if (settings && settings.hasOwnProperty('fixIntegerDivisionAccuracy')) {
61486153
this.fixIntegerDivisionAccuracy = settings.fixIntegerDivisionAccuracy;
61496154
}

dist/gpu-browser.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* GPU Accelerated JavaScript
66
*
77
* @version 2.0.0-rc.18
8-
* @date Thu Jun 27 2019 13:44:26 GMT-0400 (Eastern Daylight Time)
8+
* @date Sat Jun 29 2019 10:06:59 GMT-0400 (Eastern Daylight Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -6999,6 +6999,7 @@ class FunctionNode {
69996999
this.followingReturnStatement = null;
70007000
this.dynamicOutput = null;
70017001
this.strictTypingChecking = false;
7002+
this.fixIntegerDivisionAccuracy = null;
70027003

70037004
if (settings) {
70047005
for (const p in settings) {
@@ -7318,17 +7319,22 @@ class FunctionNode {
73187319
case 'BinaryExpression':
73197320
switch (ast.operator) {
73207321
case '%':
7321-
return 'Number';
7322-
case '>':
7323-
case '<':
7324-
return 'Boolean';
7325-
case '&':
7326-
case '|':
7327-
case '^':
7328-
case '<<':
7329-
case '>>':
7330-
case '>>>':
7331-
return 'Integer';
7322+
case '/':
7323+
if (this.fixIntegerDivisionAccuracy) {
7324+
return 'Number';
7325+
} else {
7326+
break;
7327+
}
7328+
case '>':
7329+
case '<':
7330+
return 'Boolean';
7331+
case '&':
7332+
case '|':
7333+
case '^':
7334+
case '<<':
7335+
case '>>':
7336+
case '>>>':
7337+
return 'Integer';
73327338
}
73337339
const type = this.getType(ast.left);
73347340
return typeLookupMap[type] || type;
@@ -8427,7 +8433,7 @@ class FunctionTracer {
84278433
this.scan(ast.elements);
84288434
break;
84298435
case 'ConditionalExpression':
8430-
this.scan(ast.consequent);
8436+
this.scan(ast.test);
84318437
this.scan(ast.alternate);
84328438
this.scan(ast.consequent);
84338439
break;
@@ -8986,7 +8992,6 @@ class GLKernel extends Kernel {
89868992
this.renderOutput = null;
89878993
this.renderRawOutput = null;
89888994
this.texSize = null;
8989-
this.fixIntegerDivisionAccuracy = null;
89908995
this.translatedSource = null;
89918996
this.renderStrategy = null;
89928997
this.compiledFragmentShader = null;
@@ -10223,6 +10228,7 @@ class Kernel {
1022310228
this.followingReturnStatement = null;
1022410229
this.optimizeFloatMemory = null;
1022510230
this.strictIntegers = false;
10231+
this.fixIntegerDivisionAccuracy = null;
1022610232
}
1022710233

1022810234
mergeSettings(settings) {
@@ -10894,7 +10900,6 @@ const localPrefix = 'this.';
1089410900
class WebGLFunctionNode extends FunctionNode {
1089510901
constructor(source, settings) {
1089610902
super(source, settings);
10897-
this.fixIntegerDivisionAccuracy = null;
1089810903
if (settings && settings.hasOwnProperty('fixIntegerDivisionAccuracy')) {
1089910904
this.fixIntegerDivisionAccuracy = settings.fixIntegerDivisionAccuracy;
1090010905
}

dist/gpu-browser.min.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* GPU Accelerated JavaScript
66
*
77
* @version 2.0.0-rc.18
8-
* @date Thu Jun 27 2019 13:44:28 GMT-0400 (Eastern Daylight Time)
8+
* @date Sat Jun 29 2019 10:07:01 GMT-0400 (Eastern Daylight Time)
99
*
1010
* @license MIT
1111
* The MIT License
@@ -18,7 +18,7 @@
1818
* GPU Accelerated JavaScript
1919
*
2020
* @version 2.0.0-rc.18
21-
* @date Thu Jun 27 2019 13:44:26 GMT-0400 (Eastern Daylight Time)
21+
* @date Sat Jun 29 2019 10:06:59 GMT-0400 (Eastern Daylight Time)
2222
*
2323
* @license MIT
2424
* The MIT License
@@ -7012,6 +7012,7 @@ class FunctionNode {
70127012
this.followingReturnStatement = null;
70137013
this.dynamicOutput = null;
70147014
this.strictTypingChecking = false;
7015+
this.fixIntegerDivisionAccuracy = null;
70157016

70167017
if (settings) {
70177018
for (const p in settings) {
@@ -7331,17 +7332,22 @@ class FunctionNode {
73317332
case 'BinaryExpression':
73327333
switch (ast.operator) {
73337334
case '%':
7334-
return 'Number';
7335-
case '>':
7336-
case '<':
7337-
return 'Boolean';
7338-
case '&':
7339-
case '|':
7340-
case '^':
7341-
case '<<':
7342-
case '>>':
7343-
case '>>>':
7344-
return 'Integer';
7335+
case '/':
7336+
if (this.fixIntegerDivisionAccuracy) {
7337+
return 'Number';
7338+
} else {
7339+
break;
7340+
}
7341+
case '>':
7342+
case '<':
7343+
return 'Boolean';
7344+
case '&':
7345+
case '|':
7346+
case '^':
7347+
case '<<':
7348+
case '>>':
7349+
case '>>>':
7350+
return 'Integer';
73457351
}
73467352
const type = this.getType(ast.left);
73477353
return typeLookupMap[type] || type;
@@ -8440,7 +8446,7 @@ class FunctionTracer {
84408446
this.scan(ast.elements);
84418447
break;
84428448
case 'ConditionalExpression':
8443-
this.scan(ast.consequent);
8449+
this.scan(ast.test);
84448450
this.scan(ast.alternate);
84458451
this.scan(ast.consequent);
84468452
break;
@@ -8999,7 +9005,6 @@ class GLKernel extends Kernel {
89999005
this.renderOutput = null;
90009006
this.renderRawOutput = null;
90019007
this.texSize = null;
9002-
this.fixIntegerDivisionAccuracy = null;
90039008
this.translatedSource = null;
90049009
this.renderStrategy = null;
90059010
this.compiledFragmentShader = null;
@@ -10236,6 +10241,7 @@ class Kernel {
1023610241
this.followingReturnStatement = null;
1023710242
this.optimizeFloatMemory = null;
1023810243
this.strictIntegers = false;
10244+
this.fixIntegerDivisionAccuracy = null;
1023910245
}
1024010246

1024110247
mergeSettings(settings) {
@@ -10907,7 +10913,6 @@ const localPrefix = 'this.';
1090710913
class WebGLFunctionNode extends FunctionNode {
1090810914
constructor(source, settings) {
1090910915
super(source, settings);
10910-
this.fixIntegerDivisionAccuracy = null;
1091110916
if (settings && settings.hasOwnProperty('fixIntegerDivisionAccuracy')) {
1091210917
this.fixIntegerDivisionAccuracy = settings.fixIntegerDivisionAccuracy;
1091310918
}

examples/cat-image/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<title>Cat image with GPU.js</title>
6-
<script src="../../bin/gpu-browser.js"></script>
6+
<script src="../../dist/gpu-browser.js"></script>
77
</head>
88
<body>
99
<h1>Image to GPU.js from <a href="https://observablehq.com/@fil/image-to-gpu">https://observablehq.com/@fil/image-to-gpu</a></h1>

examples/fluid.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<title>SSPS - Chadams Studios</title>
6-
<script src="../bin/gpu-browser.js"></script>
6+
<script src="../dist/gpu-browser.js"></script>
77
<script>
88
window.xSSPS = function(PCOUNT, RSIZE) {
99

0 commit comments

Comments
 (0)