text:
// -*- mode: java -*-
//
// file: cool-tree.m4
//
// This file defines the AST
//
//////////////////////////////////////////////////////////

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.io.PrintStream;
import java.util.Vector;

/** Defines simple phylum Program */
abstract class Program extends TreeNode {

    protected Program(int lineNumber) {
        super(lineNumber);
    }
    public abstract void dump_with_types(PrintStream out, int n);
    public abstract void semant();
    public abstract void cgen(PrintStream s);

    public abstract void registerVisitor(ITreeVisitor tv);
	public abstract ClassTable getClassTable();

}

/** Defines simple phylum Class_ */
abstract class Class_ extends TreeNode implements IVisitable {
	protected Class_(int lineNumber) {
		super(lineNumber);
	}
	public abstract void dump_with_types(PrintStream out, int n);
	public abstract AbstractSymbol getName();
	public abstract AbstractSymbol getParent();
	public abstract AbstractSymbol getFilename();
	public abstract Features getFeatures();
	public abstract FeaturesTable getFeaturesTable();
}

/** Defines list phylum Classes

    See ListNode for full documentation. */
class Classes extends ListNode {
	public final static Class elementClass = Class_.class;
	/** Returns class of this lists's elements */
	public Class getElementClass() {
		return elementClass;
	}
	protected Classes(int lineNumber, Vector elements) {
		super(lineNumber, elements);
	}
	/** Creates an empty "Classes" list */
	public Classes(int lineNumber) {
		super(lineNumber);
	}
	/** Appends "Class_" element to this list */
	public Classes appendElement(TreeNode elem) {
		addElement(elem);
		return this;
	}
	public TreeNode copy() {
		return new Classes(lineNumber, copyElements());
	}
	@Override
	public Object accept(ITreeVisitor visitor) {
		for (Enumeration e = getElements(); e.hasMoreElements(); )
		{
			Class_ itm = (Class_) e.nextElement();
			itm.accept(visitor);
		}
		return null;
	}

}

/** Defines simple phylum Feature */
abstract class Feature extends TreeNode {
	protected Feature(int lineNumber) {
		super(lineNumber);
	}
	public abstract void dump_with_types(PrintStream out, int n);

	public abstract AbstractSymbol getFeatureName();

	public abstract AbstractSymbol getReturnType();
}

/** Defines list phylum Features

    See ListNode for full documentation. */
class Features extends ListNode {
	public final static Class elementClass = Feature.class;
	/** Returns class of this lists's elements */
	public Class getElementClass() {
		return elementClass;
	}
	protected Features(int lineNumber, Vector elements) {
		super(lineNumber, elements);
	}
	/** Creates an empty "Features" list */
	public Features(int lineNumber) {
		super(lineNumber);
	}
	/** Appends "Feature" element to this list */
	public Features appendElement(TreeNode elem) {
		addElement(elem);
		return this;
	}
	public TreeNode copy() {
		return new Features(lineNumber, copyElements());
	}
	@Override
	public Object accept(ITreeVisitor visitor) {
		for (Enumeration e = getElements(); e.hasMoreElements(); )
		{
			Feature itm = (Feature) e.nextElement();
			itm.accept(visitor);
		}
		return null;
	}
}

/** Defines simple phylum Formal */
abstract class Formal extends TreeNode {
	protected Formal(int lineNumber) {
		super(lineNumber);
	}
	public abstract void dump_with_types(PrintStream out, int n);
	public abstract AbstractSymbol getName();
	public abstract AbstractSymbol getTypeDecl();
}

/** Defines list phylum Formals

    See ListNode for full documentation. */
class Formals extends ListNode {
	public final static Class elementClass = Formal.class;
	/** Returns class of this lists's elements */
	public Class getElementClass() {
		return elementClass;
	}
	protected Formals(int lineNumber, Vector elements) {
		super(lineNumber, elements);
	}
	/** Creates an empty "Formals" list */
	public Formals(int lineNumber) {
		super(lineNumber);
	}
	/** Appends "Formal" element to this list */
	public Formals appendElement(TreeNode elem) {
		addElement(elem);
		return this;
	}
	public TreeNode copy() {
		return new Formals(lineNumber, copyElements());
	}
	@Override
	public Object accept(ITreeVisitor visitor) {
		for (Enumeration e = getElements(); e.hasMoreElements(); )
		{
			Formal itm = (Formal) e.nextElement();
			itm.accept(visitor);
		}
		return null;
	}
}

/** Defines simple phylum Expression */
abstract class Expression extends TreeNode {
	protected Expression(int lineNumber) {
		super(lineNumber);
	}
	private AbstractSymbol type = null;
	public AbstractSymbol get_type() { return type; }
	public Expression set_type(AbstractSymbol s) { type = s; return this; }
	public abstract void dump_with_types(PrintStream out, int n);
	public void dump_type(PrintStream out, int n) {
		Object rt = getData("rt");
		AbstractSymbol tmp = (AbstractSymbol) ((rt != null) ? rt : type);
		if (tmp != null)
		{ out.println(Utilities.pad(n) + ": " + tmp.getString()); }
		else
		{ out.println(Utilities.pad(n) + ": _no_type"); }
	}
	public abstract void code(PrintStream s);

}

/** Defines list phylum Expressions

    See ListNode for full documentation. */
class Expressions extends ListNode {
	public final static Class elementClass = Expression.class;
	/** Returns class of this lists's elements */
	public Class getElementClass() {
		return elementClass;
	}
	protected Expressions(int lineNumber, Vector elements) {
		super(lineNumber, elements);
	}
	/** Creates an empty "Expressions" list */
	public Expressions(int lineNumber) {
		super(lineNumber);
	}
	/** Appends "Expression" element to this list */
	public Expressions appendElement(TreeNode elem) {
		addElement(elem);
		return this;
	}
	public TreeNode copy() {
		return new Expressions(lineNumber, copyElements());
	}
	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		for (Enumeration e = getElements(); e.hasMoreElements(); )
		{
			Expression itm = (Expression) e.nextElement();
			itm.accept(visitor);
		}
		/*

		 */
		return visitor.onVisitPostOrder(this);
	}
}

/** Defines simple phylum Case */
abstract class Case extends TreeNode {
	protected Case(int lineNumber) {
		super(lineNumber);
	}
	public abstract void dump_with_types(PrintStream out, int n);

	public abstract AbstractSymbol getName();
	public abstract AbstractSymbol getTypeDecl();
}

/** Defines list phylum Cases

    See ListNode for full documentation. */
class Cases extends ListNode {
	public final static Class elementClass = Case.class;
	/** Returns class of this lists's elements */
	public Class getElementClass() {
		return elementClass;
	}
	protected Cases(int lineNumber, Vector elements) {
		super(lineNumber, elements);
	}
	/** Creates an empty "Cases" list */
	public Cases(int lineNumber) {
		super(lineNumber);
	}
	/** Appends "Case" element to this list */
	public Cases appendElement(TreeNode elem) {
		addElement(elem);
		return this;
	}
	public TreeNode copy() {
		return new Cases(lineNumber, copyElements());
	}
	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);

		AbstractSymbol[] lubArray = new AbstractSymbol[getLength()];
		AbstractSymbol[] lubRTArray = new AbstractSymbol[getLength()];

		HashMap<AbstractSymbol, Boolean> branches = new HashMap<AbstractSymbol, Boolean>();

		ArrayList<AbstractSymbol> lub = new ArrayList<AbstractSymbol>();
		ArrayList<AbstractSymbol> lubRT = new ArrayList<AbstractSymbol>();

		boolean validRT = false, containsNULL = false;
		int howManySelfType = 0, size = 0;

		for (Enumeration e = getElements(); e.hasMoreElements(); size++)
		{
			Case itm = (Case) e.nextElement();
			AbstractSymbol abs = (AbstractSymbol) itm.accept(visitor);
			AbstractSymbol toAdd = itm.getTypeDecl();

			AbstractSymbol rt = (AbstractSymbol) itm.getData("rt");

			if (rt != null)
			{
				//validRT = true;
				if (rt.equals(TreeConstants.SELF_TYPE))
					howManySelfType++;
			}
			else
				containsNULL = true;

			lubRT.add(rt);

			/* toAdd is always null in the first visit */
			if(toAdd != null && branches.containsKey(toAdd))
			{
				SemantErrorsManager.getInstance().semantError(itm, "Duplicate branch %s in case statement.", toAdd);
				SemantErrorsManager.getInstance().validate(true);
			}
			else if (toAdd != null)
			{
				branches.put(toAdd, true);
				lub.add(abs);
			}
		}

		lub.toArray(lubArray);
		lubRT.toArray(lubRTArray);

		if (!containsNULL)
		{
			if (howManySelfType == size)
			{
				decorate("rt", TreeConstants.SELF_TYPE);
			}
			else
			{
				if (howManySelfType == 0)
				{
					decorate("rt", ClassTable.getInstance().leastUpperBound(lubRTArray));
				}
				else
				{
					decorate("rt", ClassTable.getInstance().leastUpperBound(TypeCheckerHelper.inferSelfType(lubRTArray)));
				}
			}
		}
		decorate("type_list", lubArray);
		/*
		 * calcolare il lub di tutti i branch e restituirlo
		 */
		return visitor.onVisitPostOrder(this);
	}
}

/** Defines AST constructor 'programc'.

    See TreeNode for full documentation. */
class programc extends Program {
	protected Classes classes;
	protected ClassTable class_table;

