bug fix #2335
This commit is contained in:
parent
cb6af182a8
commit
80384a89dd
|
|
@ -6,6 +6,6 @@ namespace PascalABCCompiler.PCU
|
|||
{
|
||||
public static class PCUFileFormatVersion
|
||||
{
|
||||
public static System.Int16 Version = 115;
|
||||
public static System.Int16 Version = 116;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2129,6 +2129,8 @@ namespace PascalABCCompiler.PCU
|
|||
//Читаем, является ли тип интерфейсом
|
||||
bool type_is_interface = (br.ReadByte() == 1);
|
||||
|
||||
bool type_is_class = (br.ReadByte() == 1);
|
||||
|
||||
//Читаем, является ли тип делегатом
|
||||
bool type_is_delegate = (br.ReadByte() == 1);
|
||||
|
||||
|
|
@ -2165,21 +2167,14 @@ namespace PascalABCCompiler.PCU
|
|||
}
|
||||
AddMember(ctn, offset);
|
||||
|
||||
int_members.Insert(0,ctn);
|
||||
int_members.Insert(0, ctn);
|
||||
common_type_node saved_ctn = ctn;
|
||||
type_node base_type = GetTypeReference();
|
||||
bool is_value_type = br.ReadBoolean();
|
||||
|
||||
//Читаем поддерживаемые интерфейсы
|
||||
List<SemanticTree.ITypeNode> interf_implemented = ReadImplementingInterfaces();
|
||||
//int interf_count = br.ReadInt32();
|
||||
//List<SemanticTree.ITypeNode> interf_implemented = new List<SemanticTree.ITypeNode>(interf_count);
|
||||
//for (int i = 0; i < interf_count; i++)
|
||||
//{
|
||||
// interf_implemented.Add(GetTypeReference());
|
||||
//}
|
||||
constant_node low_val=null;
|
||||
constant_node upper_val=null;
|
||||
constant_node low_val = null;
|
||||
constant_node upper_val = null;
|
||||
SemanticTree.type_access_level tal = (SemanticTree.type_access_level)br.ReadByte();
|
||||
SemanticTree.type_special_kind tsk = (SemanticTree.type_special_kind)br.ReadByte();
|
||||
ctn.SetIsSealed(br.ReadBoolean());
|
||||
|
|
@ -2203,12 +2198,10 @@ namespace PascalABCCompiler.PCU
|
|||
}
|
||||
iscope.TopInterfaceScopeArray = interf_scopes.ToArray();
|
||||
}
|
||||
//ctn = new wrapped_common_type_node(this, base_type, name, tal, cun.namespaces[0], scope, null, offset);
|
||||
//AddMember(ctn, offset);
|
||||
//int_members.Insert(0,ctn);
|
||||
ctn.SetBaseType(base_type);
|
||||
ctn.IsInterface = type_is_interface;
|
||||
ctn.IsDelegate = type_is_delegate;
|
||||
ctn.is_class = type_is_class;
|
||||
ctn.ImplementingInterfaces.AddRange(interf_implemented);
|
||||
ctn.internal_is_value = is_value_type;
|
||||
ctn.type_special_kind = tsk;
|
||||
|
|
@ -2252,36 +2245,31 @@ namespace PascalABCCompiler.PCU
|
|||
}
|
||||
br.ReadInt32();//comprehensive unit;
|
||||
ctn.attributes.AddRange(GetAttributes());
|
||||
//common_namespace_node ns = cun.namespaces[0];
|
||||
byte flag = br.ReadByte();
|
||||
int def_prop_off=0;
|
||||
int def_prop_off = 0;
|
||||
if (flag == 1)
|
||||
{
|
||||
def_prop_off = br.ReadInt32();
|
||||
}
|
||||
location loc= ReadDebugInfo();
|
||||
location loc = ReadDebugInfo();
|
||||
ctn.loc = loc;
|
||||
if (type_is_delegate)
|
||||
{
|
||||
SystemLibrary.SystemLibrary.type_constructor.AddOperatorsToDelegate(ctn, loc);
|
||||
}
|
||||
|
||||
//создаем scope для класса
|
||||
//ctn = new wrapped_common_type_node(this, base_type, name, tal, ns, scope, loc, offset);
|
||||
//members[offset] = ctn;
|
||||
//AddMember(ctn, offset);
|
||||
class_names[ctn] = AddClassMemberNames(scope);
|
||||
if (flag == 1) ctn.default_property = GetPropertyNode(def_prop_off);
|
||||
//ivan
|
||||
if (ctn.IsEnum)
|
||||
{
|
||||
AddEnumOperators(ctn);
|
||||
MakeTypeAsOrdinal(ctn,0,class_names.Count);
|
||||
MakeTypeAsOrdinal(ctn, 0, class_names.Count);
|
||||
ctn.add_additional_enum_operations();
|
||||
}
|
||||
if (ctn.type_special_kind == SemanticTree.type_special_kind.diap_type)
|
||||
{
|
||||
type_constructor.add_convertions_to_diap(ctn,low_val,upper_val);
|
||||
type_constructor.add_convertions_to_diap(ctn, low_val, upper_val);
|
||||
}
|
||||
if (ctn.type_special_kind == SemanticTree.type_special_kind.array_kind)
|
||||
{
|
||||
|
|
@ -2295,7 +2283,7 @@ namespace PascalABCCompiler.PCU
|
|||
|
||||
}
|
||||
//RestoreAllFields(ctn);
|
||||
if(!waited_types_to_restore_fields.Contains(ctn))
|
||||
if (!waited_types_to_restore_fields.Contains(ctn))
|
||||
waited_types_to_restore_fields.Add(ctn);
|
||||
|
||||
if (type_is_delegate)
|
||||
|
|
@ -2309,11 +2297,6 @@ namespace PascalABCCompiler.PCU
|
|||
ctn.add_internal_interface(dii);
|
||||
}
|
||||
|
||||
/*if (ctn.type_special_kind == PascalABCCompiler.SemanticTree.type_special_kind.array_wrapper)
|
||||
{
|
||||
bounded_array_interface bai = new bounded_array_interface(oti_indexer, ctn.element_type, cpn, oti_indexer.lower_value.type, int_arr);
|
||||
ctn.add_internal_interface(bai);
|
||||
}*/
|
||||
if (type_is_interface)
|
||||
{
|
||||
RestoreAllFields(ctn);
|
||||
|
|
@ -2333,10 +2316,6 @@ namespace PascalABCCompiler.PCU
|
|||
}
|
||||
}
|
||||
}
|
||||
/*if (ctn.type_special_kind == SemanticTree.type_special_kind.array_wrapper)
|
||||
{
|
||||
RestoreAllFields(ctn);
|
||||
}*/
|
||||
|
||||
return ctn;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2508,11 +2508,7 @@ namespace PascalABCCompiler.PCU
|
|||
bw.Write(GetNameIndex(type));
|
||||
else
|
||||
bw.Write(type.name);
|
||||
/*if (type.base_type != null)
|
||||
WriteTypeReference(type.base_type);
|
||||
else*/
|
||||
|
||||
//Пишем, является ли данный класс интерфейсом
|
||||
if (type.IsInterface)
|
||||
{
|
||||
bw.Write((byte)1);
|
||||
|
|
@ -2522,7 +2518,15 @@ namespace PascalABCCompiler.PCU
|
|||
bw.Write((byte)0);
|
||||
}
|
||||
|
||||
//Пишем, является ли данный класс делегатом
|
||||
if (type.is_class)
|
||||
{
|
||||
bw.Write((byte)1);
|
||||
}
|
||||
else
|
||||
{
|
||||
bw.Write((byte)0);
|
||||
}
|
||||
|
||||
if (type.IsDelegate)
|
||||
{
|
||||
bw.Write((byte)1);
|
||||
|
|
@ -2553,9 +2557,6 @@ namespace PascalABCCompiler.PCU
|
|||
|
||||
bw.Seek(GetSizeOfReference(type.base_type), SeekOrigin.Current);
|
||||
|
||||
//(ssyy) На кой чёрт это надо?
|
||||
//WriteTypeReference(SystemLibrary.SystemLibrary.object_type);
|
||||
//WriteTypeReference(type.base_type);
|
||||
bw.Write(type.internal_is_value);
|
||||
|
||||
//Пишем поддерживаемые интерфейсы
|
||||
|
|
@ -2563,7 +2564,7 @@ namespace PascalABCCompiler.PCU
|
|||
//WriteImplementingInterfaces(type);
|
||||
int interface_impl_off = (int)bw.BaseStream.Position;
|
||||
int seek_off = sizeof(int);
|
||||
for (int k=0; k<type.ImplementingInterfaces.Count; k++)
|
||||
for (int k = 0; k < type.ImplementingInterfaces.Count; k++)
|
||||
seek_off += GetSizeOfReference(type.ImplementingInterfaces[k] as TreeRealization.type_node);
|
||||
bw.Seek(seek_off, SeekOrigin.Current);
|
||||
bw.Write((byte)type.type_access_level);
|
||||
|
|
@ -2572,6 +2573,7 @@ namespace PascalABCCompiler.PCU
|
|||
bw.Write(type.IsAbstract);
|
||||
bw.Write(type.IsStatic);
|
||||
bw.Write(type.IsPartial);
|
||||
|
||||
if (type.type_special_kind == SemanticTree.type_special_kind.diap_type)
|
||||
{
|
||||
ordinal_type_interface oti = type.get_internal_interface(internal_interface_kind.ordinal_interface) as ordinal_type_interface;
|
||||
|
|
@ -2584,7 +2586,7 @@ namespace PascalABCCompiler.PCU
|
|||
//Ограничители параметров
|
||||
WriteTypeParamsEliminations(type.generic_params);
|
||||
}
|
||||
if(CanWriteObject(type.element_type))
|
||||
if (CanWriteObject(type.element_type))
|
||||
WriteTypeReference(type.element_type);
|
||||
|
||||
bw.Write(GetUnitReference(type.comprehensive_namespace));
|
||||
|
|
@ -2599,36 +2601,36 @@ namespace PascalABCCompiler.PCU
|
|||
bw.Write(0);//default_property
|
||||
WriteDebugInfo(type.loc);
|
||||
//заполнение списка имен членов этого класса
|
||||
int num = type.const_defs.Count + type.fields.Count + type.properties.Count + type.methods.Count+type.events.Count;
|
||||
int num = type.const_defs.Count + type.fields.Count + type.properties.Count + type.methods.Count + type.events.Count;
|
||||
NameRef[] names = new NameRef[num];
|
||||
int pos = (int)bw.BaseStream.Position;
|
||||
int int_size = System.Runtime.InteropServices.Marshal.SizeOf(typeof(int));
|
||||
int size = int_size;
|
||||
int i=0,j=0;
|
||||
for (i=j; i<type.const_defs.Count+j; i++)
|
||||
int i = 0, j = 0;
|
||||
for (i = j; i < type.const_defs.Count + j; i++)
|
||||
{
|
||||
names[i] = new NameRef(type.const_defs[i - j].name, i);
|
||||
name_pool[type.const_defs[i - j]] = names[i];
|
||||
size += names[i].Size;
|
||||
}
|
||||
j=i;
|
||||
for (i=j; i<type.fields.Count+j; i++)
|
||||
j = i;
|
||||
for (i = j; i < type.fields.Count + j; i++)
|
||||
{
|
||||
names[i] = new NameRef(type.fields[i - j].name, i, convert_field_access_level(type.fields[i - j].field_access_level), type.fields[i - j].semantic_node_type);
|
||||
name_pool[type.fields[i - j]] = names[i];
|
||||
names[i].is_static = type.fields[i - j].polymorphic_state == SemanticTree.polymorphic_state.ps_static;
|
||||
size += names[i].Size;
|
||||
}
|
||||
j=i;
|
||||
for (i=j; i<type.properties.Count+j; i++)
|
||||
j = i;
|
||||
for (i = j; i < type.properties.Count + j; i++)
|
||||
{
|
||||
names[i] = new NameRef(type.properties[i - j].name, i, convert_field_access_level(type.properties[i - j].field_access_level), type.properties[i - j].semantic_node_type);
|
||||
name_pool[type.properties[i - j]] = names[i];
|
||||
names[i].is_static = type.properties[i - j].polymorphic_state == SemanticTree.polymorphic_state.ps_static;
|
||||
size += names[i].Size;
|
||||
}
|
||||
j=i;
|
||||
for (i=j; i<type.methods.Count+j; i++)
|
||||
j = i;
|
||||
for (i = j; i < type.methods.Count + j; i++)
|
||||
{
|
||||
names[i] = new NameRef(type.methods[i - j].name, i, convert_field_access_level(type.methods[i - j].field_access_level), type.methods[i - j].semantic_node_type);
|
||||
name_pool[type.methods[i - j]] = names[i];
|
||||
|
|
@ -2638,14 +2640,14 @@ namespace PascalABCCompiler.PCU
|
|||
names[i].is_static = type.methods[i - j].polymorphic_state == SemanticTree.polymorphic_state.ps_static && !type.methods[i - j].is_constructor;
|
||||
size += names[i].Size;
|
||||
}
|
||||
j=i;
|
||||
for (i=j; i<type.events.Count+j; i++)
|
||||
j = i;
|
||||
for (i = j; i < type.events.Count + j; i++)
|
||||
{
|
||||
names[i] = new NameRef(type.events[i - j].name, i, convert_field_access_level(type.events[i - j].field_access_level), type.events[i - j].semantic_node_type);
|
||||
name_pool[type.events[i - j]] = names[i];
|
||||
size += names[i].Size;
|
||||
}
|
||||
bw.BaseStream.Seek(size,SeekOrigin.Current);
|
||||
bw.BaseStream.Seek(size, SeekOrigin.Current);
|
||||
/*VisitConstantInTypeDefinitions(type);
|
||||
VisitFieldDefinitions(type);
|
||||
VisitMethodDefinitions(type);
|
||||
|
|
@ -2665,7 +2667,7 @@ namespace PascalABCCompiler.PCU
|
|||
bw.Write(names[i].offset);
|
||||
}
|
||||
bw.BaseStream.Seek(tmp,SeekOrigin.Begin);*/
|
||||
ClassInfo ci = new ClassInfo(pos, def_prop_off, base_class_off, interface_impl_off,names);
|
||||
ClassInfo ci = new ClassInfo(pos, def_prop_off, base_class_off, interface_impl_off, names);
|
||||
class_info[type] = ci;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -830,4 +830,13 @@ end;
|
|||
|
||||
{$endregion Utils}
|
||||
|
||||
///--
|
||||
procedure __InitModule__;
|
||||
begin
|
||||
end;
|
||||
|
||||
///--
|
||||
procedure __FinalizeModule__;
|
||||
begin
|
||||
end;
|
||||
end.
|
||||
|
|
@ -2776,5 +2776,13 @@ end;
|
|||
{$endregion}
|
||||
|
||||
//----------------------------------------
|
||||
///--
|
||||
procedure __InitModule__;
|
||||
begin
|
||||
end;
|
||||
|
||||
///--
|
||||
procedure __FinalizeModule__;
|
||||
begin
|
||||
end;
|
||||
end.
|
||||
|
|
@ -223,4 +223,15 @@ procedure Tr<T>(a: array of T; transform: T->T) := a.Transform(transform);
|
|||
function H<T>(Self: array of T): integer; extensionmethod := Self.High;
|
||||
|
||||
|
||||
///--
|
||||
procedure __InitModule__;
|
||||
begin
|
||||
end;
|
||||
|
||||
///--
|
||||
procedure __FinalizeModule__;
|
||||
begin
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
|
@ -755,4 +755,13 @@ end;
|
|||
|
||||
{$endregion}
|
||||
|
||||
///--
|
||||
procedure __InitModule__;
|
||||
begin
|
||||
end;
|
||||
|
||||
///--
|
||||
procedure __FinalizeModule__;
|
||||
begin
|
||||
end;
|
||||
end.
|
||||
7
TestSuite/units/u_questiondot1.pas
Normal file
7
TestSuite/units/u_questiondot1.pas
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
unit u_questiondot1;
|
||||
|
||||
type
|
||||
t1 = class end;
|
||||
|
||||
|
||||
end.
|
||||
7
TestSuite/usesunits/use_questiondot1.pas
Normal file
7
TestSuite/usesunits/use_questiondot1.pas
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
uses u_questiondot1;
|
||||
|
||||
begin
|
||||
var a: t1 := nil;
|
||||
var s := a?.ToString;
|
||||
assert(string.IsNullOrEmpty(s));
|
||||
end.
|
||||
Loading…
Reference in a new issue