void ESTreeIRGen::addLexicalDebugInfo(
    Function *child,
    Function *global,
    const std::shared_ptr<const SerializedScope> &scope) {
  if (!scope || !scope->parentScope) {
    buildDummyLexicalParent(Builder, global, child);
    return;
  }

  auto *current = Builder.createFunction(
      scope->originalName,
      Function::DefinitionKind::ES5Function,
      false,
      {},
      false);

  for (auto &var : scope->variables) {
    Builder.createVariable(
        current->getFunctionScope(), Variable::DeclKind::Var, var);
  }

  buildDummyLexicalParent(Builder, current, child);
  addLexicalDebugInfo(current, global, scope->parentScope);
}
void ESTreeIRGen::addLexicalDebugInfo(
    Function *child,
    Function *global,
    const std::shared_ptr<const SerializedScope> &scope) {
  if (!scope || !scope->parentScope) {
    buildDummyLexicalParent(Builder, global, child);
    return;
  }

  auto *current = Builder.createFunction(
      scope->originalName,
      Function::DefinitionKind::ES5Function,
      false,
      {},
      false);

  for (auto &var : scope->variables) {
    Builder.createVariable(
        current->getFunctionScope(), Variable::DeclKind::Var, var);
  }

  buildDummyLexicalParent(Builder, current, child);
  addLexicalDebugInfo(current, global, scope->parentScope);
}