	/**
	 * Visitors list
	 */
	ArrayList<ITreeVisitor> visitors = new ArrayList<ITreeVisitor>();

    /** Creates "programc" AST node.
      *
      * @param lineNumber the line in the source file from which this node came.
      * @param a0 initial value for classes
      */
    public programc(int lineNumber, Classes a1) {
        super(lineNumber);
        classes = a1;

    	/* ClassTable constructor may do some semantic analysis */
    	class_table = ClassTable.getInstance();
    }
    public TreeNode copy() {
        return new programc(lineNumber, (Classes)classes.copy());
    }
    public void dump(PrintStream out, int n) {
        out.print(Utilities.pad(n) + "programc\n");
        classes.dump(out, n+2);
    }
    /**
     * Registers a visitor in the visitor list
     * @arg tv The visitor to be registred
     */
    public void registerVisitor(ITreeVisitor tv) {
    	visitors.add(tv);
    }

    public void dump_with_types(PrintStream out, int n) {
        dump_line(out, n);
        out.println(Utilities.pad(n) + "_program");
        for (Enumeration e = classes.getElements(); e.hasMoreElements(); ) {
	    ((Class_)e.nextElement()).dump_with_types(out, n + 2);
        }
    }

	public void semant() {

		for (ITreeVisitor visitor : visitors)
		{
			visitor.onVisitStart();
			accept(visitor);
			visitor.onVisitEnd();
		}

		SemantErrorsManager.getInstance().validate(true);

	}

	/** This method is the entry point to the code generator.  All of the work
	 * of the code generator takes place within CgenClassTable constructor.
	 * @param s the output stream
	 * @see CgenClassTable
	 * */
	public void cgen(PrintStream s) {
		CgenClassTable codegen_classtable = new CgenClassTable(classes, s);
	}
	@Override
	public Object accept(ITreeVisitor visitor) {
		/*
		 * controllare che la classe Main sia definita
		 */
		visitor.onVisitPreOrder(this);
		classes.accept(visitor);
		visitor.onVisitPostOrder(this);
		return null;
	}
	@Override
	public ClassTable getClassTable() {
		return class_table;
	}

}

/** Defines AST constructor 'class_c'.

    See TreeNode for full documentation. */
class class_c extends Class_ {
	protected AbstractSymbol name;
	protected AbstractSymbol parent;
	protected Features features;
	protected AbstractSymbol filename;
	protected FeaturesTable featuresTable;
	/** Creates "class_c" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for name
	 * @param a1 initial value for parent
	 * @param a2 initial value for features
	 * @param a3 initial value for filename
	 */
	public class_c(int lineNumber, AbstractSymbol a1, AbstractSymbol a2, Features a3, AbstractSymbol a4) {
		super(lineNumber);
		name = a1;
		parent = a2;
		features = a3;
		filename = a4;
		ClassTable.getInstance().registerClass(this);
		featuresTable = new FeaturesTable(this);
	}
	public TreeNode copy() {
		return new class_c(lineNumber, copy_AbstractSymbol(name), copy_AbstractSymbol(parent), (Features)features.copy(), copy_AbstractSymbol(filename));
	}
	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "class_c\n");
		dump_AbstractSymbol(out, n+2, name);
		dump_AbstractSymbol(out, n+2, parent);
		features.dump(out, n+2);
		dump_AbstractSymbol(out, n+2, filename);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_class");
		dump_AbstractSymbol(out, n + 2, name);
		dump_AbstractSymbol(out, n + 2, parent);
		out.print(Utilities.pad(n + 2) + "\"");
		Utilities.printEscapedString(out, filename.getString());
		out.println("\"\n" + Utilities.pad(n + 2) + "(");
		for (Enumeration e = features.getElements(); e.hasMoreElements();) {
			((Feature)e.nextElement()).dump_with_types(out, n + 2);
		}
		out.println(Utilities.pad(n + 2) + ")");
	}

	public AbstractSymbol getName()     { return name; }
	public AbstractSymbol getParent()   { return parent; }
	public AbstractSymbol getFilename() { return filename; }
	public Features getFeatures()       { return features; }

	@Override
	public Object accept(ITreeVisitor visitor) {
		/**
		 * controllare che se la classe e' Main allora deve avere main senza parametri formali
		 * main deve essere presente e non ereditato
		 */
		SemantState.getInstance().setCurrentClass(this);
		visitor.onVisitPreOrder(this);
		features.accept(visitor);
		visitor.onVisitPostOrder(this);
		SemantState.getInstance().setCurrentClass(null);
		return null;
	}

	@Override
	public FeaturesTable getFeaturesTable() {

		if ( featuresTable == null )
			featuresTable = new FeaturesTable(this);

		return featuresTable;
	}

}

/** Defines AST constructor 'method'.

    See TreeNode for full documentation. */
class method extends Feature {
	protected AbstractSymbol name;
	protected Formals formals;
	protected AbstractSymbol return_type;
	protected Expression expr;

	/** Creates "method" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for name
	 * @param a1 initial value for formals
	 * @param a2 initial value for return_type
	 * @param a3 initial value for expr
	 */
	public method(int lineNumber, AbstractSymbol a1, Formals a2, AbstractSymbol a3, Expression a4) {
		super(lineNumber);
		name = a1;
		formals = a2;
		return_type = a3;
		expr = a4;
	}

	public AbstractSymbol getName() {
		return name;
	}

	public void setName(AbstractSymbol name) {
		this.name = name;
	}

	public Formals getFormals() {
		return formals;
	}

	public void setFormals(Formals formals) {
		this.formals = formals;
	}

	public void setReturn_type(AbstractSymbol return_type) {
		this.return_type = return_type;
	}

	public Expression getExpr() {
		return expr;
	}

	public void setExpr(Expression expr) {
		this.expr = expr;
	}

	public AbstractSymbol getReturnType() {
		return return_type;
	}

	public TreeNode copy() {
		return new method(lineNumber, copy_AbstractSymbol(name), (Formals)formals.copy(), copy_AbstractSymbol(return_type), (Expression)expr.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "method\n");
		dump_AbstractSymbol(out, n+2, name);
		formals.dump(out, n+2);
		dump_AbstractSymbol(out, n+2, return_type);
		expr.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_method");
		dump_AbstractSymbol(out, n + 2, name);
		for (Enumeration e = formals.getElements(); e.hasMoreElements();) {
			((Formal)e.nextElement()).dump_with_types(out, n + 2);
		}
		dump_AbstractSymbol(out, n + 2, return_type);
		expr.dump_with_types(out, n + 2);
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		formals.accept(visitor);

		Object last_ret = expr.accept(visitor);
		/*
		 * chiamare visitor.visit(this) per
		 * registrare il nome del metodo in M
		 * validare il return_type
		 * inserire controllo sul lub del tipo restituito da exprr e return_type [modularizzare]
		 *
		 */

		decorate("dyn_return_type", last_ret);
		Object obj = visitor.onVisitPostOrder(this);
		return null;
	}

	@Override
	public AbstractSymbol getFeatureName()
	{
		return name;
	}

}

/** Defines AST constructor 'attr'.

    See TreeNode for full documentation. */
class attr extends Feature {
	protected AbstractSymbol name;
	protected AbstractSymbol type_decl;
	protected Expression init;

	/** Creates "attr" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for name
	 * @param a1 initial value for type_decl
	 * @param a2 initial value for init
	 */
	public attr(int lineNumber, AbstractSymbol a1, AbstractSymbol a2, Expression a3) {
		super(lineNumber);
		name = a1;
		type_decl = a2;
		init = a3;
	}

	public TreeNode copy() {
		return new attr(lineNumber, copy_AbstractSymbol(name), copy_AbstractSymbol(type_decl), (Expression)init.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "attr\n");
		dump_AbstractSymbol(out, n+2, name);
		dump_AbstractSymbol(out, n+2, type_decl);
		init.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_attr");
		dump_AbstractSymbol(out, n + 2, name);
		dump_AbstractSymbol(out, n + 2, type_decl);
		init.dump_with_types(out, n + 2);
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		/*
		 * chiamare visitor.visit(this) per
		 * verificare tipo dichiarato
		 * validare tipo init
		 * lub
		 */
		visitor.onVisitPreOrder(this);
		Object ret_init = init.accept(visitor);
		decorate("init_type", ret_init);
		visitor.onVisitPostOrder(this);
		return null;
	}

	@Override
	public AbstractSymbol getFeatureName()
	{
		return name;
	}

	@Override
	public AbstractSymbol getReturnType() {
		return type_decl;
	}

}

/** Defines AST constructor 'formalc'.

    See TreeNode for full documentation. */
class formalc extends Formal {
	protected AbstractSymbol name;
	protected AbstractSymbol type_decl;

	/** Creates "formalc" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for name
	 * @param a1 initial value for type_decl
	 */
	public formalc(int lineNumber, AbstractSymbol a1, AbstractSymbol a2) {
		super(lineNumber);
		name = a1;
		type_decl = a2;
	}

	public AbstractSymbol getName() {
		return name;
	}

	public void setName(AbstractSymbol name) {
		this.name = name;
	}

	public AbstractSymbol getTypeDecl() {
		return type_decl;
	}

	public void setTypeDecl(AbstractSymbol type_decl) {
		this.type_decl = type_decl;
	}

