Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* Simple replacer that collects all closure calls of a color closure expression and passes them to the
* provided callback
* @type {exports}
*/
var Traversal = require('estraverse');
var ANNO = require("../type-system/annotation.js").ANNO;
var Shade = require("../interfaces.js");
var Syntax = Traversal.Syntax;
function isColorClosure(node) {
if (node.type !== Syntax.CallExpression) {
return false;
}
return ANNO(node).isOfKind(Shade.OBJECT_KINDS.COLOR_CLOSURE);
}
function handleCallExpression(node, colorClosureList) {
var callee = ANNO(node.callee);
// console.log("Call", node.callee.property, callee.getTypeString(), node.callee.object)
if (callee.isOfKind(Shade.OBJECT_KINDS.COLOR_CLOSURE)) {
colorClosureList.push({name: node.callee.property.name, args: node.arguments});
}
}
(function(ns){
// Dependencies
var Tools = require("../tools.js");
var Syntax = require('estraverse').Syntax;
var Shade = require("./../../interfaces.js");
var AbstractGenerator = require("../base/base-generator.js").AbstractGenerator;
var ExpressionHandler = require('../base/expression-handler.js').ExpressionHandler;
var FunctionAnnotation = require("./../../type-system/annotation.js").FunctionAnnotation;
// Shortcuts
var Types = Shade.TYPES,
Kinds = Shade.OBJECT_KINDS;
function handleInlineDeclaration(node, opt) {
if(!node)
return "";
if (node.type == Syntax.VariableDeclaration) {
var result = node.declarations.reduce(function (declString, declaration) {
'use strict';
var estraverse = require('estraverse');
// add our custom syntax definitions
estraverse.Syntax.Template = 'Template';
estraverse.Syntax.OutputStatement = 'OutputStatement';
estraverse.Syntax.BindStatement = 'BindStatement';
estraverse.Syntax.RepeatStatement = 'RepeatStatement';
estraverse.Syntax.ContentStatement = 'ContentStatement';
estraverse.Syntax.IncludeStatement = 'IncludeStatement';
estraverse.Syntax.AliasExpression = 'AliasExpression';
estraverse.Syntax.IterateExpression = 'IterateExpression';
estraverse.Syntax.CustomElement = 'CustomElement';
estraverse.VisitorKeys.Template = ['body'];
estraverse.VisitorKeys.OutputStatement = ['expression'];
estraverse.VisitorKeys.BindStatement = ['expression', 'body'];
estraverse.VisitorKeys.RepeatStatement = ['expression', 'body'];
estraverse.VisitorKeys.ContentStatement = ['body'];
estraverse.VisitorKeys.IncludeStatement = ['body'];
estraverse.VisitorKeys.AliasExpression = ['subject', 'alias'];
estraverse.VisitorKeys.IterateExpression = ['it', 'index', 'expression', 'body'];
estraverse.VisitorKeys.CustomElement = ['body'];
module.exports = estraverse;
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
"use strict";
/* eslint-disable no-underscore-dangle */
/* eslint-disable no-undefined */
const Syntax = require("estraverse").Syntax;
const Reference = require("./reference");
const Variable = require("./variable");
const Definition = require("./definition").Definition;
const assert = require("assert");
/**
* Test if scope is struct
* @param {Scope} scope - scope
* @param {Block} block - block
* @param {boolean} isMethodDefinition - is method definiton
* @param {boolean} useDirective - use directive
* @returns {boolean} is strict scope
*/
function isStrictScope(scope, block, isMethodDefinition, useDirective) {
let body;
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
"use strict";
/* eslint-disable no-underscore-dangle */
/* eslint-disable no-undefined */
const Syntax = require("estraverse").Syntax;
const esrecurse = require("esrecurse");
const Reference = require("./reference");
const Variable = require("./variable");
const PatternVisitor = require("./pattern-visitor");
const definition = require("./definition");
const assert = require("assert");
const ParameterDefinition = definition.ParameterDefinition;
const Definition = definition.Definition;
/**
* Traverse identifier in pattern
* @param {Object} options - options
* @param {pattern} rootPattern - root pattern
* @param {Refencer} referencer - referencer
* @param {callback} callback - callback
import doctrine from '@teppeis/doctrine';
import {parseScript} from 'esprima';
import estraverse from 'estraverse';
import * as estree from 'estree';
import deepEqual from 'deep-equal';
import espurify from 'espurify';
import printer from './printer';
import * as util from './util';
import {ClassInfo, EnumInfo, FunctionInfo, ModuleInfo, TypeDefInfo, VarInfo} from './types';
const Syntax = estraverse.Syntax;
export function generate(code: string): string {
const ast = parseScript(code, {
comment: true,
attachComment: true,
loc: true,
});
const declarations: Record = {};
const provides: string[] = [];
ast.body.forEach(statement => {
try {
parseStatement(statement, declarations, provides);
} catch (e) {
console.error(statement);
throw e;
}
var Set = require('analyses').Set;
var walk = require('estraverse');
var codegen = require('escodegen');
var Syntax = walk.Syntax;
var Tools = {
getSetLabels: function (s) {
if (!s)
return "Set: null";
if (!s.size)
return "Set: {}";
return "Set: {" + s.values().map(function (n) {
return n.label;
}).join(", ") + "}";
},
printMap: function (map, cfg, cb) {
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
var Syntax = require("estraverse").Syntax;
var esrecurse = _interopRequire(require("esrecurse"));
var Reference = _interopRequire(require("./reference"));
var Variable = _interopRequire(require("./variable"));
var PatternVisitor = _interopRequire(require("./pattern-visitor"));
var _definition = require("./definition");
var ParameterDefinition = _definition.ParameterDefinition;
var Definition = _definition.Definition;
var assert = _interopRequire(require("assert"));
function isProperty(nodeType, key) {
return (nodeType === estraverse.Syntax.ObjectExpression || nodeType === estraverse.Syntax.ObjectPattern) && key === 'properties';
}
(function (ns) {
var Shade = require("../../../interfaces.js");
var Syntax = require('estraverse').Syntax;
var Tools = require('./tools.js');
var ShadeInstance = {
diffuse: {
callExp: function(node) {
return;
}
},
phong: {
}
}
function ShadeConstructor(node) {
return {