In nodejs, how to get AST representation from the result of `script.runInContext` (loseless)

I am doing something like

let p = `(function (X) {
  var q = 0;
  for (; q < 5; ) {
    // do some stuff
    anotherfunc = function (a) {
      while (X === "somestring") {
        X += "_";
      }
    };
    q++;
  }
  return { anotherfunc: anotherfunc };
})("some arg");
`;

const vm = require("vm");
const script = new vm.Script(p);
const context = vm.createContext({});
const result = script.runInContext(context);

console.log(result);

I get { anotherfunc: ƒ anotherfunc() } printed, but if I use JSON.stringify(result) I get "{}"

I want to get something like

{ 
    anotherfunc: function (a) {
      while (X === "somestring") {
        X += "_";
      }
    };
}

in order to pass it to acorn.parse and get and AST representation.

Is there a way to make script.runInContext save the result to file for example, or have acorn parse the result which is not a string?