	public TreeNode copy() {
		return new formalc(lineNumber, copy_AbstractSymbol(name), copy_AbstractSymbol(type_decl));
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "formalc\n");
		dump_AbstractSymbol(out, n+2, name);
		dump_AbstractSymbol(out, n+2, type_decl);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_formal");
		dump_AbstractSymbol(out, n + 2, name);
		dump_AbstractSymbol(out, n + 2, type_decl);
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		/*
		 * chiamare visitor.visit(this) per
		 * verificare che type_decl esista,
		 * che self non sia il nome di un parametro formale
		 */
		visitor.onVisitPreOrder(this);
		visitor.onVisitPostOrder(this);
		return null;
	}

}

/** Defines AST constructor 'branch'.

    See TreeNode for full documentation. */
class branch extends Case {
	protected AbstractSymbol name;
	protected AbstractSymbol type_decl;
	protected Expression expr;

	/** Creates "branch" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for name
	 * @param a1 initial value for type_decl
	 * @param a2 initial value for expr
	 */
	public branch(int lineNumber, AbstractSymbol a1, AbstractSymbol a2, Expression a3) {
		super(lineNumber);
		name = a1;
		type_decl = a2;
		expr = a3;
	}

	public TreeNode copy() {
		return new branch(lineNumber, copy_AbstractSymbol(name), copy_AbstractSymbol(type_decl), (Expression)expr.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "branch\n");
		dump_AbstractSymbol(out, n+2, name);
		dump_AbstractSymbol(out, n+2, type_decl);
		expr.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_branch");
		dump_AbstractSymbol(out, n + 2, name);
		dump_AbstractSymbol(out, n + 2, type_decl);
		expr.dump_with_types(out, n + 2);
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		/*
		 * validare type_decl e name
		 * aggiungere type_decl/name in O e passare su expr con il visitor
		 */
		visitor.onVisitPreOrder(this);
		Object ret_expr = expr.accept(visitor);
		decorate("branch_type", ret_expr);

		AbstractSymbol returnsym =(AbstractSymbol) visitor.onVisitPostOrder(this);
		decorate("rt", ret_expr);
		return returnsym;
	}

	@Override
	public AbstractSymbol getName() {
		return name;
	}

	@Override
	public AbstractSymbol getTypeDecl() {
		return type_decl;
	}

}

/** Defines AST constructor 'assign'.

    See TreeNode for full documentation. */
class assign extends Expression {
	protected AbstractSymbol name;
	protected Expression expr;

	/** Creates "assign" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for name
	 * @param a1 initial value for expr
	 */
	public assign(int lineNumber, AbstractSymbol a1, Expression a2) {
		super(lineNumber);
		name = a1;
		expr = a2;
	}

	public AbstractSymbol getName() {
		return name;
	}

	public TreeNode copy() {
		return new assign(lineNumber, copy_AbstractSymbol(name), (Expression)expr.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "assign\n");
		dump_AbstractSymbol(out, n+2, name);
		expr.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_assign");
		dump_AbstractSymbol(out, n + 2, name);
		expr.dump_with_types(out, n + 2);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	public Expression getExpr()
	{
		return expr;
	}

	@Override
	public Object accept(ITreeVisitor visitor) {

		visitor.onVisitPreOrder(this);
		Object ret_expr = expr.accept(visitor);
		decorate("expr", ret_expr);

		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'static_dispatch'.

    See TreeNode for full documentation. */
class static_dispatch extends Expression {

	protected Expression expr;
	protected AbstractSymbol type_name;
	protected AbstractSymbol name;
	protected Expressions actual;

	/** Creates "static_dispatch" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for expr
	 * @param a1 initial value for type_name
	 * @param a2 initial value for name
	 * @param a3 initial value for actual
	 */
	public static_dispatch(int lineNumber, Expression a1, AbstractSymbol a2, AbstractSymbol a3, Expressions a4) {
		super(lineNumber);
		expr = a1;
		type_name = a2;
		name = a3;
		actual = a4;
	}

	public TreeNode copy() {
		return new static_dispatch(lineNumber, (Expression)expr.copy(), copy_AbstractSymbol(type_name), copy_AbstractSymbol(name), (Expressions)actual.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "static_dispatch\n");
		expr.dump(out, n+2);
		dump_AbstractSymbol(out, n+2, type_name);
		dump_AbstractSymbol(out, n+2, name);
		actual.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_static_dispatch");
		expr.dump_with_types(out, n + 2);
		dump_AbstractSymbol(out, n + 2, type_name);
		dump_AbstractSymbol(out, n + 2, name);
		out.println(Utilities.pad(n + 2) + "(");
		for (Enumeration e = actual.getElements(); e.hasMoreElements();) {
			((Expression)e.nextElement()).dump_with_types(out, n + 2);
		}
		out.println(Utilities.pad(n + 2) + ")");
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		/*
		 * expr@TYPE.method(params)
		 * valutare il tipo di expr, tradurre self in SELF_TYPE
		 * fare il lookup di type_name, ma non deve essere SELF_TYPE -> farlo diventare Object
		 * vedere se expr e' sottotipo di TYPE
		 * vedere se name e' registrato per TYPE
		 * validare actuals
		 * vedere se per ogni param matcha con la dichiarazione del metodo
		 * assegnare il tipo al nodo
		 *
		 */
		visitor.onVisitPreOrder(this);
		AbstractSymbol expr_type = (AbstractSymbol)expr.accept(visitor);

		actual.accept(visitor);
		decorate("expr_type", expr_type);

		visitor.onVisitPostOrder(this);
		return get_type();
	}

	public Expression getExpr() {
		return expr;
	}

	public AbstractSymbol getTypeName() {
		return type_name;
	}

	public AbstractSymbol getName() {
		return name;
	}

	public Expressions getActual() {
		return actual;
	}

}

/** Defines AST constructor 'dispatch'.

    See TreeNode for full documentation. */
class dispatch extends Expression {
	protected Expression expr;
	protected AbstractSymbol name;
	protected Expressions actual;
	/** Creates "dispatch" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for expr
	 * @param a1 initial value for name
	 * @param a2 initial value for actual
	 */
	public dispatch(int lineNumber, Expression a1, AbstractSymbol a2, Expressions a3) {
		super(lineNumber);
		expr = a1;
		name = a2;
		actual = a3;
	}
	public TreeNode copy() {
		return new dispatch(lineNumber, (Expression)expr.copy(), copy_AbstractSymbol(name), (Expressions)actual.copy());
	}
	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "dispatch\n");
		expr.dump(out, n+2);
		dump_AbstractSymbol(out, n+2, name);
		actual.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_dispatch");
		expr.dump_with_types(out, n + 2);
		dump_AbstractSymbol(out, n + 2, name);
		out.println(Utilities.pad(n + 2) + "(");
		for (Enumeration e = actual.getElements(); e.hasMoreElements();) {
			((Expression)e.nextElement()).dump_with_types(out, n + 2);
		}
		out.println(Utilities.pad(n + 2) + ")");
		dump_type(out, n);
	}
	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}
	@Override
	public Object accept(ITreeVisitor visitor) {
		/*
		 * expr.method(params)
		 * valutare il tipo di expr
		 * vedere se name e'registrato per type(expr)
		 * validare actuals
		 * vedere se per ogni param matcha con la dichiarazione del metodo
		 *
		 */
		visitor.onVisitPreOrder(this);
		AbstractSymbol expr_type = (AbstractSymbol) expr.accept(visitor);
		actual.accept(visitor);
//		System.out.println("expr type -> " + expr_type);
		decorate("expr_type", expr_type); // save the expr type
		visitor.onVisitPostOrder(this);
		return get_type();
	}

	public Expression getExpr() {
		return expr;
	}

	public AbstractSymbol getName() {
		return name;
	}

	public Expressions getActual() {
		return actual;
	}

}

/** Defines AST constructor 'cond'.

    See TreeNode for full documentation. */
class cond extends Expression {
	protected Expression pred;
	protected Expression then_exp;
	protected Expression else_exp;
	/** Creates "cond" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for pred
	 * @param a1 initial value for then_exp
	 * @param a2 initial value for else_exp
	 */
	public cond(int lineNumber, Expression a1, Expression a2, Expression a3) {
		super(lineNumber);
		pred = a1;
		then_exp = a2;
		else_exp = a3;
	}

	public TreeNode copy() {
		return new cond(lineNumber, (Expression)pred.copy(), (Expression)then_exp.copy(), (Expression)else_exp.copy());
	}

	public Expression getPred(){
		return pred;
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "cond\n");
		pred.dump(out, n+2);
		then_exp.dump(out, n+2);
		else_exp.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_cond");
		pred.dump_with_types(out, n + 2);
		then_exp.dump_with_types(out, n + 2);
		else_exp.dump_with_types(out, n + 2);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		Object ret_pred = pred.accept(visitor);
		Object ret_then_exp = then_exp.accept(visitor);
		Object ret_else_exp = else_exp.accept(visitor);

		/*
		 * valutare che ret_pred sia di sottotipo di Bool oppure metterlo Object
		 * valutare le expr, calcolarne il lub ed impostare il tipo di ritorno
		 */
		decorate("ret_pred", ret_pred);
		decorate("ret_then_exp", ret_then_exp);
		decorate("ret_else_exp", ret_else_exp);
		visitor.onVisitPostOrder(this);

		return get_type();
	}

}

/** Defines AST constructor 'loop'.

    See TreeNode for full documentation. */
class loop extends Expression {
	protected Expression pred;
	protected Expression body;

	/** Creates "loop" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for pred
	 * @param a1 initial value for body
	 */
	public loop(int lineNumber, Expression a1, Expression a2) {
		super(lineNumber);
		pred = a1;
		body = a2;
	}

