本文整理汇总了Java中com.google.javascript.rhino.jstype.BooleanLiteralSet类的典型用法代码示例。如果您正苦于以下问题:Java BooleanLiteralSet类的具体用法?Java BooleanLiteralSet怎么用?Java BooleanLiteralSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BooleanLiteralSet类属于com.google.javascript.rhino.jstype包,在下文中一共展示了BooleanLiteralSet类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: BooleanOutcomePair
import com.google.javascript.rhino.jstype.BooleanLiteralSet; //导入依赖的package包/类
BooleanOutcomePair(
BooleanLiteralSet toBooleanOutcomes, BooleanLiteralSet booleanValues,
FlowScope leftScope, FlowScope rightScope) {
this.toBooleanOutcomes = toBooleanOutcomes;
this.booleanValues = booleanValues;
this.leftScope = leftScope;
this.rightScope = rightScope;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:9,代码来源:TypeInference.java
示例2: newBooleanOutcomePair
import com.google.javascript.rhino.jstype.BooleanLiteralSet; //导入依赖的package包/类
private BooleanOutcomePair newBooleanOutcomePair(
JSType jsType, FlowScope flowScope) {
if (jsType == null) {
return new BooleanOutcomePair(
BooleanLiteralSet.BOTH, BooleanLiteralSet.BOTH, flowScope, flowScope);
}
return new BooleanOutcomePair(jsType.getPossibleToBooleanOutcomes(),
registry.getNativeType(BOOLEAN_TYPE).isSubtype(jsType) ?
BooleanLiteralSet.BOTH : BooleanLiteralSet.EMPTY,
flowScope, flowScope);
}
开发者ID:andyjko,项目名称:feedlack,代码行数:12,代码来源:TypeInference.java
示例3: joinBooleanOutcomes
import com.google.javascript.rhino.jstype.BooleanLiteralSet; //导入依赖的package包/类
private static BooleanLiteralSet joinBooleanOutcomes(
boolean isAnd, BooleanLiteralSet left, BooleanLiteralSet right) {
// A truthy value on the lhs of an {@code &&} can never make it to the
// result. Same for a falsy value on the lhs of an {@code ||}.
// Hence the intersection.
return right.union(left.intersection(BooleanLiteralSet.get(!isAnd)));
}
开发者ID:google,项目名称:closure-compiler,代码行数:8,代码来源:TypeInference.java
示例4: traverseShortCircuitingBinOp
import com.google.javascript.rhino.jstype.BooleanLiteralSet; //导入依赖的package包/类
private BooleanOutcomePair traverseShortCircuitingBinOp(
Node n, FlowScope scope, boolean condition) {
Node left = n.getFirstChild();
Node right = n.getLastChild();
// type the left node
BooleanOutcomePair leftLiterals =
traverseWithinShortCircuitingBinOp(left,
scope.createChildFlowScope());
JSType leftType = left.getJSType();
// reverse abstract interpret the left node to produce the correct
// scope in which to verify the right node
FlowScope rightScope = reverseInterpreter.
getPreciserScopeKnowingConditionOutcome(
left, leftLiterals.getOutcomeFlowScope(left.getType(), condition),
condition);
// type the right node
BooleanOutcomePair rightLiterals =
traverseWithinShortCircuitingBinOp(
right, rightScope.createChildFlowScope());
JSType rightType = right.getJSType();
JSType type;
BooleanOutcomePair literals;
if (leftType != null && rightType != null) {
leftType = leftType.getRestrictedTypeGivenToBooleanOutcome(!condition);
if (leftLiterals.toBooleanOutcomes ==
BooleanLiteralSet.get(!condition)) {
// Use the restricted left type, since the right side never gets
// evaluated.
type = leftType;
literals = leftLiterals;
} else {
// Use the join of the restricted left type knowing the outcome of the
// ToBoolean predicate and of the right type.
type = leftType.getLeastSupertype(rightType);
literals =
getBooleanOutcomePair(leftLiterals, rightLiterals, condition);
}
// Exclude the boolean type if the literal set is empty because a boolean
// can never actually be returned.
if (literals.booleanValues == BooleanLiteralSet.EMPTY &&
getNativeType(BOOLEAN_TYPE).isSubtype(type)) {
// Exclusion only make sense for a union type.
if (type instanceof UnionType) {
type = ((UnionType) type).getRestrictedUnion(
getNativeType(BOOLEAN_TYPE));
}
}
} else {
type = null;
literals = new BooleanOutcomePair(
BooleanLiteralSet.BOTH, BooleanLiteralSet.BOTH,
leftLiterals.getJoinedFlowScope(),
rightLiterals.getJoinedFlowScope());
}
n.setJSType(type);
return literals;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:64,代码来源:TypeInference.java
示例5: traverseShortCircuitingBinOp
import com.google.javascript.rhino.jstype.BooleanLiteralSet; //导入依赖的package包/类
private BooleanOutcomePair traverseShortCircuitingBinOp(
Node n, FlowScope scope, boolean condition) {
Node left = n.getFirstChild();
Node right = n.getLastChild();
// type the left node
BooleanOutcomePair leftLiterals =
traverseWithinShortCircuitingBinOp(left,
scope.createChildFlowScope());
JSType leftType = left.getJSType();
// reverse abstract interpret the left node to produce the correct
// scope in which to verify the right node
FlowScope rightScope = reverseInterpreter.
getPreciserScopeKnowingConditionOutcome(
left, leftLiterals.getOutcomeFlowScope(left.getType(), condition),
condition);
// type the right node
BooleanOutcomePair rightLiterals =
traverseWithinShortCircuitingBinOp(
right, rightScope.createChildFlowScope());
JSType rightType = right.getJSType();
JSType type;
BooleanOutcomePair literals;
if (leftType != null && rightType != null) {
leftType = leftType.getRestrictedTypeGivenToBooleanOutcome(!condition);
if (leftLiterals.toBooleanOutcomes ==
BooleanLiteralSet.get(!condition)) {
// Use the restricted left type, since the right side never gets
// evaluated.
type = leftType;
literals = leftLiterals;
} else {
// Use the join of the restricted left type knowing the outcome of the
// ToBoolean predicate and of the right type.
type = leftType.getLeastSupertype(rightType);
literals =
getBooleanOutcomePair(leftLiterals, rightLiterals, condition);
}
// Exclude the boolean type if the literal set is empty because a boolean
// can never actually be returned.
if (literals.booleanValues == BooleanLiteralSet.EMPTY &&
getNativeType(BOOLEAN_TYPE).isSubtype(type)) {
// Exclusion only make sense for a union type.
if (type.isUnionType()) {
type = type.toMaybeUnionType().getRestrictedUnion(
getNativeType(BOOLEAN_TYPE));
}
}
} else {
type = null;
literals = new BooleanOutcomePair(
BooleanLiteralSet.BOTH, BooleanLiteralSet.BOTH,
leftLiterals.getJoinedFlowScope(),
rightLiterals.getJoinedFlowScope());
}
n.setJSType(type);
return literals;
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:64,代码来源:TypeInference.java
示例6: traverseShortCircuitingBinOp
import com.google.javascript.rhino.jstype.BooleanLiteralSet; //导入依赖的package包/类
private BooleanOutcomePair traverseShortCircuitingBinOp(
Node n, FlowScope scope) {
checkArgument(n.isAnd() || n.isOr());
boolean nIsAnd = n.isAnd();
Node left = n.getFirstChild();
Node right = n.getLastChild();
// type the left node
BooleanOutcomePair leftOutcome = traverseWithinShortCircuitingBinOp(
left, scope.createChildFlowScope());
JSType leftType = left.getJSType();
// reverse abstract interpret the left node to produce the correct
// scope in which to verify the right node
FlowScope rightScope =
reverseInterpreter.getPreciserScopeKnowingConditionOutcome(
left, leftOutcome.getOutcomeFlowScope(left.getToken(), nIsAnd), nIsAnd);
// type the right node
BooleanOutcomePair rightOutcome = traverseWithinShortCircuitingBinOp(
right, rightScope.createChildFlowScope());
JSType rightType = right.getJSType();
JSType type;
BooleanOutcomePair outcome;
if (leftType != null && rightType != null) {
leftType = leftType.getRestrictedTypeGivenToBooleanOutcome(!nIsAnd);
if (leftOutcome.toBooleanOutcomes == BooleanLiteralSet.get(!nIsAnd)) {
// Either n is && and lhs is false, or n is || and lhs is true.
// Use the restricted left type; the right side never gets evaluated.
type = leftType;
outcome = leftOutcome;
} else {
// Use the join of the restricted left type knowing the outcome of the
// ToBoolean predicate and of the right type.
type = leftType.getLeastSupertype(rightType);
outcome = new BooleanOutcomePair(
joinBooleanOutcomes(nIsAnd,
leftOutcome.toBooleanOutcomes, rightOutcome.toBooleanOutcomes),
joinBooleanOutcomes(nIsAnd,
leftOutcome.booleanValues, rightOutcome.booleanValues),
leftOutcome.getJoinedFlowScope(),
rightOutcome.getJoinedFlowScope());
}
// Exclude the boolean type if the literal set is empty because a boolean
// can never actually be returned.
if (outcome.booleanValues == BooleanLiteralSet.EMPTY &&
getNativeType(BOOLEAN_TYPE).isSubtype(type)) {
// Exclusion only makes sense for a union type.
if (type.isUnionType()) {
type = type.toMaybeUnionType().getRestrictedUnion(
getNativeType(BOOLEAN_TYPE));
}
}
} else {
type = null;
outcome = new BooleanOutcomePair(
BooleanLiteralSet.BOTH, BooleanLiteralSet.BOTH,
leftOutcome.getJoinedFlowScope(),
rightOutcome.getJoinedFlowScope());
}
n.setJSType(type);
return outcome;
}
开发者ID:google,项目名称:closure-compiler,代码行数:65,代码来源:TypeInference.java
示例7: traverseShortCircuitingBinOp
import com.google.javascript.rhino.jstype.BooleanLiteralSet; //导入依赖的package包/类
private BooleanOutcomePair traverseShortCircuitingBinOp(
Node n, FlowScope scope) {
Preconditions.checkArgument(n.isAnd() || n.isOr());
boolean nIsAnd = n.isAnd();
Node left = n.getFirstChild();
Node right = n.getLastChild();
// type the left node
BooleanOutcomePair leftOutcome = traverseWithinShortCircuitingBinOp(
left, scope.createChildFlowScope());
JSType leftType = left.getJSType();
// reverse abstract interpret the left node to produce the correct
// scope in which to verify the right node
FlowScope rightScope = reverseInterpreter.
getPreciserScopeKnowingConditionOutcome(left,
leftOutcome.getOutcomeFlowScope(left.getType(), nIsAnd),
nIsAnd);
// type the right node
BooleanOutcomePair rightOutcome = traverseWithinShortCircuitingBinOp(
right, rightScope.createChildFlowScope());
JSType rightType = right.getJSType();
JSType type;
BooleanOutcomePair outcome;
if (leftType != null && rightType != null) {
leftType = leftType.getRestrictedTypeGivenToBooleanOutcome(!nIsAnd);
if (leftOutcome.toBooleanOutcomes == BooleanLiteralSet.get(!nIsAnd)) {
// Either n is && and lhs is false, or n is || and lhs is true.
// Use the restricted left type; the right side never gets evaluated.
type = leftType;
outcome = leftOutcome;
} else {
// Use the join of the restricted left type knowing the outcome of the
// ToBoolean predicate and of the right type.
type = leftType.getLeastSupertype(rightType);
outcome = new BooleanOutcomePair(
joinBooleanOutcomes(nIsAnd,
leftOutcome.toBooleanOutcomes, rightOutcome.toBooleanOutcomes),
joinBooleanOutcomes(nIsAnd,
leftOutcome.booleanValues, rightOutcome.booleanValues),
leftOutcome.getJoinedFlowScope(),
rightOutcome.getJoinedFlowScope());
}
// Exclude the boolean type if the literal set is empty because a boolean
// can never actually be returned.
if (outcome.booleanValues == BooleanLiteralSet.EMPTY &&
getNativeType(BOOLEAN_TYPE).isSubtype(type)) {
// Exclusion only makes sense for a union type.
if (type.isUnionType()) {
type = type.toMaybeUnionType().getRestrictedUnion(
getNativeType(BOOLEAN_TYPE));
}
}
} else {
type = null;
outcome = new BooleanOutcomePair(
BooleanLiteralSet.BOTH, BooleanLiteralSet.BOTH,
leftOutcome.getJoinedFlowScope(),
rightOutcome.getJoinedFlowScope());
}
n.setJSType(type);
return outcome;
}
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:66,代码来源:TypeInference.java
示例8: getBooleanOutcomes
import com.google.javascript.rhino.jstype.BooleanLiteralSet; //导入依赖的package包/类
/**
* Infers the boolean literal set that can be taken by a
* short-circuiting binary operation ({@code &&} or {@code ||}).
* @param left the set of possible {@code ToBoolean} predicate results for
* the expression on the left side of the operator
* @param right the set of possible {@code ToBoolean} predicate results for
* the expression on the right side of the operator
* @param condition the left side {@code ToBoolean} predicate result that
* causes the right side to get evaluated (i.e. not short-circuited)
* @return a set of possible {@code ToBoolean} predicate results for the
* entire expression
*/
static BooleanLiteralSet getBooleanOutcomes(BooleanLiteralSet left,
BooleanLiteralSet right, boolean condition) {
return right.union(left.intersection(BooleanLiteralSet.get(!condition)));
}
开发者ID:andyjko,项目名称:feedlack,代码行数:17,代码来源:TypeInference.java
注:本文中的com.google.javascript.rhino.jstype.BooleanLiteralSet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论