public ExpressionElement[] ToArray() { var arr = new ExpressionElement[this.myElements.Count - 1 + 1]; this.myElements.CopyTo(arr, 0); return(arr); }
public ArgumentList(ICollection elements) { var arr = new ExpressionElement[elements.Count - 1 + 1]; elements.CopyTo(arr, 0); this.myElements = arr; }
private void Configure(ExpressionElement leftChild, ExpressionElement rightChild, object op) { this.myLeftChild = leftChild; this.myRightChild = rightChild; this.GetOperation(RuntimeHelpers.GetObjectValue(op)); this.ValidateInternal(RuntimeHelpers.GetObjectValue(op)); }
public ConditionalElement(ExpressionElement condition, ExpressionElement whenTrue, ExpressionElement whenFalse) { this.myCondition = condition; this.myWhenTrue = whenTrue; this.myWhenFalse = whenFalse; var flag = this.myCondition.ResultType != typeof(bool); if (flag) { this.ThrowCompileException("FirstArgNotBoolean", CompileExceptionReason.TypeMismatch); } var flag2 = ImplicitConverter.EmitImplicitConvert(this.myWhenFalse.ResultType, this.myWhenTrue.ResultType, null); if (flag2) { this.myResultType = this.myWhenTrue.ResultType; } else { var flag3 = ImplicitConverter.EmitImplicitConvert(this.myWhenTrue.ResultType, this.myWhenFalse.ResultType, null); if (flag3) { this.myResultType = this.myWhenFalse.ResultType; } else { this.ThrowCompileException("NeitherArgIsConvertibleToTheOther", CompileExceptionReason.TypeMismatch, this.myWhenTrue.ResultType.Name, this.myWhenFalse.ResultType.Name); } } }
protected static void EmitChildWithConvert(ExpressionElement child, Type resultType, FleeIlGenerator ilg, IServiceProvider services) { child.Emit(ilg, services); var converted = ImplicitConverter.EmitImplicitConvert(child.ResultType, resultType, ilg); Debug.Assert(converted, "convert failed"); }
public InElement(ExpressionElement operand, IList listElements) { this.myOperand = operand; var arr = new ExpressionElement[listElements.Count - 1 + 1]; listElements.CopyTo(arr, 0); this.myArguments = new List <ExpressionElement>(arr); this.ResolveForListSearch(); }
public void SetChild(ExpressionElement child) { this.myChild = child; this.myResultType = this.GetResultType(child.ResultType); var flag = this.myResultType == null; if (flag) { this.ThrowCompileException("OperationNotDefinedForType", CompileExceptionReason.TypeMismatch, this.myChild.ResultType.Name); } }
private static void EmitOperand(ExpressionElement operand, ShortCircuitInfo info, FleeIlGenerator ilg, IServiceProvider services) { var flag = info.Branches.HasLabel(operand); if (flag) { var leftLabel = info.Branches.FindLabel(operand); ilg.MarkLabel(leftLabel); MarkBranchTarget(info, leftLabel, ilg); } operand.Emit(ilg, services); }
private void EmitParamArrayArguments(ParameterInfo[] parameters, ExpressionElement[] elements, FleeIlGenerator ilg, IServiceProvider services) { var fixedParameters = new ParameterInfo[this.myTargetMethodInfo.myFixedArgTypes.Length - 1 + 1]; Array.Copy(parameters, fixedParameters, fixedParameters.Length); var fixedElements = new ExpressionElement[this.myTargetMethodInfo.myFixedArgTypes.Length - 1 + 1]; Array.Copy(elements, fixedElements, fixedElements.Length); this.EmitRegularFunctionInternal(fixedParameters, fixedElements, ilg, services); var paramArrayElements = new ExpressionElement[elements.Length - fixedElements.Length - 1 + 1]; Array.Copy(elements, fixedElements.Length, paramArrayElements, 0, paramArrayElements.Length); EmitElementArrayLoad(paramArrayElements, this.myTargetMethodInfo.paramArrayElementType, ilg, services); }
private void SetupArrayIndexer() { this.myIndexerElement = this.myIndexerElements[0]; var flag = this.myIndexerElements.Count > 1; if (flag) { this.ThrowCompileException("MultiArrayIndexNotSupported", CompileExceptionReason.TypeMismatch); } else { var flag2 = !ImplicitConverter.EmitImplicitConvert(this.myIndexerElement.ResultType, typeof(int), null); if (flag2) { this.ThrowCompileException("ArrayIndexersMustBeOfType", CompileExceptionReason.TypeMismatch, typeof(int).Name); } } }
private static void EmitToAssembly(ExpressionElement rootElement, IServiceContainer services) { var assemblyName = new AssemblyName(EmitAssemblyName); var assemblyFileName = $"{EmitAssemblyName}.dll"; var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Save); var moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyFileName, assemblyFileName); var mb = moduleBuilder.DefineGlobalMethod("Evaluate", MethodAttributes.Public | MethodAttributes.Static, typeof(T), new[] { typeof(object), typeof(ExpressionContext), typeof(VariableCollection) }); var ilg = new FleeIlGenerator(mb.GetILGenerator()); rootElement.Emit(ilg, services); moduleBuilder.CreateGlobalFunctions(); assemblyBuilder.Save(assemblyFileName); }
public CastElement(ExpressionElement castExpression, string[] destTypeParts, bool isArray, IServiceProvider services) { this.myCastExpression = castExpression; this.myDestType = GetDestType(destTypeParts, services); var flag = this.myDestType == null; if (flag) { this.ThrowCompileException("CouldNotResolveType", CompileExceptionReason.UndefinedName, GetDestTypeString(destTypeParts, isArray)); } if (isArray) { this.myDestType = this.myDestType.MakeArrayType(); } var flag2 = !this.IsValidCast(this.myCastExpression.ResultType, this.myDestType); if (flag2) { this.ThrowInvalidCastException(); } }
private bool FindIndexer(Type targetType) { var members = targetType.GetDefaultMembers(); var methods = new List <MethodInfo>(); var array = members; checked { for (var i = 0; i < array.Length; i++) { var mi = array[i]; var pi = mi as PropertyInfo; var flag = pi != null; if (flag) { methods.Add(pi.GetGetMethod(true)); } } var func = new FunctionCallElement("Indexer", methods.ToArray(), this.myIndexerElements); func.Resolve(this.myServices); this.myIndexerElement = func; return(true); } }
public ExpressionMemberElement(ExpressionElement element) { this.myElement = element; }
public LocalBasedElement(ExpressionElement target, int index) { this.MyTarget = target; this.MyIndex = index; }
protected static bool IsChildOfType(ExpressionElement child, Type t) { return(child.ResultType == t); }
public void Initialize(ExpressionElement leftChild, ExpressionElement rightChild, LogicalCompareOperation op) { this.myLeftChild = leftChild; this.myRightChild = rightChild; this.myOperation = op; }
public RootExpressionElement(ExpressionElement child, Type resultType) { this.myChild = child; this.myResultType = resultType; this.Validate(); }
public InElement(ExpressionElement operand, ExpressionElement targetCollection) { this.myOperand = operand; this.myTargetCollectionElement = targetCollection; this.ResolveForCollectionSearch(); }