/**
 * 
 */
package edu.kit.iti.formal.pse.worthwhile.interpreter;

import java.util.Map;
import java.util.Set;
import java.util.Stack;

import edu.kit.iti.formal.pse.worthwhile.model.ast.Expression;
import edu.kit.iti.formal.pse.worthwhile.model.ast.Program;

/** 
 * 
 */
public class Interpreter {
	/**
	 */
	private Set<AbstractExecutionEventListener> executionEventHandlers;

	/**
	 * @return the executionEventHandlers
	 */
	public Set<AbstractExecutionEventListener> getExecutionEventHandlers() {
		// begin-user-code
		return this.executionEventHandlers;
		// end-user-code
	}

	/**
	 * @param executionEventHandlers
	 *                the executionEventHandlers to set
	 */
	public void setExecutionEventHandlers(Set<AbstractExecutionEventListener> executionEventHandlers) {
		// begin-user-code
		this.executionEventHandlers = executionEventHandlers;
		// end-user-code
	}

	/** 
	 * 
	 */
	private InterpreterASTNodeVisitor currentNodeVisitor;

	/**
	 * @return the currentNodeVisitor
	 */
	public InterpreterASTNodeVisitor getCurrentNodeVisitor() {
		// begin-user-code
		return this.currentNodeVisitor;
		// end-user-code
	}

	/**
	 * @param currentNodeVisitor
	 *                the currentNodeVisitor to set
	 */
	public void setCurrentNodeVisitor(InterpreterASTNodeVisitor currentNodeVisitor) {
		// begin-user-code
		this.currentNodeVisitor = currentNodeVisitor;
		// end-user-code
	}

	/** 
	 * 
	 */
	private Set<InterpreterASTNodeVisitor> nodeVisitors;

	/**
	 * @return the nodeVisitors
	 */
	public Set<InterpreterASTNodeVisitor> getNodeVisitors() {
		// begin-user-code
		return this.nodeVisitors;
		// end-user-code
	}

	/**
	 * @param nodeVisitors
	 *                the nodeVisitors to set
	 */
	public void setNodeVisitors(Set<InterpreterASTNodeVisitor> nodeVisitors) {
		// begin-user-code
		this.nodeVisitors = nodeVisitors;
		// end-user-code
	}

	/** 
	 * 
	 */
	private Program program;

	/**
	 * @return the program
	 */
	public Program getProgram() {
		// begin-user-code
		return this.program;
		// end-user-code
	}

	/**
	 * @param program
	 *                the program to set
	 */
	public void setProgram(Program program) {
		// begin-user-code
		this.program = program;
		// end-user-code
	}

	/**
	 * @param program
	 */
	public Interpreter(Program program) {
		this.program = program;
	}

	/** 
	 * 
	 */
	public void execute() {
		this.currentNodeVisitor = new InterpreterASTNodeVisitor();
		this.program.accept(currentNodeVisitor);
	}

	/**
	 * @param handler
	 */
	public void addExecutionEventHandler(AbstractExecutionEventListener handler) {
		this.executionEventHandlers.add(handler);
	}

	/**
	 * @param handler
	 */
	public void removeExecutionEventHandler(AbstractExecutionEventListener handler) {
		this.executionEventHandlers.remove(handler);
	}

	/**
	 * @param expression
	 * @return
	 */
	public Value evaluateExpression(Expression expression) {
		// begin-user-code
		// TODO Auto-generated method stub
		return null;
		// end-user-code
	}

	/**
	 * @param key
	 * @return
	 */
	public Value getSymbol(String key) {
		return this.currentNodeVisitor.getSymbol(key);
	}

	/**
	 * @param key
	 * @param value
	 */
	public void setSymbol(String key, Value value) {
		this.currentNodeVisitor.setSymbol(key, value);
	}

	/**
	 * @return
	 */
	public Stack<Map<String, Value>> getAllSymbols() {
		return this.currentNodeVisitor.getAllSymbols();
	}
}
@@ -61,16 +61,42 @@
 reter;%0A%0A
+import java.util.HashSet;%0A
 import j
@@ -397,16 +397,64 @@
 Handlers
+ = new HashSet%3CAbstractExecutionEventListener%3E()
 ;%0A%0A%09/**%0A
@@ -2499,16 +2499,98 @@
 itor();%0A
+%09%09this.currentNodeVisitor.setExecutionEventHandlers(this.executionEventHandlers);%0A
 %09%09this.p

Initialize private members