//generated by abstract-syntax-gen
package de.peeeq.wurstscript.jassIm;
import java.util.*;

@SuppressWarnings({"cast", "unused", "rawtypes"})
class ImNullImpl implements ImNull{
    ImNullImpl(ImType type) {
        if (type == null)
            throw new IllegalArgumentException("Element type must not be null.");
        this.type = type;
    }

    private Element parent;
    public Element getParent() { return parent; }
    public void setParent(Element parent) {
        if (parent != null && this.parent != null) {
            throw new Error("Cannot change parent of element " + this.getClass().getSimpleName() + ", as it is already used in another tree."
                + "Use the copy method to create a new tree or remove the tree from its old parent or set the parent to null before moving the tree. ");
        }
        this.parent = parent;
    }

    public void replaceBy(Element other) {
        if (parent == null)
            throw new RuntimeException("Node not attached to tree.");
        for (int i=0; i<parent.size(); i++) {
            if (parent.get(i) == this) {
                parent.set(i, other);
                return;
            }
        }
    }

    private ImType type;
    public void setType(ImType type) {
        if (type == null) throw new IllegalArgumentException();
        this.type = type;
    } 
    public ImType getType() { return type; }

    public Element get(int i) {
        switch (i) {
            default: throw new IllegalArgumentException("Index out of range: " + i);
        }
    }
    public Element set(int i, Element newElem) {
        Element oldElem;
        switch (i) {
            default: throw new IllegalArgumentException("Index out of range: " + i);
        }
    }

    @Override
    public void forEachElement(java.util.function.Consumer<? super Element> action) {
    }
    public int size() {
        return 0;
    }
    @Override public ImNull copy() {
        ImNull result = new ImNullImpl(type);
        return result;
    }

    @Override public ImNull copyWithRefs() {
        ImNull res = copy();
        return res;
    }

    @Override public void clearAttributes() {
        clearAttributesLocal();
    }
    @Override public void clearAttributesLocal() {
    }
    @Override public void accept(Visitor v) {
        v.visit(this);
    }
    @Override public <T> T match(ImExprOpt.Matcher<T> matcher) {
        return matcher.case_ImNull(this);
    }
    @Override public void match(ImExprOpt.MatcherVoid matcher) {
        matcher.case_ImNull(this);
    }

    @Override public <T> T match(ImConst.Matcher<T> matcher) {
        return matcher.case_ImNull(this);
    }
    @Override public void match(ImConst.MatcherVoid matcher) {
        matcher.case_ImNull(this);
    }

    @Override public <T> T match(ImStmt.Matcher<T> matcher) {
        return matcher.case_ImNull(this);
    }
    @Override public void match(ImStmt.MatcherVoid matcher) {
        matcher.case_ImNull(this);
    }

    @Override public <T> T match(ImPrintable.Matcher<T> matcher) {
        return matcher.case_ImNull(this);
    }
    @Override public void match(ImPrintable.MatcherVoid matcher) {
        matcher.case_ImNull(this);
    }

    @Override public <T> T match(ImExpr.Matcher<T> matcher) {
        return matcher.case_ImNull(this);
    }
    @Override public void match(ImExpr.MatcherVoid matcher) {
        matcher.case_ImNull(this);
    }

    @Override public <T> T match(Element.Matcher<T> matcher) {
        return matcher.case_ImNull(this);
    }
    @Override public void match(Element.MatcherVoid matcher) {
        matcher.case_ImNull(this);
    }

    public boolean structuralEquals(Element e) {
        if (e instanceof ImNull) {
            ImNull o = (ImNull) e;
            return this.type == o.getType();
        } else {
            return false;
        }
    }
    /** */
    public void print(java.lang.Appendable sb, int indent) {
        de.peeeq.wurstscript.translation.imtranslation.ImPrinter.print((ImNull)this, sb, indent);
    }
    /** */
    public String toString() {
        return de.peeeq.wurstscript.translation.imtranslation.ImPrinter.asString((ImNull)this);
    }
    /** */
    public de.peeeq.wurstscript.translation.imtranslation.Flatten.Result flatten(de.peeeq.wurstscript.translation.imtranslation.ImTranslator translator, de.peeeq.wurstscript.jassIm.ImFunction f) {
        return de.peeeq.wurstscript.translation.imtranslation.Flatten.flatten((ImNull)this, translator, f);
    }
    /** */
    public de.peeeq.wurstscript.translation.imtranslation.purity.PurityLevel attrPurity() {
        return de.peeeq.wurstscript.translation.imtranslation.purity.PurityLevels.calculate((ImNull)this);
    }
    /** */
    public void translate(java.util.List<de.peeeq.wurstscript.jassAst.JassStatement> stmts, de.peeeq.wurstscript.jassAst.JassFunction f, de.peeeq.wurstscript.translation.imtojass.ImToJassTranslator translator) {
        de.peeeq.wurstscript.translation.imtojass.StatementTranslation.translate((ImNull)this, stmts, f, translator);
    }
    /** */
    public de.peeeq.wurstscript.jassAst.JassExpr translate(de.peeeq.wurstscript.translation.imtojass.ImToJassTranslator translator) {
        return de.peeeq.wurstscript.translation.imtojass.ExprTranslation.translate((ImNull)this, translator);
    }
    /** */
    public boolean equalValue(ImConst other) {
        return de.peeeq.wurstscript.translation.imtojass.Equality.equalValue((ImNull)this, other);
    }
    /** */
    public ImType attrTyp() {
        return de.peeeq.wurstscript.translation.imtojass.ImAttrType.getType((ImNull)this);
    }
    /** */
    public ImFunction getNearestFunc() {
        return de.peeeq.wurstscript.translation.imtojass.ImAttributes.getNearestFunc((ImNull)this);
    }
    /** */
    public void translateStmtToLua(java.util.List<de.peeeq.wurstscript.luaAst.LuaStatement> res, de.peeeq.wurstscript.translation.lua.translation.LuaTranslator tr) {
        de.peeeq.wurstscript.translation.lua.translation.StmtTranslation.translate((ImNull)this, res, tr);
    }
    /** */
    public de.peeeq.wurstscript.luaAst.LuaExpr translateToLua(de.peeeq.wurstscript.translation.lua.translation.LuaTranslator tr) {
        return de.peeeq.wurstscript.translation.lua.translation.ExprTranslation.translate((ImNull)this, tr);
    }
    /** */
    public void runStatement(de.peeeq.wurstscript.intermediatelang.interpreter.ProgramState globalState, de.peeeq.wurstscript.intermediatelang.interpreter.LocalState localState) {
        de.peeeq.wurstscript.intermediatelang.interpreter.RunStatement.run((ImNull)this, globalState, localState);
    }
    /** */
    public de.peeeq.wurstscript.intermediatelang.ILconst evaluate(de.peeeq.wurstscript.intermediatelang.interpreter.ProgramState globalState, de.peeeq.wurstscript.intermediatelang.interpreter.LocalState localState) {
        return de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.eval((ImNull)this, globalState, localState);
    }
    /** */
    public de.peeeq.wurstscript.ast.Element attrTrace() {
        return de.peeeq.wurstscript.translation.imtojass.ImAttributes.getTrace((ImNull)this);
    }
    /** */
    public ImProg attrProg() {
        return de.peeeq.wurstscript.translation.imtojass.ImAttributes.getProg((ImNull)this);
    }
}