	public TreeNode copy() {
		return new loop(lineNumber, (Expression)pred.copy(), (Expression)body.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "loop\n");
		pred.dump(out, n+2);
		body.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_loop");
		pred.dump_with_types(out, n + 2);
		body.dump_with_types(out, n + 2);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		/**
		 * controllare che il tipo di pred sia  Bool
		 * assegnare Object a loop
		 */
		visitor.onVisitPreOrder(this);
		Object ret_pred = pred.accept(visitor);
		Object ret_body = body.accept(visitor);

		decorate("pred", ret_pred);

		visitor.onVisitPostOrder(this);

		return get_type();
	}

}

/** Defines AST constructor 'typcase'.

    See TreeNode for full documentation. */
class typcase extends Expression {
	protected Expression expr;
	protected Cases cases;

	/** Creates "typcase" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for expr
	 * @param a1 initial value for cases
	 */
	public typcase(int lineNumber, Expression a1, Cases a2) {
		super(lineNumber);
		expr = a1;
		cases = a2;
	}

	public TreeNode copy() {
		return new typcase(lineNumber, (Expression)expr.copy(), (Cases)cases.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "typcase\n");
		expr.dump(out, n+2);
		cases.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_typcase");
		expr.dump_with_types(out, n + 2);
		for (Enumeration e = cases.getElements(); e.hasMoreElements();) {
			((Case)e.nextElement()).dump_with_types(out, n + 2);
		}
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		/**
		 * valutare expr e cases
		 * i branch non possono essere di tipo SELF_TYPE, i nomi non possono essere self
		 * validare i tipi
		 * calcolare il lub ed assegnarlo come tipo di ritorno
		 */
		visitor.onVisitPreOrder(this);
		Object ret_expr = expr.accept(visitor);
		Object ret_cases = cases.accept(visitor); // this is the least upper bound
		decorate("lub", ret_cases);
		decorate("rt", cases.getData("rt"));
		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'block'.

    See TreeNode for full documentation. */
class block extends Expression {
	protected Expressions body;

	/** Creates "block" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for body
	 */
	public block(int lineNumber, Expressions a1) {
		super(lineNumber);
		body = a1;
	}

	public TreeNode copy() {
		return new block(lineNumber, (Expressions)body.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "block\n");
		body.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_block");
		for (Enumeration e = body.getElements(); e.hasMoreElements();) {
			((Expression)e.nextElement()).dump_with_types(out, n + 2);
		}
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		/**
		 * impostare il tipo
		 */
		visitor.onVisitPreOrder(this);
		Object ret_block = body.accept(visitor);
		decorate("ret_block", ret_block);

		visitor.onVisitPostOrder(this);
		decorate("rt", body.getData("rt"));
		return get_type();
	}

}

/** Defines AST constructor 'let'.

    See TreeNode for full documentation. */
class let extends Expression {
	protected AbstractSymbol identifier;
	protected AbstractSymbol type_decl;
	protected Expression init;
	protected Expression body;

	/** Creates "let" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for identifier
	 * @param a1 initial value for type_decl
	 * @param a2 initial value for init
	 * @param a3 initial value for body
	 */
	public let(int lineNumber, AbstractSymbol a1, AbstractSymbol a2, Expression a3, Expression a4) {
		super(lineNumber);
		identifier = a1;
		type_decl = a2;
		init = a3;
		body = a4;
	}

	public AbstractSymbol getIdentifier() {
		return identifier;
	}

	public AbstractSymbol getTypeDecl() {
		return type_decl;
	}

	public Expression getInit() {
		return init;
	}

	public Expression getBody() {
		return body;
	}

	public TreeNode copy() {
		return new let(lineNumber, copy_AbstractSymbol(identifier), copy_AbstractSymbol(type_decl), (Expression)init.copy(), (Expression)body.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "let\n");
		dump_AbstractSymbol(out, n+2, identifier);
		dump_AbstractSymbol(out, n+2, type_decl);
		init.dump(out, n+2);
		body.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_let");
		dump_AbstractSymbol(out, n + 2, identifier);
		dump_AbstractSymbol(out, n + 2, type_decl);
		init.dump_with_types(out, n + 2);
		body.dump_with_types(out, n + 2);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {

		Object ret_init = init.accept(visitor);
		decorate("ret_init", ret_init);

		visitor.onVisitPreOrder(this);

		Object ret_body = body.accept(visitor);

		decorate("ret_body", ret_body );
		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'plus'.

    See TreeNode for full documentation. */
class plus extends Expression {
	protected Expression e1;
	protected Expression e2;

	/** Creates "plus" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for e1
	 * @param a1 initial value for e2
	 */
	public plus(int lineNumber, Expression a1, Expression a2) {
		super(lineNumber);
		e1 = a1;
		e2 = a2;
	}

	public TreeNode copy() {
		return new plus(lineNumber, (Expression)e1.copy(), (Expression)e2.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "plus\n");
		e1.dump(out, n+2);
		e2.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_plus");
		e1.dump_with_types(out, n + 2);
		e2.dump_with_types(out, n + 2);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		Object ret_e1 = e1.accept(visitor);
		Object ret_e2 = e2.accept(visitor);
		/*
		 * valutare che siano interi e assegnare il tipo al nodo
		 */
		decorate("left", ret_e1);
		decorate("right", ret_e2);
		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'sub'.

    See TreeNode for full documentation. */
class sub extends Expression {
	protected Expression e1;
	protected Expression e2;

	/** Creates "sub" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for e1
	 * @param a1 initial value for e2
	 */
	public sub(int lineNumber, Expression a1, Expression a2) {
		super(lineNumber);
		e1 = a1;
		e2 = a2;
	}

	public TreeNode copy() {
		return new sub(lineNumber, (Expression)e1.copy(), (Expression)e2.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "sub\n");
		e1.dump(out, n+2);
		e2.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_sub");
		e1.dump_with_types(out, n + 2);
		e2.dump_with_types(out, n + 2);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		Object ret_e1 = e1.accept(visitor);
		Object ret_e2 = e2.accept(visitor);
		/*
		 * valutare che siano interi e assegnare il tipo al nodo
		 */
		decorate("left", ret_e1);
		decorate("right", ret_e2);
		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'mul'.

    See TreeNode for full documentation. */
class mul extends Expression {
	protected Expression e1;
	protected Expression e2;

	/** Creates "mul" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for e1
	 * @param a1 initial value for e2
	 */
	public mul(int lineNumber, Expression a1, Expression a2) {
		super(lineNumber);
		e1 = a1;
		e2 = a2;
	}

	public TreeNode copy() {
		return new mul(lineNumber, (Expression)e1.copy(), (Expression)e2.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "mul\n");
		e1.dump(out, n+2);
		e2.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_mul");
		e1.dump_with_types(out, n + 2);
		e2.dump_with_types(out, n + 2);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		Object ret_e1 = e1.accept(visitor);
		Object ret_e2 = e2.accept(visitor);
		/*
		 * valutare che siano interi e assegnare il tipo al nodo
		 */
		decorate("left", ret_e1);
		decorate("right", ret_e2);
		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'divide'.

    See TreeNode for full documentation. */
class divide extends Expression {
	protected Expression e1;
	protected Expression e2;

	/** Creates "divide" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for e1
	 * @param a1 initial value for e2
	 */
	public divide(int lineNumber, Expression a1, Expression a2) {
		super(lineNumber);
		e1 = a1;
		e2 = a2;
	}

	public TreeNode copy() {
		return new divide(lineNumber, (Expression)e1.copy(), (Expression)e2.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "divide\n");
		e1.dump(out, n+2);
		e2.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_divide");
		e1.dump_with_types(out, n + 2);
		e2.dump_with_types(out, n + 2);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		Object ret_e1 = e1.accept(visitor);
		Object ret_e2 = e2.accept(visitor);
		/*
		 * valutare che siano interi e assegnare il tipo al nodo
		 */
		decorate("left", ret_e1);
		decorate("right", ret_e2);
		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'neg'.

    See TreeNode for full documentation. */
class neg extends Expression {
	protected Expression e1;

	/** Creates "neg" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for e1
	 */
	public neg(int lineNumber, Expression a1) {
		super(lineNumber);
		e1 = a1;
	}

	public TreeNode copy() {
		return new neg(lineNumber, (Expression)e1.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "neg\n");
		e1.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_neg");
		e1.dump_with_types(out, n + 2);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		Object ret_e1 = e1.accept(visitor);
		/*
		 * valutare che sia intero e assegnare il tipo al nodo
		 */
		decorate("child", ret_e1);
		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'lt'.

    See TreeNode for full documentation. */
class lt extends Expression {
	protected Expression e1;
	protected Expression e2;

	/** Creates "lt" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for e1
	 * @param a1 initial value for e2
	 */
	public lt(int lineNumber, Expression a1, Expression a2) {
		super(lineNumber);
		e1 = a1;
		e2 = a2;
	}

	public TreeNode copy() {
		return new lt(lineNumber, (Expression)e1.copy(), (Expression)e2.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "lt\n");
		e1.dump(out, n+2);
		e2.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_lt");
		e1.dump_with_types(out, n + 2);
		e2.dump_with_types(out, n + 2);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		Object ret_e1 = e1.accept(visitor);
		Object ret_e2 = e2.accept(visitor);
		/*
		 * valutare che siano interi e assegnare il tipo al nodo (Bool)
		 */
		decorate("left", ret_e1);
		decorate("right", ret_e2);
		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'eq'.

    See TreeNode for full documentation. */
class eq extends Expression {
	protected Expression e1;
	protected Expression e2;

	/** Creates "eq" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for e1
	 * @param a1 initial value for e2
	 */
	public eq(int lineNumber, Expression a1, Expression a2) {
		super(lineNumber);
		e1 = a1;
		e2 = a2;
	}

	public TreeNode copy() {
		return new eq(lineNumber, (Expression)e1.copy(), (Expression)e2.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "eq\n");
		e1.dump(out, n+2);
		e2.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_eq");
		e1.dump_with_types(out, n + 2);
		e2.dump_with_types(out, n + 2);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		Object ret_e1 = e1.accept(visitor);
		Object ret_e2 = e2.accept(visitor);
		/*
		 * valutare che siano interi|stringhe| e assegnare il tipo al nodo
		 * return visitor.visit(this);
		 */
		decorate("left", ret_e1);
		decorate("right", ret_e2);
		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'leq'.

    See TreeNode for full documentation. */
class leq extends Expression {
	protected Expression e1;
	protected Expression e2;

	/** Creates "leq" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for e1
	 * @param a1 initial value for e2
	 */
	public leq(int lineNumber, Expression a1, Expression a2) {
		super(lineNumber);
		e1 = a1;
		e2 = a2;
	}

	public TreeNode copy() {
		return new leq(lineNumber, (Expression)e1.copy(), (Expression)e2.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "leq\n");
		e1.dump(out, n+2);
		e2.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_leq");
		e1.dump_with_types(out, n + 2);
		e2.dump_with_types(out, n + 2);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {

	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		Object ret_e1 = e1.accept(visitor);
		Object ret_e2 = e2.accept(visitor);
		/*
		 * valutare che siano interi e assegnare il tipo al nodo
		 */
		decorate("left", ret_e1);
		decorate("right", ret_e2);
		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'comp'.

    See TreeNode for full documentation. */
class comp extends Expression {
	protected Expression e1;

	/** Creates "comp" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for e1
	 */
	public comp(int lineNumber, Expression a1) {
		super(lineNumber);
		e1 = a1;
	}

	public TreeNode copy() {
		return new comp(lineNumber, (Expression)e1.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "comp\n");
		e1.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_comp");
		e1.dump_with_types(out, n + 2);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		/**
		 * valutare e1 (bool) ed assegnare il tipo (bool)
		 */
		visitor.onVisitPreOrder(this);
		Object ret_e1 = e1.accept(visitor);
		decorate("child", ret_e1);
		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'int_const'.

    See TreeNode for full documentation. */
class int_const extends Expression {
	protected AbstractSymbol token;

	/** Creates "int_const" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for token
	 */
	public int_const(int lineNumber, AbstractSymbol a1) {
		super(lineNumber);
		token = a1;
	}

	public TreeNode copy() {
		return new int_const(lineNumber, copy_AbstractSymbol(token));
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "int_const\n");
		dump_AbstractSymbol(out, n+2, token);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_int");
		dump_AbstractSymbol(out, n + 2, token);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method method is provided
	 * to you as an example of code generation.
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
		CgenSupport.emitLoadInt(CgenSupport.ACC,
				(IntSymbol)AbstractTable.inttable.lookup(token.getString()), s);
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		visitor.onVisitPostOrder(this); //set_type(TreeConstants.Int);
		return get_type();
	}

}

/** Defines AST constructor 'bool_const'.

    See TreeNode for full documentation. */
class bool_const extends Expression {
	protected Boolean val;

	/** Creates "bool_const" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for val
	 */
	public bool_const(int lineNumber, Boolean a1) {
		super(lineNumber);
		val = a1;
	}

	public TreeNode copy() {
		return new bool_const(lineNumber, copy_Boolean(val));
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "bool_const\n");
		dump_Boolean(out, n+2, val);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_bool");
		dump_Boolean(out, n + 2, val);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method method is provided
	 * to you as an example of code generation.
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
		CgenSupport.emitLoadBool(CgenSupport.ACC, new BoolConst(val), s);
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		visitor.onVisitPostOrder(this);
		return get_type();
	}
}

/** Defines AST constructor 'string_const'.

    See TreeNode for full documentation. */
class string_const extends Expression {
	protected AbstractSymbol token;

	/** Creates "string_const" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for token
	 */
	public string_const(int lineNumber, AbstractSymbol a1) {
		super(lineNumber);
		token = a1;
	}

	public TreeNode copy() {
		return new string_const(lineNumber, copy_AbstractSymbol(token));
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "string_const\n");
		dump_AbstractSymbol(out, n+2, token);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_string");
		out.print(Utilities.pad(n + 2) + "\"");
		Utilities.printEscapedString(out, token.getString());
		out.println("\"");
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method method is provided
	 * to you as an example of code generation.
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
		CgenSupport.emitLoadString(CgenSupport.ACC,
				(StringSymbol)AbstractTable.stringtable.lookup(token.getString()), s);
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'new_'.

    See TreeNode for full documentation. */
class new_ extends Expression {

	protected AbstractSymbol type_name;

	/** Creates "new_" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for type_name
	 */
	public new_(int lineNumber, AbstractSymbol a1) {
		super(lineNumber);
		type_name = a1;
	}

	public TreeNode copy() {
		return new new_(lineNumber, copy_AbstractSymbol(type_name));
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "new_\n");
		dump_AbstractSymbol(out, n+2, type_name);
	}

	public AbstractSymbol getTypeName() {
		return type_name;
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_new");
		dump_AbstractSymbol(out, n + 2, type_name);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		/*
		 * verificare che type_name sia valido
		 * restituirlo
		 */
		visitor.onVisitPreOrder(this);
		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'isvoid'.

    See TreeNode for full documentation. */
class isvoid extends Expression {
	protected Expression e1;

	/** Creates "isvoid" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for e1
	 */
	public isvoid(int lineNumber, Expression a1) {
		super(lineNumber);
		e1 = a1;
	}

	public TreeNode copy() {
		return new isvoid(lineNumber, (Expression)e1.copy());
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "isvoid\n");
		e1.dump(out, n+2);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_isvoid");
		e1.dump_with_types(out, n + 2);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		/**
		 * valutare e1
		 */
		visitor.onVisitPreOrder(this);
		Object ret_e1 = e1.accept(visitor);
		decorate("child", ret_e1);
		visitor.onVisitPostOrder(this);
		//		set_type(TreeConstants.Bool);
		return get_type();
	}

}

/** Defines AST constructor 'no_expr'.

    See TreeNode for full documentation. */
class no_expr extends Expression {

	/** Creates "no_expr" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 */
	public no_expr(int lineNumber) {
		super(lineNumber);
	}

	public TreeNode copy() {
		return new no_expr(lineNumber);
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "no_expr\n");
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_no_expr");
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		visitor.onVisitPreOrder(this);
		visitor.onVisitPostOrder(this);
		return get_type();
	}

}

/** Defines AST constructor 'object'.

    See TreeNode for full documentation. */
class object extends Expression {
	protected AbstractSymbol name;

	/** Creates "object" AST node.
	 *
	 * @param lineNumber the line in the source file from which this node came.
	 * @param a0 initial value for name
	 */
	public object(int lineNumber, AbstractSymbol a1) {
		super(lineNumber);
		name = a1;
	}

	public AbstractSymbol getName()
	{
		return name;
	}

	public TreeNode copy() {
		return new object(lineNumber, copy_AbstractSymbol(name));
	}

	public void dump(PrintStream out, int n) {
		out.print(Utilities.pad(n) + "object\n");
		dump_AbstractSymbol(out, n+2, name);
	}

	public void dump_with_types(PrintStream out, int n) {
		dump_line(out, n);
		out.println(Utilities.pad(n) + "_object");
		dump_AbstractSymbol(out, n + 2, name);
		dump_type(out, n);
	}

	/** Generates code for this expression.  This method is to be completed
	 * in programming assignment 5.  (You may add or remove parameters as
	 * you wish.)
	 * @param s the output stream
	 * */
	public void code(PrintStream s) {
	}

	@Override
	public Object accept(ITreeVisitor visitor) {
		/*
		 * fare il lookup nello scope corrente ed assegnare il tipo
		 */
		visitor.onVisitPreOrder(this);
		visitor.onVisitPostOrder(this);
//		System.out.println("object " +  get_type());
		return get_type();
	}

}


text:
=begin
def cartman_hates(thing)
  while true
    puts "What's there to hate about #{thing}?"
end
=end
# This is a tricky error. The line number may throw you off.

# 1. What is the name of the file with the error?
# => errors.rb
# 2. What is the line number where the error occurs?
# => Line 8
# 3. What is the type of error message?
# => Syntax error
# 4. What additional information does the interpreter provide about this type of error?
# => unexpected '=', expecting $end
# 5. Where is the error in the code?
# => Where the equals sign is in line eight. There's a ^ indicating where (incase there were multiple '=' signs).
# 6. Why did the interpreter give you this error?
# => It seems that "cartmans_phrase" was meant to have two combined strings assigned to it. If that was the case, then cartmans_phrase should have been written first. In the current order, we are attempting to assign a variable to strings. But strings aren't meant to hold or store information like that.

# --- error -------------------------------------------------------

# south_park

# 1. What is the line number where the error occurs?
# => 35
# 2. What is the type of error message?
# => NameError
# 3. What additional information does the interpreter provide about this type of error?
# => undefined local variable or method main:Object
# 4. Where is the error in the code?
# => 'south_park'
# 5. Why did the interpreter give you this error?
# => The variable or method 'south_park' needs to be defined. It can be set to something empty if necessary such as 0 or '' if it's a variable, but it needs to be defined.  Ruby is uncertain if it is a variable or method since they can be named in the same way.

# --- error -------------------------------------------------------

#def cartman()

# 1. What is the line number where the error occurs?
# => 50
# 2. What is the type of error message?
# => NoMethodError
# 3. What additional information does the interpreter provide about this type of error?
# => undefined method main:Object
# 4. Where is the error in the code?
# => 'cartman'
# 5. Why did the interpreter give you this error?
# => The method needs to be defined. This can be accomplished by adding 'def ' before 'cartman()'. An 'end' is also necessary after it has been defined.

# --- error -------------------------------------------------------
=begin
def cartmans_phrase
  puts "I'm not fat; I'm big-boned!"
end

cartmans_phrase('I hate Kyle')
=end
# 1. What is the line number where the error occurs?
# => 65 and/or 69
# 2. What is the type of error message?
# => ArgumentError
# 3. What additional information does the interpreter provide about this type of error?
# => wrong number of arguments (1 for 0)
# 4. Where is the error in the code?
# => in 'cartmans_phrase' or something is missing from 69
# 5. Why did the interpreter give you this error?
# => The method does not list and arguments, but when it is called it is called with an argument. The method either needs to be granted an argument or the call needs to have its argument removed.

# --- error -------------------------------------------------------
=begin
def cartman_says(offensive_message)
  puts offensive_message
end

cartman_says
=end
# 1. What is the line number where the error occurs?
# => 84 and/or 88
# 2. What is the type of error message?
# => ArgumentError
# 3. What additional information does the interpreter provide about this type of error?
# => wrong number of arguments (0 for 1)
# 4. Where is the error in the code?
# => 'cartman_says' or something is missing from line 88
# 5. Why did the interpreter give you this error?
# => Here we have the reverse problem. Our method lists an argument, but when we call the method, we fail to provide it with one. The argument either needs to be removed from the method, or an argument needs to be granted when calling it.

# --- error -------------------------------------------------------
=begin
def cartmans_lie(lie, name)
  puts "#{lie}, #{name}!"
end

cartmans_lie('A meteor the size of the earth is about to hit Wyoming!')
=end
# 1. What is the line number where the error occurs?
# => 105 and/or 109
# 2. What is the type of error message?
# => Argument Error
# 3. What additional information does the interpreter provide about this type of error?
# => wrong number of arguments (1 for 2)
# 4. Where is the error in the code?
# => cartmans_lie or something is missing from 109
# 5. Why did the interpreter give you this error?
# => The method requires 2 arguments, but when it's called only 1 argument is provided. Again, either give another argument or get rid of one in the method.

# --- error -------------------------------------------------------

# 5 * "Respect my authoritay!"

# 1. What is the line number where the error occurs?
# => 124
# 2. What is the type of error message?
# => TypeError
# 3. What additional information does the interpreter provide about this type of error?
# => String can't be coerced into Fixnum
# 4. The '*' sign
# => The whole line seems to be a problem.
# 5. Why did the interpreter give you this error?
# => We're attempting to multiply a number by a string. The 'string' type and 'number' are refusing to interact given racial tension (numbers are bigots). A string can't do much for a number, but a number can help a string. The reverse order would do something - add a 'print' and it would print the string 5 times.

# --- error -------------------------------------------------------

#amount_of_kfc_left = 20/0

# 1. What is the line number where the error occurs?
# => 139
# 2. What is the type of error message?
# => ZeroDivisionError
# 3. What additional information does the interpreter provide about this type of error?
# => divided by 0
# 4. Where is the error in the code?
# => The '/' sign
# 5. Why did the interpreter give you this error?
# => We're attempting to divide 20 by 0. Basic math principles say you can't divide by zero. It's an undefined circumstance.

# --- error -------------------------------------------------------

#require_relative "cartmans_essay.md"

# 1. What is the line number where the error occurs?
# => 155
# 2. What is the type of error message?
# => LoadError
# 3. What additional information does the interpreter provide about this type of error?
# => 'require_relative': cannot load such file -- /vagrant/week-4/cartmans_essay.md
# 4. Where is the error in the code?
# => The whole line
# 5. Why did the interpreter give you this error?
# => Cartman never wrote his essay. And if he did, then it's not on my computer. We're trying to load something that doesn't exist.

# --- REFLECTION -------------------------------------------------------
# Write your reflection below as a comment.
=begin
Which error was the most difficult to read?
	I guess the LoadError. It gave a lot of information. But non of them were too intimidating.
How did you figure out what the issue with the error was?
	The line number and error names were the biggest hints. Between those two, I could often find the chunk of code and figure out what was wrong.
Were you able to determine why each error message happened based on the code?
	Yeah I think so.
When you encounter errors in your future code, what process will you follow to help you debug?
	Read line number and error name. Return to code, look for error. If nothing is found check back to read full error message. Resubmit code.
=end

redpajama_set_name: RedPajamaGithub


text:
package com.michalrus.nofatty.ui.utils

import java.awt.{ GridBagConstraints, GridBagLayout }
import javax.swing.event.{ ChangeEvent, ChangeListener }
import javax.swing.{ JLabel, SwingConstants, JSlider, JPanel }

import scala.collection.immutable.NumericRange

class Slider(range: NumericRange[Double], initial: Double, label: String, render: Double ⇒ String,
             onSlide: Double ⇒ Unit, onChange: Double ⇒ Unit) extends JPanel {
  require(range.nonEmpty, "empty Slider#range")

  val realInitial: Int = range.map(d ⇒ (d - initial).abs).zipWithIndex.minBy(_._1)._2
  val realMax = range.size - 1

  private[this] val slider = new JSlider(SwingConstants.HORIZONTAL, 0, realMax, realInitial)
  private[this] val lValue = new JLabel

  slider.addChangeListener(new ChangeListener {
    override def stateChanged(e: ChangeEvent): Unit = {
      val v = slider.getValue.toDouble / realMax * range.end
      lValue.setText(render(v))
      (if (slider.getValueIsAdjusting) onSlide else onChange)(v)
    }
  })

  lValue.setText(render(initial))

  {
    slider.setOpaque(false)
    setOpaque(false)
    setLayout(new GridBagLayout)
    val c = new GridBagConstraints()
    c.fill = GridBagConstraints.HORIZONTAL
    c.gridx = 0; c.gridy = 0
    c.weightx = 1.0; c.weighty = 0.0
    add(new JLabel(s"$label:"), c)
    c.gridx += 1
    add(lValue, c)
    lValue.setHorizontalAlignment(SwingConstants.RIGHT)
    c.gridy += 1; c.gridx = 0; c.gridwidth = 2
    add(slider, c)
  }

}


text:
class AccountValidator::ValidatorDefault

  #
  # Returns the payment source format that is
  # considered valid. Example: '123-456-7890'
  def self.pattern_format
    "++ any characters ++"
  end

  #
  # Returns the regexp that validates +#pattern_format+
  def self.pattern
    /.+/
  end

  #
  # This class will not use anything you pass in.
  def initialize(*args)
  end

  #
  # Validates a payment source. Returns nil and raises
  # no +Exception+ if a payment source is open to new
  # payments. Otherwise a +AccountValidator::ValidatorError+ will be raised.
  def account_is_open!(fulfilled_at = nil)
  end

  #
  # [_return_]
  #   the latest expiration date for a payment source
  def latest_expiration
    (Time.zone.now + 50.years).end_of_day
  end

  #
  # [_return_]
  #   A +Hash+ of :component_name => component_value pairs
  def components
    {}
  end

  #
  # [_return_]
  #   true if all components of a payment source are known, false otherwise.
  # [_example_]
  #   string '123-456-789' has 3 components
  def components_exist?
    true
  end

end


text:
// This class has been generated, DO NOT EDIT!

package org.tensorflow.op.bitwise;

import java.util.Arrays;
import org.tensorflow.GraphOperation;
import org.tensorflow.Operand;
import org.tensorflow.Operation;
import org.tensorflow.OperationBuilder;
import org.tensorflow.Output;
import org.tensorflow.op.RawOp;
import org.tensorflow.op.RawOpInputs;
import org.tensorflow.op.Scope;
import org.tensorflow.op.annotation.Endpoint;
import org.tensorflow.op.annotation.OpInputsMetadata;
import org.tensorflow.op.annotation.OpMetadata;
import org.tensorflow.op.annotation.Operator;
import org.tensorflow.proto.framework.DataType;
import org.tensorflow.types.family.TNumber;

/**
 * Elementwise computes the bitwise right-shift of {@code x} and {@code y}.
 * Performs a logical shift for unsigned integer types, and an arithmetic shift
 * for signed integer types.
 *
If {@code y} is negative, or greater than or equal to than the width of {@code x} in bits
 * the result is implementation defined.
 *
Example:
 *

 * import tensorflow as tf
 * from tensorflow.python.ops import bitwise_ops
 * import numpy as np
 * dtype_list = [tf.int8, tf.int16, tf.int32, tf.int64]
 *
 * for dtype in dtype_list:
 *   lhs = tf.constant([-1, -5, -3, -14], dtype=dtype)
 *   rhs = tf.constant([5, 0, 7, 11], dtype=dtype)
 *
 *   right_shift_result = bitwise_ops.right_shift(lhs, rhs)
 *
 *   print(right_shift_result)
 *
 * # This will print:
 * # tf.Tensor([-1 -5 -1 -1], shape=(4,), dtype=int8)
 * # tf.Tensor([-1 -5 -1 -1], shape=(4,), dtype=int16)
 * # tf.Tensor([-1 -5 -1 -1], shape=(4,), dtype=int32)
 * # tf.Tensor([-1 -5 -1 -1], shape=(4,), dtype=int64)
 *
 * lhs = np.array([-2, 64, 101, 32], dtype=np.int8)
 * rhs = np.array([-1, -5, -3, -14], dtype=np.int8)
 * bitwise_ops.right_shift(lhs, rhs)
 * # <tf.Tensor: shape=(4,), dtype=int8, numpy=array([ -2,  64, 101,  32], dtype=int8)>
 *

 *
 * @param <T> data type for {@code z} output
 */
@OpMetadata(
    opType = RightShift.OP_NAME,
    inputsClass = RightShift.Inputs.class
)
@Operator(
    group = "bitwise"
)
public final class RightShift<T extends TNumber> extends RawOp implements Operand<T> {
  /**
   * The name of this op, as known by TensorFlow core engine
   */
  public static final String OP_NAME = "RightShift";

  private Output<T> z;

  public RightShift(Operation operation) {
    super(operation, OP_NAME);
    int outputIdx = 0;
    z = operation.output(outputIdx++);
  }

  /**
   * Factory method to create a class wrapping a new RightShift operation.
   *
   * @param scope current scope
   * @param x The x value
   * @param y The y value
   * @param <T> data type for {@code RightShift} output and operands
   * @return a new instance of RightShift
   */
  @Endpoint(
      describeByClass = true
  )
  public static <T extends TNumber> RightShift<T> create(Scope scope, Operand<T> x, Operand<T> y) {
    OperationBuilder opBuilder = scope.opBuilder(OP_NAME, "RightShift");
    opBuilder.addInput(x.asOutput());
    opBuilder.addInput(y.asOutput());
    return new RightShift<>(opBuilder.build());
  }

  /**
   * Gets z.
   *
   * @return z.
   */
  public Output<T> z() {
    return z;
  }

  @Override
  public Output<T> asOutput() {
    return z;
  }

  @OpInputsMetadata(
      outputsClass = RightShift.class
  )
  public static class Inputs<T extends TNumber> extends RawOpInputs<RightShift<T>> {
    /**
     * The x input
     */
    public final Operand<T> x;

    /**
     * The y input
     */
    public final Operand<T> y;

    /**
     * The T attribute
     */
    public final DataType T;

    public Inputs(GraphOperation op) {
      super(new RightShift<>(op), op, Arrays.asList("T"));
      int inputIndex = 0;
      x = (Operand<T>) op.input(inputIndex++);
      y = (Operand<T>) op.input(inputIndex++);
      T = op.attributes().getAttrType("T");
    }
  }
}


text:
using System.Configuration;

using WindowsService.Scheduling.Example.Repositories;
using WindowsService.Scheduling.Example.Web;
using WindowsService.Scheduling.Example.Workers;
using WindowsService.Scheduling.Settings;
using WindowsService.Scheduling.Unity.Registrars;

using Microsoft.Practices.Unity;

namespace WindowsService.Scheduling.Example.Registrars
{
	internal static class TimeAsyncWorkerRegistrar
	{
		public static void Register(IUnityContainer container)
		{
			container.RegisterType<ICityRepository, CityRepository>(WorkerNames.TimeAsyncWorker, new ContainerControlledLifetimeManager());
		    container.RegisterInstance(
		        WorkerNames.TimeAsyncWorker,
		        (IWorkerSettings)ConfigurationManager.GetSection("timeAsyncWorkerSettings"));

			WorkerRegistrar.Register(
				container,
				WorkerNames.TimeAsyncWorker,
				c => new TimeAsyncWorker(
					c.Resolve<ICityRepository>(WorkerNames.TimeAsyncWorker),
					c.Resolve<IHttpClient>(),
					Settings.CitiesPerRequest,
					Settings.TimeAsyncWorkerFileName));
		}
	}
}


text:
/**
 * InvalidIdListType.java
 *
 * This file was auto-generated from WSDL
 * by the Apache Axis2 version: 1.6.2  Built on : Apr 17, 2012 (05:34:40 IST)
 */

                package gov.nih.nlm.ncbi.www.soap.eutils.epost;

            /**
            *  InvalidIdListType bean class
            */
            @SuppressWarnings({"unchecked","unused"})

        public  class InvalidIdListType
        implements org.apache.axis2.databinding.ADBBean{
        /* This type was generated from the piece of schema that had
                name = InvalidIdListType
                Namespace URI = http://www.ncbi.nlm.nih.gov/soap/eutils/epost
                Namespace Prefix = ns7
                */

                        /**
                        * field for Id
                        * This was an Array!
                        */

                                    protected java.lang.String[] localId ;

                           /**
                           * Auto generated getter method
                           * @return java.lang.String[]
                           */
                           public  java.lang.String[] getId(){
                               return localId;
                           }

                              /**
                               * validate the array for Id
                               */
                              protected void validateId(java.lang.String[] param){

                              if ((param != null) && (param.length < 1)){
                                throw new java.lang.RuntimeException();
                              }

                              }

                             /**
                              * Auto generated setter method
                              * @param param Id
                              */
                              public void setId(java.lang.String[] param){

                                   validateId(param);

                                      this.localId=param;
                              }

                             /**
                             * Auto generated add method for the array for convenience
                             * @param param java.lang.String
                             */
                             public void addId(java.lang.String param){
                                   if (localId == null){
                                   localId = new java.lang.String[]{};
                                   }

                               java.util.List list =
                            org.apache.axis2.databinding.utils.ConverterUtil.toList(localId);
                               list.add(param);
                               this.localId =
                             (java.lang.String[])list.toArray(
                            new java.lang.String[list.size()]);

                             }

        /**
        *
        * @param parentQName
        * @param factory
        * @return org.apache.axiom.om.OMElement
        */
       public org.apache.axiom.om.OMElement getOMElement (
               final javax.xml.namespace.QName parentQName,
               final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{

               org.apache.axiom.om.OMDataSource dataSource =
                       new org.apache.axis2.databinding.ADBDataSource(this,parentQName);
               return factory.createOMElement(dataSource,parentQName);

        }

         public void serialize(final javax.xml.namespace.QName parentQName,
                                       javax.xml.stream.XMLStreamWriter xmlWriter)
                                throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{
                           serialize(parentQName,xmlWriter,false);
         }

         public void serialize(final javax.xml.namespace.QName parentQName,
                               javax.xml.stream.XMLStreamWriter xmlWriter,
                               boolean serializeType)
            throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{

                java.lang.String prefix = null;
                java.lang.String namespace = null;

                    prefix = parentQName.getPrefix();
                    namespace = parentQName.getNamespaceURI();
                    writeStartElement(prefix, namespace, parentQName.getLocalPart(), xmlWriter);

                  if (serializeType){

                   java.lang.String namespacePrefix = registerPrefix(xmlWriter,"http://www.ncbi.nlm.nih.gov/soap/eutils/epost");
                   if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)){
                       writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type",
                           namespacePrefix+":InvalidIdListType",
                           xmlWriter);
                   } else {
                       writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type",
                           "InvalidIdListType",
                           xmlWriter);
                   }

                   }

                             if (localId!=null) {
                                   namespace = "http://www.ncbi.nlm.nih.gov/soap/eutils/epost";
                                   for (int i = 0;i < localId.length;i++){

                                            if (localId[i] != null){

                                                writeStartElement(null, namespace, "Id", xmlWriter);

                                                        xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localId[i]));

                                                xmlWriter.writeEndElement();

                                                } else {

                                                           throw new org.apache.axis2.databinding.ADBException("Id cannot be null!!");

                                                }

                                   }
                             } else {

                                         throw new org.apache.axis2.databinding.ADBException("Id cannot be null!!");

                             }

                    xmlWriter.writeEndElement();

        }

        private static java.lang.String generatePrefix(java.lang.String namespace) {
            if(namespace.equals("http://www.ncbi.nlm.nih.gov/soap/eutils/epost")){
                return "ns7";
            }
            return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
        }

        /**
         * Utility method to write an element start tag.
         */
        private void writeStartElement(java.lang.String prefix, java.lang.String namespace, java.lang.String localPart,
                                       javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException {
            java.lang.String writerPrefix = xmlWriter.getPrefix(namespace);
            if (writerPrefix != null) {
                xmlWriter.writeStartElement(namespace, localPart);
            } else {
                if (namespace.length() == 0) {
                    prefix = "";
                } else if (prefix == null) {
                    prefix = generatePrefix(namespace);
                }

                xmlWriter.writeStartElement(prefix, localPart, namespace);
                xmlWriter.writeNamespace(prefix, namespace);
                xmlWriter.setPrefix(prefix, namespace);
            }
        }

        /**
         * Util method to write an attribute with the ns prefix
         */
        private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName,
                                    java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{
            if (xmlWriter.getPrefix(namespace) == null) {
                xmlWriter.writeNamespace(prefix, namespace);
                xmlWriter.setPrefix(prefix, namespace);
            }
            xmlWriter.writeAttribute(namespace,attName,attValue);
        }

        /**
         * Util method to write an attribute without the ns prefix
         */
        private void writeAttribute(java.lang.String namespace,java.lang.String attName,
                                    java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{
            if (namespace.equals("")) {
                xmlWriter.writeAttribute(attName,attValue);
            } else {
                registerPrefix(xmlWriter, namespace);
                xmlWriter.writeAttribute(namespace,attName,attValue);
            }
        }

           /**
             * Util method to write an attribute without the ns prefix
             */
            private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName,
                                             javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException {

                java.lang.String attributeNamespace = qname.getNamespaceURI();
                java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace);
                if (attributePrefix == null) {
                    attributePrefix = registerPrefix(xmlWriter, attributeNamespace);
                }
                java.lang.String attributeValue;
                if (attributePrefix.trim().length() > 0) {
                    attributeValue = attributePrefix + ":" + qname.getLocalPart();
                } else {
                    attributeValue = qname.getLocalPart();
                }

                if (namespace.equals("")) {
                    xmlWriter.writeAttribute(attName, attributeValue);
                } else {
                    registerPrefix(xmlWriter, namespace);
                    xmlWriter.writeAttribute(namespace, attName, attributeValue);
                }
            }
        /**
         *  method to handle Qnames
         */

        private void writeQName(javax.xml.namespace.QName qname,
                                javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException {
            java.lang.String namespaceURI = qname.getNamespaceURI();
            if (namespaceURI != null) {
                java.lang.String prefix = xmlWriter.getPrefix(namespaceURI);
                if (prefix == null) {
                    prefix = generatePrefix(namespaceURI);
                    xmlWriter.writeNamespace(prefix, namespaceURI);
                    xmlWriter.setPrefix(prefix,namespaceURI);
                }

                if (prefix.trim().length() > 0){
                    xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname));
                } else {
                    // i.e this is the default namespace
                    xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname));
                }

            } else {
                xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname));
            }
        }

        private void writeQNames(javax.xml.namespace.QName[] qnames,
                                 javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException {

            if (qnames != null) {
                // we have to store this data until last moment since it is not possible to write any
                // namespace data after writing the charactor data
                java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer();
                java.lang.String namespaceURI = null;
                java.lang.String prefix = null;

                for (int i = 0; i < qnames.length; i++) {
                    if (i > 0) {
                        stringToWrite.append(" ");
                    }
                    namespaceURI = qnames[i].getNamespaceURI();
                    if (namespaceURI != null) {
                        prefix = xmlWriter.getPrefix(namespaceURI);
                        if ((prefix == null) || (prefix.length() == 0)) {
                            prefix = generatePrefix(namespaceURI);
                            xmlWriter.writeNamespace(prefix, namespaceURI);
                            xmlWriter.setPrefix(prefix,namespaceURI);
                        }

                        if (prefix.trim().length() > 0){
                            stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i]));
                        } else {
                            stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i]));
                        }
                    } else {
                        stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i]));
                    }
                }
                xmlWriter.writeCharacters(stringToWrite.toString());
            }

        }

        /**
         * Register a namespace prefix
         */
        private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException {
            java.lang.String prefix = xmlWriter.getPrefix(namespace);
            if (prefix == null) {
                prefix = generatePrefix(namespace);
                javax.xml.namespace.NamespaceContext nsContext = xmlWriter.getNamespaceContext();
                while (true) {
                    java.lang.String uri = nsContext.getNamespaceURI(prefix);
                    if (uri == null || uri.length() == 0) {
                        break;
                    }
                    prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
                }
                xmlWriter.writeNamespace(prefix, namespace);
                xmlWriter.setPrefix(prefix, namespace);
            }
            return prefix;
        }

        /**
        * databinding method to get an XML representation of this object
        *
        */
        public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName)
                    throws org.apache.axis2.databinding.ADBException{

                 java.util.ArrayList elementList = new java.util.ArrayList();
                 java.util.ArrayList attribList = new java.util.ArrayList();

                            if (localId!=null){
                                  for (int i = 0;i < localId.length;i++){

                                         if (localId[i] != null){
                                          elementList.add(new javax.xml.namespace.QName("http://www.ncbi.nlm.nih.gov/soap/eutils/epost",
                                                                              "Id"));
                                          elementList.add(
                                          org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localId[i]));
                                          } else {

                                                    throw new org.apache.axis2.databinding.ADBException("Id cannot be null!!");

                                          }

                                  }
                            } else {

                                    throw new org.apache.axis2.databinding.ADBException("Id cannot be null!!");

                            }

                return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray());

        }

     /**
      *  Factory class that keeps the parse method
      */
    public static class Factory{

        /**
        * static method to create the object
        * Precondition:  If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable
        *                If this object is not an element, it is a complex type and the reader is at the event just after the outer start element
        * Postcondition: If this object is an element, the reader is positioned at its end element
        *                If this object is a complex type, the reader is positioned at the end element of its outer element
        */
        public static InvalidIdListType parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{
            InvalidIdListType object =
                new InvalidIdListType();

            int event;
            java.lang.String nillableValue = null;
            java.lang.String prefix ="";
            java.lang.String namespaceuri ="";
            try {

                while (!reader.isStartElement() && !reader.isEndElement())
                    reader.next();

                if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null){
                  java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance",
                        "type");
                  if (fullTypeName!=null){
                    java.lang.String nsPrefix = null;
                    if (fullTypeName.indexOf(":") > -1){
                        nsPrefix = fullTypeName.substring(0,fullTypeName.indexOf(":"));
                    }
                    nsPrefix = nsPrefix==null?"":nsPrefix;

                    java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":")+1);

                            if (!"InvalidIdListType".equals(type)){
                                //find namespace for the prefix
                                java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix);
                                return (InvalidIdListType)gov.nih.nlm.ncbi.www.soap.eutils.egquery.ExtensionMapper.getTypeObject(
                                     nsUri,type,reader);
                              }

                  }

                }

