/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
- /* ****************************************************************************
- *
- * Copyright (c) Microsoft Corporation.
- *
- * This source code is subject to terms and conditions of the Apache License, Version 2.0. A
- * copy of the license can be found in the License.html file at the root of this distribution. If
- * you cannot locate the Apache License, Version 2.0, please send an email to
- * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
- * by the terms of the Apache License, Version 2.0.
- *
- * You must not remove this notice, or any other, from this software.
- *
- *
- * ***************************************************************************/
-
- #if !CLR2
- using System.Linq.Expressions;
- #else
- using Microsoft.Scripting.Ast;
- #endif
-
- using System;
- using System.Dynamic;
-
- using Microsoft.Scripting.Runtime;
- using Microsoft.Scripting.Utils;
-
- using IronPython.Runtime.Operations;
-
- namespace IronPython.Runtime.Binding {
- using Ast = Expression;
-
- class PythonDeleteSliceBinder : DynamicMetaObjectBinder, IPythonSite, IExpressionSerializable {
- private readonly PythonContext/*!*/ _context;
-
- public PythonDeleteSliceBinder(PythonContext/*!*/ context) {
- _context = context;
- }
-
- public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args) {
- return PythonProtocol.Index(this, PythonIndexType.DeleteSlice, ArrayUtils.Insert(target, args));
- }
-
- public override int GetHashCode() {
- return base.GetHashCode() ^ _context.Binder.GetHashCode();
- }
-
- public override bool Equals(object obj) {
- PythonDeleteSliceBinder ob = obj as PythonDeleteSliceBinder;
- if (ob == null) {
- return false;
- }
-
- return ob._context.Binder == _context.Binder && base.Equals(obj);
- }
-
- #region IPythonSite Members
-
- public PythonContext/*!*/ Context {
- get { return _context; }
- }
-
- #endregion
-
- #region IExpressionSerializable Members
-
- public Expression/*!*/ CreateExpression() {
- return Ast.Call(
- typeof(PythonOps).GetMethod("MakeDeleteSliceBinder"),
- BindingHelpers.CreateBinderStateExpression()
- );
- }
-
- #endregion
- }
- }