bug fix in initializing of static fields

This commit is contained in:
Бондарев Иван 2015-08-18 12:15:22 +02:00
parent ec3421340f
commit db4196a9c9
2 changed files with 17 additions and 1 deletions

13
TestSuite/classfield1.pas Normal file
View file

@ -0,0 +1,13 @@
type
cls = class
class i: integer := 3;
j: integer := 4;
class obj: object := new object;
end;
begin
assert(cls.i = 3);
assert(cls.obj <> nil);
var obj := new cls;
assert(obj.j = 4);
end.

View file

@ -195,7 +195,10 @@ namespace PascalABCCompiler.TreeConverter
case semantic_node_type.local_variable:
return new local_variable_reference((local_variable)vd, 0, loc);
case semantic_node_type.class_field:
return new class_field_reference((class_field)vd, syntax_tree_visitor.GetCurrentObjectReference((vd as class_field).cont_type.Scope,vd,loc), loc);
if (vd.polymorphic_state == polymorphic_state.ps_static)
return new static_class_field_reference((class_field)vd, loc);
else
return new class_field_reference((class_field)vd, syntax_tree_visitor.GetCurrentObjectReference((vd as class_field).cont_type.Scope,vd,loc), loc);
case semantic_node_type.namespace_variable:
return new namespace_variable_reference((namespace_variable)vd, loc);
case semantic_node_type.local_block_variable: