• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java UndetVar类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.tools.javac.code.Type.UndetVar的典型用法代码示例。如果您正苦于以下问题:Java UndetVar类的具体用法?Java UndetVar怎么用?Java UndetVar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



UndetVar类属于com.sun.tools.javac.code.Type包,在下文中一共展示了UndetVar类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: rollback

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/** Restore the state of this inference context to the previous known checkpoint.
*  Consider that the number of saved undetermined variables can be different to the current
*  amount. This is because new captured variables could have been added.
*/
public void rollback(List<Type> saved_undet) {
    Assert.check(saved_undet != null);
    //restore bounds (note: we need to preserve the old instances)
    ListBuffer<Type> newUndetVars = new ListBuffer<>();
    ListBuffer<Type> newInferenceVars = new ListBuffer<>();
    while (saved_undet.nonEmpty() && undetvars.nonEmpty()) {
        UndetVar uv = (UndetVar)undetvars.head;
        UndetVar uv_saved = (UndetVar)saved_undet.head;
        if (uv.qtype == uv_saved.qtype) {
            uv_saved.dupTo(uv, types);
            undetvars = undetvars.tail;
            saved_undet = saved_undet.tail;
            newUndetVars.add(uv);
            newInferenceVars.add(uv.qtype);
        } else {
            undetvars = undetvars.tail;
        }
    }
    undetvars = newUndetVars.toList();
    inferencevars = newInferenceVars.toList();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:InferenceContext.java


示例2: visitUndetVar

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
@Override
public Void visitUndetVar(UndetVar t, Void _unused) {
    if (min.add(t.qtype)) {
        Set<Type> deps = minMap.getOrDefault(t.qtype, new HashSet<>(Collections.singleton(t.qtype)));
        for (InferenceBound boundKind : InferenceBound.values()) {
            for (Type b : t.getBounds(boundKind)) {
                Type undet = asUndetVar(b);
                if (!undet.hasTag(TypeTag.UNDETVAR)) {
                    visit(undet);
                } else if (isEquiv(t, b, boundKind)) {
                    deps.add(b);
                    equiv.add(b);
                } else {
                    visit(undet);
                }
            }
        }
        minMap.put(t.qtype, deps);
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:InferenceContext.java


示例3: isEquiv

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
boolean isEquiv(UndetVar from, Type t, InferenceBound boundKind) {
    UndetVar uv = (UndetVar)asUndetVar(t);
    for (InferenceBound ib : InferenceBound.values()) {
        List<Type> b1 = from.getBounds(ib);
        if (ib == boundKind) {
            b1 = b1.diff(List.of(t));
        }
        List<Type> b2 = uv.getBounds(ib);
        if (ib == boundKind.complement()) {
            b2 = b2.diff(List.of(from.qtype));
        }
        if (!b1.containsAll(b2) || !b2.containsAll(b1)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:InferenceContext.java


示例4: solveLegacy

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/**
 * Instantiate inference variables in legacy mode (JLS 15.12.2.7, 15.12.2.8).
 * During overload resolution, instantiation is done by doing a partial
 * inference process using eq/lower bound instantiation. During check,
 * we also instantiate any remaining vars by repeatedly using eq/upper
 * instantiation, until all variables are solved.
 */
public void solveLegacy(boolean partial, Warner warn, EnumSet<InferenceStep> steps) {
    while (true) {
        List<Type> solvedVars = solveBasic(steps);
        if (restvars().isEmpty() || partial) {
            //all variables have been instantiated - exit
            break;
        } else if (solvedVars.isEmpty()) {
            //some variables could not be instantiated because of cycles in
            //upper bounds - provide a (possibly recursive) default instantiation
            infer.instantiateAsUninferredVars(restvars(), this);
            break;
        } else {
            //some variables have been instantiated - replace newly instantiated
            //variables in remaining upper bounds and continue
            for (Type t : undetvars) {
                UndetVar uv = (UndetVar)t;
                uv.substBounds(solvedVars, asInstTypes(solvedVars), types);
            }
        }
    }
    infer.doIncorporation(this, warn);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:InferenceContext.java


示例5: rollback

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/** Restore the state of this inference context to the previous known checkpoint.
*  Consider that the number of saved undetermined variables can be different to the current
*  amount. This is because new captured variables could have been added.
*/
void rollback(List<Type> saved_undet) {
    Assert.check(saved_undet != null);
    //restore bounds (note: we need to preserve the old instances)
    ListBuffer<Type> newUndetVars = new ListBuffer<>();
    ListBuffer<Type> newInferenceVars = new ListBuffer<>();
    while (saved_undet.nonEmpty() && undetvars.nonEmpty()) {
        UndetVar uv = (UndetVar)undetvars.head;
        UndetVar uv_saved = (UndetVar)saved_undet.head;
        if (uv.qtype == uv_saved.qtype) {
            uv_saved.dupTo(uv, types);
            undetvars = undetvars.tail;
            saved_undet = saved_undet.tail;
            newUndetVars.add(uv);
            newInferenceVars.add(uv.qtype);
        } else {
            undetvars = undetvars.tail;
        }
    }
    undetvars = newUndetVars.toList();
    inferencevars = newInferenceVars.toList();
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:26,代码来源:InferenceContext.java


示例6: visitUndetVar

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
@Override
public String visitUndetVar(UndetVar t, Locale locale) {
    if (t.inst != null) {
        return visit(t.inst, locale);
    } else {
        return visit(t.qtype, locale) + "?";
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:9,代码来源:Printer.java


示例7: filterVars

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
private List<Type> filterVars(Filter<UndetVar> fu) {
    ListBuffer<Type> res = new ListBuffer<>();
    for (Type t : undetvars) {
        UndetVar uv = (UndetVar)t;
        if (fu.accepts(uv)) {
            res.append(uv.qtype);
        }
    }
    return res.toList();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:InferenceContext.java


示例8: instTypes

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
List<Type> instTypes() {
    ListBuffer<Type> buf = new ListBuffer<>();
    for (Type t : undetvars) {
        UndetVar uv = (UndetVar)t;
        buf.append(uv.getInst() != null ? uv.getInst() : uv.qtype);
    }
    return buf.toList();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:InferenceContext.java


示例9: save

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/**
 * Save the state of this inference context
 */
public List<Type> save() {
    ListBuffer<Type> buf = new ListBuffer<>();
    for (Type t : undetvars) {
        buf.add(((UndetVar)t).dup(infer.types));
    }
    return buf.toList();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:InferenceContext.java


示例10: visitTypeVar

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
@Override
public Void visitTypeVar(TypeVar t, Void aVoid) {
    Type undet = asUndetVar(t);
    if (undet.hasTag(TypeTag.UNDETVAR)) {
        visitUndetVar((UndetVar)undet, null);
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:InferenceContext.java


示例11: solveBasic

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
List<Type> solveBasic(List<Type> varsToSolve, EnumSet<InferenceStep> steps) {
    ListBuffer<Type> solvedVars = new ListBuffer<>();
    for (Type t : varsToSolve.intersect(restvars())) {
        UndetVar uv = (UndetVar)asUndetVar(t);
        for (InferenceStep step : steps) {
            if (step.accepts(uv, this)) {
                uv.setInst(step.solve(uv, this));
                solvedVars.add(uv.qtype);
                break;
            }
        }
    }
    return solvedVars.toList();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:InferenceContext.java


示例12: checkEqualityBound

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
void checkEqualityBound(UndetVar uv, Type boundType) {
    com.sun.tools.javac.util.List<Type> equalBounds = uv.getBounds(InferenceBound.EQ);
    Assert.check(!equalBounds.isEmpty() && equalBounds.length() == 1,
            "undetVar must have only one equality bound");
    Type bound = equalBounds.head;
    Assert.check(bound == boundType, "equal bound must be of type " + boundType);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:TypeEqualityInInferenceTest.java


示例13: restvars

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/**
 * returns the list of uninstantiated variables (as type-variables) in this
 * inference context
 */
List<Type> restvars() {
    return filterVars(new Filter<UndetVar>() {
        public boolean accepts(UndetVar uv) {
            return uv.getInst() == null;
        }
    });
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:12,代码来源:InferenceContext.java


示例14: instvars

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/**
 * returns the list of instantiated variables (as type-variables) in this
 * inference context
 */
List<Type> instvars() {
    return filterVars(new Filter<UndetVar>() {
        public boolean accepts(UndetVar uv) {
            return uv.getInst() != null;
        }
    });
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:12,代码来源:InferenceContext.java


示例15: boundedVars

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/**
 * Get list of bounded inference variables (where bound is other than
 * declared bounds).
 */
final List<Type> boundedVars() {
    return filterVars(new Filter<UndetVar>() {
        public boolean accepts(UndetVar uv) {
            return uv.getBounds(InferenceBound.UPPER)
                     .diff(uv.getDeclaredBounds())
                     .appendList(uv.getBounds(InferenceBound.EQ, InferenceBound.LOWER)).nonEmpty();
        }
    });
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:14,代码来源:InferenceContext.java


示例16: save

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
/**
 * Save the state of this inference context
 */
List<Type> save() {
    ListBuffer<Type> buf = new ListBuffer<>();
    for (Type t : undetvars) {
        buf.add(((UndetVar)t).dup(infer.types));
    }
    return buf.toList();
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:11,代码来源:InferenceContext.java


示例17: min

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
InferenceContext min(List<Type> roots, boolean shouldSolve, Warner warn) {
    if (roots.length() == inferencevars.length()) {
        return this;
    }
    ReachabilityVisitor rv = new ReachabilityVisitor();
    rv.scan(roots);
    if (rv.min.size() == inferencevars.length()) {
        return this;
    }

    List<Type> minVars = List.from(rv.min);
    List<Type> redundantVars = inferencevars.diff(minVars);

    //compute new undet variables (bounds associated to redundant variables are dropped)
    ListBuffer<Type> minUndetVars = new ListBuffer<>();
    for (Type minVar : minVars) {
        UndetVar uv = (UndetVar)asUndetVar(minVar);
        Assert.check(uv.incorporationActions.isEmpty());
        UndetVar uv2 = uv.dup(types);
        for (InferenceBound ib : InferenceBound.values()) {
            List<Type> newBounds = uv.getBounds(ib).stream()
                    .filter(b -> !redundantVars.contains(b))
                    .collect(List.collector());
            uv2.setBounds(ib, newBounds);
        }
        minUndetVars.add(uv2);
    }

    //compute new minimal inference context
    InferenceContext minContext = new InferenceContext(infer, minVars, minUndetVars.toList());
    for (Type t : minContext.inferencevars) {
        //add listener that forwards notifications to original context
        minContext.addFreeTypeListener(List.of(t), (inferenceContext) -> {
            ((UndetVar)asUndetVar(t)).setInst(inferenceContext.asInstType(t));
            infer.doIncorporation(inferenceContext, warn);
            solve(List.from(rv.minMap.get(t)), warn);
            notifyChange();
        });
    }
    if (shouldSolve) {
        //solve definitively unreachable variables
        List<Type> unreachableVars = redundantVars.diff(List.from(rv.equiv));
        minContext.addFreeTypeListener(minVars, (inferenceContext) -> {
            solve(unreachableVars, warn);
            notifyChange();
        });
    }
    return minContext;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:50,代码来源:InferenceContext.java


示例18: min

import com.sun.tools.javac.code.Type.UndetVar; //导入依赖的package包/类
InferenceContext min(List<Type> roots, boolean shouldSolve, Warner warn) {
    ReachabilityVisitor rv = new ReachabilityVisitor();
    rv.scan(roots);
    if (rv.min.size() == inferencevars.length()) {
        return this;
    }

    List<Type> minVars = List.from(rv.min);
    List<Type> redundantVars = inferencevars.diff(minVars);

    //compute new undet variables (bounds associated to redundant variables are dropped)
    ListBuffer<Type> minUndetVars = new ListBuffer<>();
    for (Type minVar : minVars) {
        UndetVar uv = (UndetVar)asUndetVar(minVar);
        Assert.check(uv.incorporationActions.size() == 0);
        UndetVar uv2 = new UndetVar((TypeVar)minVar, infer.incorporationEngine(), types);
        for (InferenceBound ib : InferenceBound.values()) {
            List<Type> newBounds = uv.getBounds(ib).stream()
                    .filter(b -> !redundantVars.contains(b))
                    .collect(List.collector());
            uv2.setBounds(ib, newBounds);
        }
        minUndetVars.add(uv2);
    }

    //compute new minimal inference context
    InferenceContext minContext = new InferenceContext(infer, minVars, minUndetVars.toList());
    for (Type t : minContext.inferencevars) {
        //add listener that forwards notifications to original context
        minContext.addFreeTypeListener(List.of(t), (inferenceContext) -> {
                List<Type> depVars = List.from(rv.minMap.get(t));
                solve(depVars, warn);
                notifyChange();
        });
    }
    if (shouldSolve) {
        //solve definitively unreachable variables
        List<Type> unreachableVars = redundantVars.diff(List.from(rv.equiv));
        solve(unreachableVars, warn);
    }
    return minContext;
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:43,代码来源:InferenceContext.java



注:本文中的com.sun.tools.javac.code.Type.UndetVar类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FenceResponse类代码示例发布时间:2022-05-22
下一篇:
Java PanListener类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap