//generated by abstract-syntax-gen package de.peeeq.wurstscript.jassIm; import java.util.*; @SuppressWarnings({"cast", "unused", "rawtypes"}) class ImProgImpl implements ImProg{ ImProgImpl(de.peeeq.wurstscript.ast.Element trace, ImVars globals, ImFunctions functions, ImMethods methods, ImClasses classes, ImTypeClassFuncs typeClassFunctions, java.util.Map> globalInits) { if (trace == null) throw new IllegalArgumentException("Element trace must not be null."); if (globals == null) throw new IllegalArgumentException("Element globals must not be null."); if (functions == null) throw new IllegalArgumentException("Element functions must not be null."); if (methods == null) throw new IllegalArgumentException("Element methods must not be null."); if (classes == null) throw new IllegalArgumentException("Element classes must not be null."); if (typeClassFunctions == null) throw new IllegalArgumentException("Element typeClassFunctions must not be null."); if (globalInits == null) throw new IllegalArgumentException("Element globalInits must not be null."); this.trace = trace; this.globals = globals; this.functions = functions; this.methods = methods; this.classes = classes; this.typeClassFunctions = typeClassFunctions; this.globalInits = globalInits; globals.setParent(this); functions.setParent(this); methods.setParent(this); classes.setParent(this); typeClassFunctions.setParent(this); } 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> globalInits; public void setGlobalInits(java.util.Map> globalInits) { if (globalInits == null) throw new IllegalArgumentException(); this.globalInits = globalInits; } public java.util.Map> getGlobalInits() { return globalInits; } public Element get(int i) { switch (i) { case 0: return globals; case 1: return functions; case 2: return methods; case 3: return classes; case 4: return typeClassFunctions; default: throw new IllegalArgumentException("Index out of range: " + i); } } public Element set(int i, Element newElem) { Element oldElem; switch (i) { case 0: oldElem = globals; setGlobals((ImVars) newElem); return oldElem; case 1: oldElem = functions; setFunctions((ImFunctions) newElem); return oldElem; case 2: oldElem = methods; setMethods((ImMethods) newElem); return oldElem; case 3: oldElem = classes; setClasses((ImClasses) newElem); return oldElem; case 4: oldElem = typeClassFunctions; setTypeClassFunctions((ImTypeClassFuncs) newElem); return oldElem; default: throw new IllegalArgumentException("Index out of range: " + i); } } @Override public void forEachElement(java.util.function.Consumer action) { action.accept(this.globals); action.accept(this.functions); action.accept(this.methods); action.accept(this.classes); action.accept(this.typeClassFunctions); } public int size() { return 5; } @Override public ImProg copy() { ImProg result = new ImProgImpl(trace, (ImVars) this.globals.copy(), (ImFunctions) this.functions.copy(), (ImMethods) this.methods.copy(), (ImClasses) this.classes.copy(), (ImTypeClassFuncs) this.typeClassFunctions.copy(), globalInits); return result; } @Override public ImProg copyWithRefs() { ImProg res = copy(); Element self = this; res.accept(new Element.DefaultVisitor() { @Override public void visit(ImVarArrayAccess e) { super.visit(e); // check reference var { Element elem = e.getVar(); while (elem != self && elem != null) { elem = elem.getParent(); } if (elem == self) { e.setVar((ImVar) res.followPath(self.pathTo(e.getVar()))); } } } @Override public void visit(ImVarargLoop e) { super.visit(e); // check reference loopVar { Element elem = e.getLoopVar(); while (elem != self && elem != null) { elem = elem.getParent(); } if (elem == self) { e.setLoopVar((ImVar) res.followPath(self.pathTo(e.getLoopVar()))); } } } @Override public void visit(ImMemberAccess e) { super.visit(e); // check reference var { Element elem = e.getVar(); while (elem != self && elem != null) { elem = elem.getParent(); } if (elem == self) { e.setVar((ImVar) res.followPath(self.pathTo(e.getVar()))); } } } @Override public void visit(ImFuncRef e) { super.visit(e); // check reference func { Element elem = e.getFunc(); while (elem != self && elem != null) { elem = elem.getParent(); } if (elem == self) { e.setFunc((ImFunction) res.followPath(self.pathTo(e.getFunc()))); } } } @Override public void visit(ImFunctionCall e) { super.visit(e); // check reference func { Element elem = e.getFunc(); while (elem != self && elem != null) { elem = elem.getParent(); } if (elem == self) { e.setFunc((ImFunction) res.followPath(self.pathTo(e.getFunc()))); } } } @Override public void visit(ImMethodCall e) { super.visit(e); // check reference method { Element elem = e.getMethod(); while (elem != self && elem != null) { elem = elem.getParent(); } if (elem == self) { e.setMethod((ImMethod) res.followPath(self.pathTo(e.getMethod()))); } } } @Override public void visit(ImMethod e) { super.visit(e); // check reference implementation { Element elem = e.getImplementation(); while (elem != self && elem != null) { elem = elem.getParent(); } if (elem == self) { e.setImplementation((ImFunction) res.followPath(self.pathTo(e.getImplementation()))); } } } @Override public void visit(ImVarAccess e) { super.visit(e); // check reference var { Element elem = e.getVar(); while (elem != self && elem != null) { elem = elem.getParent(); } if (elem == self) { e.setVar((ImVar) res.followPath(self.pathTo(e.getVar()))); } } } @Override public void visit(ImTypeVarDispatch e) { super.visit(e); // check reference typeClassFunc { Element elem = e.getTypeClassFunc(); while (elem != self && elem != null) { elem = elem.getParent(); } if (elem == self) { e.setTypeClassFunc((ImTypeClassFunc) res.followPath(self.pathTo(e.getTypeClassFunc()))); } } // check reference typeVariable { Element elem = e.getTypeVariable(); while (elem != self && elem != null) { elem = elem.getParent(); } if (elem == self) { e.setTypeVariable((ImTypeVar) res.followPath(self.pathTo(e.getTypeVariable()))); } } } }); return res; } @Override public void clearAttributes() { globals.clearAttributes(); functions.clearAttributes(); methods.clearAttributes(); classes.clearAttributes(); typeClassFunctions.clearAttributes(); clearAttributesLocal(); } @Override public void clearAttributesLocal() { zzattr_attrVariableUses_state = 0; zzattr_attrTypeId_state = 0; zzattr_attrSubclasses_state = 0; } @Override public void accept(Visitor v) { v.visit(this); } @Override public T match(ElementWithTrace.Matcher matcher) { return matcher.case_ImProg(this); } @Override public void match(ElementWithTrace.MatcherVoid matcher) { matcher.case_ImProg(this); } @Override public T match(ImPrintable.Matcher matcher) { return matcher.case_ImProg(this); } @Override public void match(ImPrintable.MatcherVoid matcher) { matcher.case_ImProg(this); } @Override public T match(Element.Matcher matcher) { return matcher.case_ImProg(this); } @Override public void match(Element.MatcherVoid matcher) { matcher.case_ImProg(this); } public boolean structuralEquals(Element e) { if (e instanceof ImProg) { ImProg o = (ImProg) e; return this.globals.structuralEquals(o.getGlobals()) && this.functions.structuralEquals(o.getFunctions()) && this.methods.structuralEquals(o.getMethods()) && this.classes.structuralEquals(o.getClasses()) && this.typeClassFunctions.structuralEquals(o.getTypeClassFunctions()) && java.util.Objects.equals(globalInits, o.getGlobalInits()); } else { return false; } } /** */ public void print(java.lang.Appendable sb, int indent) { de.peeeq.wurstscript.translation.imtranslation.ImPrinter.print((ImProg)this, sb, indent); } /** */ public String toString() { return de.peeeq.wurstscript.translation.imtranslation.ImPrinter.asString((ImProg)this); } /** */ public void flatten(de.peeeq.wurstscript.translation.imtranslation.ImTranslator translator) { de.peeeq.wurstscript.translation.imtranslation.Flatten.flattenProg((ImProg)this, translator); } /** */ public ImFunction getNearestFunc() { return de.peeeq.wurstscript.translation.imtojass.ImAttributes.getNearestFunc((ImProg)this); } /** */ public de.peeeq.wurstscript.ast.Element attrTrace() { return de.peeeq.wurstscript.translation.imtojass.ImAttributes.getTrace((ImProg)this); } /** */ public ImProg attrProg() { return de.peeeq.wurstscript.translation.imtojass.ImAttributes.getProg((ImProg)this); } // circular = null private int zzattr_attrVariableUses_state = 0; private de.peeeq.wurstscript.translation.imoptimizer.VariableUses.Uses zzattr_attrVariableUses_cache; /** */ public de.peeeq.wurstscript.translation.imoptimizer.VariableUses.Uses attrVariableUses() { if (zzattr_attrVariableUses_state == 0) { try { zzattr_attrVariableUses_state = 1; zzattr_attrVariableUses_cache = de.peeeq.wurstscript.translation.imoptimizer.VariableUses.calcVarUses((ImProg)this); } finally { zzattr_attrVariableUses_state = 0; } zzattr_attrVariableUses_state = 2; } else if (zzattr_attrVariableUses_state == 1) { throw new CyclicDependencyError(this, "attrVariableUses"); } return zzattr_attrVariableUses_cache; } // circular = null private int zzattr_attrTypeId_state = 0; private java.util.Map zzattr_attrTypeId_cache; /** */ public java.util.Map attrTypeId() { if (zzattr_attrTypeId_state == 0) { try { zzattr_attrTypeId_state = 1; zzattr_attrTypeId_cache = de.peeeq.wurstscript.translation.imtranslation.TypeId.calculate((ImProg)this); } finally { zzattr_attrTypeId_state = 0; } zzattr_attrTypeId_state = 2; } else if (zzattr_attrTypeId_state == 1) { throw new CyclicDependencyError(this, "attrTypeId"); } return zzattr_attrTypeId_cache; } // circular = null private int zzattr_attrSubclasses_state = 0; private com.google.common.collect.Multimap zzattr_attrSubclasses_cache; /** */ public com.google.common.collect.Multimap attrSubclasses() { if (zzattr_attrSubclasses_state == 0) { try { zzattr_attrSubclasses_state = 1; zzattr_attrSubclasses_cache = de.peeeq.wurstscript.translation.imtranslation.Subclasses.calculate((ImProg)this); } finally { zzattr_attrSubclasses_state = 0; } zzattr_attrSubclasses_state = 2; } else if (zzattr_attrSubclasses_state == 1) { throw new CyclicDependencyError(this, "attrSubclasses"); } return zzattr_attrSubclasses_cache; } }