public override IsExpressionResult IsExpression(Expression?expression, int level, RequestFor requestFlag) { return(base.IsExpression(expression, level, requestFlag)); }
public override void VisitConditionOf(ConditionOf cof) { defExpr = cof; }
public override void VisitApplication(Application appl) { defExpr = appl; }
public static GotoExpression MakeGoto(GotoExpressionKind kind, LabelTarget?target, Expression?value, Type type) { if (target == null) { throw new ArgumentNullException(nameof(target)); } ValidateGoto(target, ref value, nameof(value), type); return(new GotoExpression(kind, target, value, type)); }
internal override Expression Return(Expression?result) { result ??= lambdaResult; return(new AsyncResultExpression(result, taskType)); }
public MethodInvokeExpression(Expression?method) : this(method, parameters : null) { }
private Identifier RewriteDstOp(MachineOperand op, PrimitiveType width, Func <Expression, Expression> fn, Expression?index = null) { switch (op) { case RegisterOperand regOp: var reg = binder.EnsureRegister(regOp.Register); if (reg == null) { return(null !); } if (width.BitSize < 32) { var tmpLo = binder.CreateTemporary(width); var tmpHi = binder.CreateTemporary(PrimitiveType.CreateWord(32 - width.BitSize)); m.Assign(tmpLo, fn(m.Slice(width, reg, 0))); m.Assign(tmpHi, m.Slice(tmpHi.DataType, reg, width.BitSize)); m.Assign(reg, m.Seq(tmpHi, tmpLo)); return(tmpLo); } else if (width.BitSize == 64) { var rHi = arch.GetRegister(1 + (int)reg.Storage.Domain); if (rHi == null) { return(null !); } var regHi = binder.EnsureRegister(rHi); reg = binder.EnsureSequence(width, regHi.Storage, reg.Storage); } else if (width.BitSize == 128) { var regHi1 = binder.EnsureRegister(arch.GetRegister(1 + (int)reg.Storage.Domain) !); var regHi2 = binder.EnsureRegister(arch.GetRegister(2 + (int)reg.Storage.Domain) !); var regHi3 = binder.EnsureRegister(arch.GetRegister(3 + (int)reg.Storage.Domain) !); var regLo = binder.EnsureSequence(PrimitiveType.Word64, regHi1.Storage, reg.Storage); var regHi = binder.EnsureSequence(PrimitiveType.Word64, regHi3.Storage, regHi2.Storage); reg = binder.EnsureSequence(width, regHi.Storage, regLo.Storage); } m.Assign(reg, fn(reg)); return(reg); case MemoryOperand memOp: Expression ea; Identifier?regEa = null; if (memOp.Base is RegisterOperand rbase) { regEa = binder.EnsureRegister(rbase.Register); if (memOp.AutoDecrement) { m.Assign(regEa, m.ISub(regEa, width.Size)); } ea = regEa; if (memOp.Offset != null) { if (memOp.Offset.DataType.BitSize < ea.DataType.BitSize) { ea = m.IAddS(ea, memOp.Offset.ToInt32()); } else { ea = m.IAdd(ea, memOp.Offset); } } } else { ea = arch.MakeAddressFromConstant(memOp.Offset !, false); } var tmp = binder.CreateTemporary(width); m.Assign(tmp, fn(m.Mem(width, ea))); Expression load; if (memOp.Deferred) { ea = m.Mem32(ea); } if (index != null) { ea = m.IAdd(ea, index); } load = m.Mem(width, ea); m.Assign(load, tmp); if (regEa != null && memOp.AutoIncrement) { int inc = (memOp.Deferred) ? 4 : width.Size; m.Assign(regEa, m.IAdd(regEa, inc)); } return(tmp); case IndexOperand indexOperand: Expression idx = binder.EnsureRegister(indexOperand.Index); if (width.Size != 1) { idx = m.IMul(idx, Constant.Int32(width.Size)); } return(RewriteDstOp(indexOperand.Base, PrimitiveType.Word32, fn, idx)); case ImmediateOperand _: case AddressOperand _: return(null !); } throw new NotImplementedException(op.GetType().Name); }
public IBuildContext?GetContext(Expression?expression, int level, BuildInfo buildInfo) { throw new NotImplementedException(); }
public Expression BuildExpression(Expression?expression, int level, bool enforceServerSide) { var index = ConvertToIndex(expression, level, ConvertFlags.Field)[0].Index; return(Builder.BuildSql(_elementType, index)); }
public bool Compare(Expression?a, Expression?b) { if (a == b) { return(true); } if (a == null || b == null) { return(false); } if (a.NodeType != b.NodeType) { return(false); } if (a.Type != b.Type) { return(false); } switch (a.NodeType) { case ExpressionType.Negate: case ExpressionType.NegateChecked: case ExpressionType.Not: case ExpressionType.Convert: case ExpressionType.ConvertChecked: case ExpressionType.ArrayLength: case ExpressionType.Quote: case ExpressionType.TypeAs: case ExpressionType.UnaryPlus: return(CompareUnary((UnaryExpression)a, (UnaryExpression)b)); case ExpressionType.Add: case ExpressionType.AddChecked: case ExpressionType.Subtract: case ExpressionType.SubtractChecked: case ExpressionType.Multiply: case ExpressionType.MultiplyChecked: case ExpressionType.Divide: case ExpressionType.Modulo: case ExpressionType.And: case ExpressionType.AndAlso: case ExpressionType.Or: case ExpressionType.OrElse: case ExpressionType.LessThan: case ExpressionType.LessThanOrEqual: case ExpressionType.GreaterThan: case ExpressionType.GreaterThanOrEqual: case ExpressionType.Equal: case ExpressionType.NotEqual: case ExpressionType.Coalesce: case ExpressionType.ArrayIndex: case ExpressionType.RightShift: case ExpressionType.LeftShift: case ExpressionType.ExclusiveOr: case ExpressionType.Power: return(CompareBinary((BinaryExpression)a, (BinaryExpression)b)); case ExpressionType.TypeIs: return(CompareTypeIs((TypeBinaryExpression)a, (TypeBinaryExpression)b)); case ExpressionType.Conditional: return(CompareConditional((ConditionalExpression)a, (ConditionalExpression)b)); case ExpressionType.Constant: return(CompareConstant((ConstantExpression)a, (ConstantExpression)b)); case ExpressionType.Parameter: return(CompareParameter((ParameterExpression)a, (ParameterExpression)b)); case ExpressionType.MemberAccess: return(CompareMemberAccess((MemberExpression)a, (MemberExpression)b)); case ExpressionType.Call: return(CompareMethodCall((MethodCallExpression)a, (MethodCallExpression)b)); case ExpressionType.Lambda: return(CompareLambda((LambdaExpression)a, (LambdaExpression)b)); case ExpressionType.New: return(CompareNew((NewExpression)a, (NewExpression)b)); case ExpressionType.NewArrayInit: case ExpressionType.NewArrayBounds: return(CompareNewArray((NewArrayExpression)a, (NewArrayExpression)b)); case ExpressionType.Invoke: return(CompareInvocation((InvocationExpression)a, (InvocationExpression)b)); case ExpressionType.MemberInit: return(CompareMemberInit((MemberInitExpression)a, (MemberInitExpression)b)); case ExpressionType.ListInit: return(CompareListInit((ListInitExpression)a, (ListInitExpression)b)); // case ExpressionType.Extension: // return CompareExtension(a, b); default: throw new NotImplementedException(); } }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual int GetHashCode(Expression?obj) { if (obj == null) { return(0); } unchecked { var hashCode = (int)obj.NodeType; hashCode += (hashCode * 397) ^ obj.Type.GetHashCode(); switch (obj.NodeType) { case ExpressionType.Negate: case ExpressionType.NegateChecked: case ExpressionType.Not: case ExpressionType.Convert: case ExpressionType.ConvertChecked: case ExpressionType.ArrayLength: case ExpressionType.Quote: case ExpressionType.TypeAs: case ExpressionType.UnaryPlus: { var unaryExpression = (UnaryExpression)obj; if (unaryExpression.Method != null) { hashCode += hashCode * 397 ^ unaryExpression.Method.GetHashCode(); } hashCode += (hashCode * 397) ^ GetHashCode(unaryExpression.Operand); break; } case ExpressionType.Add: case ExpressionType.AddChecked: case ExpressionType.Subtract: case ExpressionType.SubtractChecked: case ExpressionType.Multiply: case ExpressionType.MultiplyChecked: case ExpressionType.Divide: case ExpressionType.Modulo: case ExpressionType.And: case ExpressionType.AndAlso: case ExpressionType.Or: case ExpressionType.OrElse: case ExpressionType.LessThan: case ExpressionType.LessThanOrEqual: case ExpressionType.GreaterThan: case ExpressionType.GreaterThanOrEqual: case ExpressionType.Equal: case ExpressionType.NotEqual: case ExpressionType.Coalesce: case ExpressionType.ArrayIndex: case ExpressionType.RightShift: case ExpressionType.LeftShift: case ExpressionType.ExclusiveOr: case ExpressionType.Power: { var binaryExpression = (BinaryExpression)obj; hashCode += (hashCode * 397) ^ GetHashCode(binaryExpression.Left); hashCode += (hashCode * 397) ^ GetHashCode(binaryExpression.Right); break; } case ExpressionType.TypeIs: { var typeBinaryExpression = (TypeBinaryExpression)obj; hashCode += (hashCode * 397) ^ GetHashCode(typeBinaryExpression.Expression); hashCode += (hashCode * 397) ^ typeBinaryExpression.TypeOperand.GetHashCode(); break; } case ExpressionType.Constant: { var constantExpression = (ConstantExpression)obj; if (constantExpression.Value != null && !(constantExpression.Value is IQueryable)) { hashCode += (hashCode * 397) ^ constantExpression.Value.GetHashCode(); } break; } case ExpressionType.Parameter: { var parameterExpression = (ParameterExpression)obj; hashCode += hashCode * 397; // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (parameterExpression.Name != null) { hashCode ^= parameterExpression.Name.GetHashCode(); } break; } case ExpressionType.MemberAccess: { var memberExpression = (MemberExpression)obj; hashCode += (hashCode * 397) ^ memberExpression.Member.GetHashCode(); hashCode += (hashCode * 397) ^ GetHashCode(memberExpression.Expression); break; } case ExpressionType.Call: { var methodCallExpression = (MethodCallExpression)obj; hashCode += (hashCode * 397) ^ methodCallExpression.Method.GetHashCode(); hashCode += (hashCode * 397) ^ GetHashCode(methodCallExpression.Object); hashCode += (hashCode * 397) ^ GetHashCode(methodCallExpression.Arguments); break; } case ExpressionType.Lambda: { var lambdaExpression = (LambdaExpression)obj; hashCode += (hashCode * 397) ^ lambdaExpression.ReturnType.GetHashCode(); hashCode += (hashCode * 397) ^ GetHashCode(lambdaExpression.Body); hashCode += (hashCode * 397) ^ GetHashCode(lambdaExpression.Parameters); break; } case ExpressionType.New: { var newExpression = (NewExpression)obj; hashCode += (hashCode * 397) ^ (newExpression.Constructor?.GetHashCode() ?? 0); if (newExpression.Members != null) { for (var i = 0; i < newExpression.Members.Count; i++) { hashCode += (hashCode * 397) ^ newExpression.Members[i].GetHashCode(); } } hashCode += (hashCode * 397) ^ GetHashCode(newExpression.Arguments); break; } case ExpressionType.NewArrayInit: case ExpressionType.NewArrayBounds: { var newArrayExpression = (NewArrayExpression)obj; hashCode += (hashCode * 397) ^ GetHashCode(newArrayExpression.Expressions); break; } case ExpressionType.Invoke: { var invocationExpression = (InvocationExpression)obj; hashCode += (hashCode * 397) ^ GetHashCode(invocationExpression.Expression); hashCode += (hashCode * 397) ^ GetHashCode(invocationExpression.Arguments); break; } case ExpressionType.MemberInit: { var memberInitExpression = (MemberInitExpression)obj; hashCode += (hashCode * 397) ^ GetHashCode(memberInitExpression.NewExpression); for (var i = 0; i < memberInitExpression.Bindings.Count; i++) { var memberBinding = memberInitExpression.Bindings[i]; hashCode += (hashCode * 397) ^ memberBinding.Member.GetHashCode(); hashCode += (hashCode * 397) ^ (int)memberBinding.BindingType; switch (memberBinding.BindingType) { case MemberBindingType.Assignment: var memberAssignment = (MemberAssignment)memberBinding; hashCode += (hashCode * 397) ^ GetHashCode(memberAssignment.Expression); break; case MemberBindingType.ListBinding: var memberListBinding = (MemberListBinding)memberBinding; for (var j = 0; j < memberListBinding.Initializers.Count; j++) { hashCode += (hashCode * 397) ^ GetHashCode(memberListBinding.Initializers[j].Arguments); } break; default: throw new NotImplementedException(); } } break; } case ExpressionType.ListInit: { var listInitExpression = (ListInitExpression)obj; hashCode += (hashCode * 397) ^ GetHashCode(listInitExpression.NewExpression); for (var i = 0; i < listInitExpression.Initializers.Count; i++) { hashCode += (hashCode * 397) ^ GetHashCode(listInitExpression.Initializers[i].Arguments); } break; } case ExpressionType.Conditional: { var conditionalExpression = (ConditionalExpression)obj; hashCode += (hashCode * 397) ^ GetHashCode(conditionalExpression.Test); hashCode += (hashCode * 397) ^ GetHashCode(conditionalExpression.IfTrue); hashCode += (hashCode * 397) ^ GetHashCode(conditionalExpression.IfFalse); break; } case ExpressionType.Default: { hashCode += (hashCode * 397) ^ obj.Type.GetHashCode(); break; } // case ExpressionType.Extension: // { // if (obj is NullConditionalExpression nullConditionalExpression) // { // hashCode += (hashCode * 397) ^ GetHashCode(nullConditionalExpression.AccessOperation); // } // else if (obj is NullConditionalEqualExpression nullConditionalEqualExpression) // { // hashCode += (hashCode * 397) ^ GetHashCode(nullConditionalEqualExpression.OuterNullProtection); // hashCode += (hashCode * 397) ^ GetHashCode(nullConditionalEqualExpression.OuterKey); // hashCode += (hashCode * 397) ^ GetHashCode(nullConditionalEqualExpression.InnerKey); // } // else // { // hashCode += (hashCode * 397) ^ obj.GetHashCode(); // } // // break; // } default: throw new NotImplementedException(); } return(hashCode); } }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual bool Equals(Expression?x, Expression?y) => new ExpressionComparer().Compare(x, y);
protected abstract bool TryCreateExpression( FilterOperation operation, Expression property, Func <object> parseValue, [NotNullWhen(true)] out Expression?expression);
public override IBuildContext?GetContext(Expression?expression, int level, BuildInfo buildInfo) { return(base.GetContext(expression, level, buildInfo)); }
public override Expression?Visit(Expression?node) { VisitCalled = true; return(base.Visit(node)); }
public SqlInfo[] ConvertToSql(Expression?expression, int level, ConvertFlags flags) { if (expression == null) { var query = SelectQuery; var sql = SelectQuery.Select.Columns[0]; if (Parent != null) { query = Parent.SelectQuery; } return(new[] { new SqlInfo(sql, query) }); } switch (flags) { case ConvertFlags.Field: { if (expression.NodeType == ExpressionType.MemberAccess) { var memberExpression = (MemberExpression)expression; foreach (var column in _entityDescriptor.Columns) { if (column.MemberInfo.EqualsTo(memberExpression.Member, _elementType)) { if (!Table.Fields.TryGetValue(column.MemberInfo.Name, out var newField)) { newField = new SqlField(column); Table.Add(newField); for (var i = 0; i < _records.Count; i++) { object value; if (column.MemberInfo.IsPropertyEx()) { value = ((PropertyInfo)column.MemberInfo).GetValue(_records[i].Value); } else if (column.MemberInfo.IsFieldEx()) { value = ((FieldInfo)column.MemberInfo).GetValue(_records[i].Value); } else { throw new InvalidOperationException(); } var valueExpr = Expression.Constant(value, column.MemberType); var expr = Builder.ConvertToSqlExpression(Parent !, valueExpr); if (expr is SqlParameter p) { // avoid parameters is source, because their number is limited p.IsQueryParameter = !Builder.MappingSchema.ValueToSqlConverter.CanConvert(p.Type.SystemType); p.Type = p.Type.WithoutSystemType(column); } else if (expr is SqlValue val) { val.ValueType = val.ValueType.WithoutSystemType(column); } Table.Rows[i].Add(expr); } } return(new[] { new SqlInfo(column.MemberInfo, newField, SelectQuery) }); } } } break; } } throw new NotImplementedException(); }
/// <summary> /// Checks whether the given <paramref name="expression"/> representing a /// child expression should be saved in a temporary variable upon spilling /// the stack. If the expression has no have side-effects, the introduction /// of a temporary variable can be avoided, reducing the number of locals. /// </summary> /// <param name="expression">The expression to check for side-effects.</param> /// <returns> /// <c>true</c> if the expression should be saved to a temporary variable; /// otherwise, <c>false</c>. /// </returns> private static bool ShouldSaveToTemp(Expression?expression) { if (expression == null) { return(false); } // Some expressions have no side-effects and don't have to be // stored into temporaries, e.g. // // xs[0] = try { ... } // | // v // t0 = xs // t1 = 0 // <-- this is redundant // t2 = try { ... } // t0[t1] = t2 // | // v // t0 = xs // t1 = try { ... } // t0[0] = t1 switch (expression.NodeType) { // Emits ldnull, ldc, initobj, closure constant access, etc. case ExpressionType.Constant: case ExpressionType.Default: return(false); // Emits calls to pure RuntimeOps methods with immutable arguments case ExpressionType.RuntimeVariables: return(false); case ExpressionType.MemberAccess: var member = (MemberExpression)expression; var field = member.Member as FieldInfo; if (field != null) { // Emits ldc for the raw value of the field if (field.IsLiteral) { return(false); } // For read-only fields we could save the receiver, but // that's more involved, so we'll just handle static fields if (field.IsInitOnly && field.IsStatic) { return(false); } } break; } // NB: We omit Lambda because it may interfere with the Invoke/Lambda // inlining optimizations. Parameter is out too because we don't // have any sophisticated load/store analysis. // NB: We omit Quote because the emitted call to RuntimeOps.Quote will // trigger reduction of extension nodes which can cause the timing // of exceptions thrown from Reduce methods to change. return(true); }
private void RewriteMem(int iOp, Expression src, Action <Expression, Expression> write, Expression?seg) { var op = instr.Operands[iOp]; var mop = (MemoryOperand)op; var baseReg = binder.EnsureRegister(mop.Base !); Expression ea = baseReg; if (mop.PreDecrement) { m.Assign(baseReg, m.ISubS(baseReg, 1)); } else if (mop.Displacement != 0) { ea = m.IAddS(ea, mop.Displacement); } Expression val; if (seg != null) { val = m.SegMem(mop.Width, seg, ea); } else { val = m.Mem(mop.Width, ea); } write(val, src); if (mop.PostIncrement) { m.Assign(baseReg, m.IAddS(baseReg, 1)); } }
public MethodInvokeExpression(Expression?method, params Expression[] arguments) : this(method, parameters : null, arguments) { }
protected override Expression CreateInstantiationExpression(Expression source, Expression?destination, CompileArgument arg) { var listType = arg.DestinationType; if (arg.DestinationType.GetTypeInfo().IsInterface) { var dict = arg.DestinationType.GetDictionaryType(); if (dict != null) { var dictArgs = dict.GetGenericArguments(); listType = typeof(Dictionary <,>).MakeGenericType(dictArgs); } else if (arg.DestinationType.IsAssignableFromList()) { var destinationElementType = arg.DestinationType.ExtractCollectionType(); listType = typeof(List <>).MakeGenericType(destinationElementType); } else // if (arg.DestinationType.IsAssignableFromSet()) { var destinationElementType = arg.DestinationType.ExtractCollectionType(); listType = typeof(HashSet <>).MakeGenericType(destinationElementType); } } var count = ExpressionEx.CreateCountExpression(source, false); if (count == null) { return(Expression.New(listType)); //new List<T>() } var ctor = (from c in listType.GetConstructors() let args = c.GetParameters() where args.Length == 1 && args[0].ParameterType == typeof(int) select c).FirstOrDefault(); if (ctor == null) { return(Expression.New(listType)); //new List<T>() } else { return(Expression.New(ctor, count)); //new List<T>(count) } }
public static bool TryParse(string value, [NotNullWhen(true)] out Expression?expression) { expression = null; int i = 0; int length = value.Length; while (i < length) { switch (value[i]) { case '=': { switch (Peek()) { case '(': case '<': { expression = ParseInterval(); return(expression != null); } case '-': { expression = new DecrementExpression( value, value.Substring(0, i), value.Substring(i + 2)); return(true); } default: { expression = new BinaryExpression( value, value.Substring(0, i), value.Substring(i + 1), ExpressionKind.EqualsExpression); return(true); } } } case '>': { if (Peek() == '=') { expression = new BinaryExpression( value, value.Substring(0, i), value.Substring(i + 2), ExpressionKind.GreaterThanOrEqualExpression); } else { expression = new BinaryExpression( value, value.Substring(0, i), value.Substring(i + 1), ExpressionKind.GreaterThanExpression); } return(true); } case '<': { if (Peek() == '=') { expression = new BinaryExpression( value, value.Substring(0, i), value.Substring(i + 2), ExpressionKind.LessThanOrEqualExpression); } else { expression = new BinaryExpression( value, value.Substring(0, i), value.Substring(i + 1), ExpressionKind.LessThanExpression); } return(true); } } i++; } return(false); char Peek() { return((i < length - 1) ? value[i + 1] : default);
public override SqlInfo[] ConvertToIndex(Expression?expression, int level, ConvertFlags flags) { switch (flags) { case ConvertFlags.Field: return(_index ?? (_index = new[]
private Expression BuildReaderExpression() { if (MappingSchema.IsScalarType(ObjectType)) { return(new ConvertFromDataReaderExpression(ObjectType, 0, null, DataReaderLocal, DataContext)); } var entityDescriptor = MappingSchema.GetEntityDescriptor(ObjectType); var inheritanceMapping = entityDescriptor.InheritanceMapping; if (inheritanceMapping.Count == 0) { return(BuildReadExpression(true, ObjectType)); } Expression?expr = null; var defaultMapping = inheritanceMapping.SingleOrDefault(m => m.IsDefault); if (defaultMapping != null) { expr = Expression.Convert( BuildReadExpression(false, defaultMapping.Type), ObjectType); } else { var exceptionMethod = MemberHelper.MethodOf(() => DefaultInheritanceMappingException(null !, null !)); var dindex = GetReaderIndex(entityDescriptor, null, inheritanceMapping[0].DiscriminatorName); if (dindex >= 0) { expr = Expression.Convert( Expression.Call(null, exceptionMethod, Expression.Call( DataReaderLocal, ReflectionHelper.DataReader.GetValue, Expression.Constant(dindex)), Expression.Constant(ObjectType)), ObjectType); } } if (expr == null) { return(BuildReadExpression(true, ObjectType)); } foreach (var mapping in inheritanceMapping.Select((m, i) => new { m, i }).Where(m => m.m != defaultMapping)) { var ed = MappingSchema.GetEntityDescriptor(mapping.m.Type); var dindex = GetReaderIndex(ed, null, mapping.m.DiscriminatorName); if (dindex >= 0) { Expression testExpr; var isNullExpr = Expression.Call( DataReaderLocal, ReflectionHelper.DataReader.IsDBNull, Expression.Constant(dindex)); if (mapping.m.Code == null) { testExpr = isNullExpr; } else { var codeType = mapping.m.Code.GetType(); testExpr = ExpressionBuilder.Equal( MappingSchema, new ConvertFromDataReaderExpression(codeType, dindex, mapping.m.Discriminator.ValueConverter, DataReaderLocal, DataContext), Expression.Constant(mapping.m.Code)); if (mapping.m.Discriminator.CanBeNull) { testExpr = Expression.AndAlso( Expression.Not(isNullExpr), testExpr); } } expr = Expression.Condition( testExpr, Expression.Convert(BuildReadExpression(false, mapping.m.Type), ObjectType), expr); } } return(expr); }
public ProcSignature(ParseTree.Node?parseTreeNode, IReadOnlyList <Parameter> parameters, Expression?ret) : base(parseTreeNode) { Parameters = parameters; Return = ret; }
public override void VisitBinaryExpression(BinaryExpression binExp) { defExpr = binExp; }
public Block(ParseTree.Node?parseTreeNode, IReadOnlyList <Statement> statements, Expression?value) : base(parseTreeNode) { Statements = statements; Value = value; }
public override void VisitPhiFunction(PhiFunction phi) { defExpr = phi; }
public If(ParseTree.Node?parseTreeNode, Expression condition, Expression then, Expression?els) : base(parseTreeNode) { Condition = condition; Then = then; Else = els; }
protected override Expression CreateInstantiationExpression(Expression source, Expression?destination, CompileArgument arg) { //new TDestination(src.Prop1, src.Prop2) if (arg.GetConstructUsing() != null || arg.Settings.MapToConstructor == null) { return(base.CreateInstantiationExpression(source, destination, arg)); } ClassMapping?classConverter; var ctor = arg.Settings.MapToConstructor as ConstructorInfo; if (ctor == null) { var destType = arg.DestinationType.GetTypeInfo().IsInterface ? DynamicTypeGenerator.GetTypeForInterface(arg.DestinationType) : arg.DestinationType; classConverter = destType.GetConstructors() .OrderByDescending(it => it.GetParameters().Length) .Select(it => GetConstructorModel(it, true)) .Select(it => CreateClassConverter(source, it, arg)) .FirstOrDefault(it => it != null); } else { var model = GetConstructorModel(ctor, false); classConverter = CreateClassConverter(source, model, arg); } if (classConverter == null) { return(base.CreateInstantiationExpression(source, destination, arg)); } return(CreateInstantiationExpression(source, classConverter, arg)); }
public override SqlInfo[] ConvertToIndex(Expression?expression, int level, ConvertFlags flags) { return(base.ConvertToIndex(expression, level, flags)); }