// Path: src/arden/codegenerator/Label.java
// public final class Label {
// 	/** Target position (byte index where the label is pointing to), -1=not yet set */
// 	int markedPosition = -1;
// 	/** Stack size at target position, -1=currently unknown */
// 	int stackSize = -1;
// 	/** Initially true, is set to false by markForwardOnly() to signal that backward jumps are forbidden */
// 	boolean allowJumps = true;
// }
// 
// Path: src/arden/runtime/ArdenValue.java
// public abstract class ArdenValue {
// 	public static final long NOPRIMARYTIME = Long.MIN_VALUE;
// 	public final long primaryTime;
// 
// 	protected ArdenValue() {
// 		this.primaryTime = NOPRIMARYTIME;
// 	}
// 
// 	protected ArdenValue(long primaryTime) {
// 		this.primaryTime = primaryTime;
// 	}
// 
// 	/**
// 	 * Creates a copy of this value with the primary time set to newPrimaryTime.
// 	 */
// 	public abstract ArdenValue setTime(long newPrimaryTime);
// 
// 	/**
// 	 * Returns whether this value is 'true' in a boolean context. Returns 'true'
// 	 * for boolean true; false for everything else (even for the list ",true")
// 	 */
// 	public boolean isTrue() {
// 		return false;
// 	}
// 
// 	/**
// 	 * Returns whether this value is 'false' in a boolean context. Returns
// 	 * 'true' for boolean false; returns 'false' for everything else (boolean
// 	 * true or null)
// 	 */
// 	public boolean isFalse() {
// 		return false;
// 	}
// 
// 	/** Gets the elements that a FOR loop will iterate through */
// 	public ArdenValue[] getElements() {
// 		return new ArdenValue[] { this };
// 	}
// 
// 	/**
// 	 * Compares this ArdenValue with another. Does not implement Comparable
// 	 * interface because we have an additional return value MIN_VALUE with
// 	 * special meaning.
// 	 * 
// 	 * @return Returns Integer.MIN_VALUE if the types don't match or the type is
// 	 *         not ordered. Returns -1 if this is less than rhs. Returns 0 if
// 	 *         this is equal to rhs. Returns 1 if this is larger than rhs.
// 	 */
// 	public int compareTo(ArdenValue rhs) {
// 		return Integer.MIN_VALUE;
// 	}
// }


