This commit is contained in:
Бондарев Иван 2018-01-30 20:39:20 +01:00
parent 07e102cd91
commit d200e3d616
7 changed files with 85 additions and 15 deletions

View file

@ -9846,9 +9846,15 @@ namespace PascalABCCompiler.NETGenerator
is_addr = tmp_is_addr;
il.Emit(OpCodes.Brfalse, FalseLabel);
value.ret_if_true.visit(this);
var ti = helper.GetTypeReference(value.ret_if_true.type);
if (ti != null)
EmitBox(value.ret_if_true, ti.tp);
il.Emit(OpCodes.Br, EndLabel);
il.MarkLabel(FalseLabel);
value.ret_if_false.visit(this);
ti = helper.GetTypeReference(value.ret_if_false.type);
if (ti != null)
EmitBox(value.ret_if_false, ti.tp);
il.MarkLabel(EndLabel);
}

View file

@ -1,20 +1,21 @@
const r = 3**2;
const
r = 3 ** 2;
begin
assert(round(2**3)=8);
assert(round(3 * 2**3)=24);
assert(round(2**3 * 3)=24);
assert(round(2.0**3)=8);
assert(round(2**3.0)=8);
assert(round(-2**2)=4);
assert(round(-(2**2))=-4);
assert(round(2 ** 3) = 8);
assert(round(3 * 2 ** 3) = 24);
assert(round(2 ** 3 * 3) = 24);
assert(round(2.0 ** 3) = 8);
assert(round(2 ** 3.0) = 8);
assert(round(-2 ** 2) = 4);
assert(round(-(2 ** 2)) = -4);
var b: byte := 2;
assert(round(b**2) = 4);
assert(abs(2**-2-0.25) < 0.0001);
var i := round(2**3);
assert(round(b ** 2) = 4);
assert(abs(2 ** -2 - 0.25) < 0.0001);
var i := round(2 ** 3);
assert(i = 8);
assert(round(r) = 9);
var bi := new BigInteger(3);
assert(bi**2 = 9);
assert(bi ** 2 = 9);
var bi2 := bi ** 2;
end.

44
TestSuite/question3.pas Normal file
View file

@ -0,0 +1,44 @@
var i: integer;
type
I1 = interface
procedure p1;
end;
R1 = record(I1)
public procedure p1;
begin
Inc(i);
end;
public constructor;
begin
end;
end;
R2 = record(I1)
public next1: I1;
public next2: I1;
public procedure p1;
begin
next1.p1;
next2.p1;
end;
public constructor(b:boolean);
begin
next1 := b? I1(new R2(false)) : I1(new R1);
next2 := b? I1(new R2(false)) : I1(new R1);
end;
end;
begin
var a := new R2(true);
a.p1;
assert(i = 4);
end.

9
TestSuite/question4.pas Normal file
View file

@ -0,0 +1,9 @@
begin
var o: object;
var b := true;
o := b ? 1 : 2;
assert(integer(o) = 1);
b := false;
o := b ? 1 : 2;
assert(integer(o) = 2);
end.

View file

@ -273,6 +273,10 @@ namespace PascalABCCompiler.TreeRealization
this._condition = condition;
this._ret_if_true = ret_if_true;
this._ret_if_false = ret_if_false;
/*if (ret_if_true is null_const_node)
this.conversion_type = ret_if_false.conversion_type;
else
this.conversion_type = ret_if_true.conversion_type;*/
}
public expression_node internal_condition

Binary file not shown.

View file

@ -1,4 +1,4 @@
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// Copyright (c) Ivan Bondarev, Stanislav Mihalkovich (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
{$reference Compiler.dll}
{$reference CodeCompletion.dll}
@ -60,6 +60,8 @@ begin
if comp.ErrorsList[0].GetType() = typeof(PascalABCCompiler.Errors.CompilerInternalError) then
System.Windows.Forms.MessageBox.Show('Compilation of '+files[i]+' failed'+System.Environment.NewLine+comp.ErrorsList[0].ToString());
end;
if i mod 20 = 0 then
System.GC.Collect();
end;
end;
@ -91,6 +93,8 @@ begin
System.Windows.Forms.MessageBox.Show('Compilation of '+files[i]+' failed'+System.Environment.NewLine+comp.ErrorsList[0].ToString());
Halt();
end;
if i mod 20 = 0 then
System.GC.Collect();
end;
end;
@ -121,6 +125,8 @@ begin
System.Windows.Forms.MessageBox.Show('Compilation of '+files[i]+' failed'+System.Environment.NewLine+comp.ErrorsList[0].ToString());
Halt();
end;
if i mod 20 = 0 then
System.GC.Collect();
end;
end;
@ -149,7 +155,7 @@ begin
Halt();
end;
end;
System.GC.Collect;
end;
procedure CompileAllUsesUnits;
@ -176,7 +182,7 @@ begin
Halt();
end;
end;
System.GC.Collect;
end;
procedure CopyPCUFiles;