PageRenderTime 63ms CodeModel.GetById 38ms RepoModel.GetById 0ms app.codeStats 0ms

/IronPython_Main/Languages/IronPython/IronPython/Runtime/Binding/PythonDeleteSliceBinder.cs

#
C# | 76 lines | 45 code | 17 blank | 14 comment | 4 complexity | 06b6b3ccebf2102dae2aac1d2a7f4b92 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
  1. /* ****************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
  6. * copy of the license can be found in the License.html file at the root of this distribution. If
  7. * you cannot locate the Apache License, Version 2.0, please send an email to
  8. * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. * by the terms of the Apache License, Version 2.0.
  10. *
  11. * You must not remove this notice, or any other, from this software.
  12. *
  13. *
  14. * ***************************************************************************/
  15. #if !CLR2
  16. using System.Linq.Expressions;
  17. #else
  18. using Microsoft.Scripting.Ast;
  19. #endif
  20. using System;
  21. using System.Dynamic;
  22. using Microsoft.Scripting.Runtime;
  23. using Microsoft.Scripting.Utils;
  24. using IronPython.Runtime.Operations;
  25. namespace IronPython.Runtime.Binding {
  26. using Ast = Expression;
  27. class PythonDeleteSliceBinder : DynamicMetaObjectBinder, IPythonSite, IExpressionSerializable {
  28. private readonly PythonContext/*!*/ _context;
  29. public PythonDeleteSliceBinder(PythonContext/*!*/ context) {
  30. _context = context;
  31. }
  32. public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args) {
  33. return PythonProtocol.Index(this, PythonIndexType.DeleteSlice, ArrayUtils.Insert(target, args));
  34. }
  35. public override int GetHashCode() {
  36. return base.GetHashCode() ^ _context.Binder.GetHashCode();
  37. }
  38. public override bool Equals(object obj) {
  39. PythonDeleteSliceBinder ob = obj as PythonDeleteSliceBinder;
  40. if (ob == null) {
  41. return false;
  42. }
  43. return ob._context.Binder == _context.Binder && base.Equals(obj);
  44. }
  45. #region IPythonSite Members
  46. public PythonContext/*!*/ Context {
  47. get { return _context; }
  48. }
  49. #endregion
  50. #region IExpressionSerializable Members
  51. public Expression/*!*/ CreateExpression() {
  52. return Ast.Call(
  53. typeof(PythonOps).GetMethod("MakeDeleteSliceBinder"),
  54. BindingHelpers.CreateBinderStateExpression()
  55. );
  56. }
  57. #endregion
  58. }
  59. }