Fix warnings and possible NullReference exceptions
This commit is contained in:
parent
5f3ac6842c
commit
84ca54d190
|
|
@ -14,14 +14,17 @@ namespace PascalABCCompiler.TreeRealization
|
|||
public abstract definition_node CreateInterfaceMember(int offset, string name);
|
||||
public static void RestoreSymbolsInterfaceMember(SymbolInfoList si, string name)
|
||||
{
|
||||
foreach(var si_unit in si.InfoUnitList)
|
||||
if (si != null)
|
||||
{
|
||||
if(si_unit.sym_info != null)
|
||||
if(si_unit.sym_info.semantic_node_type == PascalABCCompiler.TreeRealization.semantic_node_type.wrap_def)
|
||||
{
|
||||
PascalABCCompiler.TreeRealization.wrapped_definition_node wdn = (PascalABCCompiler.TreeRealization.wrapped_definition_node)si_unit.sym_info;
|
||||
si_unit.sym_info = wdn.PCUReader.CreateInterfaceMember(wdn.offset, name);
|
||||
}
|
||||
foreach (var si_unit in si.InfoUnitList)
|
||||
{
|
||||
if (si_unit.sym_info != null)
|
||||
if (si_unit.sym_info.semantic_node_type == PascalABCCompiler.TreeRealization.semantic_node_type.wrap_def)
|
||||
{
|
||||
PascalABCCompiler.TreeRealization.wrapped_definition_node wdn = (PascalABCCompiler.TreeRealization.wrapped_definition_node)si_unit.sym_info;
|
||||
si_unit.sym_info = wdn.PCUReader.CreateInterfaceMember(wdn.offset, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -32,14 +35,17 @@ namespace PascalABCCompiler.TreeRealization
|
|||
|
||||
public static void RestoreSymbols(SymbolInfoList si, string name, int index = 0)
|
||||
{
|
||||
for(int i = index; i < si.InfoUnitList.Count; ++i)
|
||||
if (si != null)
|
||||
{
|
||||
if (si.InfoUnitList[i].sym_info != null)
|
||||
if (si.InfoUnitList[i].sym_info.semantic_node_type == PascalABCCompiler.TreeRealization.semantic_node_type.wrap_def)
|
||||
{
|
||||
PascalABCCompiler.TreeRealization.wrapped_definition_node wdn = (PascalABCCompiler.TreeRealization.wrapped_definition_node)si.InfoUnitList[i].sym_info;
|
||||
RestoreSymbols(si.InfoUnitList[i], wdn, name);
|
||||
}
|
||||
for (int i = index; i < si.InfoUnitList.Count; ++i)
|
||||
{
|
||||
if (si.InfoUnitList[i].sym_info != null)
|
||||
if (si.InfoUnitList[i].sym_info.semantic_node_type == PascalABCCompiler.TreeRealization.semantic_node_type.wrap_def)
|
||||
{
|
||||
PascalABCCompiler.TreeRealization.wrapped_definition_node wdn = (PascalABCCompiler.TreeRealization.wrapped_definition_node)si.InfoUnitList[i].sym_info;
|
||||
RestoreSymbols(si.InfoUnitList[i], wdn, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -506,27 +506,62 @@ namespace PascalABCCompiler.TreeConverter
|
|||
return -1;
|
||||
}
|
||||
|
||||
public static bool operator ==(SymbolInfoList a, SymbolInfoList b)
|
||||
|
||||
public override bool Equals(System.Object obj)
|
||||
{
|
||||
if (System.Object.ReferenceEquals(a, b))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (((object)a == null) || ((object)b == null))
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (a.InfoUnitList.Count != b.InfoUnitList.Count)
|
||||
|
||||
SymbolInfoList p = obj as SymbolInfoList;
|
||||
if ((System.Object)p == null)
|
||||
{
|
||||
return false;
|
||||
for (int i = 0; i < a.InfoUnitList.Count; ++i)
|
||||
if (a.InfoUnitList[i] != b.InfoUnitList[i])
|
||||
}
|
||||
|
||||
if (p.InfoUnitList.Count != InfoUnitList.Count)
|
||||
return false;
|
||||
for (int i = 0; i < InfoUnitList.Count; ++i)
|
||||
if (p.InfoUnitList[i] != InfoUnitList[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Equals(SymbolInfoList p)
|
||||
{
|
||||
if ((object)p == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (p.InfoUnitList.Count != InfoUnitList.Count)
|
||||
return false;
|
||||
for (int i = 0; i < InfoUnitList.Count; ++i)
|
||||
if (p.InfoUnitList[i] != InfoUnitList[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static bool operator ==(SymbolInfoList a, SymbolInfoList b)
|
||||
{
|
||||
if (object.ReferenceEquals(a, null))
|
||||
{
|
||||
return object.ReferenceEquals(b, null);
|
||||
}
|
||||
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
public static bool operator !=(SymbolInfoList a, SymbolInfoList b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -916,48 +951,6 @@ namespace PascalABCCompiler.TreeConverter
|
|||
_symbol_kind = skind;
|
||||
}
|
||||
|
||||
|
||||
public override bool Equals(System.Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SymbolInfoUnit p = obj as SymbolInfoUnit;
|
||||
if ((System.Object)p == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return (_access_level == p._access_level) && (_symbol_kind == p._symbol_kind) && (_sym_info == p.sym_info) && (scope == p.scope);
|
||||
}
|
||||
|
||||
public bool Equals(SymbolInfoUnit p)
|
||||
{
|
||||
if ((object)p == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return (_access_level == p._access_level) && (_symbol_kind == p._symbol_kind) && (_sym_info == p.sym_info) && (scope == p.scope);
|
||||
}
|
||||
|
||||
|
||||
public static bool operator ==(SymbolInfoUnit a, SymbolInfoUnit b)
|
||||
{
|
||||
if (object.ReferenceEquals(a, null))
|
||||
{
|
||||
return object.ReferenceEquals(b, null);
|
||||
}
|
||||
|
||||
return a.Equals(b);
|
||||
}
|
||||
|
||||
public static bool operator !=(SymbolInfoUnit a, SymbolInfoUnit b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2531,20 +2531,23 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
SymbolInfoList si = cnode.find_in_type(meth.name, cnode.Scope);
|
||||
function_node fn = null;
|
||||
foreach(var si_unit in si.InfoUnitList)
|
||||
if (si != null)
|
||||
{
|
||||
if (si_unit.sym_info.general_node_type == general_node_type.function_node)
|
||||
foreach (var si_unit in si.InfoUnitList)
|
||||
{
|
||||
fn = si_unit.sym_info as function_node;
|
||||
//Сверяем параметры и тип возвращаемого значения
|
||||
if (convertion_data_and_alghoritms.function_eq_params_and_result(meth, fn))
|
||||
if (si_unit.sym_info.general_node_type == general_node_type.function_node)
|
||||
{
|
||||
//Нашли нужную функцию
|
||||
if (meth == fn || fn is common_method_node && (fn as common_method_node).overrided_method == null) si = null;
|
||||
break;
|
||||
fn = si_unit.sym_info as function_node;
|
||||
//Сверяем параметры и тип возвращаемого значения
|
||||
if (convertion_data_and_alghoritms.function_eq_params_and_result(meth, fn))
|
||||
{
|
||||
//Нашли нужную функцию
|
||||
if (meth == fn || fn is common_method_node && (fn as common_method_node).overrided_method == null) si = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Переходим к следующей функции-кандидату
|
||||
}
|
||||
//Переходим к следующей функции-кандидату
|
||||
}
|
||||
if (si == null)
|
||||
{
|
||||
|
|
@ -2597,7 +2600,13 @@ namespace PascalABCCompiler.TreeConverter
|
|||
* SymbolInfo tmp_si2 = tmp_si;
|
||||
while (tmp_si2.Next != null)
|
||||
tmp_si2 = tmp_si2.Next;*/
|
||||
si.InfoUnitList.Insert(0, tmp_si.First());
|
||||
if (si != null)
|
||||
si.InfoUnitList.Insert(0, tmp_si.First());
|
||||
else
|
||||
{
|
||||
si = tmp_si;
|
||||
si.InfoUnitList.RemoveRange(1, si.InfoUnitList.Count - 1);
|
||||
}
|
||||
}
|
||||
|
||||
function_node fn = null;
|
||||
|
|
@ -2915,18 +2924,21 @@ namespace PascalABCCompiler.TreeConverter
|
|||
if (_ctn is compiled_generic_instance_type_node && fn is common_namespace_function_node)
|
||||
{
|
||||
si_list = (_ctn as compiled_generic_instance_type_node).compiled_original_generic.find_in_type(fn.name);
|
||||
foreach(var tmp_si in si_list.InfoUnitList)
|
||||
if (si_list != null)
|
||||
{
|
||||
if (tmp_si.sym_info.general_node_type != general_node_type.function_node)
|
||||
foreach (var tmp_si in si_list.InfoUnitList)
|
||||
{
|
||||
TreeRealization.BasePCUReader.RestoreSymbols(si_list, fn.name);
|
||||
}
|
||||
common_namespace_function_node cnfn = tmp_si.sym_info as common_namespace_function_node;
|
||||
if (cnfn != null)
|
||||
{
|
||||
if (cnfn.namespace_node == (fn as common_namespace_function_node).namespace_node)
|
||||
if (tmp_si.sym_info.general_node_type != general_node_type.function_node)
|
||||
{
|
||||
break;
|
||||
TreeRealization.BasePCUReader.RestoreSymbols(si_list, fn.name);
|
||||
}
|
||||
common_namespace_function_node cnfn = tmp_si.sym_info as common_namespace_function_node;
|
||||
if (cnfn != null)
|
||||
{
|
||||
if (cnfn.namespace_node == (fn as common_namespace_function_node).namespace_node)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3144,16 +3156,19 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
}
|
||||
bool compar_not_assign = true;
|
||||
foreach(var siint_unit in siint.InfoUnitList)
|
||||
if (siint != null)
|
||||
{
|
||||
if(siint_unit.sym_info == fn)
|
||||
foreach (var siint_unit in siint.InfoUnitList)
|
||||
{
|
||||
siint_unit.sym_info = compar;
|
||||
compar_not_assign = false;
|
||||
break;
|
||||
if (siint_unit.sym_info == fn)
|
||||
{
|
||||
siint_unit.sym_info = compar;
|
||||
compar_not_assign = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (compar_not_assign)
|
||||
if (compar_not_assign && siint != null)
|
||||
siint.Last().sym_info = compar;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1245,10 +1245,13 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
expressions_list pars = null;
|
||||
function_node fnsel = null;
|
||||
foreach(SymbolInfoUnit tmp_si in si.InfoUnitList)
|
||||
if (si != null)
|
||||
{
|
||||
if (tmp_si.sym_info is wrapped_definition_node)
|
||||
BasePCUReader.RestoreSymbols(si, name);
|
||||
foreach (SymbolInfoUnit tmp_si in si.InfoUnitList)
|
||||
{
|
||||
if (tmp_si.sym_info is wrapped_definition_node)
|
||||
BasePCUReader.RestoreSymbols(si, name);
|
||||
}
|
||||
}
|
||||
pars = new expressions_list();
|
||||
pars.AddElement(left);
|
||||
|
|
@ -5951,7 +5954,6 @@ namespace PascalABCCompiler.TreeConverter
|
|||
is_format_allowed = false;
|
||||
if (SystemUnitAssigned)
|
||||
{
|
||||
//si.ToSymbolInfo();//notCreatedSymbol problem
|
||||
if (SystemLibrary.SystemLibInitializer.read_procedure.Equal(si) || SystemLibrary.SystemLibInitializer.readln_procedure.Equal(si))
|
||||
{
|
||||
|
||||
|
|
@ -6546,6 +6548,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
is_format_allowed = false;
|
||||
CheckSpecialFunctionCall(si, exprs, get_location(_method_call));
|
||||
|
||||
si.InfoUnitList.RemoveRange(1, si.InfoUnitList.Count - 1);
|
||||
si.Add(sibak);
|
||||
|
||||
if (to_type != null)
|
||||
|
|
@ -9292,11 +9295,11 @@ namespace PascalABCCompiler.TreeConverter
|
|||
private bool can_convert_to_method_call(ref SymbolInfoList si)
|
||||
{
|
||||
SymbolInfoList tmp_list = si.copy();
|
||||
foreach(SymbolInfoUnit tmp_si in tmp_list.InfoUnitList)
|
||||
foreach (SymbolInfoUnit tmp_si in tmp_list.InfoUnitList)
|
||||
{
|
||||
if (tmp_si.sym_info is function_node && (tmp_si.sym_info as function_node).is_extension_method && !has_property(ref si)
|
||||
|| tmp_si.sym_info is common_method_node && (tmp_si.sym_info as common_method_node).is_constructor
|
||||
|| tmp_si.sym_info is compiled_constructor_node)
|
||||
|| tmp_si.sym_info is common_method_node && (tmp_si.sym_info as common_method_node).is_constructor
|
||||
|| tmp_si.sym_info is compiled_constructor_node)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -11268,11 +11271,14 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
private bool FunctionExsistsInSymbolInfo(function_node fn, SymbolInfoList si)
|
||||
{
|
||||
foreach(SymbolInfoUnit si_unit in si.InfoUnitList)
|
||||
if (si != null)
|
||||
{
|
||||
if (si_unit.sym_info is function_node)
|
||||
if (convertion_data_and_alghoritms.function_eq_params(fn, si_unit.sym_info as function_node))
|
||||
return true;
|
||||
foreach (SymbolInfoUnit si_unit in si.InfoUnitList)
|
||||
{
|
||||
if (si_unit.sym_info is function_node)
|
||||
if (convertion_data_and_alghoritms.function_eq_params(fn, si_unit.sym_info as function_node))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -544,7 +544,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
en_cmn = new common_method_node(compiler_string_consts.GetEnumeratorMethodName, compiled_type_node.get_type_node(NetHelper.NetHelper.FindType(compiler_string_consts.IGenericEnumeratorInterfaceName)).get_instance(generic_args), null, ctn, SemanticTree.polymorphic_state.ps_virtual, SemanticTree.field_access_level.fal_public, null);
|
||||
//en_fnc = en_tn.find_in_type("GetEnumerator").sym_info as function_node;//NetHelper.NetHelper.FindName(NetHelper.NetHelper.FindType(compiler_string_consts.IGenericEnumerableInterfaceName), compiler_string_consts.GetEnumeratorMethodName).sym_info as compiled_function_node;
|
||||
SymbolInfoList en_si = en_tn.find_in_type("GetEnumerator");
|
||||
if (en_si.InfoUnitList.Count > 1 && (en_si.InfoUnitList[1].sym_info as function_node).return_value_type.is_generic_type_instance)
|
||||
if (en_si != null && en_si.InfoUnitList.Count > 1 && (en_si.InfoUnitList[1].sym_info as function_node).return_value_type.is_generic_type_instance)
|
||||
en_si.InfoUnitList = en_si.InfoUnitList.GetRange(1, en_si.InfoUnitList.Count - 1);
|
||||
function_node en_fnc_inst = en_si.First().sym_info as function_node; ;//.get_instance(generic_args, true, loc);
|
||||
sl = new statements_list(null);
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in a new issue