Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function handleInlineDeclaration(node, opt) {
if(!node)
return "";
if (node.type == Syntax.VariableDeclaration) {
var result = node.declarations.reduce(function (declString, declaration) {
var decl = toOSLType(declaration.extra) + " " + declaration.id.name;
if (declaration.init) {
decl += " = " + handler.expression(declaration.init);
}
return declString + decl;
}, "");
return result;
}
// GLSL allows only declaration in init, but since this is a new scope, it should be fine
if (node.type == Syntax.AssignmentExpression) {
return toOSLType(node.extra) + " " + handler.expression(node.left) + " = " + handler.expression(node.right);
}
Shade.throwError(node, "Internal error in GLSL::handleInlineDeclaration, found " + node.type);
}
visitForIn(node) {
if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") {
this.materializeTDZScope(node.right, node);
this.visit(node.right);
this.close(node.right);
this.materializeIterationScope(node);
this.visit(node.body);
this.close(node);
} else {
if (node.left.type === Syntax.VariableDeclaration) {
this.visit(node.left);
this.visitPattern(node.left.declarations[0].id, pattern => {
this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
});
} else {
this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => {
let maybeImplicitGlobal = null;
if (!this.currentScope().isStrict) {
maybeImplicitGlobal = {
pattern,
node
};
}
this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, true, false);
visitForIn(node) {
if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") {
this.scopeManager.__nestForScope(node);
}
if (node.left.type === Syntax.VariableDeclaration) {
this.visit(node.left);
this.visitPattern(node.left.declarations[0].id, pattern => {
this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
});
} else {
this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => {
let maybeImplicitGlobal = null;
if (!this.currentScope().isStrict) {
maybeImplicitGlobal = {
pattern,
node
};
}
this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, true, false);
value: function visitForIn(node) {
var _this = this;
if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") {
this.materializeTDZScope(node.right, node);
this.visit(node.right);
this.close(node.right);
this.materializeIterationScope(node);
this.visit(node.body);
this.close(node);
} else {
if (node.left.type === Syntax.VariableDeclaration) {
this.visit(node.left);
this.visitPattern(node.left.declarations[0].id, function (pattern) {
_this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
});
} else {
this.visitPattern(node.left, { processRightHandNodes: true }, function (pattern, info) {
var maybeImplicitGlobal = null;
visitForIn(node) {
if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== 'var') {
this.materializeTDZScope(node.right, node);
this.visit(node.right);
this.close(node.right);
this.materializeIterationScope(node);
this.visit(node.body);
this.close(node);
} else {
if (node.left.type === Syntax.VariableDeclaration) {
this.visit(node.left);
this.visitPattern(node.left.declarations[0].id, (pattern) => {
this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
});
} else {
this.visitPattern(node.left, {processRightHandNodes: true}, (pattern, info) => {
var maybeImplicitGlobal = null;
if (!this.currentScope().isStrict) {
maybeImplicitGlobal = {
pattern: pattern,
node: node
};
}
this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, true, false);
});
value: function visitForIn(node) {
var _this = this;
if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") {
this.materializeTDZScope(node.right, node);
this.visit(node.right);
this.close(node.right);
this.materializeIterationScope(node);
this.visit(node.body);
this.close(node);
} else {
if (node.left.type === Syntax.VariableDeclaration) {
this.visit(node.left);
this.visitPattern(node.left.declarations[0].id, function (pattern) {
_this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
});
} else {
this.visitPattern(node.left, { processRightHandNodes: true }, function (pattern, info) {
var maybeImplicitGlobal = null;
visitForIn(node) {
if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") {
this.materializeTDZScope(node.right, node);
this.visit(node.right);
this.close(node.right);
this.materializeIterationScope(node);
this.visit(node.body);
this.close(node);
} else {
if (node.left.type === Syntax.VariableDeclaration) {
this.visit(node.left);
this.visitPattern(node.left.declarations[0].id, pattern => {
this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
});
} else {
this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => {
let maybeImplicitGlobal = null;
public visitForIn(
node: ESTree.ForInStatement | ESTree.ForOfStatement,
) {
if (
node.left.type === Syntax.VariableDeclaration &&
node.left.kind !== "var"
) {
this.materializeTDZScope(node.right, node);
this.visit(node.right);
this.close(node.right);
this.materializeIterationScope(node);
this.visit(node.body);
this.close(node);
} else {
if (node.left.type === Syntax.VariableDeclaration) {
this.visit(node.left);
this.visitPattern(
node.left.declarations[0].id,
undefined,
pattern => {
visitForIn(node) {
if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") {
this.materializeTDZScope(node.right, node);
this.visit(node.right);
this.close(node.right);
this.materializeIterationScope(node);
this.visit(node.body);
this.close(node);
} else {
if (node.left.type === Syntax.VariableDeclaration) {
this.visit(node.left);
this.visitPattern(node.left.declarations[0].id, pattern => {
this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
});
} else {
this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => {
let maybeImplicitGlobal = null;
value: function visitForIn(node) {
var _this = this;
if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") {
this.materializeTDZScope(node.right, node);
this.visit(node.right);
this.close(node.right);
this.materializeIterationScope(node);
this.visit(node.body);
this.close(node);
} else {
if (node.left.type === Syntax.VariableDeclaration) {
this.visit(node.left);
this.visitPattern(node.left.declarations[0].id, function (pattern) {
_this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
});
} else {
this.visitPattern(node.left, { processRightHandNodes: true }, function (pattern, info) {
var maybeImplicitGlobal = null;
if (!_this.currentScope().isStrict) {
maybeImplicitGlobal = {
pattern: pattern,
node: node
};
}
_this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
_this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, true, false);
});