This commit is contained in:
miks1965 2017-01-10 21:18:48 +03:00
commit 67b9159df5
3 changed files with 49 additions and 5 deletions

View file

@ -127,6 +127,7 @@ namespace PascalABCCompiler.NETGenerator
protected CompilerOptions comp_opt = new CompilerOptions();//опции компилятора
protected Dictionary<string, ISymbolDocumentWriter> sym_docs = new Dictionary<string, ISymbolDocumentWriter>();//таблица отладочных документов
protected bool is_constructor = false;//флаг, переводим ли мы конструктор
protected bool init_call_awaited = false;
protected bool save_debug_info = false;
protected bool add_special_debug_variables = false;
protected bool make_next_spoint = true;
@ -5782,15 +5783,17 @@ namespace PascalABCCompiler.NETGenerator
ConvertCommonFunctionConstantDefinitions(value.constants);
ConvertLocalVariables(value.var_definition_nodes);
//вызываем метод $Init$ для инициализации массивов и проч.
if (value.polymorphic_state != polymorphic_state.ps_static && value.common_comprehensive_type.base_type is ICompiledTypeNode && (value.common_comprehensive_type.base_type as ICompiledTypeNode).compiled_type == TypeFactory.ObjectType)
/*if (value.polymorphic_state != polymorphic_state.ps_static && value.common_comprehensive_type.base_type is ICompiledTypeNode && (value.common_comprehensive_type.base_type as ICompiledTypeNode).compiled_type == TypeFactory.ObjectType)
{
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Call, TypeFactory.ObjectType.GetConstructor(Type.EmptyTypes));
}
}*/
if (value.polymorphic_state != polymorphic_state.ps_static)
{
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Call, cur_ti.init_meth);
init_call_awaited = true;
//il.Emit(OpCodes.Ldarg_0);
//il.Emit(OpCodes.Call, cur_ti.init_meth);
}
//переводим тело
is_constructor = true;
@ -9182,6 +9185,12 @@ namespace PascalABCCompiler.NETGenerator
{
is_dot_expr = false;
}
if (init_call_awaited && !value.new_obj_awaited())
{
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Call, cur_ti.init_meth);
init_call_awaited = false;
}
}
//вызов откомпилированного конструктора
@ -9263,7 +9272,13 @@ namespace PascalABCCompiler.NETGenerator
{
is_dot_expr = false;
}
//\ssyy
//\ssyy
if (init_call_awaited && !value.new_obj_awaited())
{
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Call, cur_ti.init_meth);
init_call_awaited = false;
}
}
private bool TypeNeedToFix(ITypeNode type)

View file

@ -0,0 +1,5 @@
begin
var a := Arr(1,3,5,4,3);
var b := a.Println.ToArray;
assert(b[2] = 5);
end.

View file

@ -8975,6 +8975,30 @@ namespace PascalABCCompiler.TreeConverter
{
return new indefinite_reference(dn as indefinite_definition_node, get_location(id_right));
}
if (expected_delegate && en != null)
{
SymbolInfo tmp_si = si;
function_node tmp_fn = null;
bool has_empty_methods = false;
bool only_extension_methods = true;
while (tmp_si != null)
{
tmp_fn = tmp_si.sym_info as function_node;
if (tmp_fn != null)
{
if (!tmp_fn.is_extension_method)
only_extension_methods = false;
else
{
if (tmp_fn.parameters.Count == 1 || tmp_fn.parameters.Count == 2 && (tmp_fn.parameters[1].is_params || tmp_fn.parameters[1].default_value != null))
has_empty_methods = true;
}
}
tmp_si = tmp_si.Next;
}
if (has_empty_methods && only_extension_methods)
expected_delegate = false;
}
if (expected_delegate)
return make_delegate_wrapper(en, si, get_location(id_right), false);
else