parent
e2f1583058
commit
543d0b678a
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "4";
|
||||
public const string Build = "2";
|
||||
public const string Revision = "1888";
|
||||
public const string Revision = "1889";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%MINOR%=4
|
||||
%REVISION%=1888
|
||||
%COREVERSION%=2
|
||||
%REVISION%=1889
|
||||
%MINOR%=4
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.4.2.1888'
|
||||
!define VERSION '3.4.2.1889'
|
||||
|
|
|
|||
|
|
@ -375,10 +375,18 @@ namespace PascalABCCompiler.SyntaxTree
|
|||
{
|
||||
return new bin_expr(left, right, Operators.Greater);
|
||||
}
|
||||
public static bin_expr GreaterEqual(expression left, expression right)
|
||||
{
|
||||
return new bin_expr(left, right, Operators.GreaterEqual);
|
||||
}
|
||||
public static bin_expr Less(expression left, expression right)
|
||||
{
|
||||
return new bin_expr(left, right, Operators.Less);
|
||||
}
|
||||
public static bin_expr LessEqual(expression left, expression right)
|
||||
{
|
||||
return new bin_expr(left, right, Operators.LessEqual);
|
||||
}
|
||||
|
||||
public static bin_expr LogicalAnd(expression left, expression right)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -371,25 +371,61 @@ namespace SyntaxVisitors
|
|||
//var ass1 = new var_statement(fn.loop_variable, fn.type_name, fn.initial_value);
|
||||
//var ass2 = new var_statement(endtemp, fn.type_name, fn.finish_value);
|
||||
|
||||
// Исправления в связи с #1254 (новый алгоритм)
|
||||
// цикл for i:=a to b do
|
||||
// i := a
|
||||
// if i > b then goto break
|
||||
//Start: stmts
|
||||
// if i >= b then goto break
|
||||
//Continue: Inc(i)
|
||||
// goto Start
|
||||
//Break:
|
||||
|
||||
// цикл for i:=a downto b do
|
||||
// i := a
|
||||
// if i < b then goto break
|
||||
//Start: stmts
|
||||
// if i <= b then goto break
|
||||
//Continue: Dec(i)
|
||||
// goto Start
|
||||
//Break:
|
||||
|
||||
// frninja 05/06/16 - фиксим для !fn.create_variable
|
||||
var ass1 = fn.create_loop_variable
|
||||
? new var_statement(fn.loop_variable, fn.type_name, fn.initial_value) as statement
|
||||
: new assign(fn.loop_variable, fn.initial_value) as statement;
|
||||
|
||||
|
||||
var if0 = new if_node((fn.cycle_type == for_cycle_type.to) ?
|
||||
bin_expr.Greater(fn.loop_variable, fn.finish_value) :
|
||||
bin_expr.Less(fn.loop_variable, fn.finish_value), gotoBreak);
|
||||
|
||||
var lb2 = new labeled_statement(gotoStart.label, if0);
|
||||
var lb1 = new labeled_statement(gotoBreak.label);
|
||||
var if1 = new if_node((fn.cycle_type == for_cycle_type.to) ?
|
||||
bin_expr.GreaterEqual(fn.loop_variable, fn.finish_value) :
|
||||
bin_expr.LessEqual(fn.loop_variable, fn.finish_value), gotoBreak);
|
||||
|
||||
var lb1 = new labeled_statement(gotoStart.label);
|
||||
var lb2 = new labeled_statement(gotoBreak.label); // пустой оператор
|
||||
var Inc = new procedure_call(new method_call((fn.cycle_type == for_cycle_type.to) ?
|
||||
new ident("Inc") :
|
||||
new ident("Dec"), new expression_list(fn.loop_variable)));
|
||||
|
||||
var lbInc = new labeled_statement(gotoContinue.label, Inc);
|
||||
|
||||
ReplaceStatement(fn, SeqStatements(ass1, lb2, fn.statements, lbInc, gotoStart, lb1));
|
||||
ReplaceStatement(fn, SeqStatements(ass1, if0, lb1, fn.statements, if1, lbInc, gotoStart, lb2));
|
||||
|
||||
/*var if0 = new if_node((fn.cycle_type == for_cycle_type.to) ?
|
||||
bin_expr.Greater(fn.loop_variable, fn.finish_value) :
|
||||
bin_expr.Less(fn.loop_variable, fn.finish_value), gotoBreak);
|
||||
|
||||
var lb2 = new labeled_statement(gotoStart.label, if0);
|
||||
var lb1 = new labeled_statement(gotoBreak.label); // пустой оператор
|
||||
var Inc = new procedure_call(new method_call((fn.cycle_type == for_cycle_type.to) ?
|
||||
new ident("Inc") :
|
||||
new ident("Dec"), new expression_list(fn.loop_variable)));
|
||||
|
||||
var lbInc = new labeled_statement(gotoContinue.label, Inc);
|
||||
|
||||
ReplaceStatement(fn, SeqStatements(ass1, lb2, fn.statements, lbInc, gotoStart, lb1));*/
|
||||
|
||||
// в declarations ближайшего блока добавить описание labels
|
||||
block bl = listNodes.FindLast(x => x is block) as block;
|
||||
|
|
|
|||
22
TestSuite/yield_byte_boolean.pas
Normal file
22
TestSuite/yield_byte_boolean.pas
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
function fff: sequence of byte;
|
||||
begin
|
||||
for var b: byte := 0 to byte.MaxValue do
|
||||
yield b
|
||||
end;
|
||||
|
||||
function fff1: sequence of byte;
|
||||
begin
|
||||
for var b: byte := byte.MaxValue downto 0 do
|
||||
yield b
|
||||
end;
|
||||
|
||||
function fff2: sequence of boolean;
|
||||
begin
|
||||
for var b := False to True do
|
||||
yield b
|
||||
end;
|
||||
|
||||
begin
|
||||
Assert(fff.SequenceEqual(fff1.Reverse));
|
||||
Assert(fff2.SequenceEqual(Seq(False,True)));
|
||||
end.
|
||||
|
|
@ -12115,8 +12115,6 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
if (tn == SystemLibrary.SystemLibrary.void_type)
|
||||
AddError(loc, "TYPE_{0}_NOT_VALID", tn.name);
|
||||
if (tn.IsDelegate)
|
||||
AddError(loc, "CONSTRUCTOR_CALL_FOR_DELEGATE_TYPES_IS_FORBIDDEN");
|
||||
}
|
||||
|
||||
private void check_cycle_inheritance(common_type_node cnode, type_node base_of_cnode)
|
||||
|
|
@ -18282,6 +18280,8 @@ namespace PascalABCCompiler.TreeConverter
|
|||
type_node tn = ret.visit(_new_expr.type);
|
||||
//if (tn == SystemLibrary.SystemLibrary.void_type)
|
||||
// AddError(new VoidNotValid(get_location(_new_expr.type)));
|
||||
if (tn.IsDelegate)
|
||||
AddError(get_location(_new_expr), "CONSTRUCTOR_CALL_FOR_DELEGATE_TYPES_IS_FORBIDDEN");
|
||||
check_for_type_allowed(tn,get_location(_new_expr.type));
|
||||
location loc = get_location(_new_expr);
|
||||
expressions_list exprs = null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue