//generated by abstract-syntax-gen package de.peeeq.wurstscript.jassIm; import java.util.*; @SuppressWarnings({"cast", "unused", "rawtypes"}) class ImClassImpl implements ImClass{ ImClassImpl(de.peeeq.wurstscript.ast.Element trace, String name, ImTypeVars typeVariables, ImVars fields, ImMethods methods, ImFunctions functions, java.util.List superClasses) { if (trace == null) throw new IllegalArgumentException("Element trace must not be null."); if (name == null) throw new IllegalArgumentException("Element name must not be null."); if (typeVariables == null) throw new IllegalArgumentException("Element typeVariables must not be null."); if (fields == null) throw new IllegalArgumentException("Element fields must not be null."); if (methods == null) throw new IllegalArgumentException("Element methods must not be null."); if (functions == null) throw new IllegalArgumentException("Element functions must not be null."); if (superClasses == null) throw new IllegalArgumentException("Element superClasses must not be null."); this.trace = trace; this.name = name; this.typeVariables = typeVariables; this.fields = fields; this.methods = methods; this.functions = functions; this.superClasses = superClasses; typeVariables.setParent(this); fields.setParent(this); methods.setParent(this); functions.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 superClasses; public void setSuperClasses(java.util.List superClasses) { if (superClasses == null) throw new IllegalArgumentException(); this.superClasses = superClasses; } public java.util.List getSuperClasses() { return superClasses; } public Element get(int i) { switch (i) { case 0: return typeVariables; case 1: return fields; case 2: return methods; case 3: return functions; default: throw new IllegalArgumentException("Index out of range: " + i); } } public Element set(int i, Element newElem) { Element oldElem; switch (i) { case 0: oldElem = typeVariables; setTypeVariables((ImTypeVars) newElem); return oldElem; case 1: oldElem = fields; setFields((ImVars) newElem); return oldElem; case 2: oldElem = methods; setMethods((ImMethods) newElem); return oldElem; case 3: oldElem = functions; setFunctions((ImFunctions) newElem); return oldElem; default: throw new IllegalArgumentException("Index out of range: " + i); } } @Override public void forEachElement(java.util.function.Consumer action) { action.accept(this.typeVariables); action.accept(this.fields); action.accept(this.methods); action.accept(this.functions); } public int size() { return 4; } @Override public ImClass copy() { ImClass result = new ImClassImpl(trace, name, (ImTypeVars) this.typeVariables.copy(), (ImVars) this.fields.copy(), (ImMethods) this.methods.copy(), (ImFunctions) this.functions.copy(), superClasses); return result; } @Override public ImClass copyWithRefs() { ImClass 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 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() { typeVariables.clearAttributes(); fields.clearAttributes(); methods.clearAttributes(); functions.clearAttributes(); clearAttributesLocal(); } @Override public void clearAttributesLocal() { zzattr_attrSubclasses_state = 0; } @Override public void accept(Visitor v) { v.visit(this); } @Override public T match(JassImElementWithName.Matcher matcher) { return matcher.case_ImClass(this); } @Override public void match(JassImElementWithName.MatcherVoid matcher) { matcher.case_ImClass(this); } @Override public T match(ElementWithTrace.Matcher matcher) { return matcher.case_ImClass(this); } @Override public void match(ElementWithTrace.MatcherVoid matcher) { matcher.case_ImClass(this); } @Override public T match(ImPrintable.Matcher matcher) { return matcher.case_ImClass(this); } @Override public void match(ImPrintable.MatcherVoid matcher) { matcher.case_ImClass(this); } @Override public T match(Element.Matcher matcher) { return matcher.case_ImClass(this); } @Override public void match(Element.MatcherVoid matcher) { matcher.case_ImClass(this); } public boolean structuralEquals(Element e) { if (e instanceof ImClass) { ImClass o = (ImClass) e; return java.util.Objects.equals(name, o.getName()) && this.typeVariables.structuralEquals(o.getTypeVariables()) && this.fields.structuralEquals(o.getFields()) && this.methods.structuralEquals(o.getMethods()) && this.functions.structuralEquals(o.getFunctions()) && java.util.Objects.equals(superClasses, o.getSuperClasses()); } else { return false; } } /** */ public void print(java.lang.Appendable sb, int indent) { de.peeeq.wurstscript.translation.imtranslation.ImPrinter.print((ImClass)this, sb, indent); } /** */ public String toString() { return de.peeeq.wurstscript.translation.imtranslation.ImPrinter.asString((ImClass)this); } /** */ public ImFunction getNearestFunc() { return de.peeeq.wurstscript.translation.imtojass.ImAttributes.getNearestFunc((ImClass)this); } /** */ public de.peeeq.wurstscript.ast.Element attrTrace() { return de.peeeq.wurstscript.translation.imtojass.ImAttributes.getTrace((ImClass)this); } /** */ public ImProg attrProg() { return de.peeeq.wurstscript.translation.imtojass.ImAttributes.getProg((ImClass)this); } /** */ public int attrTypeId() { return de.peeeq.wurstscript.translation.imtranslation.TypeId.get((ImClass)this); } /** */ public boolean isSubclassOf(ImClass other) { return de.peeeq.wurstscript.translation.imtranslation.TypeId.isSubclass((ImClass)this, other); } // circular = null private int zzattr_attrSubclasses_state = 0; private java.util.List zzattr_attrSubclasses_cache; /** */ public java.util.List attrSubclasses() { if (zzattr_attrSubclasses_state == 0) { try { zzattr_attrSubclasses_state = 1; zzattr_attrSubclasses_cache = de.peeeq.wurstscript.translation.imtranslation.Subclasses.get((ImClass)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; } }