Permalink
Browse files

Merge branch 'master' of https://github.com/pascalabcnet/pascalabcnet

  • Loading branch information...
2 parents 1557775 + 3663833 commit 67b9159df52d3dc0bf96160e608c91a7e3febef1 @miks1965 miks1965 committed Jan 10, 2017
@@ -127,6 +127,7 @@ public class ILConverter : AbstractVisitor
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 @@ private void ConvertConstructorBody(SemanticTree.ICommonMethodNode value)
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 @@ public override void visit(SemanticTree.ICommonConstructorCall value)
{
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 @@ public override void visit(SemanticTree.ICompiledConstructorCall value)
{
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)
@@ -0,0 +1,5 @@
+begin
+ var a := Arr(1,3,5,4,3);
+ var b := a.Println.ToArray;
+ assert(b[2] = 5);
+end.
@@ -8975,6 +8975,30 @@ private expression_node expression_value_reciving(SyntaxTree.ident id_right, Sym
{
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

0 comments on commit 67b9159

Please sign in to comment.