public boolean isDynamicParameterBound(DSLExpression expression) { Set<VariableElement> boundVariables = expression.findBoundVariableElements(); for (Parameter parameter : getDynamicParameters()) { if (boundVariables.contains(parameter.getVariableElement())) { return true; } } return false; }
public boolean isDynamicParameterBound(DSLExpression expression) { Set<VariableElement> boundVariables = expression.findBoundVariableElements(); for (Parameter parameter : getDynamicParameters()) { if (boundVariables.contains(parameter.getVariableElement())) { return true; } } return false; }
public Set<CacheExpression> getBoundCaches(DSLExpression guardExpression) { List<CacheExpression> resolvedCaches = getCaches(); if (resolvedCaches.isEmpty()) { return Collections.emptySet(); } Set<VariableElement> boundVars = guardExpression.findBoundVariableElements(); Set<CacheExpression> foundCaches = new LinkedHashSet<>(); for (CacheExpression cache : resolvedCaches) { VariableElement cacheVar = cache.getParameter().getVariableElement(); if (boundVars.contains(cacheVar)) { // bound caches for caches are returned before foundCaches.addAll(getBoundCaches(cache.getExpression())); foundCaches.add(cache); } } return foundCaches; }
public boolean isGuardBoundWithCache(GuardExpression guardExpression) { List<CacheExpression> resolvedCaches = getCaches(); if (resolvedCaches.isEmpty()) { return false; } Set<VariableElement> boundVars = guardExpression.getExpression().findBoundVariableElements(); if (boundVars.isEmpty()) { return false; } for (CacheExpression cache : resolvedCaches) { VariableElement cacheVar = cache.getParameter().getVariableElement(); if (boundVars.contains(cacheVar)) { // bound caches for caches are returned before return true; } } return false; }
public boolean isFrameUsedByGuard() { Parameter frame = getFrame(); if (frame != null) { for (GuardExpression guard : getGuards()) { if (guard.getExpression().findBoundVariableElements().contains(frame.getVariableElement())) { return true; } } for (CacheExpression cache : getCaches()) { if (cache.getExpression().findBoundVariableElements().contains(frame.getVariableElement())) { return true; } } } return false; }
public boolean isCacheBoundByGuard(CacheExpression cacheExpression) { VariableElement cachedVariable = cacheExpression.getParameter().getVariableElement(); for (GuardExpression expression : getGuards()) { if (expression.getExpression().findBoundVariableElements().contains(cachedVariable)) { return true; } } for (AssumptionExpression expression : getAssumptionExpressions()) { if (expression.getExpression().findBoundVariableElements().contains(cachedVariable)) { return true; } } // check all next binding caches if they are bound to a guard and use this cache variable boolean found = false; for (CacheExpression expression : getCaches()) { if (cacheExpression == expression) { found = true; } else if (found) { if (expression.getExpression().findBoundVariableElements().contains(cachedVariable)) { if (isCacheBoundByGuard(expression)) { return true; } } } } return false; }
public boolean isFrameUsedByAnyGuard() { for (SpecializationData specialization : specializations) { if (!specialization.isReachable()) { continue; } Parameter frame = specialization.getFrame(); if (frame != null) { for (GuardExpression guard : specialization.getGuards()) { if (guard.getExpression().findBoundVariableElements().contains(frame.getVariableElement())) { return true; } } for (CacheExpression cache : specialization.getCaches()) { if (cache.getExpression().findBoundVariableElements().contains(frame.getVariableElement())) { return true; } } } } return false; }
public boolean isGuardBindsCache() { if (!getCaches().isEmpty() && !getGuards().isEmpty()) { for (GuardExpression guard : getGuards()) { DSLExpression guardExpression = guard.getExpression(); Set<VariableElement> boundVariables = guardExpression.findBoundVariableElements(); if (isDynamicParameterBound(guardExpression)) { for (CacheExpression cache : getCaches()) { if (boundVariables.contains(cache.getParameter().getVariableElement())) { return true; } } } } } return false; }
public boolean isCacheBoundByGuard(CacheExpression cacheExpression) { for (GuardExpression expression : getGuards()) { if (expression.getExpression().findBoundVariableElements().contains(cacheExpression.getParameter().getVariableElement())) { return true; } } // check all next binding caches if they are bound by guard Set<VariableElement> boundVariables = cacheExpression.getExpression().findBoundVariableElements(); boolean found = false; for (CacheExpression expression : getCaches()) { if (cacheExpression == expression) { found = true; } else if (found) { if (boundVariables.contains(expression.getParameter().getVariableElement())) { if (isCacheBoundByGuard(expression)) { return true; } } } } return false; }
public boolean hasMultipleInstances() { if (!getCaches().isEmpty()) { for (GuardExpression guard : getGuards()) { DSLExpression guardExpression = guard.getExpression(); Set<VariableElement> boundVariables = guardExpression.findBoundVariableElements(); if (isDynamicParameterBound(guardExpression)) { for (CacheExpression cache : getCaches()) { if (boundVariables.contains(cache.getParameter().getVariableElement())) { return true; } } } } } return false; }
private List<IfTriple> initializeCasts(FrameState frameState, SpecializationGroup group, DSLExpression expression, NodeExecutionMode specializationExecution) { Set<VariableElement> boundElements = expression.findBoundVariableElements(); if (boundElements.isEmpty()) { return Collections.emptyList(); } List<IfTriple> triples = new ArrayList<>(); for (VariableElement variable : boundElements) { Parameter p = group.getSpecialization().findByVariable(variable); if (p != null) { NodeExecutionData execution = p.getSpecification().getExecution(); if (execution != null) { LocalVariable var = frameState.getValue(execution); if (var == null) { throw new AssertionError(); } IfTriple triple = createTypeCheckOrCast(frameState, group, new TypeGuard(p.getType(), execution.getIndex()), specializationExecution, true, false); if (triple != null) { triples.add(triple); } } } } return triples; }
Set<VariableElement> boundVariables = currentExpression.getExpression().findBoundVariableElements(); for (int j = i + 1; j < expressions.size(); j++) { CacheExpression boundExpression = expressions.get(j);
Set<VariableElement> boundVariables = currentExpression.getExpression().findBoundVariableElements(); for (int j = i + 1; j < expressions.size(); j++) { CacheExpression boundExpression = expressions.get(j);