How to use the debug.js.log function in debug

To help you get started, we’ve selected a few debug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Yoric / Marv-the-Tinker / src / comp / main.js View on Github external
function(file) {
      Log.progress("Reading file "+file);
      try {

      let code = Parse.fromFile(file);

      // Reprinting with esprima
      Debug.log("Sanity check");
      Debug.log(Parse.toJS(code));

      // Analyzing identifiers
      Log.progress("Analyzing identifiers");
      let rewritten = Identifiers.resolve(code);
        let js = Parse.toJS(rewritten);
        text += js + "\n";
        Debug.log(js);
      } catch (x) {
        Debug.error(x);
        Debug.error(x.stack);
      }
    }
  );
github Yoric / Marv-the-Tinker / src / comp / pass_ident.js View on Github external
exit: function(node) {
          Debug.log("VariableDeclaration.exit");
          for (let i = 0; i < node.declarations.length; ++i) {
            let variable = node.declarations[i];
            // We may have several declarations with the same name
            // in the same scope. In this case, merge them if they
            // are |var|/|let|, reject if one is |const|.
            let previous;
            if ((previous = block_scope.local_get(variable.id.name))
              || (previous = function_scope.local_get(variable.id.name))) {
              // Another let-definition exists in the exact same
              // (block) scope
              report_redef(variable, previous, false);
              // Merge
              variable.id.become(previous.id);
            } else {
              // Nothing weird here, just update the scope
              if (variable.isLet()) {
github Yoric / Marv-the-Tinker / src / comp / main.js View on Github external
function(file) {
      Log.progress("Reading file "+file);
      try {

      let code = Parse.fromFile(file);

      // Reprinting with esprima
      Debug.log("Sanity check");
      Debug.log(Parse.toJS(code));

      // Analyzing identifiers
      Log.progress("Analyzing identifiers");
      let rewritten = Identifiers.resolve(code);
        let js = Parse.toJS(rewritten);
        text += js + "\n";
        Debug.log(js);
      } catch (x) {
        Debug.error(x);
        Debug.error(x.stack);
      }
    }
  );
github Yoric / Marv-the-Tinker / src / comp / pass_ident.js View on Github external
let previous;
            let definition = new Ast.VariableDeclarator(node.id.loc, node.id.range, null,
                                                        node.id, null, "function");
            if (  (previous = function_scope.get(node.id.name))
              || (previous = block_scope.get(node.id.name))) {
              report_redef(definition, previous);
            }
            function_scope.put(definition);
          }

          // Then advance to subscope and introduce arguments in that subscope
          block_scope = block_scope.enter();
          function_scope = function_scope.enter();
          for (let i = 0; i < node.params.length; ++i) {
            let current = node.params[i];
            Debug.log("Declaring argument "+current.toSource());
            function_scope.put(new Ast.VariableDeclarator(current.loc, current.range, null,
                                                  current, null, "argument"));
          }

          // Also introduce |arguments|
          function_scope.put(new Ast.VariableDeclarator(node.loc, node.range, null,
                                                        new Ast.Identifier(node.loc, node.range, null,
                                                                          "arguments"), null, "auto"));
        },
        exit: function() {
github Yoric / Marv-the-Tinker / src / comp / pass_ident.js View on Github external
exit: function() {
          Debug.log("FunctionDeclaration.exit");
          block_scope = block_scope.parent;
          function_scope = function_scope.parent;
        }
      },
github Yoric / Marv-the-Tinker / src / comp / ast.js View on Github external
function walk_array(array, cb) {
  for (let i = 0; i < array.length; ++i) {
    Debug.log(array[i].type);
    let current = array[i].walk(cb);
    if (current) {
      array[i] = current;
    }
  }
}
github Yoric / Marv-the-Tinker / src / comp / parse.js View on Github external
fromFile: function File(fileName) {
    let source = read(fileName);
    Debug.log("Parsing starts");
    var start = Date.now();
    let untyped_ast = esprima.parse(source, options);
    var stop = Date.now();
    printErr("Parsing took "+(stop - start)/1000+" seconds");
    Debug.log("Parsing done, transformation starts");
    Debug.log(untyped_ast.toSource());
    let typed_ast = to_typed_ast(untyped_ast, fileName);
    return typed_ast;
  },
  toJS: function JS(code) {
github Yoric / Marv-the-Tinker / src / comp / parse.js View on Github external
add_comments: function(comments) {
      for (let i = 0; i < comments.length; ++i) {
        let comment = comments[i];
        let first_char = comment.value[0];
        Debug.log("Examining comment '"+comment.value+"'");
        if (first_char != '*') {
          Debug.log("Not a meaningful comment");
          continue;
        }
        let last_line = comment.end.line;
        let entry = this._unattached[last_line];
        if (!entry) {
          this._unattached[last_line] = entry = [];
        }
        entry.push(comment);
        Debug.log("This is a meaningful comment, ending at line "+last_line);
      }
    },
    /**
github Yoric / Marv-the-Tinker / src / comp / parse.js View on Github external
add_comments: function(comments) {
      for (let i = 0; i < comments.length; ++i) {
        let comment = comments[i];
        let first_char = comment.value[0];
        Debug.log("Examining comment '"+comment.value+"'");
        if (first_char != '*') {
          Debug.log("Not a meaningful comment");
          continue;
        }
        let last_line = comment.end.line;
        let entry = this._unattached[last_line];
        if (!entry) {
          this._unattached[last_line] = entry = [];
        }
        entry.push(comment);
        Debug.log("This is a meaningful comment, ending at line "+last_line);
      }
    },
    /**