protected virtual IndexExpression UpdateIndexExpression(IndexExpression exp, Expression obj, ReadOnlyCollection<Expression> args) { if (exp.Object != obj || exp.Arguments != args) { return Expression.MakeIndex(obj, exp.Indexer, args); } return exp; }
public IndexVisitor(IndexExpression expr, Expression newObject, Expression[] newArguments) { _dict = new Dictionary<Expression, Expression> { {expr.Object, newObject} }; for (int i = 0; i < expr.Arguments.Count; i++) { _dict.Add(expr.Arguments[i], newArguments?[i]); } }
private Expression ReplaceIn(IndexExpression indexAccess) => ReplaceIn(indexAccess, idx => idx.Update(Replace(idx.Object), idx.Arguments.ProjectToArray(Replace)));
public abstract string DumpIndexExpression( IndexExpression exp );
public override void PostWalk(IndexExpression node) { }
private void AddressOf(IndexExpression node, Type type) { if (!TypeUtils.AreEquivalent(type, node.Type) || node.Indexer != null) { EmitExpressionAddress(node, type); return; } if (node.ArgumentCount == 1) { EmitExpression(node.Object); EmitExpression(node.GetArgument(0)); _ilg.Emit(OpCodes.Ldelema, node.Type); } else { MethodInfo address = node.Object.Type.GetMethod("Address", BindingFlags.Public | BindingFlags.Instance); EmitMethodCall(node.Object, address, node); } }
public IndexExpressionProxy(IndexExpression node) { _node = node; }
private void AddressOf(IndexExpression node, Type type) { if (type != node.Type || node.Indexer != null) { EmitExpressionAddress(node, type); return; } if (node.Arguments.Count == 1) { EmitExpression(node.Object); EmitExpression(node.Arguments[0]); _ilg.Emit(OpCodes.Ldelema, node.Type); } else { var address = node.Object.Type.GetMethod("Address", BindingFlags.Public | BindingFlags.Instance); EmitMethodCall(node.Object, address, node); } }
/// <inheritdoc/> protected override Expression VisitIndex(IndexExpression node) { Hash(node.Indexer); return(base.VisitIndex(node)); }
public override void PostWalk(IndexExpression node) { PostWalkWorker(node); }
// IndexExpression public override bool Walk(IndexExpression node) { return(ShouldWalkWorker(node)); }
protected override Expression VisitIndex(IndexExpression node) { this.expressions.Add(node); return(base.VisitIndex(node)); }
protected override Expression VisitIndex(IndexExpression node) { Console.WriteLine($"call {MethodBase.GetCurrentMethod().Name} : {node}"); return(base.VisitIndex(node)); }
protected virtual Expression VisitIndex(IndexExpression index) { return index; }
private WriteBack AddressOfWriteBack(IndexExpression node) { if (node.Indexer == null || !node.Indexer.CanWrite) { return(null); } // emit instance, if any LocalBuilder instanceLocal = null; Type instanceType = null; if (node.Object != null) { EmitInstance(node.Object, instanceType = node.Object.Type); _ilg.Emit(OpCodes.Dup); _ilg.Emit(OpCodes.Stloc, instanceLocal = GetLocal(instanceType)); } // Emit indexes. We don't allow byref args, so no need to worry // about writebacks or EmitAddress List <LocalBuilder> args = new List <LocalBuilder>(); foreach (var arg in node.Arguments) { EmitExpression(arg); var argLocal = GetLocal(arg.Type); _ilg.Emit(OpCodes.Dup); _ilg.Emit(OpCodes.Stloc, argLocal); args.Add(argLocal); } // emit the get EmitGetIndexCall(node, instanceType); // emit the address of the value var valueLocal = GetLocal(node.Type); _ilg.Emit(OpCodes.Stloc, valueLocal); _ilg.Emit(OpCodes.Ldloca, valueLocal); // Set the property after the method call // don't re-evaluate anything return(delegate() { if (instanceLocal != null) { _ilg.Emit(OpCodes.Ldloc, instanceLocal); FreeLocal(instanceLocal); } foreach (var arg in args) { _ilg.Emit(OpCodes.Ldloc, arg); FreeLocal(arg); } _ilg.Emit(OpCodes.Ldloc, valueLocal); FreeLocal(valueLocal); EmitSetIndexCall(node, instanceType); }); }
protected override Expression VisitIndexExpression(IndexExpression exp) { Accumulate(exp.Indexer); return base.VisitIndexExpression(exp); }
private Expression GetExpression(ParameterExpression param, ExpressionFilter filter) { if (param == null) { throw new ArgumentNullException(nameof(param)); } if (this.type != typeof(JObject)) { PropertyInfo propertyInfo = this.propertyList.FirstOrDefault(p => string.Compare(p.Name, filter.Property, StringComparison.InvariantCultureIgnoreCase) == 0); if (propertyInfo != null) { MemberExpression member = Expression.Property(param, filter.Property); ConstantExpression constant = filter.Value != null ? Expression.Constant(filter.Value, Nullable.GetUnderlyingType(filter.Value.GetType()) ?? filter.Value.GetType()) : Expression.Constant(filter.Value); Expression left = propertyInfo.PropertyType != typeof(DateTime?) ? member : (Expression)Expression.Call(member, this.getValueOrDefault); switch (filter.Operator) { case Operator.Equal: return(Expression.Equal(left, constant)); case Operator.NotEqual: return(Expression.NotEqual(left, constant)); case Operator.GreaterThan: return(Expression.GreaterThan(left, constant)); case Operator.GreaterThanOrEqual: return(Expression.GreaterThanOrEqual(left, constant)); case Operator.LessThan: return(Expression.LessThan(left, constant)); case Operator.LessThanOrEqual: return(Expression.LessThanOrEqual(left, constant)); case Operator.Contains: return(Expression.Call(left, this.containsMethod, constant)); case Operator.StartsWith: return(Expression.Call(left, this.startsWithMethod, constant)); case Operator.EndsWith: return(Expression.Call(left, this.endsWithMethod, constant)); } } } else { IndexExpression member = Expression.Property( param, typeof(JObject).GetProperty("Item", new[] { typeof(string) }), Expression.Constant(filter.Property, typeof(string))); //var value = Expression.Call(member, typeof (JToken).GetMethod("Value").MakeGenericMethod(typeof(string))); ConstantExpression constant = filter.Value != null ? Expression.Constant(filter.Value, Nullable.GetUnderlyingType(filter.Value.GetType()) ?? filter.Value.GetType()) : Expression.Constant(filter.Value); MethodInfo changeTypeMethod = typeof(Convert).GetMethod("ChangeType", new[] { typeof(object), typeof(Type) }); Expression value = Expression.Call(changeTypeMethod, member, Expression.Constant(typeof(string))); //Expression.Call(member, typeof(JToken).GetMethod("ToString", new Type[] { })); value = Expression.Convert(value, typeof(string)); if (filter.Value is double) { MethodInfo parseMethod = typeof(double).GetMethod("Parse", new[] { typeof(string) }); value = Expression.Call(parseMethod, value); } Expression left = value; switch (filter.Operator) { case Operator.Equal: return(Expression.Equal(left, constant)); case Operator.NotEqual: return(Expression.NotEqual(left, constant)); case Operator.GreaterThan: return(Expression.GreaterThan(left, constant)); case Operator.GreaterThanOrEqual: return(Expression.GreaterThanOrEqual(left, constant)); case Operator.LessThan: return(Expression.LessThan(left, constant)); case Operator.LessThanOrEqual: return(Expression.LessThanOrEqual(left, constant)); case Operator.Contains: return(Expression.Call(left, this.containsMethod, constant)); case Operator.StartsWith: return(Expression.Call(left, this.startsWithMethod, constant)); case Operator.EndsWith: return(Expression.Call(left, this.endsWithMethod, constant)); } } return(null); }
// IndexExpression public override bool Walk(IndexExpression node) { return Location >= node.StartIndex && Location <= node.EndIndex; }
public bool BackwalkInstruction(Instruction instr) { var ass = instr as Assignment; if (ass != null) { var assSrc = ass.Src.Accept(eval); var regSrc = RegisterOf(assSrc as Identifier); var binSrc = assSrc as BinaryExpression; if (binSrc != null) { if (RegisterOf(ass.Dst) == Index || ass.Dst == IndexExpression) { regSrc = RegisterOf(binSrc.Left); var immSrc = binSrc.Right as Constant; if (binSrc.Operator == Operator.IAdd || binSrc.Operator == Operator.ISub) { Index = HandleAddition(Index, Index, regSrc, immSrc, binSrc.Operator == Operator.IAdd); return(true); } if (binSrc.Operator == Operator.And) { if (immSrc != null && IsEvenPowerOfTwo(immSrc.ToInt32() + 1)) { Operations.Add(new BackwalkOperation(BackwalkOperator.cmp, immSrc.ToInt32() + 1)); } else { Index = null; } return(false); } if (binSrc.Operator is IMulOperator && immSrc != null) { var m = immSrc.ToInt32(); Operations.Add(new BackwalkOperation(BackwalkOperator.mul, m)); Stride *= m; return(true); } if (binSrc.Operator is ShlOperator && immSrc != null) { var m = 1 << immSrc.ToInt32(); Operations.Add(new BackwalkOperation(BackwalkOperator.mul, m)); Stride *= m; return(true); } } if (Index != null && binSrc.Operator == Operator.Xor && binSrc.Left == ass.Dst && binSrc.Right == ass.Dst && RegisterOf(ass.Dst) == host.GetSubregister(Index, 8, 8)) { Operations.Add(new BackwalkOperation(BackwalkOperator.and, 0xFF)); Index = host.GetSubregister(Index, 0, 8); } } var cSrc = assSrc as Constant; if (Index != null && cSrc != null && cSrc.IsIntegerZero && RegisterOf(ass.Dst) == host.GetSubregister(Index, 8, 8)) { // mov bh,0 ;; xor bh,bh // jmp [bx...] Operations.Add(new BackwalkOperation(BackwalkOperator.and, 0xFF)); Index = host.GetSubregister(Index, 0, 8); return(true); } var cof = assSrc as ConditionOf; if (cof != null && UsedFlagIdentifier != null) { var grfDef = (ass.Dst.Storage as FlagGroupStorage).FlagGroupBits; var grfUse = (UsedFlagIdentifier.Storage as FlagGroupStorage).FlagGroupBits; if ((grfDef & grfUse) == 0) { return(true); } var binCmp = cof.Expression as BinaryExpression; if (binCmp != null && (binCmp.Operator is ISubOperator || binCmp.Operator is USubOperator)) { var idLeft = RegisterOf(binCmp.Left as Identifier); if (idLeft != null && (idLeft == Index || idLeft == host.GetSubregister(Index, 0, 8)) || (IndexExpression != null && IndexExpression.ToString() == idLeft.ToString())) //$HACK: sleazy, but we don't appear to have an expression comparer { var immSrc = binCmp.Right as Constant; if (immSrc != null) { // Found the bound of the table. Operations.Add(new BackwalkOperation(BackwalkOperator.cmp, immSrc.ToInt32())); return(false); } } } var idCof = cof.Expression as Identifier; if (idCof != null) { IndexExpression = idCof; Index = null; UsedFlagIdentifier = null; UsedAsFlag = idCof; return(true); } } //$BUG: this is rubbish, the simplifier should _just_ // perform simplification, no substitutions. var src = assSrc == Constant.Invalid ? ass.Src : assSrc; var castSrc = src as Cast; if (castSrc != null) { src = castSrc.Expression; } var memSrc = src as MemoryAccess; var regDst = RegisterOf(ass.Dst); if (memSrc != null && (regDst == Index || (Index != null && regDst != null && regDst.Name != "None" && regDst.IsSubRegisterOf(Index)))) { // R = Mem[xxx] var rIdx = Index; var rDst = RegisterOf(ass.Dst); if ((rDst != host.GetSubregister(rIdx, 0, 8) && castSrc == null) && rDst != rIdx) { Index = RegisterStorage.None; IndexExpression = src; return(true); } var binEa = memSrc.EffectiveAddress as BinaryExpression; if (binEa == null) { Index = RegisterStorage.None; IndexExpression = null; return(false); } var memOffset = binEa.Right as Constant; var scale = GetMultiplier(binEa.Left); var baseReg = GetBaseRegister(binEa.Left); if (memOffset != null && binEa.Operator == Operator.IAdd) { var mOff = memOffset.ToInt32(); if (mOff > 0x200) { Operations.Add(new BackwalkDereference(memOffset.ToInt32(), scale)); Index = baseReg; return(true); } } // Some architectures have pc-relative addressing, which the rewriters // should convert to an _address_. var addr = binEa.Left as Address; baseReg = GetBaseRegister(binEa.Right); if (addr != null && VectorAddress == null) { this.VectorAddress = addr; Index = baseReg; return(true); } Index = RegisterStorage.None; IndexExpression = ass.Src; return(true); } if (regSrc != null && regDst == Index) { Index = regSrc; return(true); } UsedAsFlag = null; return(true); } var bra = instr as Branch; if (bra != null) { var cond = bra.Condition as TestCondition; if (cond != null) { if (cond.ConditionCode == ConditionCode.UGE || cond.ConditionCode == ConditionCode.UGT || cond.ConditionCode == ConditionCode.GT) { Operations.Add(new BackwalkBranch(cond.ConditionCode)); UsedFlagIdentifier = (Identifier)cond.Expression; } } return(true); } Debug.WriteLine("Backwalking not supported: " + instr); return(true); }
private WriteBack AddressOfWriteBack(IndexExpression node) { if (node.Indexer == null || !node.Indexer.CanWrite) { return null; } // emit instance, if any LocalBuilder instanceLocal = null; Type instanceType = null; if (node.Object != null) { EmitInstance(node.Object, instanceType = node.Object.Type); _ilg.Emit(OpCodes.Dup); _ilg.Emit(OpCodes.Stloc, instanceLocal = GetLocal(instanceType)); } // Emit indexes. We don't allow byref args, so no need to worry // about writebacks or EmitAddress List<LocalBuilder> args = new List<LocalBuilder>(); foreach (var arg in node.Arguments) { EmitExpression(arg); var argLocal = GetLocal(arg.Type); _ilg.Emit(OpCodes.Dup); _ilg.Emit(OpCodes.Stloc, argLocal); args.Add(argLocal); } // emit the get EmitGetIndexCall(node, instanceType); // emit the address of the value var valueLocal = GetLocal(node.Type); _ilg.Emit(OpCodes.Stloc, valueLocal); _ilg.Emit(OpCodes.Ldloca, valueLocal); // Set the property after the method call // don't re-evaluate anything return delegate () { if (instanceLocal != null) { _ilg.Emit(OpCodes.Ldloc, instanceLocal); FreeLocal(instanceLocal); } foreach (var arg in args) { _ilg.Emit(OpCodes.Ldloc, arg); FreeLocal(arg); } _ilg.Emit(OpCodes.Ldloc, valueLocal); FreeLocal(valueLocal); EmitSetIndexCall(node, instanceType); }; }
public virtual bool IsEvaluatableIndex(IndexExpression node) { ArgumentUtility.CheckNotNull("node", node); return(true); }
public override bool Walk(IndexExpression node) { node.Parent = _currentScope; return base.Walk(node); }
protected override Expression VisitIndex(IndexExpression node) { return(Visiting((expr) => base.VisitIndex(expr as IndexExpression), node)); }
private WriteBack AddressOfWriteBackCore(IndexExpression node) { // emit instance, if any LocalBuilder instanceLocal = null; Type instanceType = null; if (node.Object != null) { EmitInstance(node.Object, out instanceType); // store in local _ilg.Emit(OpCodes.Dup); _ilg.Emit(OpCodes.Stloc, instanceLocal = GetInstanceLocal(instanceType)); } // Emit indexes. We don't allow byref args, so no need to worry // about write-backs or EmitAddress int n = node.ArgumentCount; var args = new LocalBuilder[n]; for (var i = 0; i < n; i++) { Expression arg = node.GetArgument(i); EmitExpression(arg); LocalBuilder argLocal = GetLocal(arg.Type); _ilg.Emit(OpCodes.Dup); _ilg.Emit(OpCodes.Stloc, argLocal); args[i] = argLocal; } // emit the get EmitGetIndexCall(node, instanceType); // emit the address of the value LocalBuilder valueLocal = GetLocal(node.Type); _ilg.Emit(OpCodes.Stloc, valueLocal); _ilg.Emit(OpCodes.Ldloca, valueLocal); // Set the property after the method call // don't re-evaluate anything return @this => { if (instanceLocal != null) { @this._ilg.Emit(OpCodes.Ldloc, instanceLocal); @this.FreeLocal(instanceLocal); } foreach (LocalBuilder arg in args) { @this._ilg.Emit(OpCodes.Ldloc, arg); @this.FreeLocal(arg); } @this._ilg.Emit(OpCodes.Ldloc, valueLocal); @this.FreeLocal(valueLocal); @this.EmitSetIndexCall(node, instanceLocal?.LocalType); }; }
public static int ArgumentCount(this IndexExpression expression) { return(expression.Arguments.Count()); }
public virtual void PostWalk(IndexExpression node) { }
public static Expression GetArgument(this IndexExpression expression, int index) { return(expression.Arguments[index]); }
/// <summary> /// Visits the children of <see cref="System.Linq.Expressions.IndexExpression"/>. /// </summary> /// <param name="node">The expression to visit.</param> /// <returns>The modified expression, if it or any subexpression was modified; otherwise, /// returns the original expression.</returns> protected override Expression VisitIndex(IndexExpression node) { throw new NotSupportedException(string.Format(Resources.EX_PROCESS_NODE_NOT_SUPPORT, node.GetType().Name)); }
private bool CompareIndex(IndexExpression a, IndexExpression b) => Equals(a.Indexer, b.Indexer) && Compare(a.Object, b.Object) && CompareExpressionList(a.Arguments, b.Arguments);
static IndexExpression MutateIndex(IndexExpression node, IList <Expression> operands) { var args = operands.Skip(1); return(node.Update(operands[0], args)); }
public ArrayIndexExpressionWithLinqExpressions(IndexExpression expression) { Expression = expression; array = LinqExpressionBuilder.BuildExpression(expression.Object); indexes = LinqExpressionBuilder.BuildExpressions(expression.Arguments); }
public override bool Walk(IndexExpression node) { node.Walk(_fc); return(false); }
protected virtual Expression VisitIndexExpression(IndexExpression exp) { var obj = this.Visit(exp.Object); var args = this.VisitExpressionList(exp.Arguments); return this.UpdateIndexExpression(exp, obj, args); }
public override bool Visit(IndexExpression indexExpression) => this.VisitConstant(indexExpression);
public abstract object EvalIndexExpression( object obj, IndexExpression exp );
public bool BackwalkInstruction(Instruction instr) { var ass = instr as Assignment; if (ass != null) { var regSrc = RegisterOf(ass.Src as Identifier); var binSrc = ass.Src as BinaryExpression; if (binSrc != null) { if (RegisterOf(ass.Dst) == Index) { regSrc = RegisterOf(binSrc.Left as Identifier); var immSrc = binSrc.Right as Constant; if (binSrc.Operator == Operator.IAdd || binSrc.Operator == Operator.ISub) { Index = HandleAddition(Index, Index, regSrc, immSrc, binSrc.Operator == Operator.IAdd); return(true); } if (binSrc.Operator == Operator.And) { if (immSrc != null && IsEvenPowerOfTwo(immSrc.ToInt32() + 1)) { Operations.Add(new BackwalkOperation(BackwalkOperator.cmp, immSrc.ToInt32() + 1)); } else { Index = null; } return(false); } if (binSrc.Operator is IMulOperator && immSrc != null) { var m = immSrc.ToInt32(); Operations.Add(new BackwalkOperation(BackwalkOperator.mul, m)); Stride *= m; return(true); } if (binSrc.Operator is ShlOperator && immSrc != null) { var m = 1 << immSrc.ToInt32(); Operations.Add(new BackwalkOperation(BackwalkOperator.mul, m)); Stride *= m; return(true); } } if (Index != null && binSrc.Operator == Operator.Xor && binSrc.Left == ass.Dst && binSrc.Right == ass.Dst && RegisterOf(ass.Dst) == Index.GetSubregister(8, 8)) { Operations.Add(new BackwalkOperation(BackwalkOperator.and, 0xFF)); Index = Index.GetSubregister(0, 8); } } var cof = ass.Src as ConditionOf; if (cof != null && UsedFlagIdentifier != null) { var grfDef = (ass.Dst.Storage as FlagGroupStorage).FlagGroupBits; var grfUse = (UsedFlagIdentifier.Storage as FlagGroupStorage).FlagGroupBits; if ((grfDef & grfUse) == 0) { return(true); } var binCmp = cof.Expression as BinaryExpression; if (binCmp != null && (binCmp.Operator is ISubOperator || binCmp.Operator is USubOperator)) { var idLeft = RegisterOf(binCmp.Left as Identifier); if (idLeft != null && (idLeft == Index || idLeft == Index.GetPart(PrimitiveType.Byte)) || (IndexExpression != null && IndexExpression.ToString() == idLeft.ToString())) //$HACK: sleazy, but we don't appear to have an expression comparer { var immSrc = binCmp.Right as Constant; if (immSrc != null) { // Found the bound of the table. Operations.Add(new BackwalkOperation(BackwalkOperator.cmp, immSrc.ToInt32())); return(false); } } } } var src = ass.Src; var castSrc = src as Cast; if (castSrc != null) { src = castSrc.Expression; } var memSrc = src as MemoryAccess; var regDst = RegisterOf(ass.Dst); if (memSrc != null && (regDst == Index || regDst.IsSubRegisterOf(Index))) { // R = Mem[xxx] var rIdx = Index; var rDst = RegisterOf(ass.Dst); if (rDst != rIdx.GetSubregister(0, 8) && castSrc == null) { Index = RegisterStorage.None; IndexExpression = src; return(true); } var binEa = memSrc.EffectiveAddress as BinaryExpression; if (binEa == null) { return(false); } var memOffset = binEa.Right as Constant; var scale = GetMultiplier(binEa.Left); var baseReg = GetBaseRegister(binEa.Left); if (memOffset != null && binEa.Operator == Operator.IAdd) { var mOff = memOffset.ToInt32(); if (mOff > 0x200) { Operations.Add(new BackwalkDereference(memOffset.ToInt32(), scale)); Index = baseReg; return(true); } } return(false); } if (regSrc != null && regDst == Index) { Index = regSrc; return(true); } return(true); } var bra = instr as Branch; if (bra != null) { var cond = bra.Condition as TestCondition; if (cond != null) { if (cond.ConditionCode == ConditionCode.UGT) { Operations.Add(new BackwalkBranch(ConditionCode.UGT)); UsedFlagIdentifier = (Identifier)cond.Expression; } else if (cond.ConditionCode == ConditionCode.ULE) { Operations.Add(new BackwalkBranch(ConditionCode.ULE)); UsedFlagIdentifier = (Identifier)cond.Expression; } } return(true); } Debug.WriteLine("Backwalking not supported: " + instr); return(true); }
///////////////////////////////////////////////////////////////////////////// protected Expression IndexMember( bool isRootNode, string memberName, bool validToken, IInput input ) { // ****** Expression expression = null; //IArgumentsProcessor ap = new ArgumentsProcessor( argScanner, recognizer ); IArgumentsProcessor ap = new ArgumentsProcessor( scanner, recognizer ); //NmpStringList strArgs = argScanner( input, RecognizedCharType.CloseBracketChar ); NmpStringList strArgs = scanner.ArgScanner( input, RecognizedCharType.CloseBracketChar ); // ****** if( ! validToken ) { // // IndexResult // return new UnnamedIndexExpression( ap, strArgs ); } else { if( isRootNode ) { expression = new UnnamedIndexExpression(memberName, ap, strArgs ); } else { expression = new IndexExpression( memberName, ap, strArgs ); } } // ****** return expression; }
private static StringBuilder AppendExpression(this StringBuilder builder, IndexExpression expression) { return(builder.AppendExpression(expression.Object) .AppendCommaSeparated("[", expression.Arguments, AppendExpression, "]")); }
private List <Inferred> InferIndexExpression(IndexExpression node, Scope scope) { Debug.Print("Not implemented: InferIndexExpressionIn"); return(null); }
protected override Expression VisitIndex(IndexExpression node) { _runningTotal += node.GetHashCodeFor(node.Indexer); return(base.VisitIndex(node)); }
public override bool Walk(IndexExpression node) { node.Walk(_fc); return false; }
protected override Expression VisitIndex(IndexExpression node) => base.VisitIndex(node);
///////////////////////////////////////////////////////////////////////////// public override object EvalIndexExpression( object objIn, IndexExpression exp ) { // ****** // // expression: macro.fieldOrProperty[ i ] // // exp.MemberName should be the name of an indexer (property with arguments) // that we need to access // var invoker = Invokers.GetIndexerInvoker( objIn, exp.MemberName, typeHelpers ); if( null == invoker ) { ThreadContext.MacroError( "there is no indexer named \"{0}\" on the object type \"{1}\"", exp.MemberName, ObjectInfo.GetTypeName(objIn) ); } object objResult = invoker.Invoke( EvaluateArguments(exp.Arguments) ); // ****** CheckNullResult( objResult, objIn, exp.MemberName ); return objResult; }
protected override Expression VisitIndex(IndexExpression node) { return(base.VisitIndex(node)); }
private void EmitSetIndexCall(IndexExpression node, Type objectType) { if (node.Indexer != null) { // For indexed properties, just call the setter var method = node.Indexer.GetSetMethod(true); EmitCall(objectType, method); } else if (node.Arguments.Count != 1) { // Multidimensional arrays, call set _ilg.Emit(OpCodes.Call, node.Object.Type.GetMethod("Set", BindingFlags.Public | BindingFlags.Instance)); } else { // For one dimensional arrays, emit store _ilg.EmitStoreElement(node.Type); } }
// IndexExpression public virtual bool Walk(IndexExpression node) { return(true); }
private WriteBack AddressOfWriteBack(IndexExpression node) { if (node.Indexer == null || !node.Indexer.CanWrite) { return null; } return AddressOfWriteBackCore(node); // avoids closure allocation }
// IndexExpression public override bool Walk(IndexExpression node) { return false; }
// IndexExpression public override bool Walk(IndexExpression node) { return(Location >= node.StartIndex && Location <= node.EndIndex); }
// IndexExpression public virtual bool Walk(IndexExpression node) { return true; }
// IndexExpression public override bool Walk(IndexExpression node) { return(false); }
private void EmitSetIndexCall(IndexExpression node, Type objectType) { if (node.Indexer != null) { // For indexed properties, just call the setter var method = node.Indexer.GetSetMethod(true); EmitCall(objectType, method); } else { EmitSetArrayElement(objectType); } }
///////////////////////////////////////////////////////////////////////////// public override string DumpIndexExpression( IndexExpression exp ) { return string.Format( ".{0}[{1}]", exp.MemberName, Arguments(exp.Arguments) ); }