Skip to content

Commit

Permalink
Rename Woodchipper-related stuff.
Browse files Browse the repository at this point in the history
No functional changes introduced by this commit.

Renamed:

    woodchipper.js -> constants.js
    Woodchipper -> ConstantVisitor
    debranch -> propagate
  • Loading branch information
benjamn committed Jun 17, 2013
1 parent 2195a47 commit 0f87e8e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions bin/jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

var visitors = require('../vendor/fbtransform/visitors').transformVisitors;
var transform = require('../vendor/fbtransform/lib/transform').transform;
var debranch = require("../vendor/woodchipper").debranch;
var propagate = require("../vendor/constants").propagate;

require("commoner").resolve(function(id) {
var context = this;
Expand Down Expand Up @@ -32,10 +32,9 @@ require("commoner").resolve(function(id) {
return context.makePromise(function(callback) {
var constants = context.config.constants || {};

// Debranching means removing any obviously dead code after
// replacing constant conditional expressions with literal
// (boolean) values.
debranch(constants, source, function(source) {
// Constant propagation means removing dead code after replacing
// constant conditional expressions with literal (boolean) values.
propagate(constants, source, function(source) {
callback(null, source);
});
});
Expand Down
8 changes: 4 additions & 4 deletions vendor/woodchipper.js → vendor/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@

var recast = require('recast');

exports.debranch = function(constants, source, writeback) {
exports.propagate = function(constants, source, writeback) {
recast.runString(
source,
function(ast, callback) {
callback(new Woodchipper(constants).visit(ast));
callback(new ConstantVisitor(constants).visit(ast));
},
{ writeback: writeback }
);
};

var Woodchipper = recast.Visitor.extend({
var ConstantVisitor = recast.Visitor.extend({
init: function(constants) {
this.constants = constants || {};
},
Expand Down Expand Up @@ -57,6 +57,6 @@ var Woodchipper = recast.Visitor.extend({
if (!module.parent) {
var constants = JSON.parse(process.argv[3]);
recast.run(function(ast, callback) {
callback(new Woodchipper(constants).visit(ast));
callback(new ConstantVisitor(constants).visit(ast));
});
}

0 comments on commit 0f87e8e

Please sign in to comment.