Commits

Mathias Panzenböck committed 757c775

bugfixes

Comments (0)

Files changed (2)

 				id = strings[s];
 			}
 			else {
-				id = '_'+(nextid++);
+				strings[s] = id = '_'+(nextid++);
 			}
 			return make.id('_').get(id);
 		}).transform(code, options);

lib/transformer.js

 	this.handlers = [];
 }
 
+var TransformOptions = {
+	optimize: true,
+	optimizeBefore: true,
+	optimizeAfter: true
+};
+
 Transformer.prototype = {
 	replace: function (pattern, callback) {
 		this.handlers.push({pattern: pattern, callback: callback});
 	},
 	transform: function (code, options) {
 		if (!options) options = {};
-		if (typeof code === "string") code = esprima.parse(code);
+		var espoptions = {};
+		for (var name in options) {
+			if (TransformOptions[name] !== true) {
+				espoptions[name] = options[name];
+			}
+		}
+		if (typeof code === "string") code = esprima.parse(code, espoptions);
 		if (options.optimize || options.optimizeBefore) {
 			code = new OptimizingVisitor().visit(code);
 		}