//generated by abstract-syntax-gen package de.peeeq.wurstscript.ast; import java.util.*; @SuppressWarnings({"cast", "unused", "rawtypes"}) class SwitchStmtImpl implements SwitchStmt{ SwitchStmtImpl(de.peeeq.wurstscript.parser.WPos source, Expr expr, SwitchCases cases, SwitchDefaultCase switchDefault) { if (source == null) throw new IllegalArgumentException("Element source must not be null."); if (expr == null) throw new IllegalArgumentException("Element expr must not be null."); if (cases == null) throw new IllegalArgumentException("Element cases must not be null."); if (switchDefault == null) throw new IllegalArgumentException("Element switchDefault must not be null."); this.source = source; this.expr = expr; this.cases = cases; this.switchDefault = switchDefault; expr.setParent(this); cases.setParent(this); switchDefault.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 action) { action.accept(this.expr); action.accept(this.cases); action.accept(this.switchDefault); } public int size() { return 3; } @Override public SwitchStmt copy() { SwitchStmt result = new SwitchStmtImpl(source, (Expr) this.expr.copy(), (SwitchCases) this.cases.copy(), (SwitchDefaultCase) this.switchDefault.copy()); return result; } @Override public SwitchStmt copyWithRefs() { SwitchStmt res = copy(); return res; } @Override public void clearAttributes() { expr.clearAttributes(); cases.clearAttributes(); switchDefault.clearAttributes(); clearAttributesLocal(); } @Override public void clearAttributesLocal() { zzattr_attrNextStatements_state = 0; zzattr_attrPreviousStatements_state = 0; zzattr_attrAfterBodyStatements_state = 0; zzattr_attrListIndex_state = 0; zzattr_attrReadVariables_state = 0; zzattr_attrUsedGlobalVariables_state = 0; zzattr_attrReadGlobalVariables_state = 0; } @Override public void accept(Visitor v) { v.visit(this); } @Override public T match(ControlflowStatement.Matcher matcher) { return matcher.case_SwitchStmt(this); } @Override public void match(ControlflowStatement.MatcherVoid matcher) { matcher.case_SwitchStmt(this); } @Override public T match(HasReadVariables.Matcher matcher) { return matcher.case_SwitchStmt(this); } @Override public void match(HasReadVariables.MatcherVoid matcher) { matcher.case_SwitchStmt(this); } @Override public T match(Element.Matcher matcher) { return matcher.case_SwitchStmt(this); } @Override public void match(Element.MatcherVoid matcher) { matcher.case_SwitchStmt(this); } @Override public T match(CompoundStatement.Matcher matcher) { return matcher.case_SwitchStmt(this); } @Override public void match(CompoundStatement.MatcherVoid matcher) { matcher.case_SwitchStmt(this); } @Override public T match(AstElementWithSource.Matcher matcher) { return matcher.case_SwitchStmt(this); } @Override public void match(AstElementWithSource.MatcherVoid matcher) { matcher.case_SwitchStmt(this); } @Override public T match(WStatement.Matcher matcher) { return matcher.case_SwitchStmt(this); } @Override public void match(WStatement.MatcherVoid matcher) { matcher.case_SwitchStmt(this); } @Override public T match(ExprOrStatements.Matcher matcher) { return matcher.case_SwitchStmt(this); } @Override public void match(ExprOrStatements.MatcherVoid matcher) { matcher.case_SwitchStmt(this); } @Override public String toString() { return "SwitchStmt(" + source + ", " +expr + ", " +cases + ", " +switchDefault+")"; } public boolean structuralEquals(Element e) { if (e instanceof SwitchStmt) { SwitchStmt o = (SwitchStmt) e; return this.expr.structuralEquals(o.getExpr()) && this.cases.structuralEquals(o.getCases()) && this.switchDefault.structuralEquals(o.getSwitchDefault()); } else { return false; } } // circular = null private int zzattr_attrNextStatements_state = 0; private java.util.List zzattr_attrNextStatements_cache; /** "returns all statements which can be executed after this statement"*/ public java.util.List attrNextStatements() { if (zzattr_attrNextStatements_state == 0) { try { zzattr_attrNextStatements_state = 1; zzattr_attrNextStatements_cache = de.peeeq.wurstscript.attributes.Flow.getNext((SwitchStmt)this); } finally { zzattr_attrNextStatements_state = 0; } zzattr_attrNextStatements_state = 2; } else if (zzattr_attrNextStatements_state == 1) { throw new CyclicDependencyError(this, "attrNextStatements"); } return zzattr_attrNextStatements_cache; } // circular = null private int zzattr_attrPreviousStatements_state = 0; private java.util.List zzattr_attrPreviousStatements_cache; /** "returns all statements which could have been executed before this statement"*/ public java.util.List attrPreviousStatements() { if (zzattr_attrPreviousStatements_state == 0) { try { zzattr_attrPreviousStatements_state = 1; zzattr_attrPreviousStatements_cache = de.peeeq.wurstscript.attributes.Flow.getPrevious((SwitchStmt)this); } finally { zzattr_attrPreviousStatements_state = 0; } zzattr_attrPreviousStatements_state = 2; } else if (zzattr_attrPreviousStatements_state == 1) { throw new CyclicDependencyError(this, "attrPreviousStatements"); } return zzattr_attrPreviousStatements_cache; } // circular = null private int zzattr_attrAfterBodyStatements_state = 0; private java.util.List zzattr_attrAfterBodyStatements_cache; /** "returns all statements which can be executed after the body/thenBlock/elseBlock of this statement is executed"*/ public java.util.List attrAfterBodyStatements() { if (zzattr_attrAfterBodyStatements_state == 0) { try { zzattr_attrAfterBodyStatements_state = 1; zzattr_attrAfterBodyStatements_cache = de.peeeq.wurstscript.attributes.Flow.getAfterBody((SwitchStmt)this); } finally { zzattr_attrAfterBodyStatements_state = 0; } zzattr_attrAfterBodyStatements_state = 2; } else if (zzattr_attrAfterBodyStatements_state == 1) { throw new CyclicDependencyError(this, "attrAfterBodyStatements"); } return zzattr_attrAfterBodyStatements_cache; } // circular = null private int zzattr_attrListIndex_state = 0; private int zzattr_attrListIndex_cache; /** "returns the index this statement has in the underlying list"*/ public int attrListIndex() { if (zzattr_attrListIndex_state == 0) { try { zzattr_attrListIndex_state = 1; zzattr_attrListIndex_cache = de.peeeq.wurstscript.attributes.Flow.getListIndex((SwitchStmt)this); } finally { zzattr_attrListIndex_state = 0; } zzattr_attrListIndex_state = 2; } else if (zzattr_attrListIndex_state == 1) { throw new CyclicDependencyError(this, "attrListIndex"); } return zzattr_attrListIndex_cache; } // circular = null private int zzattr_attrReadVariables_state = 0; private de.peeeq.immutablecollections.ImmutableList zzattr_attrReadVariables_cache; /** */ public de.peeeq.immutablecollections.ImmutableList attrReadVariables() { if (zzattr_attrReadVariables_state == 0) { try { zzattr_attrReadVariables_state = 1; zzattr_attrReadVariables_cache = de.peeeq.wurstscript.attributes.ReadVariables.calculate((SwitchStmt)this); } finally { zzattr_attrReadVariables_state = 0; } zzattr_attrReadVariables_state = 2; } else if (zzattr_attrReadVariables_state == 1) { throw new CyclicDependencyError(this, "attrReadVariables"); } return zzattr_attrReadVariables_cache; } /** */ public boolean attrIsDynamicContext() { return de.peeeq.wurstscript.attributes.IsDynamicContext.calculate((SwitchStmt)this); } /** */ public @org.eclipse.jdt.annotation.Nullable PackageOrGlobal attrNearestPackage() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestPackage((SwitchStmt)this); } /** */ public @org.eclipse.jdt.annotation.Nullable NamedScope attrNearestNamedScope() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestNamedScope((SwitchStmt)this); } /** */ public @org.eclipse.jdt.annotation.Nullable WScope attrNearestScope() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestScope((SwitchStmt)this); } /** */ public String attrPathDescription() { return de.peeeq.wurstscript.attributes.PathDescription.get((SwitchStmt)this); } /** */ public CompilationUnit attrCompilationUnit() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestCompilationUnit((SwitchStmt)this); } /** */ public @org.eclipse.jdt.annotation.Nullable ClassDef attrNearestClassDef() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestClassDef((SwitchStmt)this); } /** */ public @org.eclipse.jdt.annotation.Nullable ClassOrInterface attrNearestClassOrInterface() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestClassOrInterface((SwitchStmt)this); } /** */ public @org.eclipse.jdt.annotation.Nullable ClassOrModule attrNearestClassOrModule() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestClassOrModule((SwitchStmt)this); } /** */ public @org.eclipse.jdt.annotation.Nullable StructureDef attrNearestStructureDef() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestStructureDef((SwitchStmt)this); } /** */ public @org.eclipse.jdt.annotation.Nullable FunctionImplementation attrNearestFuncDef() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestFuncDef((SwitchStmt)this); } /** */ public @org.eclipse.jdt.annotation.Nullable ExprClosure attrNearestExprClosure() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestExprClosure((SwitchStmt)this); } /** */ public @org.eclipse.jdt.annotation.Nullable ExprStatementsBlock attrNearestExprStatementsBlock() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestExprStatementsBlock((SwitchStmt)this); } /** "returns the element itself if it is a NameDef or returns the referenced NameDef if the elem is a reference or returns null otherwise "*/ public @org.eclipse.jdt.annotation.Nullable NameDef tryGetNameDef() { return de.peeeq.wurstscript.attributes.AttrNameDef.tryGetNameDef((SwitchStmt)this); } /** */ public de.peeeq.wurstscript.parser.WPos attrSource() { return de.peeeq.wurstscript.attributes.AttrPos.getPos((SwitchStmt)this); } /** "returns the position where errors are marked"*/ public de.peeeq.wurstscript.parser.WPos attrErrorPos() { return de.peeeq.wurstscript.attributes.AttrPos.getErrorPos((SwitchStmt)this); } /** */ public WurstModel getModel() { return de.peeeq.wurstscript.attributes.AttrImportedPackage.getModel((SwitchStmt)this); } /** */ public de.peeeq.wurstscript.jassIm.ImStmt imTranslateStmt(de.peeeq.wurstscript.translation.imtranslation.ImTranslator translator, de.peeeq.wurstscript.jassIm.ImFunction f) { return de.peeeq.wurstscript.translation.imtranslation.StmtTranslation.translate((SwitchStmt)this, translator, f); } /** */ public void addError(String msg) { de.peeeq.wurstscript.attributes.ErrorHandling.addError((SwitchStmt)this, msg); } /** */ public void addWarning(String msg) { de.peeeq.wurstscript.attributes.ErrorHandling.addWarning((SwitchStmt)this, msg); } /** */ public de.peeeq.wurstscript.attributes.ErrorHandler getErrorHandler() { return de.peeeq.wurstscript.attributes.ErrorHandling.getErrorHandler((SwitchStmt)this); } /** */ public @org.eclipse.jdt.annotation.Nullable TypeDef lookupType(String name, boolean showErrors) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupType((SwitchStmt)this, name, showErrors); } /** */ public de.peeeq.wurstscript.attributes.names.PackageLink lookupPackage(String name, boolean showErrors) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupPackage((SwitchStmt)this, name, showErrors); } /** */ public de.peeeq.wurstscript.attributes.names.NameLink lookupVar(String name, boolean showErrors) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupVar((SwitchStmt)this, name, showErrors); } /** */ public de.peeeq.wurstscript.attributes.names.NameLink lookupVarNoConfig(String name, boolean showErrors) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupVarNoConfig((SwitchStmt)this, name, showErrors); } /** */ public de.peeeq.wurstscript.attributes.names.NameLink lookupMemberVar(de.peeeq.wurstscript.types.WurstType receiverType, String name, boolean showErrors) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupMemberVar((SwitchStmt)this, receiverType, name, showErrors); } /** */ public com.google.common.collect.ImmutableCollection lookupFuncs(String name, boolean showErrors) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupFuncs((SwitchStmt)this, name, showErrors); } /** */ public com.google.common.collect.ImmutableCollection lookupFuncsNoConfig(String name, boolean showErrors) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupFuncsNoConfig((SwitchStmt)this, name, showErrors); } /** */ public com.google.common.collect.ImmutableCollection lookupMemberFuncs(de.peeeq.wurstscript.types.WurstType receiverType, String name, boolean showErrors) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupMemberFuncs((SwitchStmt)this, receiverType, name, showErrors); } /** */ public @org.eclipse.jdt.annotation.Nullable TypeDef lookupType(String name) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupTypeShort((SwitchStmt)this, name); } /** */ public de.peeeq.wurstscript.attributes.names.PackageLink lookupPackage(String name) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupPackageShort((SwitchStmt)this, name); } /** */ public de.peeeq.wurstscript.attributes.names.NameLink lookupVar(String name) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupVarShort((SwitchStmt)this, name); } /** */ public de.peeeq.wurstscript.attributes.names.NameLink lookupMemberVar(de.peeeq.wurstscript.types.WurstType receiverType, String name) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupMemberVarShort((SwitchStmt)this, receiverType, name); } /** */ public com.google.common.collect.ImmutableCollection lookupFuncs(String name) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupFuncsShort((SwitchStmt)this, name); } /** */ public com.google.common.collect.ImmutableCollection lookupMemberFuncs(de.peeeq.wurstscript.types.WurstType receiverType, String name) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupMemberFuncsShort((SwitchStmt)this, receiverType, name); } // circular = de.peeeq.wurstscript.utils.Utils.emptyList private int zzattr_attrUsedGlobalVariables_state = 0; private com.google.common.collect.ImmutableList zzattr_attrUsedGlobalVariables_cache; /** */ public com.google.common.collect.ImmutableList attrUsedGlobalVariables() { if (zzattr_attrUsedGlobalVariables_state == 0) { zzattr_attrUsedGlobalVariables_state = 1; zzattr_attrUsedGlobalVariables_cache = de.peeeq.wurstscript.utils.Utils.emptyList(); while (true) { com.google.common.collect.ImmutableList r = de.peeeq.wurstscript.attributes.UsedGlobalVariables.getUsedGlobals((SwitchStmt)this); if (zzattr_attrUsedGlobalVariables_state == 3) { if (!zzattr_attrUsedGlobalVariables_cache.equals(r)) { zzattr_attrUsedGlobalVariables_cache = r; continue; } } zzattr_attrUsedGlobalVariables_cache = r; break; } zzattr_attrUsedGlobalVariables_state = 2; } else if (zzattr_attrUsedGlobalVariables_state == 1) { zzattr_attrUsedGlobalVariables_state = 3; } return zzattr_attrUsedGlobalVariables_cache; } // circular = de.peeeq.wurstscript.utils.Utils.emptyList private int zzattr_attrReadGlobalVariables_state = 0; private com.google.common.collect.ImmutableList zzattr_attrReadGlobalVariables_cache; /** */ public com.google.common.collect.ImmutableList attrReadGlobalVariables() { if (zzattr_attrReadGlobalVariables_state == 0) { zzattr_attrReadGlobalVariables_state = 1; zzattr_attrReadGlobalVariables_cache = de.peeeq.wurstscript.utils.Utils.emptyList(); while (true) { com.google.common.collect.ImmutableList r = de.peeeq.wurstscript.attributes.UsedGlobalVariables.getReadGlobals((SwitchStmt)this); if (zzattr_attrReadGlobalVariables_state == 3) { if (!zzattr_attrReadGlobalVariables_cache.equals(r)) { zzattr_attrReadGlobalVariables_cache = r; continue; } } zzattr_attrReadGlobalVariables_cache = r; break; } zzattr_attrReadGlobalVariables_state = 2; } else if (zzattr_attrReadGlobalVariables_state == 1) { zzattr_attrReadGlobalVariables_state = 3; } return zzattr_attrReadGlobalVariables_cache; } /** */ public com.google.common.collect.ImmutableCollection attrUsedPackages() { return de.peeeq.wurstscript.attributes.UsedPackages.usedPackages((SwitchStmt)this); } /** */ public String description() { return de.peeeq.wurstscript.attributes.Description.description((SwitchStmt)this); } /** */ public String descriptionHtml() { return de.peeeq.wurstscript.attributes.DescriptionHtml.description((SwitchStmt)this); } /** */ public boolean isSubtreeOf(Element other) { return de.peeeq.wurstscript.attributes.SmallHelpers.isSubtreeOf((SwitchStmt)this, other); } /** */ public void prettyPrint(de.peeeq.wurstscript.attributes.prettyPrint.Spacer spacer, StringBuilder sb, int indent) { de.peeeq.wurstscript.attributes.prettyPrint.PrettyPrinter.prettyPrint((SwitchStmt)this, spacer, sb, indent); } /** */ public java.util.List calculateUnhandledCases() { return de.peeeq.wurstscript.attributes.SwitchStatements.unhandledCases((SwitchStmt)this); } /** */ public boolean calculateHandlesAllCases() { return de.peeeq.wurstscript.attributes.SwitchStatements.handlesAllCases((SwitchStmt)this); } }