Skip to content

Commit 87871ec

Browse files
fix: Handle operations on LiteralInteger and LiteralInteger
fix: Typo for module path
1 parent 2c4ef75 commit 87871ec

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/backend/web-gl/function-node.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,15 @@ class WebGLFunctionNode extends FunctionNode {
270270
this.astGeneric(ast.right, retArr);
271271
break;
272272
case 'LiteralInteger & LiteralInteger':
273-
this.castLiteralToFloat(ast.left, retArr);
274-
retArr.push(operatorMap[ast.operator] || ast.operator);
275-
this.castLiteralToFloat(ast.right, retArr);
273+
if (this.isState('casting-to-integer')) {
274+
this.astGeneric(ast.left, retArr);
275+
retArr.push(operatorMap[ast.operator] || ast.operator);
276+
this.astGeneric(ast.right, retArr);
277+
} else {
278+
this.castLiteralToFloat(ast.left, retArr);
279+
retArr.push(operatorMap[ast.operator] || ast.operator);
280+
this.castLiteralToFloat(ast.right, retArr);
281+
}
276282
break;
277283

278284
case 'Integer & Float':
@@ -421,7 +427,8 @@ class WebGLFunctionNode extends FunctionNode {
421427
if (!foundOperator) return null;
422428
retArr.push(foundOperator);
423429
retArr.push('(');
424-
switch (this.getType(ast.left)) {
430+
const leftType = this.getType(ast.left);
431+
switch (leftType) {
425432
case 'Number':
426433
case 'Float':
427434
this.castValueToInteger(ast.left, retArr);
@@ -433,7 +440,8 @@ class WebGLFunctionNode extends FunctionNode {
433440
this.astGeneric(ast.left, retArr);
434441
}
435442
retArr.push(',');
436-
switch (this.getType(ast.right)) {
443+
const rightType = this.getType(ast.right);
444+
switch (rightType) {
437445
case 'Number':
438446
case 'Float':
439447
this.castValueToInteger(ast.right, retArr);
@@ -1338,4 +1346,4 @@ const operatorMap = {
13381346

13391347
module.exports = {
13401348
WebGLFunctionNode
1341-
};
1349+
};

src/backend/web-gl/kernel-value/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { utils } = require('../../../utils');
22
const { Input } = require('../../../input');
3-
const { KernelValue } = require('../../kernel-Value');
3+
const { KernelValue } = require('../../kernel-value');
44

55
class WebGLKernelValue extends KernelValue {
66
/**
@@ -113,4 +113,4 @@ class WebGLKernelValue extends KernelValue {
113113

114114
module.exports = {
115115
WebGLKernelValue
116-
};
116+
};

0 commit comments

Comments
 (0)