Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
// Copyright (C) 2011 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.server.rules;
import com.google.common.flogger.FluentLogger;
import com.google.gerrit.server.AnonymousUser;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.PatchSetUtil;
import com.google.gerrit.server.account.Emails;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.PluginConfigFactory;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.patch.DiffOperations;
import com.google.gerrit.server.patch.PatchSetInfoFactory;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.project.ProjectCache;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import com.google.inject.assistedinject.Assisted;
import com.googlecode.prolog_cafe.lang.BufferingPrologControl;
import com.googlecode.prolog_cafe.lang.Predicate;
import com.googlecode.prolog_cafe.lang.PredicateEncoder;
import com.googlecode.prolog_cafe.lang.Prolog;
import com.googlecode.prolog_cafe.lang.PrologMachineCopy;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.jgit.lib.Config;
/**
* Per-thread Prolog interpreter.
*
*
This class is not thread safe.
*
*
A single copy of the Prolog interpreter, for the current thread.
*/
public class PrologEnvironment extends BufferingPrologControl {
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
public interface Factory {
/**
* Construct a new Prolog interpreter.
*
* @param src the machine to template the new environment from.
* @return the new interpreter.
*/
PrologEnvironment create(PrologMachineCopy src);
}
private final Args args;
private final Map, Object> storedValues;
private List cleanup;
@Inject
PrologEnvironment(Args a, @Assisted PrologMachineCopy src) {
super(src);
setEnabled(EnumSet.allOf(Prolog.Feature.class), false);
args = a;
storedValues = new HashMap<>();
cleanup = new ArrayList<>();
}
public Args getArgs() {
return args;
}
@Override
public void setPredicate(Predicate goal) {
super.setPredicate(goal);
int reductionLimit = args.reductionLimit(goal);
setReductionLimit(reductionLimit);
}
/**
* Lookup a stored value in the interpreter's hash manager.
*
* @param type of stored Java object.
* @param sv unique key.
* @return the value; null if not stored.
*/
@SuppressWarnings("unchecked")
public T get(StoredValue sv) {
return (T) storedValues.get(sv);
}
/**
* Set a stored value on the interpreter's hash manager.
*
* @param type of stored Java object.
* @param sv unique key.
* @param obj the value to store under {@code sv}.
*/
@SuppressWarnings("unchecked")
public void set(StoredValue sv, T obj) {
storedValues.put((StoredValue