fix #2667
This commit is contained in:
parent
3d9be59793
commit
7f2776dbe3
|
|
@ -835,15 +835,7 @@ namespace PascalABCCompiler.NETGenerator
|
||||||
ConvertGenericFunctionInstance(igfi);
|
ConvertGenericFunctionInstance(igfi);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int iii = 0; iii < cnns.Length; iii++)
|
|
||||||
{
|
|
||||||
if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.document.file_name];
|
|
||||||
cur_type = NamespacesTypes[cnns[iii]];
|
|
||||||
cur_unit_type = NamespacesTypes[cnns[iii]];
|
|
||||||
//генерим инциализацию для полей
|
|
||||||
foreach (SemanticTree.ICommonTypeNode ctn in cnns[iii].types)
|
|
||||||
GenerateInitCodeForFields(ctn);
|
|
||||||
}
|
|
||||||
|
|
||||||
ConstructorBuilder unit_cci = null;
|
ConstructorBuilder unit_cci = null;
|
||||||
|
|
||||||
|
|
@ -899,6 +891,16 @@ namespace PascalABCCompiler.NETGenerator
|
||||||
cur_unit = tmp_unit_name;
|
cur_unit = tmp_unit_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int iii = 0; iii < cnns.Length; iii++)
|
||||||
|
{
|
||||||
|
if (save_debug_info) doc = sym_docs[cnns[iii].Location == null ? SourceFileName : cnns[iii].Location.document.file_name];
|
||||||
|
cur_type = NamespacesTypes[cnns[iii]];
|
||||||
|
cur_unit_type = NamespacesTypes[cnns[iii]];
|
||||||
|
//генерим инциализацию для полей
|
||||||
|
foreach (SemanticTree.ICommonTypeNode ctn in cnns[iii].types)
|
||||||
|
GenerateInitCodeForFields(ctn);
|
||||||
|
}
|
||||||
|
|
||||||
if (p.InitializationCode != null)
|
if (p.InitializationCode != null)
|
||||||
{
|
{
|
||||||
tmp_il = il;
|
tmp_il = il;
|
||||||
|
|
@ -4656,6 +4658,8 @@ namespace PascalABCCompiler.NETGenerator
|
||||||
{
|
{
|
||||||
//Console.WriteLine(is_in_unit);
|
//Console.WriteLine(is_in_unit);
|
||||||
//if (is_in_unit && helper.IsUsed(var)==false) return;
|
//if (is_in_unit && helper.IsUsed(var)==false) return;
|
||||||
|
if (helper.GetVariable(var) != null)
|
||||||
|
return;
|
||||||
TypeInfo ti = helper.GetTypeReference(var.type);
|
TypeInfo ti = helper.GetTypeReference(var.type);
|
||||||
FieldBuilder fb = cur_type.DefineField(var.name, ti.tp, FieldAttributes.Public | FieldAttributes.Static);
|
FieldBuilder fb = cur_type.DefineField(var.name, ti.tp, FieldAttributes.Public | FieldAttributes.Static);
|
||||||
helper.AddGlobalVariable(var, fb);
|
helper.AddGlobalVariable(var, fb);
|
||||||
|
|
|
||||||
14
TestSuite/classfield3.pas
Normal file
14
TestSuite/classfield3.pas
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
var x := 1;
|
||||||
|
|
||||||
|
type
|
||||||
|
t1 = static class
|
||||||
|
static o := x;
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
assert(x = 1);
|
||||||
|
x := 5;
|
||||||
|
assert(x = 5);
|
||||||
|
assert(t1.o = 5);
|
||||||
|
assert(x = 5);
|
||||||
|
end.
|
||||||
14
TestSuite/classfield4.pas
Normal file
14
TestSuite/classfield4.pas
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
type
|
||||||
|
t1 = static class
|
||||||
|
static o := 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var x := t1.o;
|
||||||
|
|
||||||
|
begin
|
||||||
|
assert(x = 1);
|
||||||
|
x := 5;
|
||||||
|
assert(x = 5);
|
||||||
|
assert(t1.o = 1);
|
||||||
|
assert(x = 5);
|
||||||
|
end.
|
||||||
Loading…
Reference in a new issue