VimUnDoT$<+!I7˲""!/v u ) {HU_ .U-/ -/5_ .U-/ console.log()5_ / U.0) content = "class " + node.name.name5_ .U-. console.log(node)5_ n2UWmp5 } else if (node.type == "AssignmentExpression") {5_  n UYmo2 } else if (node.type == "AssignmentExpression" ) {5_ n2UYmp5 } else if (node.type == "AssignmentExpression") {5_oU\np! node.type == "") {op5_p)Uhoq oq5_pUkoq console.log()5_pUnoq oq5_p Upoq if ()pq5_p+Upoq+ if (node.type == "AssignmentPattern")5_p-Uppror. if (node.type == "AssignmentPattern") {}5_sUqrs console.log(node)5_rUqqsrs5_rUr qs console.log(node)5_ppsVUop- if (node.type == "AssignmentPattern") { console.log(node) }5_qppVUpr5_qppVUpq node.operator 5_pppVUoq oq5_p qqVUoq if ()5_pqqVUoq if (!node.operator )5_ pqqVUoq if (!node.operator)5_! pqqVUor if (!node.operator) {}5_ "!p rrVUpr5_!#"qssVUprqr5_"$#qssVUpr!node.operator5_#%$qssVUpr !node.operator5_$&%qssVUpr node.operator5_%'&qssVUpr node.operator = ""5_&('qssVUpr node.operator = "="5_')(pssVUoq if (!node.operator) { node.operator = "=";5_(*)prrVUoq0 if (!node.operator) { node.operator = "="; }5_)+*pqqVUop2 if (!node.operator) { node.operator = "="; }5_*,+pppVUprpq5_+-,qppVUpr5_,.-rppVU rt5_-/.qppVUpq5_.0/rppVUqr5_/10r/ppVUqs] content = visit(node.left, node) + " " + node.operator + " " + visit(node.right, node);5_021r/ppVUqsR content = visit(node.left, node) + " " + () + " " + visit(node.right, node);rs5_132r=ppVUqs_ content = visit(node.left, node) + " " + (node.operator) + " " + visit(node.right, node);5_243rBppVUqse content = visit(node.left, node) + " " + (node.operator || "") + " " + visit(node.right, node);5_354qppVU pq2 if (!node.operator) { node.operator = "="; }5_475qppVUpr5_5867  VU X@ arrowFunctions: true, // enable parsing of arrow functions  9 blockBindings: true, // enable parsing of let/constO destructuring: true, // enable parsing of destructured arrays and objectsF regexYFlag: true, // enable parsing of regular expression y flagF regexUFlag: true, // enable parsing of regular expression u flagB templateStrings: true, // enable parsing of template strings@ binaryLiterals: true, // enable parsing of binary literalsB octalLiterals: true, // enable parsing of ES6 octal literalsZ unicodeCodePointEscapes: true, // enable parsing unicode code point escape sequencesB defaultParams: true, // enable parsing of default parameters< restParams: true, // enable parsing of rest parameters8 forOf: true, // enable parsing of for-of statementa objectLiteralComputedProperties: true, // enable parsing computed object literal properties` objectLiteralShorthandMethods: true, // enable parsing of shorthand object literal methodsf objectLiteralShorthandProperties: true, // enable parsing of shorthand object literal propertieso objectLiteralDuplicateProperties: true, // Allow duplicate object literal properties (except '__proto__')= generators: true, // enable parsing of generators/yield5 spread: true, // enable parsing spread operator. classes: true, // enable parsing classes9 globalReturn: true // enable return in global scope5_798  XVU   5_8:9  XVU! 5_9;:  WVU" 4, // enable parsing of arrow functions5_:<; WVU# 4 arrowFunctions: true,5_;=< WVU# 4 arrowFunctions: true, 45_<>=  WVU#  5_=?> VVU$ 5_>@? UVU% 2& // enable parsing of let/const2 blockBindings: true,25_?A@ SVU&0< // enable parsing of destructured arrays and objects0 destructuring: true,05_@BA QVU&.6 // enable parsing of regular expression y flag. regexYFlag: true,.5_ACB OVU',6 // enable parsing of regular expression u flag, regexUFlag: true,,5_BDC MVU'*- // enable parsing of template strings* templateStrings: true,*5_CED KVU'(, // enable parsing of binary literals( binaryLiterals: true,(5_DFE IVU(&/ // enable parsing of ES6 octal literals& octalLiterals: true,&5_EGF GVU($= // enable parsing unicode code point escape sequences$& unicodeCodePointEscapes: true,$5_FHG EVU("/ // enable parsing of default parameters" defaultParams: true,"5_GIH CVU) , // enable parsing of rest parameters  restParams: true, 5_HJI AVU)- // enable parsing of for-of statement forOf: true,5_IKJ ?VU)< // enable parsing computed object literal properties. objectLiteralComputedProperties: true,5_JLK =VU)= // enable parsing of shorthand object literal methods, objectLiteralShorthandMethods: true,5_KML ;VU*@ // enable parsing of shorthand object literal properties/ objectLiteralShorthandProperties: true,5_LNM 9VU*I // Allow duplicate object literal properties (except '__proto__')/ objectLiteralDuplicateProperties: true,5_MON 7VU*- // enable parsing of generators/yield generators: true,5_NPO 5VU+) // enable parsing spread operator  spread: true, 5_OQP 3VU+ $ // enable super in functions! superInFunctions: true, !5_PRQ  1VU+ ! ! // enable parsing classes " classes: true,!"5_QSR! /VU,!" ! ' // enable parsing of new.target!#  newTarget: false,"# 5_RTS" -VU,"#!" $ // enable parsing of modules"$  modules: true,#$ 5_SUT# +VU,#$"## // enable React JSX parsing#% jsx: true,$%5_TVU$ )VU,$%#$( // enable return in global scope$& globalReturn: true,%&5_UWV% 'VU-%& }$%0 // allow experimental object rest/spread%'* experimentalObjectRestSpread: true&'5_VXW& &VU2%'5_WYX' 'VU4&('(5_XZY' (VU5&( });5_Y[Z' (VU5&( }5_Z\[& (VU5%&5_[]\ & VU7$&S experimentalObjectRestSpread: true // allow experimental object rest/spread#%< globalReturn: true, // enable return in global scope"$. jsx: true, // enable React JSX parsing!#3 modules: true, // enable parsing of modules "9 newTarget: false, // enable parsing of new.target!0 classes: true, // enable parsing classes < superInFunctions: true, // enable super in functions7 spread: true, // enable parsing spread operator? generators: true, // enable parsing of generators/yieldq objectLiteralDuplicateProperties: true, // Allow duplicate object literal properties (except '__proto__')h objectLiteralShorthandProperties: true, // enable parsing of shorthand object literal propertiesb objectLiteralShorthandMethods: true, // enable parsing of shorthand object literal methodsc objectLiteralComputedProperties: true, // enable parsing computed object literal properties: forOf: true, // enable parsing of for-of statement> restParams: true, // enable parsing of rest parametersD defaultParams: true, // enable parsing of default parameters\ unicodeCodePointEscapes: true, // enable parsing unicode code point escape sequencesD octalLiterals: true, // enable parsing of ES6 octal literalsB binaryLiterals: true, // enable parsing of binary literalsD templateStrings: true, // enable parsing of template stringsH regexUFlag: true, // enable parsing of regular expression u flagH regexYFlag: true, // enable parsing of regular expression y flagQ destructuring: true, // enable parsing of destructured arrays and objects ; blockBindings: true, // enable parsing of let/const B arrowFunctions: true, // enable parsing of arrow functions5_\^]& VUTvar core = require('./core'), scope = require('./scope'), utils = require('./utils'), espree = require('espree');!module.exports = function(code) { var ast = espree.parse(code, { loc : true, range : true, tokens : true, comment : true, ecmaFeatures: {@ arrowFunctions: true, // enable parsing of arrow functions9 blockBindings: true, // enable parsing of let/constO destructuring: true, // enable parsing of destructured arrays and objectsF regexYFlag: true, // enable parsing of regular expression y flagF regexUFlag: true, // enable parsing of regular expression u flagB templateStrings: true, // enable parsing of template strings@ binaryLiterals: true, // enable parsing of binary literalsB octalLiterals: true, // enable parsing of ES6 octal literalsZ unicodeCodePointEscapes: true, // enable parsing unicode code point escape sequencesB defaultParams: true, // enable parsing of default parameters< restParams: true, // enable parsing of rest parameters8 forOf: true, // enable parsing of for-of statementa objectLiteralComputedProperties: true, // enable parsing computed object literal properties` objectLiteralShorthandMethods: true, // enable parsing of shorthand object literal methodsf objectLiteralShorthandProperties: true, // enable parsing of shorthand object literal propertieso objectLiteralDuplicateProperties: true, // Allow duplicate object literal properties (except '__proto__')= generators: true, // enable parsing of generators/yield5 spread: true, // enable parsing spread operator: superInFunctions: true, // enable super in functions. classes: true, // enable parsing classes7 newTarget: false, // enable parsing of new.target1 modules: true, // enable parsing of modules, jsx: true, // enable React JSX parsing: globalReturn: true, // enable return in global scopeQ experimentalObjectRestSpread: true // allow experimental object rest/spread } });5 var rootScope = scope.create(ast, scope.KIND_ROOT); function visit(node, parent) {( var content = "", semicolon = false; // set parent node) if (parent) { node.parent = parent; }^ if (node.type == "Program" || node.type == "BlockStatement" || node.type == "ClassBody") {< for (var i=0,length = node.body.length;i node.parent.parent.type !== "ForStatement") { content += ' = null'; semicolon = true; }+ } else if (node.type == "Identifier") {1 var identifier = (node.name || node.value);G if (!node.static && !node.isCallee && !node.isMemberExpression) {, scope.get(node).getDefinition(node); content = "$"; } content += identifier;+ } else if (node.type == "Punctuator") { content = node.value;( } else if (node.type == "Literal") {N var value = (node.raw.match(/^["']undefined["']$/)) ? "NULL" : node.raw; content = value;U } else if (node.type == "BinaryExpression" || node.type == "LogicalExpression") {" if (node.operator == 'in') { content = visit({! type: 'CallExpression', callee: { type: 'Identifier', name: 'isset', }, arguments: [{% type: 'MemberExpression', computed: true, object: node.right, property: node.left }] }, node); } else {_ content = visit(node.left, node) + " " + node.operator + " " + visit(node.right, node); }5 } else if (node.type == "AssignmentExpression" ||2 node.type == "AssignmentPattern") {* scope.get(node).register(node.left);f content = visit(node.left, node) + " " + (node.operator || "=") + " " + visit(node.right, node);6 } else if (node.type == "ConditionalExpression") {4 content = "(" + visit(node.test, node) + ")" +. " ? " + visit(node.consequent, node) +, " : " + visit(node.alternate, node);0 } else if (node.type == "UnaryExpression") {) // override typeof unary expression& if (node.operator == 'typeof') { content = visit({! type: 'CallExpression', callee: { type: 'Identifier', name: 'gettype', },$ arguments: [node.argument] }, node);) // override delete unary expression- } else if (node.operator == 'delete') { content = visit({! type: 'CallExpression', callee: { type: 'Identifier', name: 'unset', },$ arguments: [node.argument] }, node); } else {= content = node.operator + visit(node.argument, node); }4 } else if (node.type == "ExpressionStatement") {- content = visit(node.expression, node); semicolon = true;/ } else if (node.type == "CallExpression") {E var calleeDefined = scope.get(node).getDefinition(node.callee);g node.callee.isCallee = (!calleeDefined || calleeDefined && (calleeDefined.type != "Identifier" &&o calleeDefined.type != "VariableDeclarator"));* content += visit(node.callee, node); // inline anonymous callN if (node.callee.isCallee && node.callee.type == "FunctionDeclaration") { var identifier = null;7 if (node.parent.type == "VariableDeclarator") {: // var something = (function() { return 0; })();+ identifier = node.parent.id.name;@ } else if (node.parent.type == "AssignmentExpression") {6 // something = (function() { return 0; })();- identifier = node.parent.left.name; }@ content += ";$" + identifier + " = " + "$" + identifier; } if (node.arguments) { var arguments = [];H for (var i=0, length = node.arguments.length; i < length; i++) {; arguments.push( visit(node.arguments[i], node) ); }4 content += "(" + arguments.join(', ') + ")"; }J // allow semicolon if parent node isn't MemberExpression or PropertyE if (node.parent && node.parent.type == "ExpressionStatement") { semicolon = true; }1 } else if (node.type == "MemberExpression") {( var newNode = core.evaluate(node); if (node != newNode) { // fix parent node type. content = visit(newNode, node.parent); } else { var object, property;c if (node.object.type == "MemberExpression" && node.object.object && node.object.property) {& object = node.object.object,* property = node.object.property; } else { object = node.object;# property = node.property; }L object.static = (object.name || object.value || "").match(/^[A-Z]/);R property.static = (property.name || property.value || "").match(/^[A-Z]/); var accessor;4 if (node.property.static && object.static) {' accessor = "\\"; // namespace6 } else if (property.static || object.static) {$ accessor = "::"; // static } else {& accessor = "->"; // instance } if (node.computed) {V content = visit(node.object, node) + "[" + visit(node.property, node) + "]"; } else {2 node.property.isMemberExpression = true;U content = visit(node.object, node) + accessor + visit(node.property, node); } }4 } else if (node.type == "FunctionDeclaration") { var param, parameters = [],) defaults = node.defaults || [];1 // function declaration creates a new scope scope.create(node); // compute function params2 for (var i=0; i < node.params.length; i++) { if (defaults[i]) { param = visit({% type: "BinaryExpression",! left: node.params[i], operator: '=', right: defaults[i] }, node); } else {- param = visit(node.params[i], node) }) // register parameter identifiers% if (scope.get(node).parent) {3 scope.get(node).register(node.params[i]); } parameters.push(param); }1 var func_contents = visit(node.body, node),( using = scope.get(node).using;+ content = "function " + node.id.name;4 content += "(" + parameters.join(", ") + ") ";& // try to use parent's variables< // http://php.net/manual/pt_BR/functions.anonymous.php if (using.length > 0) {= content += "use (" + using.map(function(identifier) {# return "&$" + identifier; }).join(', ') + ") "; } content += "{\n"; content += func_contents; content += "}\n";1 } else if (node.type == "ObjectExpression") { var properties = [];6 for (var i=0; i < node.properties.length; i++) {: properties.push( visit(node.properties[i], node) ) }7 content = "array(" + properties.join(", ") + ")";0 } else if (node.type == "ArrayExpression") { var elements = [];4 for (var i=0; i < node.elements.length; i++) {6 elements.push( visit(node.elements[i], node) ) }5 content = "array(" + elements.join(", ") + ")";) } else if (node.type == "Property") {V var property = (node.key.type == 'Identifier') ? node.key.name : node.key.value;? content = '"'+property+'" => ' + visit(node.value, node);0 } else if (node.type == "ReturnStatement") { semicolon = true; content = "return"; if (node.argument) {4 content += " " + visit(node.argument, node); }1 } else if (node.type == "ClassDeclaration") {' content = "class " + node.id.name if (node.superClass) {6 content += " extends " + node.superClass.name; }! var s = scope.create(node); content += "\n{\n";( content += visit(node.body, node);! if (s.getters.length > 0) {4 content += "function __get($_property) {\n";. for (var i=0;i 0) {< content += "function __set($_property, $value) {\n";. for (var i=0;i $___)";4 content += "{" + visit(node.body, node) + "}";1 } else if (node.type == "UpdateExpression") { if (node.prefix) {! content += node.operator; }, content += visit(node.argument, node); if (!node.prefix) {! content += node.operator; }0 } else if (node.type == "SwitchStatement") {B content = "switch (" + visit(node.discriminant, node) + ")"; content += "{";1 for (var i=0; i < node.cases.length; i++) {5 content += visit(node.cases[i], node) + "\n"; } content += "}";+ } else if (node.type == "SwitchCase") { if (node.test) {< content += "case " + visit(node.test, node) + ":\n"; } else { content = "default:\n"; }6 for (var i=0; i < node.consequent.length; i++) {3 content += visit(node.consequent[i], node); }/ } else if (node.type == "BreakStatement") { content = "break;";. } else if (node.type == "NewExpression") {2 // re-use CallExpression for NewExpression's& var newNode = utils.clone(node);& newNode.type = "CallExpression";+ return "new " + visit(newNode, node);3 } else if (node.type == "FunctionExpression") {D // Re-use FunctionDeclaration structure for method definitions( node.type = "FunctionDeclaration";( node.id = { name: node.id || "" };) content = visit(node, node.parent);[ // Modules & Export (http://wiki.ecmascript.org/doku.php?id=harmony:modules_examples)2 } else if (node.type == "ModuleDeclaration") {E content = "namespace " + utils.classize(node.id.value) + ";\n";( content += visit(node.body, node);2 } else if (node.type == "ExportDeclaration") {. content = visit(node.declaration, node);2 } else if (node.type == "ImportDeclaration") {B for (var i=0,length = node.specifiers.length;i content += "use \\" + namespace + "\\" + node.id.name; // alias> if (node.name) { content += " as " + node.name.name; } content += ";\n"; } else {@ console.log("'" + node.type + "' not implemented.", node); }% // append semicolon when required/ if (semicolon && !content.match(/;\n?$/)) { content += ";\n"; } return content; } return " content += "use \\" + namespace + "\\" + node.id.name;5_<VU3A content += "use \\" + namespace + "\\" + node.local.name;5_6VU?A content += "use \\" + namespace + "\\" + node.local.name;5_VUA> if (node.name) { content += " as " + node.name.name; }5_3VUD6? if (node.local) { content += " as " + node.name.name; }5_K  vUtN if (node.callee.isCallee && node.callee.type == "FunctionDeclaration") {5_  JvJUtW if (node.callee.isCallee && node.callee.type == "FunctionDeclaration" || node.) {5_  JvJUt if (() || node.) {5_Q JvJUtY if ((node.callee.isCallee && node.callee.type == "FunctionDeclaration") || node.) {5_ JvJUt node.) {5_ JvJUt node.type == "") {5_ JvJUt<Q if ((node.callee.isCallee && node.callee.type == "FunctionDeclaration") || 5_1 JvJUt4 node.type == "ArrowFunctionExpression") {5_C JvJUt=G node.type == "ArrowFunctionExpression" || node.type == "") {5_C JvJUt>^ node.type == "ArrowFunctionExpression" || node.type == "ArrowFunctionExpression") {5_1 JvJUt^ node.type == "ArrowFunctionExpression" || node.type == "ArrowFunctionExpression") {5_1 JvJUt4 } else if (node.type == "FunctionDeclaration") {5_5 JvJUtA } else if (node.type == "FunctionDeclaration" || node.type) {5_ JvJUt node.type) {5_ JvJUt! node.type == '') {5_ JvJUt! node.type == "") {5_ JvJUt?5 } else if (node.type == "FunctionDeclaration" || 5_ JvJUt 5_ JvJUt console.log()5_  JvJUt console.log(node)5_ JvJUt@ console.log(node)5_ JvJUuB5_ JvJUuC + content = "function " + node.id.name;5_ JvJUu 6 content = "function " + node.id && node.id.name;5_ JvJUuD ! content = "function " + ();5_ JvJUuF console.log(node)5_  JvJUu  8 content = "function " + (node.id && node.id.name);5_  JvJUu  3 content = "function " + (() && node.id.name);  5_ ( JvJUu  : content = "function " + ((node.id) && node.id.name);5_ : JvJUuG  < content = "function " + ((node.id) ? && node.id.name);5_ + JvJUuI  A content = "function " + ((node.id) ? && node.id.name : "");5_ JvJUx 5_ JvJUx5_ JvJUx5_ JvJUx TaggedTemplateExpression5_ JvJUx0 } else if (node.type == "ImportSpecifier") {5_5 JvJUxH } else if (node.type == "TaggedTemplateExpressionImportSpecifier") {5_ JvJUxN 5_ JvJUx  5_ JvJUxO  content += visit()5_VUy content += visit(node.tag)9 } else if (node.type == "TaggedTemplateExpression") {5_VUy  5_VUy 5_ VUy  //5_VUy  /5_VUy< // } else if (node.type == "TaggedTemplateExpression") {5_VUy  9 } else if (node.type == "TaggedTemplateExpression") { 5_VUy!Q 5_VUy$  5_VUy%# // content += visit(node.tag)5_VUy&R< // } else if (node.type == "TaggedTemplateExpression") { //# // content += visit(node.tag)5_VUy;  5_VUyA  var expressions5_VUyF  , quasis = 5_VUyHT  , quasis = node.quasis5_VUy   5_VUy  p5_VUyU 5_VUz   content += visit(node.tag)5_VUz   content += ''5_VUzY  content += '""'5_VUz  content += '""';5_VUz_  content += '"';5_VUz   5_ VUz  for ()5_.VUz . for (var i=0; i , nodes = quasis.concat(expressions).sort(function());5_@/v/U}B , nodes = quasis.concat(expressions).sort(function(item));5_B/v/U}E , nodes = quasis.concat(expressions).sort(function(item) {});5_/v/U}v });5_;/v/U}B , nodes = quasis.concat(expressions).sort(function(item) {5_=/v/U}A , nodes = quasis.concat(expressions).sort(function(a,b) {5_B/v/U}B , nodes = quasis.concat(expressions).sort(function(a, b) {5_/v/U} return5_/v/U} return5_ /v/U} return5_/v/U} return5_/v/U} return a.range[]5_/v/U} return a.range[0]5_/v/U} return a.range[0] > 5_/v/U} return a.range[0] < 5_!/v/U}! return a.range[0] < b5_(/v/U}) return a.range[0] < b.range[]5_*/v/U}x* return a.range[0] < b.range[0]5_/v/U}y+ for (var i=0; i=VU~ } else {5_=?>VU~ } else if () {5_>@?VU~ } else if (nodes[]) {5_?A@VU~ } else if (nodes[i]) {5_@BA%VU~) } else if (nodes[i].type == "") {5_ACBVU~5_BDCVU~5_CEDVU~( cooked += visit(nodes[i], node);5_DFE VU~5_EGFVU~( cooked += visit(nodes[i], node);5_FHGVU~5_GIHVU~* cooked += visit(nodes[i], node);5_HJIVU~ cooked += 5_IKJVU~ cooked +=5_JLKVU~ cooked += ''5_KMLVU~ cooked += '{}'5_LNMVU~ cooked += '{''}'5_MONVU~ cooked += '{'++'}'5_NPOVU~# cooked += '{'+visit()+'}'5_OQP$VU~* cooked += '{'+visit(nodes[])+'}'5_PRQ&VU~+ cooked += '{'+visit(nodes[i])+'}'5_QSRVU~1 cooked += '{'+visit(nodes[i], node)+'}'5_RTSVU~2 cooked += '{' +visit(nodes[i], node)+'}'5_SUT/VU~3 cooked += '{' + visit(nodes[i], node)+'}'5_TVU1VU~4 cooked += '{' + visit(nodes[i], node) +'}'5_UWV5VU~5 cooked += '{' + visit(nodes[i], node) + '}'5_VXW VU~! content += node.cooked;5_WYXVU~ cooked += node.cooked;5_XZYVU~# cooked += nodes[].cooked;5_Y[ZVU~$ cooked += nodes[i].cooked;5_Z\[VU~3 } else if (nodes[i].type == "Identifier") {5_[]\VU~ } else {5_\^]VU~6 cooked += '{' + visit(nodes[i], node) + '}';5_]_^4VU~7 cooked += '{ ' + visit(nodes[i], node) + '}';5_^`_VU8 cooked += '{ ' + visit(nodes[i], node) + ' }';5__a`3VU7 cooked += '{' + visit(nodes[i], node) + ' }';5_`ba}VU|~}~5_acb}VU|~/ } else if (node.type == "ThisExpression") {5_bdc}&VU|& } else if (node.type == "Super") {5_ced}VU}}~5_dfe~  VU} content = "$this";5_egf'  VU'* ')5_fhg)   VU(* console.log())*5_gih)  VU(* console.log(ast)5_hji)  VU(* console.log(ast.body)5_ikj)  VU(* console.log(ast.body[])5_jlk)  VU(* console.log(ast.body[1])5_kml)  VU(* console.log(ast.body[1])5_lnm)  VU(* console.log(ast.body[1].body)5_mon)$  VU(*& console.log(ast.body[1].body.body[])5_npo)&  VU(*' console.log(ast.body[1].body.body[0])5_oqp)1  VU(*2 console.log(ast.body[1].body.body[0].value.body)5_prq)7  VU(*9 console.log(ast.body[1].body.body[0].value.body.body[])5_qsr)9  VU%(*: console.log(ast.body[1].body.body[0].value.body.body[0])5_rts3  VUx6 } else if (property.static || object.static) {5_sut  VU|6 } else if (property.static || object.static) {5_tvu  VU~ } else if (()) {5_uwv5  VU8 } else if ((property.static || object.static)) {5_vxw(  VU'(E console.log(ast.body[1].body.body[0].value.body.body[0].expression)5_wyx  VU 5_xzy  VU5_y{z  VU console.log()5_z|{  VU console.log(object)5_{}|5  VU8 } else if ((property.static || object.static)) {5_|}I  VUM } else if ((property.static || object.static) || object.type == "") {5_}~~  VU} content = "parent::";5_~  VUvar core = require('./core'), scope = require('./scope'), utils = require('./utils'), espree = require('espree');!module.exports = function(code) { var ast = espree.parse(code, { loc : true, range : true, tokens : true, comment : true, ecmaFeatures: {@ arrowFunctions: true, // enable parsing of arrow functions9 blockBindings: true, // enable parsing of let/constO destructuring: true, // enable parsing of destructured arrays and objectsF regexYFlag: true, // enable parsing of regular expression y flagF regexUFlag: true, // enable parsing of regular expression u flagB templateStrings: true, // enable parsing of template strings@ binaryLiterals: true, // enable parsing of binary literalsB octalLiterals: true, // enable parsing of ES6 octal literalsZ unicodeCodePointEscapes: true, // enable parsing unicode code point escape sequencesB defaultParams: true, // enable parsing of default parameters< restParams: true, // enable parsing of rest parameters8 forOf: true, // enable parsing of for-of statementa objectLiteralComputedProperties: true, // enable parsing computed object literal properties` objectLiteralShorthandMethods: true, // enable parsing of shorthand object literal methodsf objectLiteralShorthandProperties: true, // enable parsing of shorthand object literal propertieso objectLiteralDuplicateProperties: true, // Allow duplicate object literal properties (except '__proto__')= generators: true, // enable parsing of generators/yield5 spread: true, // enable parsing spread operator: superInFunctions: true, // enable super in functions. classes: true, // enable parsing classes7 newTarget: false, // enable parsing of new.target1 modules: true, // enable parsing of modules, jsx: true, // enable React JSX parsing: globalReturn: true, // enable return in global scopeQ experimentalObjectRestSpread: true // allow experimental object rest/spread } });5 var rootScope = scope.create(ast, scope.KIND_ROOT); function visit(node, parent) {( var content = "", semicolon = false; // set parent node) if (parent) { node.parent = parent; }^ if (node.type == "Program" || node.type == "BlockStatement" || node.type == "ClassBody") {< for (var i=0,length = node.body.length;i node.parent.parent.type !== "ForStatement") { content += ' = null'; semicolon = true; }+ } else if (node.type == "Identifier") {1 var identifier = (node.name || node.value);G if (!node.static && !node.isCallee && !node.isMemberExpression) {, scope.get(node).getDefinition(node); content = "$"; } content += identifier;+ } else if (node.type == "Punctuator") { content = node.value;( } else if (node.type == "Literal") {N var value = (node.raw.match(/^["']undefined["']$/)) ? "NULL" : node.raw; content = value;U } else if (node.type == "BinaryExpression" || node.type == "LogicalExpression") {" if (node.operator == 'in') { content = visit({! type: 'CallExpression', callee: { type: 'Identifier', name: 'isset', }, arguments: [{% type: 'MemberExpression', computed: true, object: node.right, property: node.left }] }, node); } else {_ content = visit(node.left, node) + " " + node.operator + " " + visit(node.right, node); }5 } else if (node.type == "AssignmentExpression" ||2 node.type == "AssignmentPattern") {* scope.get(node).register(node.left);f content = visit(node.left, node) + " " + (node.operator || "=") + " " + visit(node.right, node);6 } else if (node.type == "ConditionalExpression") {4 content = "(" + visit(node.test, node) + ")" +. " ? " + visit(node.consequent, node) +, " : " + visit(node.alternate, node);0 } else if (node.type == "UnaryExpression") {) // override typeof unary expression& if (node.operator == 'typeof') { content = visit({! type: 'CallExpression', callee: { type: 'Identifier', name: 'gettype', },$ arguments: [node.argument] }, node);) // override delete unary expression- } else if (node.operator == 'delete') { content = visit({! type: 'CallExpression', callee: { type: 'Identifier', name: 'unset', },$ arguments: [node.argument] }, node); } else {= content = node.operator + visit(node.argument, node); }4 } else if (node.type == "ExpressionStatement") {- content = visit(node.expression, node); semicolon = true;/ } else if (node.type == "CallExpression") {E var calleeDefined = scope.get(node).getDefinition(node.callee);g node.callee.isCallee = (!calleeDefined || calleeDefined && (calleeDefined.type != "Identifier" &&o calleeDefined.type != "VariableDeclarator"));* content += visit(node.callee, node); // inline anonymous callP if ((node.callee.isCallee && node.callee.type == "FunctionDeclaration") ||4 node.type == "ArrowFunctionExpression") { var identifier = null;7 if (node.parent.type == "VariableDeclarator") {: // var something = (function() { return 0; })();+ identifier = node.parent.id.name;@ } else if (node.parent.type == "AssignmentExpression") {6 // something = (function() { return 0; })();- identifier = node.parent.left.name; }@ content += ";$" + identifier + " = " + "$" + identifier; } if (node.arguments) { var arguments = [];H for (var i=0, length = node.arguments.length; i < length; i++) {; arguments.push( visit(node.arguments[i], node) ); }4 content += "(" + arguments.join(', ') + ")"; }J // allow semicolon if parent node isn't MemberExpression or PropertyE if (node.parent && node.parent.type == "ExpressionStatement") { semicolon = true; }1 } else if (node.type == "MemberExpression") {( var newNode = core.evaluate(node); if (node != newNode) { // fix parent node type. content = visit(newNode, node.parent); } else { var object, property;c if (node.object.type == "MemberExpression" && node.object.object && node.object.property) {& object = node.object.object,* property = node.object.property; } else { object = node.object;# property = node.property; }L object.static = (object.name || object.value || "").match(/^[A-Z]/);R property.static = (property.name || property.value || "").match(/^[A-Z]/); var accessor;4 if (node.property.static && object.static) {' accessor = "\\"; // namespaceR } else if ((property.static || object.static) || object.type == "Super") {$ accessor = "::"; // static } else {& accessor = "->"; // instance } if (node.computed) {V content = visit(node.object, node) + "[" + visit(node.property, node) + "]"; } else {2 node.property.isMemberExpression = true;U content = visit(node.object, node) + accessor + visit(node.property, node); } }4 } else if (node.type == "FunctionDeclaration" ||8 node.type == "ArrowFunctionExpression") { var param, parameters = [],) defaults = node.defaults || [];1 // function declaration creates a new scope scope.create(node); // compute function params2 for (var i=0; i < node.params.length; i++) { if (defaults[i]) { param = visit({% type: "BinaryExpression",! left: node.params[i], operator: '=', right: defaults[i] }, node); } else {- param = visit(node.params[i], node) }) // register parameter identifiers% if (scope.get(node).parent) {3 scope.get(node).register(node.params[i]); } parameters.push(param); }1 var func_contents = visit(node.body, node),( using = scope.get(node).using;> content = "function " + ((node.id) ? node.id.name : "");4 content += "(" + parameters.join(", ") + ") ";& // try to use parent's variables< // http://php.net/manual/pt_BR/functions.anonymous.php if (using.length > 0) {= content += "use (" + using.map(function(identifier) {# return "&$" + identifier; }).join(', ') + ") "; } content += "{\n"; content += func_contents; content += "}\n";1 } else if (node.type == "ObjectExpression") { var properties = [];6 for (var i=0; i < node.properties.length; i++) {: properties.push( visit(node.properties[i], node) ) }7 content = "array(" + properties.join(", ") + ")";0 } else if (node.type == "ArrayExpression") { var elements = [];4 for (var i=0; i < node.elements.length; i++) {6 elements.push( visit(node.elements[i], node) ) }5 content = "array(" + elements.join(", ") + ")";) } else if (node.type == "Property") {V var property = (node.key.type == 'Identifier') ? node.key.name : node.key.value;? content = '"'+property+'" => ' + visit(node.value, node);0 } else if (node.type == "ReturnStatement") { semicolon = true; content = "return"; if (node.argument) {4 content += " " + visit(node.argument, node); }1 } else if (node.type == "ClassDeclaration") {' content = "class " + node.id.name if (node.superClass) {6 content += " extends " + node.superClass.name; }! var s = scope.create(node); content += "\n{\n";( content += visit(node.body, node);! if (s.getters.length > 0) {4 content += "function __get($_property) {\n";. for (var i=0;i 0) {< content += "function __set($_property, $value) {\n";. for (var i=0;i $___)";4 content += "{" + visit(node.body, node) + "}";1 } else if (node.type == "UpdateExpression") { if (node.prefix) {! content += node.operator; }, content += visit(node.argument, node); if (!node.prefix) {! content += node.operator; }0 } else if (node.type == "SwitchStatement") {B content = "switch (" + visit(node.discriminant, node) + ")"; content += "{";1 for (var i=0; i < node.cases.length; i++) {5 content += visit(node.cases[i], node) + "\n"; } content += "}";+ } else if (node.type == "SwitchCase") { if (node.test) {< content += "case " + visit(node.test, node) + ":\n"; } else { content = "default:\n"; }6 for (var i=0; i < node.consequent.length; i++) {3 content += visit(node.consequent[i], node); }/ } else if (node.type == "BreakStatement") { content = "break;";. } else if (node.type == "NewExpression") {2 // re-use CallExpression for NewExpression's& var newNode = utils.clone(node);& newNode.type = "CallExpression";+ return "new " + visit(newNode, node);3 } else if (node.type == "FunctionExpression") {D // Re-use FunctionDeclaration structure for method definitions( node.type = "FunctionDeclaration";( node.id = { name: node.id || "" };) content = visit(node, node.parent);[ // Modules & Export (http://wiki.ecmascript.org/doku.php?id=harmony:modules_examples)2 } else if (node.type == "ModuleDeclaration") {E content = "namespace " + utils.classize(node.id.value) + ";\n";( content += visit(node.body, node);7 } else if (node.type == "ExportNamedDeclaration") {. content = visit(node.declaration, node);2 } else if (node.type == "ImportDeclaration") {B for (var i=0,length = node.specifiers.length;i  VUľB } else if (node.type == "ForInStatement" || node.type == "") {5_K  VU 5_  VU console.log()5_  VU console.log(node.left)5_G;  VUFH> node.parent.parent.type !== "ForStatement") {5_G?GG>v>UFIB node.parent.parent.type !== "ForStatement" && ) {5_HGG>v>UGI ) {HI5_HGG>v>UGIA node.parent.parent.type !== "ForStatement" && ) {5_HGG>v>UGID node.parent.parent.type !== "ForStatement" && ) {5_HGG>v>UGIC node.parent.parent.type !== "ForStatement" && ) {5_H>GG>v>UGIB node.parent.parent.type !== "ForStatement" && ) {5_H=GG>v>UGIA node.parent.parent.type !== "ForStatement" &&) {5_H<GG>v>UGI@ node.parent.parent.type !== "ForStatement" &) {5_H;GG>v>UGI? node.parent.parent.type !== "ForStatement" ) {5_H.GG>v>UGI> node.parent.parent.type !== "ForStatement") {5_GGG>v>UFH? node.parent.parent.type !== "ForStatement" && 5_}~9  VU9 } else if ((property.static || object.static) || , object.type == "Super") {5_%')&/v/U~i0 } else if (node.type == "TemplateElement") {5_&('/v/U~i5_'(/v/U~k content += node.cooked;5_/v/U}5_;/v/U}B , nodes = quasis.concat(expressions).sort(function(node) {5_/v/U} });5_ /v/U}^ var 5_ /v/U}^ var , quasis = node.quasis5_ /v/U}^ var 5_ /v/U}_9 var , nodes = node.quasis.concat(node.expressions);5_VUy  \`${str1}, ${str2}, ${n1}, ${n2}` // } else if (node.type == "TaggedTemplateExpression") {5_ JvJUx 5_ JvJUx , } else {5_,  vUtB } else if (node.type == "CallExpression" || node.type == "") {5_>  vUt8Y } else if (node.type == "CallExpression" || node.type == "ArrowFunctionExpression") {5_L  vUt?L if (node.callee.isCallee && node.callee.type == "FunctionDeclaration") {5_7VU>= content += "use \\" + namespace + "\\" + node.l.name;5_576nooVUmpY } else if (node.type == "AssignmentExpression" || node.type == "AssignmentPattern") {5_n2Uemo5 } else if (node.type == "AssignmentExpression" || ) {5_o Ufopnp4 node.type == "AssignmentExpression") {5_oUgnp5 node.type == "AssignmentExpression") {5_o'Uhnp2 node.type == "AssignmentPattern") {5_p)Urop oq console.log()5_pUtoq console.log(node)5_n'U[mo2 } else if (node.type == "AssignmentPattern") {5