package jetbrains.mps.baseLanguage.doubleDispatch.typesystem; /*Generated by MPS */ import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.internal.collections.runtime.ListSequence; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.internal.collections.runtime.ISelector; import jetbrains.mps.internal.collections.runtime.Sequence; import java.util.Iterator; import jetbrains.mps.internal.collections.runtime.ILeftCombinator; import jetbrains.mps.lang.core.behavior.BaseConcept__BehaviorDescriptor; /** * This describes a group of related dispatch methods, i.e. which dispatch to each other */ public class DispatchGroupDescriptor { private String methodName; private boolean isStatic; private Iterable<SNode> otherParamTypes; public DispatchGroupDescriptor(SNode pattern) { methodName = SPropertyOperations.getString(pattern, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name")); isStatic = SNodeOperations.isInstanceOf(pattern, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbbebabf0aL, "jetbrains.mps.baseLanguage.structure.StaticMethodDeclaration")); otherParamTypes = ListSequence.fromList(SLinkOperations.getChildren(pattern, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b1fcL, 0xf8cc56b1feL, "parameter"))).skip(1).select(new ISelector<SNode, SNode>() { public SNode select(SNode it) { return SLinkOperations.getTarget(it, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x450368d90ce15bc3L, 0x4ed4d318133c80ceL, "type")); } }); } @Override public boolean equals(Object o) { if (!(o instanceof DispatchGroupDescriptor)) { return false; } DispatchGroupDescriptor other = (DispatchGroupDescriptor) o; if (isStatic != other.isStatic) { return false; } if (!(methodName.equals(other.methodName))) { return false; } if (Sequence.fromIterable(otherParamTypes).count() != Sequence.fromIterable(other.otherParamTypes).count()) { return false; } { Iterator<SNode> ths_it = Sequence.fromIterable(otherParamTypes).iterator(); Iterator<SNode> oth_it = Sequence.fromIterable(other.otherParamTypes).iterator(); SNode ths_var; SNode oth_var; while (ths_it.hasNext() && oth_it.hasNext()) { ths_var = ths_it.next(); oth_var = oth_it.next(); if (!(typesEqual(ths_var, oth_var))) { return false; } } } return true; } @Override public int hashCode() { return methodName.hashCode() + ((isStatic ? 1 : 0)) + Sequence.fromIterable(otherParamTypes).foldLeft(0, new ILeftCombinator<SNode, Integer>() { public Integer combine(Integer s, SNode it) { return s + typeHashCode(it); } }); } private boolean typesEqual(SNode typ1, SNode typ2) { { final SNode cls = typ1; if (SNodeOperations.isInstanceOf(cls, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType"))) { { final SNode cls2 = typ2; if (SNodeOperations.isInstanceOf(cls2, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType"))) { return SLinkOperations.getTarget(cls, MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, 0x101de490babL, "classifier")) == SLinkOperations.getTarget(cls2, MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, 0x101de490babL, "classifier")); } } return false; } } if (SNodeOperations.isInstanceOf(typ2, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType"))) { return false; } return BaseConcept__BehaviorDescriptor.getPresentation_idhEwIMiw.invoke(typ1).equals(BaseConcept__BehaviorDescriptor.getPresentation_idhEwIMiw.invoke(typ2)); } private int typeHashCode(SNode typ) { { final SNode cls = typ; if (SNodeOperations.isInstanceOf(cls, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType"))) { return SLinkOperations.getTarget(cls, MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, 0x101de490babL, "classifier")).hashCode(); } } return BaseConcept__BehaviorDescriptor.getPresentation_idhEwIMiw.invoke(typ).hashCode(); } }