diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index 085f2e977..1bf5d61ef 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -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); } diff --git a/TestSuite/power1.pas b/TestSuite/power1.pas index b5e2f6486..d541748a6 100644 --- a/TestSuite/power1.pas +++ b/TestSuite/power1.pas @@ -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. \ No newline at end of file diff --git a/TestSuite/question3.pas b/TestSuite/question3.pas new file mode 100644 index 000000000..b05b24e83 --- /dev/null +++ b/TestSuite/question3.pas @@ -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. \ No newline at end of file diff --git a/TestSuite/question4.pas b/TestSuite/question4.pas new file mode 100644 index 000000000..8d1357163 --- /dev/null +++ b/TestSuite/question4.pas @@ -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. \ No newline at end of file diff --git a/TreeConverter/TreeRealization/Expressions.cs b/TreeConverter/TreeRealization/Expressions.cs index 84d3f2d5b..4c930f402 100644 --- a/TreeConverter/TreeRealization/Expressions.cs +++ b/TreeConverter/TreeRealization/Expressions.cs @@ -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 diff --git a/bin/TestRunner.exe b/bin/TestRunner.exe index abd3aa0aa..2decbf7b5 100644 Binary files a/bin/TestRunner.exe and b/bin/TestRunner.exe differ diff --git a/bin/TestRunner.pas b/bin/TestRunner.pas index 78948df56..83ee50dbe 100644 --- a/bin/TestRunner.pas +++ b/bin/TestRunner.pas @@ -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;