@@ -53,7 +53,7 @@ class AnalyzePrototypeProperties implements CompilerPass {
53
53
private final boolean anchorUnusedVars ;
54
54
private final boolean rootScopeUsesAreGlobal ;
55
55
56
- private final JSChunkGraph moduleGraph ;
56
+ private final JSChunkGraph chunkGraph ;
57
57
private final @ Nullable JSChunk firstModule ;
58
58
59
59
// Properties that are implicitly used as part of the JS language.
@@ -100,7 +100,7 @@ class AnalyzePrototypeProperties implements CompilerPass {
100
100
* Creates a new pass for analyzing prototype properties.
101
101
*
102
102
* @param compiler The compiler.
103
- * @param moduleGraph The graph for resolving module dependencies.
103
+ * @param chunkGraph The graph for resolving module dependencies.
104
104
* @param canModifyExterns If true, then we can move prototype properties that are declared in the
105
105
* externs file.
106
106
* @param anchorUnusedVars If true, then we must mark all vars as referenced, even if they are
@@ -110,18 +110,18 @@ class AnalyzePrototypeProperties implements CompilerPass {
110
110
*/
111
111
AnalyzePrototypeProperties (
112
112
AbstractCompiler compiler ,
113
- JSChunkGraph moduleGraph ,
113
+ JSChunkGraph chunkGraph ,
114
114
boolean canModifyExterns ,
115
115
boolean anchorUnusedVars ,
116
116
boolean rootScopeUsesAreGlobal ) {
117
117
this .compiler = compiler ;
118
- this .moduleGraph = moduleGraph ;
118
+ this .chunkGraph = chunkGraph ;
119
119
this .canModifyExterns = canModifyExterns ;
120
120
this .anchorUnusedVars = anchorUnusedVars ;
121
121
this .rootScopeUsesAreGlobal = rootScopeUsesAreGlobal ;
122
122
123
- if (moduleGraph .getChunkCount () > 1 ) {
124
- firstModule = moduleGraph .getRootChunk ();
123
+ if (chunkGraph .getChunkCount () > 1 ) {
124
+ firstModule = chunkGraph .getRootChunk ();
125
125
} else {
126
126
firstModule = null ;
127
127
}
@@ -133,11 +133,11 @@ class AnalyzePrototypeProperties implements CompilerPass {
133
133
134
134
for (String property : IMPLICITLY_USED_PROPERTIES ) {
135
135
NameInfo nameInfo = getNameInfoForName (property , PROPERTY );
136
- if (moduleGraph == null ) {
136
+ if (chunkGraph == null ) {
137
137
symbolGraph .connect (externNode , null , nameInfo );
138
138
} else {
139
- for (JSChunk module : moduleGraph .getAllChunks ()) {
140
- symbolGraph .connect (externNode , module , nameInfo );
139
+ for (JSChunk chunk : chunkGraph .getAllChunks ()) {
140
+ symbolGraph .connect (externNode , chunk , nameInfo );
141
141
}
142
142
}
143
143
}
@@ -402,7 +402,7 @@ public void visit(NodeTraversal t, Node n, Node parent) {
402
402
}
403
403
}
404
404
405
- private void addSymbolUse (String name , JSChunk module , SymbolType type ) {
405
+ private void addSymbolUse (String name , JSChunk chunk , SymbolType type ) {
406
406
NameInfo info = getNameInfoForName (name , type );
407
407
NameInfo def = null ;
408
408
// Skip all anonymous nodes. We care only about symbols with names.
@@ -413,7 +413,7 @@ private void addSymbolUse(String name, JSChunk module, SymbolType type) {
413
413
}
414
414
}
415
415
if (!def .equals (info )) {
416
- symbolGraph .connect (def , module , info );
416
+ symbolGraph .connect (def , chunk , info );
417
417
}
418
418
}
419
419
@@ -583,8 +583,8 @@ private void processMemberDef(NodeTraversal t, Node n) {
583
583
return maybeName .isName () ? t .getScope ().getVar (maybeName .getString ()) : null ;
584
584
}
585
585
586
- private void addGlobalUseOfSymbol (String name , JSChunk module , SymbolType type ) {
587
- symbolGraph .connect (globalNode , module , getNameInfoForName (name , type ));
586
+ private void addGlobalUseOfSymbol (String name , JSChunk chunk , SymbolType type ) {
587
+ symbolGraph .connect (globalNode , chunk , getNameInfoForName (name , type ));
588
588
}
589
589
}
590
590
@@ -623,7 +623,7 @@ private class PropagateReferences implements EdgeCallback<NameInfo, JSChunk> {
623
623
public boolean traverseEdge (NameInfo start , JSChunk edge , NameInfo dest ) {
624
624
if (start .isReferenced ()) {
625
625
JSChunk startModule = start .getDeepestCommonModuleRef ();
626
- if (startModule != null && moduleGraph .dependsOn (startModule , edge )) {
626
+ if (startModule != null && chunkGraph .dependsOn (startModule , edge )) {
627
627
return dest .markReference (startModule );
628
628
} else {
629
629
return dest .markReference (edge );
@@ -639,7 +639,7 @@ interface Symbol {
639
639
Var getRootVar ();
640
640
641
641
/** Returns the module where this appears. */
642
- JSChunk getModule ();
642
+ JSChunk getChunk ();
643
643
}
644
644
645
645
private enum SymbolType {
@@ -653,15 +653,15 @@ private enum SymbolType {
653
653
*/
654
654
static class GlobalFunction implements Symbol {
655
655
private final Var var ;
656
- private final JSChunk module ;
656
+ private final JSChunk chunk ;
657
657
658
- GlobalFunction (Node nameNode , Var var , JSChunk module ) {
658
+ GlobalFunction (Node nameNode , Var var , JSChunk chunk ) {
659
659
Node parent = nameNode .getParent ();
660
660
checkState (
661
661
(NodeUtil .isNameDeclaration (parent ) && var .isGlobal ())
662
662
|| NodeUtil .isFunctionDeclaration (parent ));
663
663
this .var = var ;
664
- this .module = module ;
664
+ this .chunk = chunk ;
665
665
}
666
666
667
667
@ Override
@@ -670,8 +670,8 @@ public Var getRootVar() {
670
670
}
671
671
672
672
@ Override
673
- public JSChunk getModule () {
674
- return module ;
673
+ public JSChunk getChunk () {
674
+ return chunk ;
675
675
}
676
676
}
677
677
@@ -684,14 +684,14 @@ interface Property extends Symbol {}
684
684
static class ClassMemberFunction implements Property {
685
685
private final Node node ;
686
686
private final Var var ;
687
- private final JSChunk module ;
687
+ private final JSChunk chunk ;
688
688
689
- ClassMemberFunction (Node node , Var var , JSChunk module ) {
689
+ ClassMemberFunction (Node node , Var var , JSChunk chunk ) {
690
690
checkState (node .getParent ().isClassMembers ());
691
691
checkState (node .isMemberFunctionDef () || node .isSetterDef () || node .isGetterDef ());
692
692
this .node = node ;
693
693
this .var = var ;
694
- this .module = module ;
694
+ this .chunk = chunk ;
695
695
}
696
696
697
697
@ Override
@@ -700,8 +700,8 @@ public Var getRootVar() {
700
700
}
701
701
702
702
@ Override
703
- public JSChunk getModule () {
704
- return module ;
703
+ public JSChunk getChunk () {
704
+ return chunk ;
705
705
}
706
706
707
707
/** Returns the function node within the definition. */
@@ -751,13 +751,15 @@ interface PrototypeProperty extends Property {
751
751
static class AssignmentPrototypeProperty implements PrototypeProperty {
752
752
private final Node exprNode ;
753
753
private final Var rootVar ;
754
- private final JSChunk module ;
754
+ private final JSChunk chunk ;
755
755
756
- /** @param node An EXPR node. */
757
- AssignmentPrototypeProperty (Node node , Var rootVar , JSChunk module ) {
756
+ /**
757
+ * @param node An EXPR node.
758
+ */
759
+ AssignmentPrototypeProperty (Node node , Var rootVar , JSChunk chunk ) {
758
760
this .exprNode = node ;
759
761
this .rootVar = rootVar ;
760
- this .module = module ;
762
+ this .chunk = chunk ;
761
763
}
762
764
763
765
@ Override
@@ -780,8 +782,8 @@ private Node getAssignNode() {
780
782
}
781
783
782
784
@ Override
783
- public JSChunk getModule () {
784
- return module ;
785
+ public JSChunk getChunk () {
786
+ return chunk ;
785
787
}
786
788
}
787
789
@@ -795,13 +797,13 @@ static class LiteralPrototypeProperty implements PrototypeProperty {
795
797
private final Node value ;
796
798
private final Node assign ;
797
799
private final Var rootVar ;
798
- private final JSChunk module ;
800
+ private final JSChunk chunk ;
799
801
800
- LiteralPrototypeProperty (Node value , Node assign , Var rootVar , JSChunk module ) {
802
+ LiteralPrototypeProperty (Node value , Node assign , Var rootVar , JSChunk chunk ) {
801
803
this .value = value ;
802
804
this .assign = assign ;
803
805
this .rootVar = rootVar ;
804
- this .module = module ;
806
+ this .chunk = chunk ;
805
807
}
806
808
807
809
@ Override
@@ -820,8 +822,8 @@ public Node getValue() {
820
822
}
821
823
822
824
@ Override
823
- public JSChunk getModule () {
824
- return module ;
825
+ public JSChunk getChunk () {
826
+ return chunk ;
825
827
}
826
828
}
827
829
@@ -849,7 +851,7 @@ class NameInfo {
849
851
850
852
private boolean referenced = false ;
851
853
private final Deque <Symbol > declarations = new ArrayDeque <>();
852
- private @ Nullable JSChunk deepestCommonModuleRef = null ;
854
+ private @ Nullable JSChunk deepestCommonChunkRef = null ;
853
855
854
856
// True if this property is a function that reads a variable from an
855
857
// outer scope which isn't the global scope.
@@ -896,23 +898,23 @@ boolean referencesSuper() {
896
898
* @param module The module where it was referenced.
897
899
* @return Whether the name info has changed.
898
900
*/
899
- boolean markReference (@ Nullable JSChunk module ) {
901
+ boolean markReference (@ Nullable JSChunk chunk ) {
900
902
boolean hasChanged = false ;
901
903
if (!referenced ) {
902
904
referenced = true ;
903
905
hasChanged = true ;
904
906
}
905
907
906
- JSChunk originalDeepestCommon = deepestCommonModuleRef ;
908
+ JSChunk originalDeepestCommon = deepestCommonChunkRef ;
907
909
908
- if (deepestCommonModuleRef == null ) {
909
- deepestCommonModuleRef = module ;
910
+ if (deepestCommonChunkRef == null ) {
911
+ deepestCommonChunkRef = chunk ;
910
912
} else {
911
- deepestCommonModuleRef =
912
- moduleGraph .getDeepestCommonDependencyInclusive (deepestCommonModuleRef , module );
913
+ deepestCommonChunkRef =
914
+ chunkGraph .getDeepestCommonDependencyInclusive (deepestCommonChunkRef , chunk );
913
915
}
914
916
915
- if (originalDeepestCommon != deepestCommonModuleRef ) {
917
+ if (originalDeepestCommon != deepestCommonChunkRef ) {
916
918
hasChanged = true ;
917
919
}
918
920
@@ -921,7 +923,7 @@ boolean markReference(@Nullable JSChunk module) {
921
923
922
924
/** Returns the deepest common module of all the references to this property. */
923
925
JSChunk getDeepestCommonModuleRef () {
924
- return deepestCommonModuleRef ;
926
+ return deepestCommonChunkRef ;
925
927
}
926
928
927
929
/**
0 commit comments