| /********************************************************************* |
| * Copyright (c) 2019 The University of York. |
| * |
| * This program and the accompanying materials are made |
| * available under the terms of the Eclipse Public License 2.0 |
| * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| **********************************************************************/ |
| package org.eclipse.epsilon.executors.egl; |
| |
| import java.io.File; |
| import java.util.Collection; |
| import java.util.List; |
| import java.util.Map; |
| import java.util.Optional; |
| |
| import org.eclipse.epsilon.common.parse.problem.ParseProblem; |
| import org.eclipse.epsilon.egl.EglTemplateFactory; |
| import org.eclipse.epsilon.egl.EgxModule; |
| import org.eclipse.epsilon.egl.IEgxModule; |
| import org.eclipse.epsilon.eol.exceptions.EolRuntimeException; |
| import org.eclipse.epsilon.eol.models.IModel; |
| import org.eclipse.epsilon.eol.types.IToolNativeTypeDelegate; |
| import org.eclipse.epsilon.erl.execute.RuleProfiler; |
| import org.eclipse.epsilon.executors.EpsilonLanguageExecutor; |
| import org.eclipse.epsilon.executors.ExecutorHelper; |
| import org.slf4j.Logger; |
| import org.slf4j.LoggerFactory; |
| |
| /** |
| * The EGX executor |
| * @author Horacio Hoyos Rodriguez |
| */ |
| public class SimpleEgxExecutor implements EpsilonLanguageExecutor<Object> { |
| |
| private static final Logger logger = LoggerFactory.getLogger(SimpleEgxExecutor.class); |
| private IEgxModule module; |
| private ExecutorHelper helper; |
| |
| public SimpleEgxExecutor() { |
| this(new EgxModule()); |
| } |
| |
| public SimpleEgxExecutor(EglTemplateFactory templateFactory) { |
| this(new EgxModule(templateFactory)); |
| } |
| |
| public SimpleEgxExecutor(IEgxModule mdl) { |
| logger.info("Creating the EgxExecutor"); |
| module = mdl; |
| helper = new ExecutorHelper(module); |
| } |
| |
| @Override |
| public Object execute() throws EolRuntimeException { |
| logger.info("Executing EGX Script."); |
| return module.execute(); |
| } |
| |
| public boolean parse(File file) throws Exception { |
| return helper.parse(file); |
| } |
| |
| public boolean parse(String code) throws Exception { |
| return helper.parse(code); |
| } |
| |
| public List<ParseProblem> getParseProblems() { |
| return helper.getParseProblems(); |
| } |
| |
| public void addModels(Collection<IModel> models) { |
| helper.addModels(models); |
| } |
| |
| public void addParamters(Map<String, ?> parameters) { |
| helper.addParamters(parameters); |
| } |
| |
| public void addNativeTypeDelegates(Collection<IToolNativeTypeDelegate> nativeDelegates) { |
| helper.addNativeTypeDelegates(nativeDelegates); |
| } |
| |
| public Optional<RuleProfiler> getRuleProfiler() { |
| return helper.getRuleProfiler(); |
| } |
| |
| public void disposeModelRepository() { |
| helper.disposeModelRepository(); |
| } |
| |
| public void clearModelRepository() { |
| helper.clearModelRepository(); |
| } |
| |
| public void dispose() { |
| helper.dispose(); |
| } |
| |
| public void preProcess() { |
| helper.preProcess(); |
| } |
| |
| public void postProcess() { |
| helper.postProcess(); |
| } |
| |
| } |