//generated by abstract-syntax-gen package de.peeeq.wurstscript.ast; import java.util.*; @SuppressWarnings({"cast", "unused", "rawtypes"}) class ExprBinaryImpl implements ExprBinary{ ExprBinaryImpl(de.peeeq.wurstscript.parser.WPos source, Expr left, de.peeeq.wurstscript.WurstOperator op, Expr right) { if (source == null) throw new IllegalArgumentException("Element source must not be null."); if (left == null) throw new IllegalArgumentException("Element left must not be null."); if (op == null) throw new IllegalArgumentException("Element op must not be null."); if (right == null) throw new IllegalArgumentException("Element right must not be null."); this.source = source; this.left = left; this.op = op; this.right = right; left.setParent(this); right.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.left); action.accept(this.right); } public int size() { return 2; } @Override public ExprBinary copy() { ExprBinary result = new ExprBinaryImpl(source, (Expr) this.left.copy(), op, (Expr) this.right.copy()); return result; } @Override public ExprBinary copyWithRefs() { ExprBinary res = copy(); return res; } @Override public void clearAttributes() { left.clearAttributes(); right.clearAttributes(); clearAttributesLocal(); } @Override public void clearAttributesLocal() { zzattr_attrReadVariables_state = 0; zzattr_attrTyp_state = 0; zzattr_attrConstantValue_state = 0; zzattr_attrTypRaw_state = 0; zzattr_attrExpectedTypRaw_state = 0; zzattr_attrExpectedTyp_state = 0; zzattr_attrFuncLink_state = 0; zzattr_attrUsedGlobalVariables_state = 0; zzattr_attrReadGlobalVariables_state = 0; } @Override public void accept(Visitor v) { v.visit(this); } @Override public T match(VarInitialization.Matcher matcher) { return matcher.case_ExprBinary(this); } @Override public void match(VarInitialization.MatcherVoid matcher) { matcher.case_ExprBinary(this); } @Override public T match(HasReadVariables.Matcher matcher) { return matcher.case_ExprBinary(this); } @Override public void match(HasReadVariables.MatcherVoid matcher) { matcher.case_ExprBinary(this); } @Override public T match(Element.Matcher matcher) { return matcher.case_ExprBinary(this); } @Override public void match(Element.MatcherVoid matcher) { matcher.case_ExprBinary(this); } @Override public T match(OptExpr.Matcher matcher) { return matcher.case_ExprBinary(this); } @Override public void match(OptExpr.MatcherVoid matcher) { matcher.case_ExprBinary(this); } @Override public T match(Expr.Matcher matcher) { return matcher.case_ExprBinary(this); } @Override public void match(Expr.MatcherVoid matcher) { matcher.case_ExprBinary(this); } @Override public T match(AstElementWithSource.Matcher matcher) { return matcher.case_ExprBinary(this); } @Override public void match(AstElementWithSource.MatcherVoid matcher) { matcher.case_ExprBinary(this); } @Override public T match(ExprOrStatements.Matcher matcher) { return matcher.case_ExprBinary(this); } @Override public void match(ExprOrStatements.MatcherVoid matcher) { matcher.case_ExprBinary(this); } @Override public String toString() { return "ExprBinary(" + source + ", " +left + ", " +op + ", " +right+")"; } public boolean structuralEquals(Element e) { if (e instanceof ExprBinary) { ExprBinary o = (ExprBinary) e; return this.left.structuralEquals(o.getLeft()) && java.util.Objects.equals(op, o.getOp()) && this.right.structuralEquals(o.getRight()); } else { return false; } } // 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((ExprBinary)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; } // circular = null private int zzattr_attrTyp_state = 0; private de.peeeq.wurstscript.types.WurstType zzattr_attrTyp_cache; /** */ public de.peeeq.wurstscript.types.WurstType attrTyp() { if (zzattr_attrTyp_state == 0) { try { zzattr_attrTyp_state = 1; zzattr_attrTyp_cache = de.peeeq.wurstscript.attributes.AttrExprType.normalizedType((ExprBinary)this); } finally { zzattr_attrTyp_state = 0; } zzattr_attrTyp_state = 2; } else if (zzattr_attrTyp_state == 1) { throw new CyclicDependencyError(this, "attrTyp"); } return zzattr_attrTyp_cache; } // circular = null private int zzattr_attrConstantValue_state = 0; private de.peeeq.wurstscript.intermediatelang.ILconst zzattr_attrConstantValue_cache; /** */ public de.peeeq.wurstscript.intermediatelang.ILconst attrConstantValue() { if (zzattr_attrConstantValue_state == 0) { try { zzattr_attrConstantValue_state = 1; zzattr_attrConstantValue_cache = de.peeeq.wurstscript.attributes.AttrConstantValue.calculate((ExprBinary)this); } finally { zzattr_attrConstantValue_state = 0; } zzattr_attrConstantValue_state = 2; } else if (zzattr_attrConstantValue_state == 1) { throw new CyclicDependencyError(this, "attrConstantValue"); } return zzattr_attrConstantValue_cache; } // circular = null private int zzattr_attrTypRaw_state = 0; private de.peeeq.wurstscript.types.WurstType zzattr_attrTypRaw_cache; /** */ public de.peeeq.wurstscript.types.WurstType attrTypRaw() { if (zzattr_attrTypRaw_state == 0) { try { zzattr_attrTypRaw_state = 1; zzattr_attrTypRaw_cache = de.peeeq.wurstscript.attributes.AttrExprType.calculate((ExprBinary)this); } finally { zzattr_attrTypRaw_state = 0; } zzattr_attrTypRaw_state = 2; } else if (zzattr_attrTypRaw_state == 1) { throw new CyclicDependencyError(this, "attrTypRaw"); } return zzattr_attrTypRaw_cache; } // circular = null private int zzattr_attrExpectedTypRaw_state = 0; private de.peeeq.wurstscript.types.WurstType zzattr_attrExpectedTypRaw_cache; /** */ public de.peeeq.wurstscript.types.WurstType attrExpectedTypRaw() { if (zzattr_attrExpectedTypRaw_state == 0) { try { zzattr_attrExpectedTypRaw_state = 1; zzattr_attrExpectedTypRaw_cache = de.peeeq.wurstscript.attributes.AttrExprExpectedType.calculate((ExprBinary)this); } finally { zzattr_attrExpectedTypRaw_state = 0; } zzattr_attrExpectedTypRaw_state = 2; } else if (zzattr_attrExpectedTypRaw_state == 1) { throw new CyclicDependencyError(this, "attrExpectedTypRaw"); } return zzattr_attrExpectedTypRaw_cache; } // circular = null private int zzattr_attrExpectedTyp_state = 0; private de.peeeq.wurstscript.types.WurstType zzattr_attrExpectedTyp_cache; /** "try to guess what type is expected here"*/ public de.peeeq.wurstscript.types.WurstType attrExpectedTyp() { if (zzattr_attrExpectedTyp_state == 0) { try { zzattr_attrExpectedTyp_state = 1; zzattr_attrExpectedTyp_cache = de.peeeq.wurstscript.attributes.AttrExprExpectedType.normalizedType((ExprBinary)this); } finally { zzattr_attrExpectedTyp_state = 0; } zzattr_attrExpectedTyp_state = 2; } else if (zzattr_attrExpectedTyp_state == 1) { throw new CyclicDependencyError(this, "attrExpectedTyp"); } return zzattr_attrExpectedTyp_cache; } /** "more precise expected type, after overloading"*/ public de.peeeq.wurstscript.types.WurstType attrExpectedTypAfterOverloading() { return de.peeeq.wurstscript.attributes.AttrExprExpectedType.afterOverloading((ExprBinary)this); } /** */ public boolean attrIsDynamicContext() { return de.peeeq.wurstscript.attributes.IsDynamicContext.calculate((ExprBinary)this); } /** */ public @org.eclipse.jdt.annotation.Nullable PackageOrGlobal attrNearestPackage() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestPackage((ExprBinary)this); } /** */ public @org.eclipse.jdt.annotation.Nullable NamedScope attrNearestNamedScope() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestNamedScope((ExprBinary)this); } /** */ public @org.eclipse.jdt.annotation.Nullable WScope attrNearestScope() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestScope((ExprBinary)this); } /** */ public String attrPathDescription() { return de.peeeq.wurstscript.attributes.PathDescription.get((ExprBinary)this); } /** */ public CompilationUnit attrCompilationUnit() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestCompilationUnit((ExprBinary)this); } /** */ public @org.eclipse.jdt.annotation.Nullable ClassDef attrNearestClassDef() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestClassDef((ExprBinary)this); } /** */ public @org.eclipse.jdt.annotation.Nullable ClassOrInterface attrNearestClassOrInterface() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestClassOrInterface((ExprBinary)this); } /** */ public @org.eclipse.jdt.annotation.Nullable ClassOrModule attrNearestClassOrModule() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestClassOrModule((ExprBinary)this); } /** */ public @org.eclipse.jdt.annotation.Nullable StructureDef attrNearestStructureDef() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestStructureDef((ExprBinary)this); } /** */ public @org.eclipse.jdt.annotation.Nullable FunctionImplementation attrNearestFuncDef() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestFuncDef((ExprBinary)this); } /** */ public @org.eclipse.jdt.annotation.Nullable ExprClosure attrNearestExprClosure() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestExprClosure((ExprBinary)this); } /** */ public @org.eclipse.jdt.annotation.Nullable ExprStatementsBlock attrNearestExprStatementsBlock() { return de.peeeq.wurstscript.attributes.AttrNearest.nearestExprStatementsBlock((ExprBinary)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((ExprBinary)this); } /** */ public de.peeeq.wurstscript.parser.WPos attrSource() { return de.peeeq.wurstscript.attributes.AttrPos.getPos((ExprBinary)this); } /** "returns the position where errors are marked"*/ public de.peeeq.wurstscript.parser.WPos attrErrorPos() { return de.peeeq.wurstscript.attributes.AttrPos.getErrorPos((ExprBinary)this); } /** */ public WurstModel getModel() { return de.peeeq.wurstscript.attributes.AttrImportedPackage.getModel((ExprBinary)this); } /** */ public de.peeeq.wurstscript.jassIm.ImExpr imTranslateExpr(de.peeeq.wurstscript.translation.imtranslation.ImTranslator translator, de.peeeq.wurstscript.jassIm.ImFunction f) { return de.peeeq.wurstscript.translation.imtranslation.ExprTranslation.translate((ExprBinary)this, translator, f); } /** */ public de.peeeq.wurstscript.jassIm.ImExprOpt imTranslateExprOpt(de.peeeq.wurstscript.translation.imtranslation.ImTranslator translator, de.peeeq.wurstscript.jassIm.ImFunction f) { return de.peeeq.wurstscript.translation.imtranslation.ExprTranslation.translate((ExprBinary)this, translator, f); } /** */ public void addError(String msg) { de.peeeq.wurstscript.attributes.ErrorHandling.addError((ExprBinary)this, msg); } /** */ public void addWarning(String msg) { de.peeeq.wurstscript.attributes.ErrorHandling.addWarning((ExprBinary)this, msg); } /** */ public de.peeeq.wurstscript.attributes.ErrorHandler getErrorHandler() { return de.peeeq.wurstscript.attributes.ErrorHandling.getErrorHandler((ExprBinary)this); } // circular = null private int zzattr_attrFuncLink_state = 0; private de.peeeq.wurstscript.attributes.names.FuncLink zzattr_attrFuncLink_cache; /** */ public de.peeeq.wurstscript.attributes.names.FuncLink attrFuncLink() { if (zzattr_attrFuncLink_state == 0) { try { zzattr_attrFuncLink_state = 1; zzattr_attrFuncLink_cache = de.peeeq.wurstscript.attributes.AttrFuncDef.calculate((ExprBinary)this); } finally { zzattr_attrFuncLink_state = 0; } zzattr_attrFuncLink_state = 2; } else if (zzattr_attrFuncLink_state == 1) { throw new CyclicDependencyError(this, "attrFuncLink"); } return zzattr_attrFuncLink_cache; } /** */ public FunctionDefinition attrFuncDef() { return de.peeeq.wurstscript.attributes.AttrFuncDef.calculateDef((ExprBinary)this); } /** */ public @org.eclipse.jdt.annotation.Nullable TypeDef lookupType(String name, boolean showErrors) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupType((ExprBinary)this, name, showErrors); } /** */ public de.peeeq.wurstscript.attributes.names.PackageLink lookupPackage(String name, boolean showErrors) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupPackage((ExprBinary)this, name, showErrors); } /** */ public de.peeeq.wurstscript.attributes.names.NameLink lookupVar(String name, boolean showErrors) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupVar((ExprBinary)this, name, showErrors); } /** */ public de.peeeq.wurstscript.attributes.names.NameLink lookupVarNoConfig(String name, boolean showErrors) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupVarNoConfig((ExprBinary)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((ExprBinary)this, receiverType, name, showErrors); } /** */ public com.google.common.collect.ImmutableCollection lookupFuncs(String name, boolean showErrors) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupFuncs((ExprBinary)this, name, showErrors); } /** */ public com.google.common.collect.ImmutableCollection lookupFuncsNoConfig(String name, boolean showErrors) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupFuncsNoConfig((ExprBinary)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((ExprBinary)this, receiverType, name, showErrors); } /** */ public @org.eclipse.jdt.annotation.Nullable TypeDef lookupType(String name) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupTypeShort((ExprBinary)this, name); } /** */ public de.peeeq.wurstscript.attributes.names.PackageLink lookupPackage(String name) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupPackageShort((ExprBinary)this, name); } /** */ public de.peeeq.wurstscript.attributes.names.NameLink lookupVar(String name) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupVarShort((ExprBinary)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((ExprBinary)this, receiverType, name); } /** */ public com.google.common.collect.ImmutableCollection lookupFuncs(String name) { return de.peeeq.wurstscript.attributes.names.NameResolution.lookupFuncsShort((ExprBinary)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((ExprBinary)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((ExprBinary)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((ExprBinary)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((ExprBinary)this); } /** */ public String description() { return de.peeeq.wurstscript.attributes.Description.description((ExprBinary)this); } /** */ public String descriptionHtml() { return de.peeeq.wurstscript.attributes.DescriptionHtml.description((ExprBinary)this); } /** */ public boolean isSubtreeOf(Element other) { return de.peeeq.wurstscript.attributes.SmallHelpers.isSubtreeOf((ExprBinary)this, other); } /** */ public void prettyPrint(de.peeeq.wurstscript.attributes.prettyPrint.Spacer spacer, StringBuilder sb, int indent) { de.peeeq.wurstscript.attributes.prettyPrint.PrettyPrinter.prettyPrint((ExprBinary)this, spacer, sb, indent); } }