This commit is contained in:
Mikhalkovich Stanislav 2018-12-07 23:10:40 +03:00
parent e2f1583058
commit 543d0b678a
8 changed files with 76 additions and 10 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3"; public const string Major = "3";
public const string Minor = "4"; public const string Minor = "4";
public const string Build = "2"; public const string Build = "2";
public const string Revision = "1888"; public const string Revision = "1889";
public const string MainVersion = Major + "." + Minor; public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%MINOR%=4
%REVISION%=1888
%COREVERSION%=2 %COREVERSION%=2
%REVISION%=1889
%MINOR%=4
%MAJOR%=3 %MAJOR%=3

Binary file not shown.

View file

@ -1 +1 @@
!define VERSION '3.4.2.1888' !define VERSION '3.4.2.1889'

View file

@ -375,10 +375,18 @@ namespace PascalABCCompiler.SyntaxTree
{ {
return new bin_expr(left, right, Operators.Greater); 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) public static bin_expr Less(expression left, expression right)
{ {
return new bin_expr(left, right, Operators.Less); 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) public static bin_expr LogicalAnd(expression left, expression right)
{ {

View file

@ -371,25 +371,61 @@ namespace SyntaxVisitors
//var ass1 = new var_statement(fn.loop_variable, fn.type_name, fn.initial_value); //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); //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 // frninja 05/06/16 - фиксим для !fn.create_variable
var ass1 = fn.create_loop_variable var ass1 = fn.create_loop_variable
? new var_statement(fn.loop_variable, fn.type_name, fn.initial_value) as statement ? new var_statement(fn.loop_variable, fn.type_name, fn.initial_value) as statement
: new assign(fn.loop_variable, 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) ? var if0 = new if_node((fn.cycle_type == for_cycle_type.to) ?
bin_expr.Greater(fn.loop_variable, fn.finish_value) : bin_expr.Greater(fn.loop_variable, fn.finish_value) :
bin_expr.Less(fn.loop_variable, fn.finish_value), gotoBreak); bin_expr.Less(fn.loop_variable, fn.finish_value), gotoBreak);
var lb2 = new labeled_statement(gotoStart.label, if0); var if1 = new if_node((fn.cycle_type == for_cycle_type.to) ?
var lb1 = new labeled_statement(gotoBreak.label); 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) ? var Inc = new procedure_call(new method_call((fn.cycle_type == for_cycle_type.to) ?
new ident("Inc") : new ident("Inc") :
new ident("Dec"), new expression_list(fn.loop_variable))); new ident("Dec"), new expression_list(fn.loop_variable)));
var lbInc = new labeled_statement(gotoContinue.label, Inc); 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 // в declarations ближайшего блока добавить описание labels
block bl = listNodes.FindLast(x => x is block) as block; block bl = listNodes.FindLast(x => x is block) as block;

View 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.

View file

@ -12115,8 +12115,6 @@ namespace PascalABCCompiler.TreeConverter
{ {
if (tn == SystemLibrary.SystemLibrary.void_type) if (tn == SystemLibrary.SystemLibrary.void_type)
AddError(loc, "TYPE_{0}_NOT_VALID", tn.name); 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) 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); type_node tn = ret.visit(_new_expr.type);
//if (tn == SystemLibrary.SystemLibrary.void_type) //if (tn == SystemLibrary.SystemLibrary.void_type)
// AddError(new VoidNotValid(get_location(_new_expr.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)); check_for_type_allowed(tn,get_location(_new_expr.type));
location loc = get_location(_new_expr); location loc = get_location(_new_expr);
expressions_list exprs = null; expressions_list exprs = null;