public override bool Equals(object obj) { if (obj is Indexing) { Indexing other = (Indexing)obj; return(this.item.Equals(other.item) && this.indexExpression.Equals(other.indexExpression)); } return(false); }
private static string ToDot(string parent, Indexing node) { string name = String.Format("Indexing{0}", counter++); string itemName = ToDot(name, node.Item); string indexExprName = ToDot(name, node.IndexExpression); text.AppendFormat(" {0} [label=\"Indexing\"];", name); text.AppendFormat(" {0} -> {1};\n", name, itemName); text.AppendFormat(" {0} -> {1};\n", name, indexExprName); return(name); }
private static DLR.Expression GenerateIndexAssign(AplusScope scope, Indexing target, DLR.Expression value) { DLR.Expression result; if (target.IndexExpression == null) { result = DLR.Expression.Dynamic( scope.GetRuntime().SetIndexBinder(new DYN.CallInfo(0)), typeof(object), target.Item.Generate(scope), DLR.Expression.Constant(null), value ); } else { IEnumerable<DLR.Expression> indexerValues = target.IndexExpression.Items.Reverse().Select( item => { return item.Generate(scope); } ); DLR.ParameterExpression indexerParam = DLR.Expression.Parameter(typeof(List<AType>), "__INDEX__"); DLR.Expression call = DLR.Expression.Call( typeof(Helpers).GetMethod("BuildIndexerArray"), DLR.Expression.NewArrayInit(typeof(AType), indexerValues) ); Aplus runtime = scope.GetRuntime(); string qualifiedName = ((Identifier)target.Item).BuildQualifiedName(runtime.CurrentContext); DLR.ParameterExpression temp = DLR.Expression.Parameter(typeof(AType)); DLR.ParameterExpression errorParam = DLR.Expression.Parameter(typeof(Error.Signal)); DLR.Expression callback = BuildCallbackCall(scope, temp); DLR.Expression presetCallback = BuildPresetCallbackCall(scope, temp); result = DLR.Expression.Block( new DLR.ParameterExpression[] { indexerParam, temp }, DLR.Expression.Assign( indexerParam, call ), DLR.Expression.Assign( scope.CallbackInfo.Index, DLR.Expression.Call( typeof(Tools).GetMethod("ConvertATypeListToAType", BindingFlags.NonPublic | BindingFlags.Static), indexerParam ) ), DLR.Expression.Assign( scope.CallbackInfo.QualifiedName, DLR.Expression.Constant(qualifiedName) ), DLR.Expression.Assign(temp, value), DLR.Expression.Assign(scope.AssignDone, DLR.Expression.Constant(false)), DLR.Expression.TryCatch( DLR.Expression.Block( typeof(void), DLR.Expression.Assign(value, presetCallback), DLR.Expression.Assign(scope.AssignDone, DLR.Expression.Constant(true)) ), DLR.Expression.Catch( errorParam, DLR.Expression.Empty() ) ), DLR.Expression.IfThen( scope.AssignDone, DLR.Expression.Block( DLR.Expression.Dynamic( scope.GetRuntime().SetIndexBinder(new System.Dynamic.CallInfo(target.IndexExpression.Length)), typeof(object), target.Item.Generate(scope), indexerParam, value ), DLR.Expression.Assign(temp, value), callback ) ), scope.CallbackInfo.NonPresetValue ); } return DLR.Expression.Convert(result, typeof(AType)); }
private static string ToDot(string parent, Indexing node) { string name = String.Format("Indexing{0}", counter++); string itemName = ToDot(name, node.Item); string indexExprName = ToDot(name, node.IndexExpression); text.AppendFormat(" {0} [label=\"Indexing\"];", name); text.AppendFormat(" {0} -> {1};\n", name, itemName); text.AppendFormat(" {0} -> {1};\n", name, indexExprName); return name; }