Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function shouldCache(callee) {
// Don't cache 'primitive' functions. It actually could be benficial to cache
// these in some cases, but correctly binding 'this' will require some
// systemic changes that I don't want to deal with right now.
if (isPrimitive(callee))
return false;
// Don't cache ERPs or other coroutine functions that deal with ERPs.
// Why do this? If the cache adaptation decides to remove one of these functions,
// then that function will have the same address as the ERP it's dealing with,
// so the adapter will also try to remove the ERP.
// Basically, a core assumption of IncrementalMH is that all cache nodes have unique
// addresses.
if (callee.type === Syntax.Identifier && cacheExempt[callee.name])
return false;
// Otherwise, go ahead
return true;
}
CallExpression(node) {
// Check this is direct call to eval
if (!this.scopeManager.__ignoreEval() && node.callee.type === Syntax.Identifier && node.callee.name === "eval") {
// NOTE: This should be `variableScope`. Since direct eval call always creates Lexical environment and
// let / const should be enclosed into it. Only VariableDeclaration affects on the caller's environment.
this.currentScope().variableScope.__detectEval();
}
this.visitChildren(node);
}
const isCallExpressionWithNonComputedMemberExpression = (currentNode, parentNode, currentKey) => {
// Do not instrument non-computed property of MemberExpression within CallExpression.
return currentNode.type === Syntax.Identifier && parentNode.type === Syntax.MemberExpression && !parentNode.computed && currentKey === 'property';
};
value: function CallExpression(node) {
// Check this is direct call to eval
if (!this.scopeManager.__ignoreEval() && node.callee.type === Syntax.Identifier && node.callee.name === "eval") {
// NOTE: This should be `variableScope`. Since direct eval call always creates Lexical environment and
// let / const should be enclosed into it. Only VariableDeclaration affects on the caller's environment.
this.currentScope().variableScope.__detectEval();
}
this.visitChildren(node);
}
},
__defineImplicit(node, def) {
if (node && node.type === Syntax.Identifier) {
this.__defineGeneric(
node.name,
this.implicit.set,
this.implicit.variables,
node,
def);
}
}
}
function createScaledClosure(color, closureName, node) {
return {
type: Syntax.BinaryExpression,
operator: "*",
left: {
type: Syntax.CallExpression,
callee: {
type: Syntax.Identifier,
name: "color"
},
arguments: [ color ]
},
right: {
type: Syntax.CallExpression,
callee: {
type: Syntax.Identifier,
name: closureName
},
arguments: node.arguments
},
extra: {
type: Shade.TYPES.OBJECT,
kind: Shade.OBJECT_KINDS.COLOR_CLOSURE
}
static isPattern(node) {
var nodeType = node.type;
return (
nodeType === Syntax.Identifier ||
nodeType === Syntax.ObjectPattern ||
nodeType === Syntax.ArrayPattern ||
nodeType === Syntax.SpreadElement ||
nodeType === Syntax.RestElement ||
nodeType === Syntax.AssignmentPattern
);
}
var parameterName = Tools.getNameForSystem(SystemDefines.CANVAS_DIMENSIONS);
state.usedParameters.system[parameterName] = state.systemParameters[SystemDefines.CANVAS_DIMENSIONS];
return {
type: Syntax.NewExpression,
callee: {
type: Syntax.Identifier,
name: "Vec3"
},
arguments: [
{
type: Syntax.BinaryExpression,
left: {
type: Syntax.MemberExpression,
object: {
type: Syntax.Identifier,
name: "gl_FragCoord"
},
property: {
type: Syntax.Identifier,
name: "xyz"
}
},
right: {
type: Syntax.Identifier,
name: Tools.getNameForSystem(SystemDefines.CANVAS_DIMENSIONS)
},
operator: "/",
extra: {
type: Shade.TYPES.OBJECT,
kind: Shade.OBJECT_KINDS.FLOAT3
}
createTypeInfo: function (node) {
var result = new Annotation(node);
if (node.type == Syntax.Identifier) {
var name = node.name;
var binding = this.getBindingByName(name);
if (binding) {
result.copy(binding);
return binding;
}
}
return result;
},
property: function (node, parent, context, state) {
var parameterName = Tools.getNameForSystem(SystemDefines.CANVAS_DIMENSIONS);
state.usedParameters.system[parameterName] = state.systemParameters[SystemDefines.CANVAS_DIMENSIONS];
return {
type: Syntax.NewExpression,
callee: {
type: Syntax.Identifier,
name: "Vec3"
},
arguments: [
{
type: Syntax.BinaryExpression,
left: {
type: Syntax.MemberExpression,
object: {
type: Syntax.Identifier,
name: "gl_FragCoord"
},
property: {
type: Syntax.Identifier,
name: "xyz"
}
},