本文整理汇总了Java中com.google.javascript.jscomp.GlobalNamespace.Ref.Type类的典型用法代码示例。如果您正苦于以下问题:Java Type类的具体用法?Java Type怎么用?Java Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Type类属于com.google.javascript.jscomp.GlobalNamespace.Ref包,在下文中一共展示了Type类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkNamespaces
import com.google.javascript.jscomp.GlobalNamespace.Ref.Type; //导入依赖的package包/类
/**
* Runs through all namespaces (prefixes of classes and enums), and checks if
* any of them have been used in an unsafe way.
*/
private void checkNamespaces() {
for (Name name : nameMap.values()) {
if (name.isNamespace() && name.refs != null &&
(name.aliasingGets > 0 || name.localSets + name.globalSets > 1)) {
boolean initialized = name.declaration != null;
for (Ref ref : name.refs) {
if (ref.type == Ref.Type.SET_FROM_GLOBAL ||
ref.type == Ref.Type.SET_FROM_LOCAL) {
if (initialized) {
warnAboutNamespaceRedefinition(name, ref);
}
initialized = true;
} else if (ref.type == Ref.Type.ALIASING_GET) {
warnAboutNamespaceAliasing(name, ref);
}
}
}
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:25,代码来源:CollapseProperties.java
示例2: inlineAliases
import com.google.javascript.jscomp.GlobalNamespace.Ref.Type; //导入依赖的package包/类
/**
* For each qualified name N in the global scope, we check if:
* (a) No ancestor of N is ever aliased or assigned an unknown value type.
* (If N = "a.b.c", "a" and "a.b" are never aliased).
* (b) N has exactly one write, and it lives in the global scope.
* (c) N is aliased in a local scope.
*
* If (a) is true, then GlobalNamespace must know all the writes to N.
* If (a) and (b) are true, then N cannot change during the execution of
* a local scope.
* If (a) and (b) and (c) are true, then the alias can be inlined if the
* alias obeys the usual rules for how we decide whether a variable is
* inlineable.
* @see InlineVariables
*/
private void inlineAliases(GlobalNamespace namespace) {
// Invariant: All the names in the worklist meet condition (a).
Deque<Name> workList = new ArrayDeque<Name>(namespace.getNameForest());
while (!workList.isEmpty()) {
Name name = workList.pop();
if (name.globalSets == 1 && name.localSets == 0 &&
name.aliasingGets > 0) {
// {@code name} meets condition (b). Find all of its local aliases
// and try to inline them.
List<Ref> refs = Lists.newArrayList(name.refs);
for (Ref ref : refs) {
if (ref.type == Type.ALIASING_GET && ref.scope.isLocal()) {
// {@code name} meets condition (c). Try to inline it.
if (inlineAliasIfPossible(ref, namespace)) {
name.removeRef(ref);
}
}
}
}
// Check if {@code name} has any aliases left after the
// local-alias-inlining above.
if ((name.type == Name.Type.OBJECTLIT ||
name.type == Name.Type.FUNCTION) &&
name.aliasingGets == 0 && name.props != null) {
// All of {@code name}'s children meet condition (a), so they can be
// added to the worklist.
workList.addAll(name.props);
}
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:48,代码来源:CollapseProperties.java
示例3: inlineAliases
import com.google.javascript.jscomp.GlobalNamespace.Ref.Type; //导入依赖的package包/类
/**
* For each qualified name N in the global scope, we check if:
* (a) No ancestor of N is ever aliased or assigned an unknown value type.
* (If N = "a.b.c", "a" and "a.b" are never aliased).
* (b) N has exactly one write, and it lives in the global scope.
* (c) N is aliased in a local scope.
*
* If (a) is true, then GlobalNamespace must know all the writes to N.
* If (a) and (b) are true, then N cannot change during the execution of
* a local scope.
* If (a) and (b) and (c) are true, then the alias can be inlined if the
* alias obeys the usual rules for how we decide whether a variable is
* inlineable.
* @see InlineVariables
*/
private void inlineAliases(GlobalNamespace namespace) {
// Invariant: All the names in the worklist meet condition (a).
Deque<Name> workList = new ArrayDeque<Name>(namespace.getNameForest());
while (!workList.isEmpty()) {
Name name = workList.pop();
// Don't attempt to inline a getter or setter property as a variable.
if (name.type == Name.Type.GET || name.type == Name.Type.SET) {
continue;
}
if (name.globalSets == 1 && name.localSets == 0 &&
name.aliasingGets > 0) {
// {@code name} meets condition (b). Find all of its local aliases
// and try to inline them.
List<Ref> refs = Lists.newArrayList(name.getRefs());
for (Ref ref : refs) {
if (ref.type == Type.ALIASING_GET && ref.scope.isLocal()) {
// {@code name} meets condition (c). Try to inline it.
if (inlineAliasIfPossible(ref, namespace)) {
name.removeRef(ref);
}
}
}
}
// Check if {@code name} has any aliases left after the
// local-alias-inlining above.
if ((name.type == Name.Type.OBJECTLIT ||
name.type == Name.Type.FUNCTION) &&
name.aliasingGets == 0 && name.props != null) {
// All of {@code name}'s children meet condition (a), so they can be
// added to the worklist.
workList.addAll(name.props);
}
}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:53,代码来源:CollapseProperties.java
示例4: checkNamespaces
import com.google.javascript.jscomp.GlobalNamespace.Ref.Type; //导入依赖的package包/类
/**
* Runs through all namespaces (prefixes of classes and enums), and checks if
* any of them have been used in an unsafe way.
*/
private void checkNamespaces() {
for (Name name : nameMap.values()) {
if (name.isNamespace() &&
(name.aliasingGets > 0 || name.localSets + name.globalSets > 1 ||
name.deleteProps > 0)) {
boolean initialized = name.getDeclaration() != null;
for (Ref ref : name.getRefs()) {
if (ref == name.getDeclaration()) {
continue;
}
if (ref.type == Ref.Type.DELETE_PROP) {
if (initialized) {
warnAboutNamespaceRedefinition(name, ref);
}
} else if (
ref.type == Ref.Type.SET_FROM_GLOBAL ||
ref.type == Ref.Type.SET_FROM_LOCAL) {
if (initialized) {
warnAboutNamespaceRedefinition(name, ref);
}
initialized = true;
} else if (ref.type == Ref.Type.ALIASING_GET) {
warnAboutNamespaceAliasing(name, ref);
}
}
}
}
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:35,代码来源:CollapseProperties.java
示例5: inlineAliases
import com.google.javascript.jscomp.GlobalNamespace.Ref.Type; //导入依赖的package包/类
/**
* For each qualified name N in the global scope, we check if: (a) No ancestor of N is ever
* aliased or assigned an unknown value type. (If N = "a.b.c", "a" and "a.b" are never aliased).
* (b) N has exactly one write, and it lives in the global scope. (c) N is aliased in a local
* scope. (d) N is aliased in global scope
*
* <p>If (a) is true, then GlobalNamespace must know all the writes to N. If (a) and (b) are true,
* then N cannot change during the execution of a local scope. If (a) and (b) and (c) are true,
* then the alias can be inlined if the alias obeys the usual rules for how we decide whether a
* variable is inlineable. If (a) and (b) and (d) are true, then inline the alias if possible (if
* it is assigned exactly once unconditionally).
*
* <p>For (a), (b), and (c) are true and the alias is of a constructor, we may also partially
* inline the alias - i.e. replace some references with the constructor but not all - since
* constructor properties are always collapsed, so we want to be more aggressive about removing
* aliases.
*
* @see InlineVariables
*/
private void inlineAliases(GlobalNamespace namespace) {
// Invariant: All the names in the worklist meet condition (a).
Deque<Name> workList = new ArrayDeque<>(namespace.getNameForest());
while (!workList.isEmpty()) {
Name name = workList.pop();
// Don't attempt to inline a getter or setter property as a variable.
if (name.type == Name.Type.GET || name.type == Name.Type.SET) {
continue;
}
if (!name.inExterns && name.globalSets == 1 && name.localSets == 0 && name.aliasingGets > 0) {
// {@code name} meets condition (b). Find all of its local aliases
// and try to inline them.
List<Ref> refs = new ArrayList<>(name.getRefs());
for (Ref ref : refs) {
Scope hoistScope = ref.scope.getClosestHoistScope();
if (ref.type == Type.ALIASING_GET && !mayBeGlobalAlias(ref) && ref.getTwin() == null) {
// {@code name} meets condition (c). Try to inline it.
// TODO(johnlenz): consider picking up new aliases at the end
// of the pass instead of immediately like we do for global
// inlines.
if (inlineAliasIfPossible(name, ref, namespace)) {
name.removeRef(ref);
}
} else if (ref.type == Type.ALIASING_GET
&& hoistScope.isGlobal()
&& ref.getTwin() == null) { // ignore aliases in chained assignments
if (inlineGlobalAliasIfPossible(name, ref, namespace)) {
name.removeRef(ref);
}
}
}
}
if (!name.inExterns && name.type == Name.Type.CLASS) {
List<Name> subclasses = name.subclasses;
if (subclasses != null && name.props != null) {
for (Name subclass : subclasses) {
for (Name prop : name.props) {
rewriteAllSubclassInheritedAccesses(name, subclass, prop, namespace);
}
}
}
}
// Check if {@code name} has any aliases left after the
// local-alias-inlining above.
if ((name.type == Name.Type.OBJECTLIT
|| name.type == Name.Type.FUNCTION
|| name.type == Name.Type.CLASS)
&& name.aliasingGets == 0
&& name.props != null) {
// All of {@code name}'s children meet condition (a), so they can be
// added to the worklist.
workList.addAll(name.props);
}
}
}
开发者ID:google,项目名称:closure-compiler,代码行数:80,代码来源:AggressiveInlineAliases.java
示例6: inlineAliases
import com.google.javascript.jscomp.GlobalNamespace.Ref.Type; //导入依赖的package包/类
/**
* For each qualified name N in the global scope, we check if:
* (a) No ancestor of N is ever aliased or assigned an unknown value type.
* (If N = "a.b.c", "a" and "a.b" are never aliased).
* (b) N has exactly one write, and it lives in the global scope.
* (c) N is aliased in a local scope.
* (d) N is aliased in global scope
*
* If (a) is true, then GlobalNamespace must know all the writes to N.
* If (a) and (b) are true, then N cannot change during the execution of
* a local scope.
* If (a) and (b) and (c) are true, then the alias can be inlined if the
* alias obeys the usual rules for how we decide whether a variable is
* inlineable.
* If (a) and (b) and (d) are true, then inline the alias if possible (if
* it is assigned exactly once unconditionally).
* @see InlineVariables
*/
private void inlineAliases(GlobalNamespace namespace) {
// Invariant: All the names in the worklist meet condition (a).
Deque<Name> workList = new ArrayDeque<>(namespace.getNameForest());
while (!workList.isEmpty()) {
Name name = workList.pop();
// Don't attempt to inline a getter or setter property as a variable.
if (name.type == Name.Type.GET || name.type == Name.Type.SET) {
continue;
}
if (!name.inExterns && name.globalSets == 1 && name.localSets == 0 &&
name.aliasingGets > 0) {
// {@code name} meets condition (b). Find all of its local aliases
// and try to inline them.
List<Ref> refs = Lists.newArrayList(name.getRefs());
for (Ref ref : refs) {
if (ref.type == Type.ALIASING_GET && ref.scope.isLocal()) {
// {@code name} meets condition (c). Try to inline it.
// TODO(johnlenz): consider picking up new aliases at the end
// of the pass instead of immediately like we do for global
// inlines.
if (inlineAliasIfPossible(ref, namespace)) {
name.removeRef(ref);
}
} else if (ref.type == Type.ALIASING_GET
&& ref.scope.isGlobal()
&& ref.getTwin() == null) { // ignore aliases in chained assignments
if (inlineGlobalAliasIfPossible(ref, namespace)) {
name.removeRef(ref);
}
}
}
}
// Check if {@code name} has any aliases left after the
// local-alias-inlining above.
if ((name.type == Name.Type.OBJECTLIT ||
name.type == Name.Type.FUNCTION) &&
name.aliasingGets == 0 && name.props != null) {
// All of {@code name}'s children meet condition (a), so they can be
// added to the worklist.
workList.addAll(name.props);
}
}
}
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:66,代码来源:CollapseProperties.java
示例7: inlineAliases
import com.google.javascript.jscomp.GlobalNamespace.Ref.Type; //导入依赖的package包/类
/**
* For each qualified name N in the global scope, we check if:
* (a) No ancestor of N is ever aliased or assigned an unknown value type.
* (If N = "a.b.c", "a" and "a.b" are never aliased).
* (b) N has exactly one write, and it lives in the global scope.
* (c) N is aliased in a local scope.
* (d) N is aliased in global scope
*
* If (a) is true, then GlobalNamespace must know all the writes to N.
* If (a) and (b) are true, then N cannot change during the execution of
* a local scope.
* If (a) and (b) and (c) are true, then the alias can be inlined if the
* alias obeys the usual rules for how we decide whether a variable is
* inlineable.
* If (a) and (b) and (d) are true, then inline the alias if possible (if
* it is assigned exactly once unconditionally).
* @see InlineVariables
*/
private void inlineAliases(GlobalNamespace namespace) {
// Invariant: All the names in the worklist meet condition (a).
Deque<Name> workList = new ArrayDeque<Name>(namespace.getNameForest());
while (!workList.isEmpty()) {
Name name = workList.pop();
// Don't attempt to inline a getter or setter property as a variable.
if (name.type == Name.Type.GET || name.type == Name.Type.SET) {
continue;
}
if (!name.inExterns && name.globalSets == 1 && name.localSets == 0 &&
name.aliasingGets > 0) {
// {@code name} meets condition (b). Find all of its local aliases
// and try to inline them.
List<Ref> refs = Lists.newArrayList(name.getRefs());
for (Ref ref : refs) {
if (ref.type == Type.ALIASING_GET && ref.scope.isLocal()) {
// {@code name} meets condition (c). Try to inline it.
// TODO(johnlenz): consider picking up new aliases at the end
// of the pass instead of immediately like we do for global
// inlines.
if (inlineAliasIfPossible(ref, namespace)) {
name.removeRef(ref);
}
} else if (ref.type == Type.ALIASING_GET
&& ref.scope.isGlobal()
&& ref.getTwin() == null) { // ignore aliases in chained assignments
if (inlineGlobalAliasIfPossible(ref, namespace)) {
name.removeRef(ref);
}
}
}
}
// Check if {@code name} has any aliases left after the
// local-alias-inlining above.
if ((name.type == Name.Type.OBJECTLIT ||
name.type == Name.Type.FUNCTION) &&
name.aliasingGets == 0 && name.props != null) {
// All of {@code name}'s children meet condition (a), so they can be
// added to the worklist.
workList.addAll(name.props);
}
}
}
开发者ID:Robbert,项目名称:closure-compiler-copy,代码行数:66,代码来源:CollapseProperties.java
注:本文中的com.google.javascript.jscomp.GlobalNamespace.Ref.Type类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论