Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Three ways to generate a name in the compiler #2447

Closed
JsonFreeman opened this issue Mar 20, 2015 · 2 comments
Closed

Three ways to generate a name in the compiler #2447

JsonFreeman opened this issue Mar 20, 2015 · 2 comments
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@JsonFreeman
Copy link
Contributor

Right now, we have two ways of generating a name in the compiler:

  1. createTempVariable in the emitter
  2. generateUniqueName in utilities.

The second one can further be split into two callers:

  1. getGeneratedNamesForSourceFile in the checker
  2. generateUniqueNameForLocation in the emitter

We also have 3 ways to track whether a name is unique, and both methods of generating a name do all of these:

  1. NodeLinks.generatedNames tracks the names generated for a file, and considers them all used.
  2. tempCount in createTempVariable keeps track of a different set of names per file by using a counter
  3. The ScopeFrame stack in the emitter keeps track of names per scope (lastFrame, currentScopeNames, etc)

All of these things need to be consolidated. There are some desirable qualities we want the solution to have:

  1. Only one way for callers to make a unique name in the compiler.
  2. This way should support the case where the caller prefers some ideal base name to use, and the case where any old name will do.
  3. We need to decide whether uniqueness should be tracked per file or per scope, and treat uniqueness that way consistently throughout the compiler.
@JsonFreeman JsonFreeman added the Bug A bug in TypeScript label Mar 20, 2015
@basarat
Copy link
Contributor

basarat commented Mar 20, 2015

I haven't looked at the code. Hope no one is using Random 🌹

@mhegazy mhegazy added this to the TypeScript 1.5 milestone Mar 24, 2015
@vladima
Copy link
Contributor

vladima commented Mar 24, 2015

Should be addressed by #2471

vladima added a commit that referenced this issue Mar 24, 2015
@vladima vladima added the Fixed A PR has been merged for this issue label Mar 24, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants