This commit is contained in:
parent
6e58bb53a4
commit
1521fe39c7
|
|
@ -9065,6 +9065,35 @@ namespace PascalABCCompiler.NETGenerator
|
|||
il.Emit(OpCodes.Call, mi_right);
|
||||
}
|
||||
EmitOperator(value);
|
||||
if (!(real_parameters[0] is IDefaultOperatorNode) && !(real_parameters[1] is IDefaultOperatorNode))
|
||||
{
|
||||
real_parameters[0].visit(this);
|
||||
if (real_parameters[0].type is IGenericTypeInstance)
|
||||
mi_left = TypeBuilder.GetMethod(ti_right.tp, typeof(Nullable<>).GetMethod("get_HasValue", new Type[] { }));
|
||||
else
|
||||
mi_left = ti_left.tp.GetMethod("get_HasValue", new Type[] { });
|
||||
il.Emit(OpCodes.Call, mi_left);
|
||||
real_parameters[1].visit(this);
|
||||
if (real_parameters[1].type is IGenericTypeInstance)
|
||||
mi_right = TypeBuilder.GetMethod(ti_right.tp, typeof(Nullable<>).GetMethod("get_HasValue", new Type[] { }));
|
||||
else
|
||||
mi_right = ti_right.tp.GetMethod("get_HasValue", new Type[] { });
|
||||
|
||||
il.Emit(OpCodes.Call, mi_right);
|
||||
if (value.basic_function.basic_function_type == basic_function_type.objnoteq)
|
||||
{
|
||||
il.Emit(OpCodes.Ceq);
|
||||
il.Emit(OpCodes.Ldc_I4_0);
|
||||
il.Emit(OpCodes.Ceq);
|
||||
il.Emit(OpCodes.Or);
|
||||
}
|
||||
else
|
||||
{
|
||||
il.Emit(OpCodes.Ceq);
|
||||
il.Emit(OpCodes.And);
|
||||
}
|
||||
|
||||
}
|
||||
is_dot_expr = tmp_dot;
|
||||
if (tmp_dot)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@
|
|||
a[0,0] := 1;
|
||||
assert(a[0,0] = 1);
|
||||
a[0,0] := nil;
|
||||
assert(a[0,0] = 0);
|
||||
assert(a[0,0] <> 0);
|
||||
assert(a[0,0] = nil);
|
||||
var a2 : array of array of System.Nullable<integer>;
|
||||
SetLength(a2,1);
|
||||
SetLength(a2[0],1);
|
||||
a2[0,0] := nil;
|
||||
assert(a2[0,0] = 0);
|
||||
assert(a2[0,0] <> 0);
|
||||
assert(a2[0,0] = nil);
|
||||
end.
|
||||
8
TestSuite/nullable5.pas
Normal file
8
TestSuite/nullable5.pas
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
begin
|
||||
var i: integer? := nil;
|
||||
var j: integer? := nil;
|
||||
assert(not (i = 0));
|
||||
assert(i <> 0);
|
||||
assert(not (i <> j));
|
||||
assert(i = j);
|
||||
end.
|
||||
Loading…
Reference in a new issue