Commits

Mathias Panzenböck committed e13e420

file renames

  • Participants
  • Parent commits edcd078

Comments (0)

Files changed (4)

 	TransformingVisitor: require("./lib/transformingvisitor.js").TransformingVisitor
 };
 exports.nodes = require("./lib/nodes.js");
-exports.transform = require("./lib/transform.js");
+exports.Transformer = require("./lib/transformer.js").Transformer;
 exports.i18n = require("./lib/i18n.js");
 
 function optimize (code) {
 "use strict";
 
-var transform = require("./transform.js");
+var Transformer = require("./transformer.js").Transformer;
 var match = require("./patterns.js").PatternHelper;
 var make = require("./nodes.js").NodeHelper;
 
 	if (!options) options = {};
 	var strings = {};
 	var has = Object.prototype.hasOwnProperty;
-	new transform.Transformer().on(
+	new Transformer().on(
 		match.global('_').call(match.string(), match.many()),
 		options.loc ? function (node) {
 			var s = node.arguments[0].value;
 	var strings = {};
 	var nextid = 0;
 	var has = Object.prototype.hasOwnProperty;
-	var node = new transform.Transformer().replace(
+	var node = new Transformer().replace(
 		match.global('_').call(match.string(), match.many()),
 		function (node) {
 			var s = node.arguments[0].value;

File lib/transform.js

-"use strict";
-
-var esprima = require("esprima");
-var nodes = require("./nodes.js");
-var CloneVisitor = require("./clonevisitor.js").CloneVisitor;
-var OptimizingVisitor = require("./optimizingvisitor.js").OptimizingVisitor;
-var EnrichingVisitor = require("./enrichingvisitor.js").EnrichingVisitor;
-var TransformingVisitor = require("./transformingvisitor.js").TransformingVisitor;
-
-function Transformer () {
-	this.handlers = [];
-}
-
-Transformer.prototype = {
-	replace: function (pattern, callback) {
-		this.handlers.push({pattern: pattern, callback: callback});
-		return this;
-	},
-	on: function (pattern, callback) {
-		return this.replace(pattern, function (node) {
-			callback.call(this, node);
-			return node;
-		});
-	},
-	delete: function (pattern) {
-		return this.replace(pattern, function (node) { return null; });
-	},
-	transform: function (code, options) {
-		if (!options) options = {};
-		if (typeof code === "string") code = esprima.parse(code);
-		if (options.optimize || options.optimizeBefore) {
-			code = new OptimizingVisitor().visit(code);
-		}
-		else {
-			code = new CloneVisitor().visit(code);
-		}
-		new EnrichingVisitor().visit(code);
-		code = new TransformingVisitor(this).visit(code) || new nodes.Program([]);
-		if (options.optimize || options.optimizeAfter) {
-			code = new OptimizingVisitor().visit(code);
-		}
-		return code;
-	}
-};
-
-
-exports.Transformer = Transformer;

File lib/transformer.js

+"use strict";
+
+var esprima = require("esprima");
+var nodes = require("./nodes.js");
+var CloneVisitor = require("./clonevisitor.js").CloneVisitor;
+var OptimizingVisitor = require("./optimizingvisitor.js").OptimizingVisitor;
+var EnrichingVisitor = require("./enrichingvisitor.js").EnrichingVisitor;
+var TransformingVisitor = require("./transformingvisitor.js").TransformingVisitor;
+
+function Transformer () {
+	this.handlers = [];
+}
+
+Transformer.prototype = {
+	replace: function (pattern, callback) {
+		this.handlers.push({pattern: pattern, callback: callback});
+		return this;
+	},
+	on: function (pattern, callback) {
+		return this.replace(pattern, function (node) {
+			callback.call(this, node);
+			return node;
+		});
+	},
+	delete: function (pattern) {
+		return this.replace(pattern, function (node) { return null; });
+	},
+	transform: function (code, options) {
+		if (!options) options = {};
+		if (typeof code === "string") code = esprima.parse(code);
+		if (options.optimize || options.optimizeBefore) {
+			code = new OptimizingVisitor().visit(code);
+		}
+		else {
+			code = new CloneVisitor().visit(code);
+		}
+		new EnrichingVisitor().visit(code);
+		code = new TransformingVisitor(this).visit(code) || new nodes.Program([]);
+		if (options.optimize || options.optimizeAfter) {
+			code = new OptimizingVisitor().visit(code);
+		}
+		return code;
+	}
+};
+
+
+exports.Transformer = Transformer;