ABCPascal.cs
ABCPascalYacc.cs вернул на место
This commit is contained in:
Mikhalkovich Stanislav 2020-06-18 23:17:13 +03:00
parent ee3394ca12
commit c9617a5afc
16 changed files with 10478 additions and 26 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "6";
public const string Build = "3";
public const string Revision = "2509";
public const string Revision = "2511";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%MINOR%=6
%REVISION%=2509
%REVISION%=2511
%COREVERSION%=3
%MAJOR%=3

Binary file not shown.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1 +1 @@
3.6.3.2509
3.6.3.2511

View file

@ -1 +1 @@
!define VERSION '3.6.3.2509'
!define VERSION '3.6.3.2511'

View file

@ -1,10 +1,12 @@
// Это холостой тест. В оригинале было where G: integer но это мы запретили
type cl<T> = class where T: constructor;
public procedure pr<G>(a: IEnumerable<G>); where G: integer;
public procedure pr<G>(a: IEnumerable<G>); where G: record;
begin
var tt := a.OrderBy(x -> begin var d: T := new T(); result := x end).ToList;
assert(tt[0] = 1);
assert(tt[1] = 2);
assert(tt[2] = 3);
//assert(tt[0] = 1);
//assert(tt[1] = 2);
//assert(tt[2] = 3);
end;
end;

View file

@ -1,24 +1,25 @@
type cl1<T> = class where T: integer, constructor;
// Это холостой тест. В оригинале было where G: integer но это мы запретили
type cl1<T> = class where T: record, constructor;
private
k: T:= new T();
public
function r<G>(gg: G): T; where G: integer;
function r<G>(gg: G): T; where G: record;
begin
begin
var l := Seq(1,2,3);
var fff := 5;
var tttt := l.Select(x -> begin fff := fff + 1; result := gg + k + fff + x end).ToList();
assert(tttt[0] = 72);
assert(tttt[1] = 74);
assert(tttt[2] = 76);
//var tttt := l.Select(x -> begin fff := fff + 1; result := gg + k + fff + x end).ToList();
//assert(tttt[0] = 72);
//assert(tttt[1] = 74);
//assert(tttt[2] = 76);
end;
begin
var l := Seq(1,2,3);
var fff := 5;
var tttt := l.Select(x -> gg + k + fff).ToList();
assert(tttt[0] = 70);
assert(tttt[1] = 70);
assert(tttt[2] = 70);
//var tttt := l.Select(x -> gg + k + fff).ToList();
//assert(tttt[0] = 70);
//assert(tttt[1] = 70);
//assert(tttt[2] = 70);
end;
end;
public constructor(a:T);
@ -26,7 +27,7 @@ type cl1<T> = class where T: integer, constructor;
end;
end;
procedure pr<T>(a: T); where T: integer, constructor;
procedure pr<T>(a: T); where T: record, constructor;
begin
var g: cl1<T> := new cl1<T>(a);
g.r(65);

View file

