Giter VIP home page Giter VIP logo

Comments (1)

alangpierce avatar alangpierce commented on June 15, 2024

I'm working on this (and also decaffeinate/decaffeinate#605 ), and it turns out to be a pretty significant change to this project, so I guess I'll write down some notes of my plan in case I'm overlooking a better way:

  • Rather than ever doing magic-string operations while traversing the tree, the new plan is to maintain tentative information about all bindings, which might change as we discover more information, and then only "commit" those bindings at the end (or, at least, when we know they won't change anymore).
  • Each of these tentative binding objects is "owned" by some function (or program) scope (really some TraverseState with a function scope), even if we end up adding the var in a more specific scope. That means we won't miss declarations within if statements (fixing decaffeinate/decaffeinate#605 ) and lets us know that two variables are the same for the purpose of finding the most specific scope.
  • As we see variable declarations and usages, we traverse up to the enclosing function scope to find the latest binding information, then update the "most specific scope" information to the lowest common ancestor of the two.
  • In cases where we'd prefer to do an inline declaration (e.g. a destructure), we only end up doing so if none of the assigned variables ended up moving to a parent scope.

from add-variable-declarations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.