protected static void GenerateCodeForArgument(ILGenerator gen, CodeFlow cf, SpelNode argument, TypeDescriptor paramDesc) { cf.EnterCompilationScope(); argument.GenerateCode(gen, cf); var lastDesc = cf.LastDescriptor(); if (lastDesc == null) { throw new InvalidOperationException("No last descriptor"); } var valueTypeOnStack = CodeFlow.IsValueType(lastDesc); // Check if need to box it for the method reference? if (valueTypeOnStack && paramDesc.IsReferenceType) { CodeFlow.InsertBoxIfNecessary(gen, lastDesc); } else if (paramDesc.IsValueType && !paramDesc.IsBoxed && !valueTypeOnStack) { gen.Emit(OpCodes.Unbox_Any, paramDesc.Value); } else { // This would be unnecessary in the case of subtyping (e.g. method takes Number but Integer passed in) CodeFlow.InsertCastClass(gen, paramDesc); } cf.ExitCompilationScope(); }
private bool GetBooleanValue(ExpressionState state, SpelNode operand) { try { var value = operand.GetValue <bool>(state); return(value); } catch (SpelEvaluationException ee) { ee.Position = operand.StartPosition; throw; } }
public override void GenerateCode(ILGenerator gen, CodeFlow cf) { var executor = (ReflectiveConstructorExecutor)_cachedExecutor; if (executor == null) { throw new InvalidOperationException("No cached executor"); } var constructor = executor.Constructor; // children[0] is the type of the constructor, don't want to include that in argument processing var arguments = new SpelNode[_children.Length - 1]; Array.Copy(_children, 1, arguments, 0, _children.Length - 1); GenerateCodeForArguments(gen, cf, constructor, arguments); gen.Emit(OpCodes.Newobj, constructor); cf.PushDescriptor(_exitTypeDescriptor); }
private void Walk(ILGenerator gen, CodeFlow cf, SpelNode operand) { if (operand is OpPlus plus) { Walk(gen, cf, plus.LeftOperand); Walk(gen, cf, plus.RightOperand); } else if (operand != null) { cf.EnterCompilationScope(); operand.GenerateCode(gen, cf); if (cf.LastDescriptor() != TypeDescriptor.STRING) { gen.Emit(OpCodes.Castclass, typeof(string)); } cf.ExitCompilationScope(); gen.Emit(OpCodes.Callvirt, _appendString); } }
protected static void GenerateCodeForArgument(DynamicMethod mv, CodeFlow cf, SpelNode argument, string paramDesc) { // cf.EnterCompilationScope(); // argument.GenerateCode(mv, cf); // String lastDesc = cf.lastDescriptor(); // Assert.state(lastDesc != null, "No last descriptor"); // bool primitiveOnStack = CodeFlow.isPrimitive(lastDesc); //// Check if need to box it for the method reference? // if (primitiveOnStack && paramDesc.charAt(0) == 'L') // { // CodeFlow.insertBoxIfNecessary(mv, lastDesc.charAt(0)); // } // else if (paramDesc.length() == 1 && !primitiveOnStack) // { // CodeFlow.insertUnboxInsns(mv, paramDesc.charAt(0), lastDesc); // } // else if (!paramDesc.equals(lastDesc)) // { // // This would be unnecessary in the case of subtyping (e.g. method takes Number but Integer passed in) // CodeFlow.insertCheckCast(mv, paramDesc); // } // cf.exitCompilationScope(); }
public Selection(bool nullSafe, int variant, int startPos, int endPos, SpelNode expression) : base(startPos, endPos, expression) { _nullSafe = nullSafe; _variant = variant; }
public OperatorNot(int startPos, int endPos, SpelNode operand) : base(startPos, endPos, operand) { _exitTypeDescriptor = TypeDescriptor.Z; }
public Indexer(int startPos, int endPos, SpelNode expr) : base(startPos, endPos, expr) { }
public Projection(bool nullSafe, int startPos, int endPos, SpelNode expression) : base(startPos, endPos, expression) { _nullSafe = nullSafe; }
public TypeReference(int startPos, int endPos, SpelNode qualifiedId, int dims) : base(startPos, endPos, qualifiedId) { _dimensions = dims; }
public TypeReference(int startPos, int endPos, SpelNode qualifiedId) : this(startPos, endPos, qualifiedId, 0) { }
private readonly SpelNode _node; // used only for error reporting public TypedValueHolderValueRef(ITypedValue typedValue, SpelNode node) { _typedValue = typedValue; _node = node; }