Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(127)

Issue 140066: Strawman: a way to rework Scope to make it more flexible. (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
16 years, 5 months ago by MikeSamuel
Modified:
16 years, 5 months ago
Reviewers:
ihab.awad
CC:
google-caja-discuss_googlegroups.com
Base URL:
http://google-caja.googlecode.com/svn/trunk/
Visibility:
Public.

Description

Parts of this CL will be resubmitted as smaller CLs, but as a whole it is defunct. Decisions re scopes are documented at https://groups.google.com/group/google-caja-discuss/browse_thread/thread/50db6111ae71c2c9 ================= We currently have a Scope class which was defined for the Rewriter scheme. For each optimization pass I've done, I've ended up writing my own scope scheme, often on top of Scope. E.g. the AlphaRenaming uses an identity map to associate extra info with scopes, and the array index optimization builds it's own scope tree, so that it can easily walk from a scope to its children. The linter uses a scoping scheme that abstracts away the decision of where declarations are introduced into scopes and which scopes they are hoisted to, so that it can make sure that scoping is consistent between JScript and other interpreters. I would like to unify these scoping schemes and support more scoping. Scopes are used in a few different ways: # In a rewriter to scope lazily # On an entire tree to attach a scope to each node # To generate masking errors about violations of Cajita specific invariants (such as forbidding declaration of the name "cajita") # To identify the kind of symbol -- function declaration, local function name, exception, data, globals # To collect information about declarations # To resolve references to declaration points or to scopes # To detect redelcaration # To emulate ES5 scoping rules # To emulate broken IE scoping # To collect uses of a variable # To determine whether/where a symbol is used as a LeftHandSideExpression # To collect uses in narrower scopes. # To collect the set of symbols from wider scopes. There are a few separable concerns here: # Applying scoping rules of a given variant of JS -- exception hoisting, whether function constructors' names intrude on the containing scope to introduce scopes, and collect declarations # Associating scopes with parse tree nodes Collecting usage information Please see ScopeListener for a general interface to collecting and collating Scope information. See ScopeAnalyzer for a general implementation that implements a scoping scheme, and its concrete implementations: ES5ScopeAnalyzer, JScriptScopeAnalyzer, WorstCaseScopeAnalyzer. The ScopeAnalyzerTests give an idea of how ScopeAnalyzer works. Finally, Scope has been rewritten to use ES5ScopeAnalyzer.

Patch Set 1 #

Patch Set 2 : Strawman: a way to rework Scope to make it more flexible. #

Patch Set 3 : Strawman: a way to rework Scope to make it more flexible. #

Patch Set 4 : Strawman: a way to rework Scope to make it more flexible. #

Patch Set 5 : Strawman: a way to rework Scope to make it more flexible. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1844 lines, -498 lines) Patch
M build.xml View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M src/com/google/caja/ancillary/opt/LocalVarRenamer.java View 3 chunks +3 lines, -2 lines 0 comments Download
M src/com/google/caja/parser/js/Operation.java View 1 2 3 1 chunk +5 lines, -0 lines 0 comments Download
A src/com/google/caja/parser/js/scope/AbstractScope.java View 1 chunk +46 lines, -0 lines 0 comments Download
A src/com/google/caja/parser/js/scope/ES5ScopeAnalyzer.java View 1 chunk +42 lines, -0 lines 0 comments Download
A src/com/google/caja/parser/js/scope/JScriptScopeAnalyzer.java View 1 chunk +26 lines, -0 lines 0 comments Download
A src/com/google/caja/parser/js/scope/ScopeAnalyzer.java View 1 2 3 1 chunk +435 lines, -0 lines 0 comments Download
A src/com/google/caja/parser/js/scope/ScopeFactory.java View 1 chunk +32 lines, -0 lines 0 comments Download
A src/com/google/caja/parser/js/scope/ScopeListener.java View 1 1 chunk +106 lines, -0 lines 0 comments Download
A src/com/google/caja/parser/js/scope/ScopeType.java View 1 chunk +88 lines, -0 lines 0 comments Download
A src/com/google/caja/parser/js/scope/WorstCaseScopeAnalyzer.java View 1 chunk +33 lines, -0 lines 0 comments Download
M src/com/google/caja/parser/quasiliteral/Scope.java View 1 2 3 12 chunks +220 lines, -331 lines 0 comments Download
M src/com/google/caja/parser/quasiliteral/SyntheticRuleSet.java View 1 2 3 3 chunks +10 lines, -3 lines 0 comments Download
M tests/com/google/caja/parser/html/DomParserTest.java View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
A tests/com/google/caja/parser/js/scope/ScopeAnalyzerTest.java View 1 2 3 1 chunk +593 lines, -0 lines 0 comments Download
M tests/com/google/caja/parser/quasiliteral/CajitaRewriterTest.java View 1 2 3 1 chunk +5 lines, -6 lines 0 comments Download
M tests/com/google/caja/parser/quasiliteral/RewriterTestCase.java View 1 2 3 4 chunks +2 lines, -53 lines 0 comments Download
M tests/com/google/caja/parser/quasiliteral/ScopeTest.java View 1 2 3 24 chunks +187 lines, -99 lines 0 comments Download
M tests/com/google/caja/util/MoreAsserts.java View 1 2 3 4 chunks +9 lines, -2 lines 0 comments Download

Messages

Total messages: 2
MikeSamuel
16 years, 5 months ago (2009-10-26 22:25:09 UTC) #1
MikeSamuel
16 years, 5 months ago (2009-10-26 22:54:16 UTC) #2
Commented ScopeAnalyzer and cleaned up confusion between "definition" and
"declaration."  See the glossary in ScopeAnalyzer's class comment for details.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b