Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pascalabcnet/pascalabcnet
Browse files Browse the repository at this point in the history
…into test
  • Loading branch information
BH_build_bot authored and BH_build_bot committed Nov 1, 2024
2 parents f59e410 + 746c4ae commit f3a3829
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
43 changes: 35 additions & 8 deletions NETGenerator/NETGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public class ILConverter : AbstractVisitor
private List<LocalBuilder> pinned_variables = new List<LocalBuilder>();
private bool pabc_rtl_converted = false;
bool has_unmanaged_resources = false;
private Dictionary<ICommonFunctionNode, Tuple<MethodBuilder, MethodBuilder, List<ICommonFunctionNode>>> non_local_variables =
new Dictionary<ICommonFunctionNode, Tuple<MethodBuilder, MethodBuilder, List<ICommonFunctionNode>>>();

private void CheckLocation(SemanticTree.ILocation Location)
{
Expand Down Expand Up @@ -978,8 +980,23 @@ public void ConvertFromTree(SemanticTree.IProgramNode p, string TargetFileName,
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]];
ConvertFunctionHeaders(cnns[iii].functions);
ConvertFunctionHeaders(cnns[iii].functions, false);
}

//Переводим псевдоинстанции функций
foreach (IGenericFunctionInstance igfi in p.generic_function_instances)
{
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]];
ConvertFunctionHeaders(cnns[iii].functions, true);
}

if (p.InitializationCode != null)
{
tmp_il = il;
Expand All @@ -993,13 +1010,15 @@ public void ConvertFromTree(SemanticTree.IProgramNode p, string TargetFileName,



//Переводим псевдоинстанции функций
foreach (IGenericFunctionInstance igfi in p.generic_function_instances)

/*foreach (var item in non_local_variables)
{
ConvertGenericFunctionInstance(igfi);
}
tmp_il = il;
il = item.Value.Item2.GetILGenerator();
ConvertNonLocalVariables(item.Key.var_definition_nodes, item.Value.Item1);
il = tmp_il;
}*/



ConstructorBuilder unit_cci = null;

Expand Down Expand Up @@ -2659,10 +2678,14 @@ private void ConvertTypeHeader(ICommonTypeNode value)
}

//перевод заголовков функций
private void ConvertFunctionHeaders(ICommonNamespaceFunctionNode[] funcs)
private void ConvertFunctionHeaders(ICommonNamespaceFunctionNode[] funcs, bool with_nested)
{
for (int i = 0; i < funcs.Length; i++)
{
if (!with_nested && funcs[i].functions_nodes != null && funcs[i].functions_nodes.Length > 0)
continue;
if (with_nested && (funcs[i].functions_nodes == null || funcs[i].functions_nodes.Length == 0))
continue;
IStatementsListNode sl = (IStatementsListNode)funcs[i].function_code;
IStatementNode[] statements = sl.statements;
if (statements.Length > 0 && statements[0] is IExternalStatementNode)
Expand Down Expand Up @@ -2728,6 +2751,7 @@ private void ConvertFunctionHeaders(ICommonNamespaceFunctionNode[] funcs)
ConvertFunctionHeader(funcs[i]);
}
//(ssyy) 21.05.2008
if (!with_nested)
foreach (ICommonNamespaceFunctionNode ifn in funcs)
{
if (ifn.is_generic_function)
Expand Down Expand Up @@ -3019,9 +3043,11 @@ private void ConvertFunctionHeader(ICommonFunctionNode func)
funcs.Add(func); //здесь наверное дублирование
MethodBuilder tmp = cur_meth;
cur_meth = methb;

//если функция не содержит вложенных процедур, то
//переводим переменные как локальные
//if (func.functions_nodes.Length > 0)
// non_local_variables[func] = new Tuple<MethodBuilder, MethodBuilder, List<ICommonFunctionNode>>(frm.mb, methb, new List<ICommonFunctionNode>(funcs));
if (func.functions_nodes.Length > 0)
ConvertNonLocalVariables(func.var_definition_nodes, frm.mb);
//переводим заголовки вложенных функций
Expand Down Expand Up @@ -7003,6 +7029,7 @@ private void ConvertNestedInMethodFunctionHeader(ICommonNestedInFunctionFunction
MethodBuilder tmp = cur_meth;
cur_meth = methb;
//переводим переменные как нелокальные
//non_local_variables[func] = new Tuple<MethodBuilder, MethodBuilder, List<ICommonFunctionNode>>(frm.mb, methb, new List<ICommonFunctionNode>(funcs));
ConvertNonLocalVariables(func.var_definition_nodes, frm.mb);
//переводим описания вложенных процедур
ConvertNestedInMethodFunctionHeaders(func.functions_nodes, decl_type);
Expand Down
3 changes: 2 additions & 1 deletion TestSuite/CompilationSamples/PABCExtensions.pas
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ function SSet<T>(s: set of T): SortedSet<T>;

///--
function operator implicit(a: array of integer): set of integer; extensionmethod := TypedSet.InitBy(a);
///--
{///--
function operator implicit(a: array of real): set of real; extensionmethod := TypedSet.InitBy(a);
///--
function operator implicit(a: array of string): set of string; extensionmethod := TypedSet.InitBy(a);
Expand All @@ -433,6 +433,7 @@ function operator implicit(a: array of BigInteger): set of BigInteger; extension
function operator implicit(a: array of decimal): set of decimal; extensionmethod := TypedSet.InitBy(a);
///--
function operator implicit(a: array of single): set of single; extensionmethod := TypedSet.InitBy(a);
}
///--
function operator implicit<T>(a: array of T): set of T; extensionmethod := TypedSet.InitBy(a);

Expand Down
2 changes: 1 addition & 1 deletion TestSuite/CompilationSamples/XLSX.pas
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ implementation
{$reference System.Xml.dll}

uses System.IO.Compression;
uses System.Xml,sf;
uses System.Xml,SF;

var
numFmt, numBrd: List<int>;
Expand Down

0 comments on commit f3a3829

Please sign in to comment.