import arden.runtime.BinaryOperator;
import arden.runtime.DatabaseQuery;
import arden.codegenerator.Label;
import arden.compiler.node.*;
import arden.runtime.ArdenValue;

		// of_read_func_op =
		// {avge} average
		// | {avg} avg
		// | {cnt} count
		// | {ex} exist
		// | {exs} exists
		// | {sum} sum
		// | {med} median;
		if (node.getOfReadFuncOp() instanceof AAvgeOfReadFuncOp || node.getOfReadFuncOp() instanceof AAvgOfReadFuncOp) {
			invokeAggregationOperator("average");
		} else if (node.getOfReadFuncOp() instanceof ACntOfReadFuncOp) {
			invokeAggregationOperator("count");
		} else if (node.getOfReadFuncOp() instanceof AExOfReadFuncOp
				|| node.getOfReadFuncOp() instanceof AExsOfReadFuncOp) {
			invokeAggregationOperator("exist");
		} else if (node.getOfReadFuncOp() instanceof ASumOfReadFuncOp) {
			invokeAggregationOperator("sum");
		} else if (node.getOfReadFuncOp() instanceof AMedOfReadFuncOp) {
			invokeAggregationOperator("median");
		} else {
			throw new RuntimeException("unknown of_read_func_op");
		}
	}

	private void invokeAggregationOperator(String name) {
		try {
			context.writer.invokeInstance(DatabaseQuery.class.getMethod(name));
		} catch (SecurityException e) {
			throw new RuntimeException(e);
// Path: src/arden/codegenerator/Label.java
// public final class Label {
// 	/** Target position (byte index where the label is pointing to), -1=not yet set */
// 	int markedPosition = -1;
// 	/** Stack size at target position, -1=currently unknown */
// 	int stackSize = -1;
// 	/** Initially true, is set to false by markForwardOnly() to signal that backward jumps are forbidden */
// 	boolean allowJumps = true;
// }
// 
// Path: src/arden/runtime/ArdenValue.java
// public abstract class ArdenValue {
// 	public static final long NOPRIMARYTIME = Long.MIN_VALUE;
// 	public final long primaryTime;
// 
// 	protected ArdenValue() {
// 		this.primaryTime = NOPRIMARYTIME;
// 	}
// 
// 	protected ArdenValue(long primaryTime) {
// 		this.primaryTime = primaryTime;
// 	}
// 
// 	/**
// 	 * Creates a copy of this value with the primary time set to newPrimaryTime.
// 	 */
// 	public abstract ArdenValue setTime(long newPrimaryTime);
// 
// 	/**
// 	 * Returns whether this value is 'true' in a boolean context. Returns 'true'
// 	 * for boolean true; false for everything else (even for the list ",true")
// 	 */
// 	public boolean isTrue() {
// 		return false;
// 	}
// 
// 	/**
// 	 * Returns whether this value is 'false' in a boolean context. Returns
// 	 * 'true' for boolean false; returns 'false' for everything else (boolean
// 	 * true or null)
// 	 */
// 	public boolean isFalse() {
// 		return false;
// 	}
// 
// 	/** Gets the elements that a FOR loop will iterate through */
// 	public ArdenValue[] getElements() {
// 		return new ArdenValue[] { this };
// 	}
// 
// 	/**
// 	 * Compares this ArdenValue with another. Does not implement Comparable
// 	 * interface because we have an additional return value MIN_VALUE with
// 	 * special meaning.
// 	 * 
// 	 * @return Returns Integer.MIN_VALUE if the types don't match or the type is
// 	 *         not ordered. Returns -1 if this is less than rhs. Returns 0 if
// 	 *         this is equal to rhs. Returns 1 if this is larger than rhs.
// 	 */
// 	public int compareTo(ArdenValue rhs) {
// 		return Integer.MIN_VALUE;
// 	}
// }


// Path: src/arden/compiler/ReadPhraseCompiler.java
import arden.runtime.BinaryOperator;
import arden.runtime.DatabaseQuery;
import arden.codegenerator.Label;
import arden.compiler.node.*;
import arden.runtime.ArdenValue;


		// of_read_func_op =
		// {avge} average
		// | {avg} avg
		// | {cnt} count
		// | {ex} exist
		// | {exs} exists
		// | {sum} sum
		// | {med} median;
		if (node.getOfReadFuncOp() instanceof AAvgeOfReadFuncOp || node.getOfReadFuncOp() instanceof AAvgOfReadFuncOp) {
			invokeAggregationOperator("average");
		} else if (node.getOfReadFuncOp() instanceof ACntOfReadFuncOp) {
			invokeAggregationOperator("count");
		} else if (node.getOfReadFuncOp() instanceof AExOfReadFuncOp
				|| node.getOfReadFuncOp() instanceof AExsOfReadFuncOp) {
			invokeAggregationOperator("exist");
		} else if (node.getOfReadFuncOp() instanceof ASumOfReadFuncOp) {
			invokeAggregationOperator("sum");
		} else if (node.getOfReadFuncOp() instanceof AMedOfReadFuncOp) {
			invokeAggregationOperator("median");
		} else {
			throw new RuntimeException("unknown of_read_func_op");
		}
	}

	private void invokeAggregationOperator(String name) {
		try {
			context.writer.invokeInstance(DatabaseQuery.class.getMethod(name));
		} catch (SecurityException e) {
			throw new RuntimeException(e);
		} catch (NoSuchMethodException e) {