本文整理了Java中com.sun.tools.javac.code.Types.setBounds()
方法的一些代码示例,展示了Types.setBounds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.setBounds()
方法的具体详情如下:
包路径:com.sun.tools.javac.code.Types
类名称:Types
方法名:setBounds
[英]Same as Types#setBounds(TypeVar,List,boolean), except that third parameter is computed directly, as follows: if all all bounds are interface types, the computed supertype is Object,otherwise the supertype is simply left null (in this case, the supertype is assumed to be the head of the bound list passed as second argument). Note that this check might cause a symbol completion. Hence, this version of setBounds may not be called during a classfile read.
[中]与类型#setBounds(TypeVar、List、boolean)相同,不同的是第三个参数是直接计算的,如下所示:如果所有边界都是接口类型,则计算出的超类型是Object,否则该超类型仅保留null(在这种情况下,假定该超类型是作为第二个参数传递的绑定列表的头)。请注意,此检查可能会导致符号完成。因此,在类文件读取期间可能不会调用此版本的setBounds。
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/**
* Set the bounds field of the given type variable to reflect a
* (possibly multiple) list of bounds.
* @param t a type variable
* @param bounds the bounds, must be nonempty
* @param supertype is objectType if all bounds are interfaces,
* null otherwise.
*/
public void setBounds(TypeVar t, List<Type> bounds) {
setBounds(t, bounds, bounds.head.tsym.isInterface());
}
代码示例来源:origin: konsoletyper/teavm-javac
/**
* Same as {@link Types#setBounds(TypeVar, List, boolean)}, except that third parameter is computed directly,
* as follows: if all all bounds are interface types, the computed supertype is Object,otherwise
* the supertype is simply left null (in this case, the supertype is assumed to be the head of
* the bound list passed as second argument). Note that this check might cause a symbol completion.
* Hence, this version of setBounds may not be called during a classfile read.
*
* @param t a type variable
* @param bounds the bounds, must be nonempty
*/
public void setBounds(TypeVar t, List<Type> bounds) {
setBounds(t, bounds, bounds.head.tsym.isInterface());
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
/**
* Same as {@link #setBounds(Type.TypeVar,List,Type)}, except that
* third parameter is computed directly. Note that this test
* might cause a symbol completion. Hence, this version of
* setBounds may not be called during a classfile read.
*/
public void setBounds(TypeVar t, List<Type> bounds) {
Type supertype = (bounds.head.tsym.flags() & INTERFACE) != 0 ?
supertype(bounds.head) : null;
setBounds(t, bounds, supertype);
t.rank_field = -1;
}
// </editor-fold>
代码示例来源:origin: sc.fiji/javac
/**
* Same as {@link #setBounds(Type.TypeVar,List,Type)}, except that
* third parameter is computed directly. Note that this test
* might cause a symbol completion. Hence, this version of
* setBounds may not be called during a classfile read.
*/
public void setBounds(TypeVar t, List<Type> bounds) {
Type supertype = (bounds.head.tsym.flags() & INTERFACE) != 0 ?
supertype(bounds.head) : null;
setBounds(t, bounds, supertype);
t.rank_field = -1;
}
// </editor-fold>
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/**
* Attribute type variables (of generic classes or methods).
* Compound types are attributed later in attribBounds.
* @param typarams the type variables to enter
* @param env the current environment
*/
void attribTypeVariables(List<JCTypeParameter> typarams, Env<AttrContext> env) {
for (JCTypeParameter tvar : typarams) {
TypeVar a = (TypeVar)tvar.type;
a.tsym.flags_field |= UNATTRIBUTED;
a.bound = Type.noType;
if (!tvar.bounds.isEmpty()) {
List<Type> bounds = List.of(attribType(tvar.bounds.head, env));
for (JCExpression bound : tvar.bounds.tail)
bounds = bounds.prepend(attribType(bound, env));
types.setBounds(a, bounds.reverse());
} else {
// if no bounds are given, assume a single bound of
// java.lang.Object.
types.setBounds(a, List.of(syms.objectType));
}
a.tsym.flags_field &= ~UNATTRIBUTED;
}
for (JCTypeParameter tvar : typarams) {
chk.checkNonCyclic(tvar.pos(), (TypeVar)tvar.type);
}
}
代码示例来源:origin: konsoletyper/teavm-javac
/**
* Attribute type variables (of generic classes or methods).
* Compound types are attributed later in attribBounds.
* @param typarams the type variables to enter
* @param env the current environment
*/
void attribTypeVariables(List<JCTypeParameter> typarams, Env<AttrContext> env) {
for (JCTypeParameter tvar : typarams) {
TypeVar a = (TypeVar)tvar.type;
a.tsym.flags_field |= UNATTRIBUTED;
a.bound = Type.noType;
if (!tvar.bounds.isEmpty()) {
List<Type> bounds = List.of(attribType(tvar.bounds.head, env));
for (JCExpression bound : tvar.bounds.tail)
bounds = bounds.prepend(attribType(bound, env));
types.setBounds(a, bounds.reverse());
} else {
// if no bounds are given, assume a single bound of
// java.lang.Object.
types.setBounds(a, List.of(syms.objectType));
}
a.tsym.flags_field &= ~UNATTRIBUTED;
}
for (JCTypeParameter tvar : typarams) {
chk.checkNonCyclic(tvar.pos(), (TypeVar)tvar.type);
}
}
代码示例来源:origin: sc.fiji/javac
/**
* Attribute type variables (of generic classes or methods).
* Compound types are attributed later in attribBounds.
* @param typarams the type variables to enter
* @param env the current environment
*/
void attribTypeVariables(List<JCTypeParameter> typarams, Env<AttrContext> env) {
for (JCTypeParameter tvar : typarams) {
TypeVar a = (TypeVar)tvar.type;
if (!tvar.bounds.isEmpty()) {
List<Type> bounds = List.of(attribType(tvar.bounds.head, env));
for (JCExpression bound : tvar.bounds.tail)
bounds = bounds.prepend(attribType(bound, env));
types.setBounds(a, bounds.reverse());
} else {
// if no bounds are given, assume a single bound of
// java.lang.Object.
types.setBounds(a, List.of(syms.objectType));
}
}
for (JCTypeParameter tvar : typarams)
chk.checkNonCyclic(tvar.pos(), (TypeVar)tvar.type);
attribStats(typarams, env);
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
/**
* Attribute type variables (of generic classes or methods).
* Compound types are attributed later in attribBounds.
* @param typarams the type variables to enter
* @param env the current environment
*/
void attribTypeVariables(List<JCTypeParameter> typarams, Env<AttrContext> env) {
for (JCTypeParameter tvar : typarams) {
TypeVar a = (TypeVar)tvar.type;
if (!tvar.bounds.isEmpty()) {
List<Type> bounds = List.of(attribType(tvar.bounds.head, env));
for (JCExpression bound : tvar.bounds.tail)
bounds = bounds.prepend(attribType(bound, env));
types.setBounds(a, bounds.reverse());
} else {
// if no bounds are given, assume a single bound of
// java.lang.Object.
types.setBounds(a, List.of(syms.objectType));
}
}
for (JCTypeParameter tvar : typarams)
chk.checkNonCyclic(tvar.pos(), (TypeVar)tvar.type);
attribStats(typarams, env);
}
代码示例来源:origin: org.jvnet.sorcerer/sorcerer-javac
/** Convert (implicit) signature to type parameter.
*/
Type sigToTypeParam() {
int start = sigp;
while (signature[sigp] != ':') sigp++;
Name name = names.fromUtf(signature, start, sigp - start);
TypeVar tvar;
if (sigEnterPhase) {
tvar = new TypeVar(name, currentOwner);
typevars.enter(tvar.tsym);
} else {
tvar = (TypeVar)findTypeVar(name);
}
List<Type> bounds = List.nil();
Type st = null;
if (signature[sigp] == ':' && signature[sigp+1] == ':') {
sigp++;
st = syms.objectType;
}
while (signature[sigp] == ':') {
sigp++;
bounds = bounds.prepend(sigToType());
}
if (!sigEnterPhase) {
types.setBounds(tvar, bounds.reverse(), st);
}
return tvar;
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
/** Convert (implicit) signature to type parameter.
*/
Type sigToTypeParam() {
int start = sigp;
while (signature[sigp] != ':') sigp++;
Name name = names.fromUtf(signature, start, sigp - start);
TypeVar tvar;
if (sigEnterPhase) {
tvar = new TypeVar(name, currentOwner, syms.botType);
typevars.enter(tvar.tsym);
} else {
tvar = (TypeVar)findTypeVar(name);
}
List<Type> bounds = List.nil();
boolean allInterfaces = false;
if (signature[sigp] == ':' && signature[sigp+1] == ':') {
sigp++;
allInterfaces = true;
}
while (signature[sigp] == ':') {
sigp++;
bounds = bounds.prepend(sigToType());
}
if (!sigEnterPhase) {
types.setBounds(tvar, bounds.reverse(), allInterfaces);
}
return tvar;
}
代码示例来源:origin: sc.fiji/javac
/** Convert (implicit) signature to type parameter.
*/
Type sigToTypeParam() {
int start = sigp;
while (signature[sigp] != ':') sigp++;
Name name = names.fromUtf(signature, start, sigp - start);
TypeVar tvar;
if (sigEnterPhase) {
tvar = new TypeVar(name, currentOwner, syms.botType);
typevars.enter(tvar.tsym);
} else {
tvar = (TypeVar)findTypeVar(name);
}
List<Type> bounds = List.nil();
Type st = null;
if (signature[sigp] == ':' && signature[sigp+1] == ':') {
sigp++;
st = syms.objectType;
}
while (signature[sigp] == ':') {
sigp++;
bounds = bounds.prepend(sigToType());
}
if (!sigEnterPhase) {
types.setBounds(tvar, bounds.reverse(), st);
}
return tvar;
}
代码示例来源:origin: konsoletyper/teavm-javac
/** Convert (implicit) signature to type parameter.
*/
Type sigToTypeParam() {
int start = sigp;
while (signature[sigp] != ':') sigp++;
Name name = names.fromUtf(signature, start, sigp - start);
TypeVar tvar;
if (sigEnterPhase) {
tvar = new TypeVar(name, currentOwner, syms.botType);
typevars.enter(tvar.tsym);
} else {
tvar = (TypeVar)findTypeVar(name);
}
List<Type> bounds = List.nil();
boolean allInterfaces = false;
if (signature[sigp] == ':' && signature[sigp+1] == ':') {
sigp++;
allInterfaces = true;
}
while (signature[sigp] == ':') {
sigp++;
bounds = bounds.prepend(sigToType());
}
if (!sigEnterPhase) {
types.setBounds(tvar, bounds.reverse(), allInterfaces);
}
return tvar;
}
内容来源于网络,如有侵权,请联系作者删除!