@ -1,8 +1,9 @@
procedure p<T>(e: IEnumerable<T>); where T:integer, constructor;
// Это холостой тест. В оригинале было where G: integer но это мы запретили
procedure p<T>(e: IEnumerable<T>); where T:record, constructor;
begin
var kkk := 5;
var rr := new List<integer>;
for var i := 1 to 4 do
{for var i := 1 to 4 do
rr.Add(e.Select(x->begin
var tt: T := new T();
var jj := e is IEnumerable<T>;
@ -12,7 +13,7 @@ begin
assert(rr[0] = 11);
assert(rr[1] = 12);
assert(rr[2] = 13);
assert(rr[3] = 14);
assert(rr[3] = 14);}
end;
begin

View file

@ -6,7 +6,7 @@
a: T1;
end;
t2<T>=class(t1<T>) where T: t0; end;
t2<T>=class(t1<T>) where T: record; end;
begin
var a := new t2<t0>;

View file

@ -12541,6 +12541,8 @@ namespace PascalABCCompiler.TreeConverter
}
else
{
if (spec_type.is_value)
AddError(get_location(specificators[i]), "RECORD_CAN_NOT_BE_USED_AS_PARENT_SPECIFICATOR");
//Тип-предок
if (spec_type == SystemLibrary.SystemLibrary.object_type)
{

View file

@ -151,14 +151,17 @@ namespace PascalABCCompiler.TreeRealization
{
return new SimpleSemanticError(null, "PARAMETER_{0}_MUST_BE_REFERENCE_TYPE", tn.PrintableName);
}
if (gpe.is_value && (!tn.is_value || tn.BaseFullName != null && tn.BaseFullName.StartsWith("System.Nullable")) && !tn.is_generic_parameter)
if (gpe.is_value && (!tn.is_value || tn.BaseFullName != null && tn.BaseFullName.StartsWith("System.Nullable")) /*&& !tn.is_generic_parameter*/)
{
return new SimpleSemanticError(null, "PARAMETER_{0}_MUST_BE_VALUE_TYPE", tn.PrintableName);
}
if (gpe.base_class != null && gpe.base_class != SystemLibrary.SystemLibrary.object_type)
if (gpe.base_class != null && gpe.base_class != SystemLibrary.SystemLibrary.object_type && !tn.is_value)
{
type_node base_type = generic_convertions.determine_type(gpe.base_class, tparams, method_param_types);
if (base_type != tn && !type_table.is_derived(base_type, tn) && !tn.is_generic_parameter)
// Если tn не соврадает со своим базовым типом и
// tn не наследуется от base_type и
// tn - не generic параметр - закомментировал
if (base_type != tn && !type_table.is_derived(base_type, tn) /*&& !tn.is_generic_parameter*/)
{
return new SimpleSemanticError(null, "PARAMETER_{0}_MUST_BE_DERIVED_FROM_{1}", tn.PrintableName, base_type.name);
}

View file

@ -53,6 +53,7 @@ PARENT_SPECIFICATOR_MUST_BE_FIRST=The parent constraint must be the first constr
CLASS_OR_RECORD_SPECIFICATOR_MUST_BE_FIRST=The class/record constraint must be the first constrained specified
CONSTRUCTOR_SPECIFICATOR_MUST_BE_LAST=The constructor constraint must be the last constrained specified
OBJECT_CAN_NOT_BE_USED_AS_PARENT_SPECIFICATOR=Constraint cannot be special class 'object'
RECORD_CAN_NOT_BE_USED_AS_PARENT_SPECIFICATOR=Constraint cannot be record
TYPE_{0}_DERIVED_FROM_ITSELF=Circular base class dependency
AMBIGUITY_BETWEEN_NAMES_{0}_AND_{1}=Äâóñìûñëåííîñòü ìåæäó èìåíàìè {0} è {1}
POINTERS_OF_GENERIC_PARAMETERS_NOT_ALLOWED=Cannot declare a pointer to generic parameter

View file

@ -53,6 +53,7 @@ PARENT_SPECIFICATOR_MUST_BE_FIRST=Спецификатор предка долж
CLASS_OR_RECORD_SPECIFICATOR_MUST_BE_FIRST=Спецификатор class/record должен быть первым в списке
CONSTRUCTOR_SPECIFICATOR_MUST_BE_LAST=Спецификатор constructor должен быть последним в списке
OBJECT_CAN_NOT_BE_USED_AS_PARENT_SPECIFICATOR=Тип object не может быть использован для указания предка шаблонного параметра
RECORD_CAN_NOT_BE_USED_AS_PARENT_SPECIFICATOR=Тип записи не может быть использован для указания предка шаблонного параметра
TYPE_{0}_DERIVED_FROM_ITSELF=Тип {0} наследуется циклически от самого себя
AMBIGUITY_BETWEEN_NAMES_{0}_AND_{1}=Двусмысленность между именами {0} и {1}
POINTERS_OF_GENERIC_PARAMETERS_NOT_ALLOWED=Указатели на параметр generic-типа недопустимы