void EmitLiftedToNullBinary(EmitContext ec) { var ig = ec.ig; var left = ec.EmitStored(this.left); var right = ec.EmitStored(this.right); var result = ig.DeclareLocal(Type); var has_value = ig.DefineLabel(); var done = ig.DefineLabel(); ec.EmitNullableHasValue(left); ec.EmitNullableHasValue(right); ig.Emit(OpCodes.And); ig.Emit(OpCodes.Brtrue, has_value); ec.EmitNullableInitialize(result); ig.Emit(OpCodes.Br, done); ig.MarkLabel(has_value); ec.EmitNullableGetValueOrDefault(left); ec.EmitNullableGetValueOrDefault(right); EmitBinaryOperator(ec); ec.EmitNullableNew(result.LocalType); ig.MarkLabel(done); }
void EmitLiftedToNullUserDefinedOperator(EmitContext ec) { var ig = ec.ig; var ret = ig.DefineLabel(); var done = ig.DefineLabel(); var left = ec.EmitStored(this.left); var right = ec.EmitStored(this.right); ec.EmitNullableHasValue(left); ec.EmitNullableHasValue(right); ig.Emit(OpCodes.And); ig.Emit(OpCodes.Brfalse, ret); ec.EmitNullableGetValueOrDefault(left); ec.EmitNullableGetValueOrDefault(right); ec.EmitCall(method); ec.EmitNullableNew(Type); ig.Emit(OpCodes.Br, done); ig.MarkLabel(ret); var temp = ig.DeclareLocal(Type); ec.EmitNullableInitialize(temp); ig.MarkLabel(done); }
void EmitLiftedUnary(EmitContext ec) { var ig = ec.ig; var from = ec.EmitStored(operand); var to = ig.DeclareLocal(Type); var has_value = ig.DefineLabel(); var done = ig.DefineLabel(); ec.EmitNullableHasValue(from); ig.Emit(OpCodes.Brtrue, has_value); // if not has value ec.EmitNullableInitialize(to); ig.Emit(OpCodes.Br, done); ig.MarkLabel(has_value); // if has value ec.EmitNullableGetValueOrDefault(from); EmitUnaryOperator(ec); ec.EmitNullableNew(Type); ig.MarkLabel(done); }
private void EmitLeftLiftedToNullBinary(EmitContext ec) { var ig = ec.ig; var ret = ig.DefineLabel(); var done = ig.DefineLabel(); var left = ec.EmitStored(this.left); ec.EmitNullableHasValue(left); ig.Emit(OpCodes.Brfalse, ret); ec.EmitNullableGetValueOrDefault(left); ec.Emit(right); EmitBinaryOperator(ec); ec.EmitNullableNew(Type); ig.Emit(OpCodes.Br, done); ig.MarkLabel(ret); var temp = ig.DeclareLocal(Type); ec.EmitNullableInitialize(temp); ig.MarkLabel(done); }
private void EmitUserDefinedLiftedLogicalShortCircuit(EmitContext ec) { ILGenerator ig = ec.ig; bool flag = base.NodeType == ExpressionType.AndAlso; Label label = ig.DefineLabel(); Label label2 = ig.DefineLabel(); Label label3 = ig.DefineLabel(); Label label4 = ig.DefineLabel(); LocalBuilder local = ec.EmitStored(left); ec.EmitNullableHasValue(local); ig.Emit(OpCodes.Brfalse, (!flag) ? label : label3); ec.EmitNullableGetValueOrDefault(local); ec.EmitCall((!flag) ? GetTrueOperator() : GetFalseOperator()); ig.Emit(OpCodes.Brtrue, label2); ig.MarkLabel(label); LocalBuilder local2 = ec.EmitStored(right); ec.EmitNullableHasValue(local2); ig.Emit(OpCodes.Brfalse, label3); ec.EmitNullableGetValueOrDefault(local); ec.EmitNullableGetValueOrDefault(local2); ec.EmitCall(method); ec.EmitNullableNew(base.Type); ig.Emit(OpCodes.Br, label4); ig.MarkLabel(label2); ec.EmitLoad(local); ig.Emit(OpCodes.Br, label4); ig.MarkLabel(label3); LocalBuilder local3 = ig.DeclareLocal(base.Type); ec.EmitNullableInitialize(local3); ig.MarkLabel(label4); }
void EmitLiftedLogicalShortCircuit(EmitContext ec) { var ig = ec.ig; var and = NodeType == ExpressionType.AndAlso; var left_is_null = ig.DefineLabel(); var ret_from_left = ig.DefineLabel(); var ret_null = ig.DefineLabel(); var ret_new = ig.DefineLabel(); var done = ig.DefineLabel(); var left = ec.EmitStored(this.left); ec.EmitNullableHasValue(left); ig.Emit(OpCodes.Brfalse, left_is_null); ec.EmitNullableGetValueOrDefault(left); ig.Emit(OpCodes.Ldc_I4_0); ig.Emit(OpCodes.Ceq); ig.Emit(and ? OpCodes.Brtrue : OpCodes.Brfalse, ret_from_left); ig.MarkLabel(left_is_null); var right = ec.EmitStored(this.right); ec.EmitNullableHasValue(right); ig.Emit(OpCodes.Brfalse_S, ret_null); ec.EmitNullableGetValueOrDefault(right); ig.Emit(OpCodes.Ldc_I4_0); ig.Emit(OpCodes.Ceq); ig.Emit(and ? OpCodes.Brtrue : OpCodes.Brfalse, ret_from_left); ec.EmitNullableHasValue(left); ig.Emit(OpCodes.Brfalse, ret_null); ig.Emit(and ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0); ig.Emit(OpCodes.Br_S, ret_new); ig.MarkLabel(ret_from_left); ig.Emit(and ? OpCodes.Ldc_I4_0 : OpCodes.Ldc_I4_1); ig.MarkLabel(ret_new); ec.EmitNullableNew(Type); ig.Emit(OpCodes.Br, done); ig.MarkLabel(ret_null); var ret = ig.DeclareLocal(Type); ec.EmitNullableInitialize(ret); ig.MarkLabel(done); }
void EmitNullableConstant(EmitContext ec, Type type, object value) { if (value == null) { var local = ec.ig.DeclareLocal(type); ec.EmitNullableInitialize(local); } else { EmitConstant(ec, type.GetFirstGenericArgument(), value); ec.EmitNullableNew(type); } }
private void EmitLiftedUnary(EmitContext ec) { ILGenerator ig = ec.ig; LocalBuilder local = ec.EmitStored(operand); LocalBuilder local2 = ig.DeclareLocal(base.Type); Label label = ig.DefineLabel(); Label label2 = ig.DefineLabel(); ec.EmitNullableHasValue(local); ig.Emit(OpCodes.Brtrue, label); ec.EmitNullableInitialize(local2); ig.Emit(OpCodes.Br, label2); ig.MarkLabel(label); ec.EmitNullableGetValueOrDefault(local); EmitUnaryOperator(ec); ec.EmitNullableNew(base.Type); ig.MarkLabel(label2); }
void EmitUserDefinedLiftedLogicalShortCircuit(EmitContext ec) { var ig = ec.ig; var and = NodeType == ExpressionType.AndAlso; var left_is_null = ig.DefineLabel(); var ret_left = ig.DefineLabel(); var ret_null = ig.DefineLabel(); var done = ig.DefineLabel(); var left = ec.EmitStored(this.left); ec.EmitNullableHasValue(left); ig.Emit(OpCodes.Brfalse, and ? ret_null : left_is_null); ec.EmitNullableGetValueOrDefault(left); ec.EmitCall(and ? GetFalseOperator() : GetTrueOperator()); ig.Emit(OpCodes.Brtrue, ret_left); ig.MarkLabel(left_is_null); var right = ec.EmitStored(this.right); ec.EmitNullableHasValue(right); ig.Emit(OpCodes.Brfalse, ret_null); ec.EmitNullableGetValueOrDefault(left); ec.EmitNullableGetValueOrDefault(right); ec.EmitCall(method); ec.EmitNullableNew(Type); ig.Emit(OpCodes.Br, done); ig.MarkLabel(ret_left); ec.EmitLoad(left); ig.Emit(OpCodes.Br, done); ig.MarkLabel(ret_null); var ret = ig.DeclareLocal(Type); ec.EmitNullableInitialize(ret); ig.MarkLabel(done); }
private void EmitUserDefinedLiftedToNullOperator(EmitContext ec) { ILGenerator ig = ec.ig; LocalBuilder local = ec.EmitStored(this.operand); Label label = ig.DefineLabel(); Label label2 = ig.DefineLabel(); ec.EmitNullableHasValue(local); ig.Emit(OpCodes.Brfalse, label); ec.EmitNullableGetValueOrDefault(local); ec.EmitCall(this.method); ec.EmitNullableNew(base.Type); ig.Emit(OpCodes.Br, label2); ig.MarkLabel(label); LocalBuilder local2 = ig.DeclareLocal(base.Type); ec.EmitNullableInitialize(local2); ig.MarkLabel(label2); }
private void EmitLeftLiftedToNullBinary(EmitContext ec) { ILGenerator ig = ec.ig; Label label = ig.DefineLabel(); Label label2 = ig.DefineLabel(); LocalBuilder local = ec.EmitStored(this.left); ec.EmitNullableHasValue(local); ig.Emit(OpCodes.Brfalse, label); ec.EmitNullableGetValueOrDefault(local); ec.Emit(this.right); this.EmitBinaryOperator(ec); ec.EmitNullableNew(base.Type); ig.Emit(OpCodes.Br, label2); ig.MarkLabel(label); LocalBuilder local2 = ig.DeclareLocal(base.Type); ec.EmitNullableInitialize(local2); ig.MarkLabel(label2); }
private void EmitLiftedLogicalShortCircuit(EmitContext ec) { ILGenerator ig = ec.ig; bool flag = base.NodeType == ExpressionType.AndAlso; Label label = ig.DefineLabel(); Label label2 = ig.DefineLabel(); Label label3 = ig.DefineLabel(); Label label4 = ig.DefineLabel(); Label label5 = ig.DefineLabel(); LocalBuilder local = ec.EmitStored(left); ec.EmitNullableHasValue(local); ig.Emit(OpCodes.Brfalse, label); ec.EmitNullableGetValueOrDefault(local); ig.Emit(OpCodes.Ldc_I4_0); ig.Emit(OpCodes.Ceq); ig.Emit((!flag) ? OpCodes.Brfalse : OpCodes.Brtrue, label2); ig.MarkLabel(label); LocalBuilder local2 = ec.EmitStored(right); ec.EmitNullableHasValue(local2); ig.Emit(OpCodes.Brfalse_S, label3); ec.EmitNullableGetValueOrDefault(local2); ig.Emit(OpCodes.Ldc_I4_0); ig.Emit(OpCodes.Ceq); ig.Emit((!flag) ? OpCodes.Brfalse : OpCodes.Brtrue, label2); ec.EmitNullableHasValue(local); ig.Emit(OpCodes.Brfalse, label3); ig.Emit((!flag) ? OpCodes.Ldc_I4_0 : OpCodes.Ldc_I4_1); ig.Emit(OpCodes.Br_S, label4); ig.MarkLabel(label2); ig.Emit((!flag) ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0); ig.MarkLabel(label4); ec.EmitNullableNew(base.Type); ig.Emit(OpCodes.Br, label5); ig.MarkLabel(label3); LocalBuilder local3 = ig.DeclareLocal(base.Type); ec.EmitNullableInitialize(local3); ig.MarkLabel(label5); }
private void EmitUserDefinedLiftedToNullOperator(EmitContext ec) { var ig = ec.ig; var local = ec.EmitStored(operand); var ret = ig.DefineLabel(); var done = ig.DefineLabel(); ec.EmitNullableHasValue(local); ig.Emit(OpCodes.Brfalse, ret); ec.EmitNullableGetValueOrDefault(local); ec.EmitCall(method); ec.EmitNullableNew(Type); ig.Emit(OpCodes.Br, done); ig.MarkLabel(ret); var temp = ig.DeclareLocal(Type); ec.EmitNullableInitialize(temp); ig.MarkLabel(done); }