This commit is contained in:
parent
dce5abc6b4
commit
c3160fe819
|
|
@ -10757,6 +10757,24 @@ namespace PascalABCCompiler.NETGenerator
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
value.condition.visit(this);
|
value.condition.visit(this);
|
||||||
|
if (value.condition.type.is_nullable_type)
|
||||||
|
{
|
||||||
|
|
||||||
|
tmp_lb = il.DeclareLocal(helper.GetTypeReference(value.type).tp);
|
||||||
|
il.Emit(OpCodes.Stloc, tmp_lb);
|
||||||
|
il.Emit(OpCodes.Ldloca, tmp_lb);
|
||||||
|
MethodInfo mi = null;
|
||||||
|
TypeInfo cond_ti = helper.GetTypeReference(value.condition.type);
|
||||||
|
if (value.condition.type is IGenericTypeInstance)
|
||||||
|
mi = TypeBuilder.GetMethod(cond_ti.tp, typeof(Nullable<>).GetMethod("get_HasValue"));
|
||||||
|
else
|
||||||
|
mi = cond_ti.tp.GetMethod("get_HasValue");
|
||||||
|
il.Emit(OpCodes.Call, mi);
|
||||||
|
il.Emit(OpCodes.Ldc_I4_0);
|
||||||
|
il.Emit(OpCodes.Ceq);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
tmp_lb = il.DeclareLocal(helper.GetTypeReference(value.type).tp);
|
tmp_lb = il.DeclareLocal(helper.GetTypeReference(value.type).tp);
|
||||||
il.Emit(OpCodes.Stloc, tmp_lb);
|
il.Emit(OpCodes.Stloc, tmp_lb);
|
||||||
il.Emit(OpCodes.Ldloc, tmp_lb);
|
il.Emit(OpCodes.Ldloc, tmp_lb);
|
||||||
|
|
@ -10764,6 +10782,8 @@ namespace PascalABCCompiler.NETGenerator
|
||||||
il.Emit(OpCodes.Ceq);
|
il.Emit(OpCodes.Ceq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
is_dot_expr = tmp_is_dot_expr;
|
is_dot_expr = tmp_is_dot_expr;
|
||||||
is_addr = tmp_is_addr;
|
is_addr = tmp_is_addr;
|
||||||
|
|
|
||||||
8
TestSuite/double_question3.pas
Normal file
8
TestSuite/double_question3.pas
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
begin
|
||||||
|
var i: integer?;
|
||||||
|
var x := i ?? 0;
|
||||||
|
assert(x.Value = 0);
|
||||||
|
i := 1;
|
||||||
|
x := i ?? 0;
|
||||||
|
assert(x.Value = 1);
|
||||||
|
end.
|
||||||
Loading…
Reference in a new issue