/// <summary> /// Get the base MethodDeclaration from its call and the mixin where the call is performed /// </summary> /// <param name="expression">the calling expression</param> /// <param name="mixin">the mixin where the call is performed</param> /// <returns>the base MethodDeclaration</returns> public MethodDeclaration GetBaseMethodFromExpression(Expression expression, ModuleMixin mixin) { var info = (VTableReference)expression.GetTag(ParadoxTags.VirtualTableReference); var thisMethod = VirtualTable.GetMethod(info.Shader, info.Slot); if (thisMethod == null) return null; var startIndex = mixin == this ? InheritanceList.Count : InheritanceList.IndexOf(mixin); for (int i = startIndex - 1; i >= 0; --i) { var dep = InheritanceList[i]; var array = VirtualTable.VirtualTableGroup[dep.MixinName]; for (int j = 0; j < array.Length; ++j) { var method = array[j]; if (method == thisMethod) return dep.VirtualTable.VirtualTableGroup[dep.MixinName][j]; } } return null; }
/// <summary> /// Get the overloaded method from its call /// </summary> /// <param name="expression">the calling Expression</param> /// <returns>the overloaded MethodDeclaration</returns> public MethodDeclaration GetMethodFromExpression(Expression expression) { var info = (VTableReference)expression.GetTag(ParadoxTags.VirtualTableReference); return VirtualTable.GetMethod(info.Shader, info.Slot); }