                // Note all attributes that were handled. Used to differ normal attributes
                // from anyAttributes.
                java.util.Vector handledAttributes = new java.util.Vector();

                    reader.next();

                        java.util.ArrayList list1 = new java.util.ArrayList();

                                    while (!reader.isStartElement() && !reader.isEndElement()) reader.next();

                                    if (reader.isStartElement() && new javax.xml.namespace.QName("http://www.ncbi.nlm.nih.gov/soap/eutils/epost","Id").equals(reader.getName())){

                                    // Process the array and step past its final element's end.
                                    list1.add(reader.getElementText());

                                            //loop until we find a start element that is not part of this array
                                            boolean loopDone1 = false;
                                            while(!loopDone1){
                                                // Ensure we are at the EndElement
                                                while (!reader.isEndElement()){
                                                    reader.next();
                                                }
                                                // Step out of this element
                                                reader.next();
                                                // Step to next element event.
                                                while (!reader.isStartElement() && !reader.isEndElement())
                                                    reader.next();
                                                if (reader.isEndElement()){
                                                    //two continuous end elements means we are exiting the xml structure
                                                    loopDone1 = true;
                                                } else {
                                                    if (new javax.xml.namespace.QName("http://www.ncbi.nlm.nih.gov/soap/eutils/epost","Id").equals(reader.getName())){
                                                         list1.add(reader.getElementText());

                                                    }else{
                                                        loopDone1 = true;
                                                    }
                                                }
                                            }
                                            // call the converter utility  to convert and set the array

                                                    object.setId((java.lang.String[])
                                                        list1.toArray(new java.lang.String[list1.size()]));

                              }  // End of if for expected property start element

