<commit_before>// import necessary libraries
// var acorn = require('acorn/acorn');
var acorn_loose = require('acorn/acorn_loose');
var aux = require('./aux');


function analyze(input) {
    // the Scope object for global scope
    // scope.Scope.globalScope = new scope.Scope(null);

    // parsing input program
    var ast = acorn_loose.parse_dammit(input);

    var nodeArrayIndexedByList = aux.getNodeList(ast);
//    console.log(nodeArrayIndexedByList);

    // Show AST before scope resolution
    // aux.showUnfolded(ast);

/*
    // attatch the global scope to program node
    ast.scope = scope.Scope.globalScope;

    // walk recursively to annotate scope objects and
    // add variables to each scopes
    walk.recursive(ast, scope.Scope.globalScope, null, 
                   scopeResolver.scopeResolver);

    // After Scope Resolution
    console.log('\n\n[[After]]\n');
    aux.showUnfolded(ast);

    var constraints = cGen.getConstraints(ast);

    console.log('\n\n[[Constraints]]\n');
    aux.showUnfolded(constraints);
*/
    var varBlock = require('./varBlock');
    var gBlockAndAnnotatedAST = varBlock.annotateBlockInfo(ast);
    var gBlock = gBlockAndAnnotatedAST.globalBlock;
    var gScope = gBlock.getScopeInstance(null, []);
    var cGen = require('./constraint/cGen');
    var initStatus = {
        self: undefined,
        ret: undefined,
        exc: undefined,
        delta: [],
        sc: gScope
    };
    var constraints = cGen.getConstraints(ast, initStatus);
    aux.showUnfolded(gBlockAndAnnotatedAST.ast);
    aux.showUnfolded(constraints);
    aux.showUnfolded(gBlock);

}

exports.analyze = analyze;<commit_msg>Use global object for current status and cx information<commit_after>// import necessary libraries
// var acorn = require('acorn/acorn');
var acorn_loose = require('acorn/acorn_loose');
var aux = require('./aux');
var types = require('./domains/types');
var context = require('./domains/context');

function analyze(input) {
    // the Scope object for global scope
    // scope.Scope.globalScope = new scope.Scope(null);

    // parsing input program
    var ast = acorn_loose.parse_dammit(input);

    var nodeArrayIndexedByList = aux.getNodeList(ast);
//    console.log(nodeArrayIndexedByList);

    // Show AST before scope resolution
    // aux.showUnfolded(ast);

/*
    // attatch the global scope to program node
    ast.scope = scope.Scope.globalScope;

    // walk recursively to annotate scope objects and
    // add variables to each scopes
    walk.recursive(ast, scope.Scope.globalScope, null, 
                   scopeResolver.scopeResolver);

    // After Scope Resolution
    console.log('\n\n[[After]]\n');
    aux.showUnfolded(ast);

    var constraints = cGen.getConstraints(ast);

    console.log('\n\n[[Constraints]]\n');
    aux.showUnfolded(constraints);
*/
    var varBlock = require('./varBlock');
    var gBlockAndAnnotatedAST = varBlock.annotateBlockInfo(ast);
    var gBlock = gBlockAndAnnotatedAST.globalBlock;
    var gScope = gBlock.getScopeInstance(null, []);
    var gObject = types.mkObjFromGlobalScope(gScope);
    var cGen = require('./constraint/cGen');
    var initialContext = new context.CallSiteContext;
    var initStatus = {
        self: gObject,
        ret: types.AValNull,
        exc: types.AValNull,
        delta: initialContext,
        sc: gScope
    };
    var cx = {
        globalObject: gObject
        // bindings for Object, Function, and so on
    };
    var constraints = cGen.getConstraints(ast, initStatus, cx);
    aux.showUnfolded(gBlockAndAnnotatedAST.ast);
    aux.showUnfolded(constraints);
    aux.showUnfolded(gBlock);

}

exports.analyze = analyze;
{'fraction_non_alphanumeric': 0.1218384552624422, 'fraction_numerical': 0.0, 'mean_word_length': 3.118701007838746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4571838', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1106, 'n_words': 253}