Java Code Examples for com.sun.tools.javac.code.Type.UndetVar.InferenceBound#values()
The following examples show how to use
com.sun.tools.javac.code.Type.UndetVar.InferenceBound#values() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Infer.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Save the state of this inference context */ List<Type> save() { ListBuffer<Type> buf = new ListBuffer<>(); for (Type t : undetvars) { UndetVar uv = (UndetVar)t; UndetVar uv2 = new UndetVar((TypeVar)uv.qtype, types); for (InferenceBound ib : InferenceBound.values()) { for (Type b : uv.getBounds(ib)) { uv2.addBound(ib, b, types); } } uv2.inst = uv.inst; buf.add(uv2); } return buf.toList(); }
Example 2
Source File: Infer.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Save the state of this inference context */ List<Type> save() { ListBuffer<Type> buf = new ListBuffer<>(); for (Type t : undetvars) { UndetVar uv = (UndetVar)t; UndetVar uv2 = new UndetVar((TypeVar)uv.qtype, types); for (InferenceBound ib : InferenceBound.values()) { for (Type b : uv.getBounds(ib)) { uv2.addBound(ib, b, types); } } uv2.inst = uv.inst; buf.add(uv2); } return buf.toList(); }
Example 3
Source File: Infer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Save the state of this inference context */ List<Type> save() { ListBuffer<Type> buf = new ListBuffer<>(); for (Type t : undetvars) { UndetVar uv = (UndetVar)t; UndetVar uv2 = new UndetVar((TypeVar)uv.qtype, types); for (InferenceBound ib : InferenceBound.values()) { for (Type b : uv.getBounds(ib)) { uv2.addBound(ib, b, types); } } uv2.inst = uv.inst; buf.add(uv2); } return buf.toList(); }
Example 4
Source File: Infer.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Save the state of this inference context */ List<Type> save() { ListBuffer<Type> buf = new ListBuffer<>(); for (Type t : undetvars) { UndetVar uv = (UndetVar)t; UndetVar uv2 = new UndetVar((TypeVar)uv.qtype, types); for (InferenceBound ib : InferenceBound.values()) { for (Type b : uv.getBounds(ib)) { uv2.addBound(ib, b, types); } } uv2.inst = uv.inst; buf.add(uv2); } return buf.toList(); }
Example 5
Source File: InferenceContext.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Void visitUndetVar(UndetVar t, Void _unused) { if (min.add(t.qtype)) { Set<Type> deps = Maps.getOrDefault(minMap,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; }
Example 6
Source File: InferenceContext.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
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; }
Example 7
Source File: Infer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Save the state of this inference context */ List<Type> save() { ListBuffer<Type> buf = new ListBuffer<>(); for (Type t : undetvars) { UndetVar uv = (UndetVar)t; UndetVar uv2 = new UndetVar((TypeVar)uv.qtype, types); for (InferenceBound ib : InferenceBound.values()) { for (Type b : uv.getBounds(ib)) { uv2.addBound(ib, b, types); } } uv2.inst = uv.inst; buf.add(uv2); } return buf.toList(); }
Example 8
Source File: Infer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Save the state of this inference context */ List<Type> save() { ListBuffer<Type> buf = new ListBuffer<>(); for (Type t : undetvars) { UndetVar uv = (UndetVar)t; UndetVar uv2 = new UndetVar((TypeVar)uv.qtype, types); for (InferenceBound ib : InferenceBound.values()) { for (Type b : uv.getBounds(ib)) { uv2.addBound(ib, b, types); } } uv2.inst = uv.inst; buf.add(uv2); } return buf.toList(); }
Example 9
Source File: InferenceContext.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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; }
Example 10
Source File: InferenceContext.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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; }
Example 11
Source File: Infer.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Save the state of this inference context */ List<Type> save() { ListBuffer<Type> buf = new ListBuffer<>(); for (Type t : undetvars) { UndetVar uv = (UndetVar)t; UndetVar uv2 = new UndetVar((TypeVar)uv.qtype, types); for (InferenceBound ib : InferenceBound.values()) { for (Type b : uv.getBounds(ib)) { uv2.addBound(ib, b, types); } } uv2.inst = uv.inst; buf.add(uv2); } return buf.toList(); }
Example 12
Source File: Infer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Restore the state of this inference context to the previous known checkpoint */ void rollback(List<Type> saved_undet) { Assert.check(saved_undet != null && saved_undet.length() == undetvars.length()); //restore bounds (note: we need to preserve the old instances) for (Type t : undetvars) { UndetVar uv = (UndetVar)t; UndetVar uv_saved = (UndetVar)saved_undet.head; for (InferenceBound ib : InferenceBound.values()) { uv.setBounds(ib, uv_saved.getBounds(ib)); } uv.inst = uv_saved.inst; saved_undet = saved_undet.tail; } }
Example 13
Source File: Infer.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Restore the state of this inference context to the previous known checkpoint */ void rollback(List<Type> saved_undet) { Assert.check(saved_undet != null && saved_undet.length() == undetvars.length()); //restore bounds (note: we need to preserve the old instances) for (Type t : undetvars) { UndetVar uv = (UndetVar)t; UndetVar uv_saved = (UndetVar)saved_undet.head; for (InferenceBound ib : InferenceBound.values()) { uv.setBounds(ib, uv_saved.getBounds(ib)); } uv.inst = uv_saved.inst; saved_undet = saved_undet.tail; } }
Example 14
Source File: Infer.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Restore the state of this inference context to the previous known checkpoint */ void rollback(List<Type> saved_undet) { Assert.check(saved_undet != null && saved_undet.length() == undetvars.length()); //restore bounds (note: we need to preserve the old instances) for (Type t : undetvars) { UndetVar uv = (UndetVar)t; UndetVar uv_saved = (UndetVar)saved_undet.head; for (InferenceBound ib : InferenceBound.values()) { uv.setBounds(ib, uv_saved.getBounds(ib)); } uv.inst = uv_saved.inst; saved_undet = saved_undet.tail; } }
Example 15
Source File: Infer.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Restore the state of this inference context to the previous known checkpoint */ void rollback(List<Type> saved_undet) { Assert.check(saved_undet != null && saved_undet.length() == undetvars.length()); //restore bounds (note: we need to preserve the old instances) for (Type t : undetvars) { UndetVar uv = (UndetVar)t; UndetVar uv_saved = (UndetVar)saved_undet.head; for (InferenceBound ib : InferenceBound.values()) { uv.setBounds(ib, uv_saved.getBounds(ib)); } uv.inst = uv_saved.inst; saved_undet = saved_undet.tail; } }
Example 16
Source File: Infer.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Restore the state of this inference context to the previous known checkpoint */ void rollback(List<Type> saved_undet) { Assert.check(saved_undet != null && saved_undet.length() == undetvars.length()); //restore bounds (note: we need to preserve the old instances) for (Type t : undetvars) { UndetVar uv = (UndetVar)t; UndetVar uv_saved = (UndetVar)saved_undet.head; for (InferenceBound ib : InferenceBound.values()) { uv.setBounds(ib, uv_saved.getBounds(ib)); } uv.inst = uv_saved.inst; saved_undet = saved_undet.tail; } }
Example 17
Source File: Infer.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Restore the state of this inference context to the previous known checkpoint */ void rollback(List<Type> saved_undet) { Assert.check(saved_undet != null && saved_undet.length() == undetvars.length()); //restore bounds (note: we need to preserve the old instances) for (Type t : undetvars) { UndetVar uv = (UndetVar)t; UndetVar uv_saved = (UndetVar)saved_undet.head; for (InferenceBound ib : InferenceBound.values()) { uv.setBounds(ib, uv_saved.getBounds(ib)); } uv.inst = uv_saved.inst; saved_undet = saved_undet.tail; } }
Example 18
Source File: Infer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Restore the state of this inference context to the previous known checkpoint */ void rollback(List<Type> saved_undet) { Assert.check(saved_undet != null && saved_undet.length() == undetvars.length()); //restore bounds (note: we need to preserve the old instances) for (Type t : undetvars) { UndetVar uv = (UndetVar)t; UndetVar uv_saved = (UndetVar)saved_undet.head; for (InferenceBound ib : InferenceBound.values()) { uv.setBounds(ib, uv_saved.getBounds(ib)); } uv.inst = uv_saved.inst; saved_undet = saved_undet.tail; } }
Example 19
Source File: InferenceContext.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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; }
Example 20
Source File: InferenceContext.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
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 = StreamSupport.stream(uv.getBounds(ib)) .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; }