                                else{
                                    // A start element we are not expecting indicates an invalid parameter was passed
                                    throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getName());
                                }

                            while (!reader.isStartElement() && !reader.isEndElement())
                                reader.next();

                                if (reader.isStartElement())
                                // A start element we are not expecting indicates a trailing invalid property
                                throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getName());

            } catch (javax.xml.stream.XMLStreamException e) {
                throw new java.lang.Exception(e);
            }

            return object;
        }

        }//end of factory class

        }


text:
using System.Threading;
using System.Threading.Tasks;
using Dapper;
using FluentValidation;
using MediatR;
using Npgsql;

namespace DDDSouthWest.Domain.Features.Account.Admin.ManageTalks.AddNewTalk
{
    public class AddNewTalk
    {
        public class Command : IRequest<Response>
        {
            public string TalkTitle { get; set; }
            public string TalkSummary { get; set; }
            public string TalkBodyMarkdown { get; set; }
            public string TalkBodyHtml { get; set; }
            public int UserId { get; set; }
        }

        public class Handler : IRequestHandler<Command, Response>
        {
            private readonly AddNewTalkValidator _validator;
            private readonly ClientConfigurationOptions _options;

            public Handler(AddNewTalkValidator validator, ClientConfigurationOptions options)
            {
                _validator = validator;
                _options = options;
            }

            public async Task<Response> Handle(Command message, CancellationToken cancellationToken)
            {
                _validator.ValidateAndThrow(message);

                using (var connection = new NpgsqlConnection(_options.Database.ConnectionString))
                {
                    const string addNewTalkSql = "INSERT INTO Talks (TalkTitle, TalkBodyHtml, TalkBodyMarkdown, TalkSummary, SubmissionDate, UserId) Values (@TalkTitle, @TalkBodyHtml, @TalkBodyMarkdown, @TalkSummary, current_timestamp, @UserId) RETURNING Id";
                    return new Response
                    {
                        Id = await connection.QuerySingleAsync<int>(addNewTalkSql, new
                        {
                            TalkTitle = message.TalkTitle,
                            TalkBodyHtml = message.TalkBodyHtml,
                            TalkBodyMarkdown = message.TalkBodyMarkdown,
                            TalkSummary = message.TalkSummary,
                            UserId = message.UserId
                        })
                    };
                }
            }
        }

        public class Response
        {
            public int Id { get; set; }
        }
    }
}