/*
 * DefUseAnalysisExecutor module
 * @lastmodifiedBy ChengFuLin(chengfulin0806@gmail.com)
 * @lastmodifiedDate 2015-08-26
 */
var jsParser = require('./jsparser'),
	scopeCtrl = require('./scopectrl'),
	modelCtrl = require('./modelctrl'),
	modelBuilder = require('./modelbuilder'),
	defuseAnalyzer = require('./defuseanalyzer'),
	variableAnalyzer = require('./variableanalyzer');

function DefUseAnalysisExecutor() {
}

/* start-public-methods */
/**
 * Initialize
 * @param {Array} codeOfPages Source code of each page
 */
DefUseAnalysisExecutor.prototype.initialize = function (codeOfPages) {
	"use strict";
	if (codeOfPages instanceof Array) {
		codeOfPages.forEach(function (code) {
			var ast = jsParser.parseAST(code, {range: true, loc: true});
			scopeCtrl.addPageScopeTree(ast);
		});
		modelCtrl.initializePageModels();
        variableAnalyzer.setLocalVariables(scopeCtrl.domainScope);
        scopeCtrl.pageScopeTrees.forEach(function (pageScopeTree) {
            pageScopeTree.scopes.forEach(function (scope) {
                variableAnalyzer.setLocalVariables(scope);
            });
        });
	}
};

/**
 * Build model graphs for each intra-procedural model in every PageModels
 */
DefUseAnalysisExecutor.prototype.buildIntraProceduralModelsOfEachPageModels = function () {
	"use strict";
	modelCtrl.collectionOfPageModels.forEach(function () {
		modelBuilder.buildIntraProceduralModels();
	});

    defuseAnalyzer.initiallyAnalyzeIntraProceduralModels();
    modelCtrl.collectionOfPageModels.forEach(function (pageModels) {
        pageModels.intraProceduralModels.forEach(function (model) {
            defuseAnalyzer.doAnalysis(model);
        });
    });
};

DefUseAnalysisExecutor.prototype.buildInterProceduralModelsOfEachPageModels = function () {
    "use strict";
    modelCtrl.collectionOfPageModels.forEach(function () {
        modelBuilder.buildInterProceduralModels();
    });

    modelCtrl.collectionOfPageModels.forEach(function (pageModels) {
        pageModels.interProceduralModels.forEach(function (model) {
            defuseAnalyzer.doAnalysis(model);
        });
    });
};

DefUseAnalysisExecutor.prototype.buildIntraPageModelsOfEachPageModels = function () {
    "use strict";
    modelCtrl.collectionOfPageModels.forEach(function () {
        modelBuilder.buildIntraPageModel();
    });

    modelCtrl.collectionOfPageModels.forEach(function (pageModels) {
        pageModels.intraPageModels.forEach(function (model) {
            defuseAnalyzer.doAnalysis(model);
        });
    });
};

DefUseAnalysisExecutor.prototype.buildInterPageModelsOfEachPageModels = function () {
    "use strict";
    modelBuilder.buildInterPageModel();
    defuseAnalyzer.doAnalysis(modelCtrl.interPageModel);
};
/* start-public-methods */

var analysisExecutor = new DefUseAnalysisExecutor();
module.exports = analysisExecutor;
@@ -1305,65 +1305,8 @@
 t%22;%0A
-%09modelCtrl.collectionOfPageModels.forEach(function () %7B%0A%09
 %09mod
@@ -1348,13 +1348,8 @@
 s();
-%0A%09%7D);
 %0A%0A  
@@ -1727,71 +1727,8 @@
 t%22;%0A
-    modelCtrl.collectionOfPageModels.forEach(function () %7B%0A    
     
@@ -1769,24 +1769,16 @@
 odels();
-%0A    %7D);
 %0A%0A    mo
@@ -2086,71 +2086,8 @@
 t%22;%0A
-    modelCtrl.collectionOfPageModels.forEach(function () %7B%0A    
     
@@ -2121,24 +2121,16 @@
 Model();
-%0A    %7D);
 %0A%0A    mo

Remove extra times for building models