refactoring (#3427)
This commit is contained in:
parent
349a3dc568
commit
4efb48894c
|
|
@ -1,33 +0,0 @@
|
|||
// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
using System;
|
||||
|
||||
namespace PascalABCCompiler.Collections
|
||||
{
|
||||
/*
|
||||
public class associated_collection<KeyType,ElementType>
|
||||
{
|
||||
private System.Collections.Generic.Dictionary<KeyType, ElementType> int_collection =
|
||||
new System.Collections.Generic.Dictionary<KeyType, ElementType>();
|
||||
|
||||
public void AssociateElement(KeyType key, ElementType element)
|
||||
{
|
||||
#if DEBUG
|
||||
if (int_collection[key]!=null)
|
||||
{
|
||||
throw new PascalABCCompiler.TreeConverter.CompilerInternalError("Duplicate key in associated collection.");
|
||||
}
|
||||
#endif
|
||||
int_collection[key] = element;
|
||||
}
|
||||
|
||||
public ElementType this[KeyType key]
|
||||
{
|
||||
get
|
||||
{
|
||||
return int_collection[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace PascalABCCompiler.Collections
|
||||
{
|
||||
[Serializable]
|
||||
public class stack<T>
|
||||
{
|
||||
protected System.Collections.Generic.Stack<T> internal_stack = new System.Collections.Generic.Stack<T>();
|
||||
|
||||
public void push(T element)
|
||||
{
|
||||
internal_stack.Push(element);
|
||||
}
|
||||
|
||||
public T pop()
|
||||
{
|
||||
return internal_stack.Pop();
|
||||
}
|
||||
|
||||
public T top()
|
||||
{
|
||||
if (internal_stack.Count == 0)
|
||||
return default(T);
|
||||
//T t = internal_stack.Pop();
|
||||
//internal_stack.Push(t);
|
||||
return internal_stack.Peek();
|
||||
}
|
||||
|
||||
public T first()
|
||||
{
|
||||
if (internal_stack.Count == 0)
|
||||
return default(T);
|
||||
return internal_stack.ToArray()[internal_stack.Count-1];
|
||||
}
|
||||
public int size
|
||||
{
|
||||
get
|
||||
{
|
||||
return internal_stack.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Empty
|
||||
{
|
||||
get
|
||||
{
|
||||
return internal_stack.Count == 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
internal_stack.Clear();
|
||||
}
|
||||
|
||||
public System.Collections.Generic.Stack<T> CloneInternalStack()
|
||||
{
|
||||
return new System.Collections.Generic.Stack<T>(internal_stack.Reverse());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -976,7 +976,7 @@ namespace TreeConverter.LambdaExpressions.Closure
|
|||
{
|
||||
var funcStackAsList = _visitor.context.func_stack == null
|
||||
? null
|
||||
: _visitor.context.func_stack.CloneInternalStack().ToList();
|
||||
: _visitor.context.func_stack.ToList();
|
||||
|
||||
var funcIsGeneric = false;
|
||||
if (funcStackAsList != null)
|
||||
|
|
@ -1015,7 +1015,7 @@ namespace TreeConverter.LambdaExpressions.Closure
|
|||
|
||||
var funcStackAsList = _visitor.context.func_stack == null
|
||||
? null
|
||||
: _visitor.context.func_stack.CloneInternalStack().ToList();
|
||||
: _visitor.context.func_stack.ToList();
|
||||
|
||||
if (funcStackAsList != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ namespace TreeConverter.LambdaExpressions.Closure
|
|||
}
|
||||
}
|
||||
|
||||
_visitor.convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
_visitor.convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
|
||||
_currentTreeNode = _currentTreeNode.ParentNode;
|
||||
}
|
||||
|
|
@ -697,7 +697,7 @@ namespace TreeConverter.LambdaExpressions.Closure
|
|||
ProcessNode(_foreach_stmt.stmt);
|
||||
|
||||
_visitor.context.loop_var_stack.Pop();
|
||||
_visitor.convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
_visitor.convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
_visitor.context.leave_cycle();
|
||||
|
||||
_currentTreeNode = _currentTreeNode.ParentNode;
|
||||
|
|
@ -782,7 +782,7 @@ namespace TreeConverter.LambdaExpressions.Closure
|
|||
|
||||
_visitor.context.leave_cycle();
|
||||
_visitor.context.loop_var_stack.Pop();
|
||||
_visitor.convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
_visitor.convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
|
||||
_currentTreeNode = _currentTreeNode.ParentNode;
|
||||
}
|
||||
|
|
@ -836,7 +836,7 @@ namespace TreeConverter.LambdaExpressions.Closure
|
|||
|
||||
var newTreeNode = new CapturedVariablesTreeNodeLambdaScope(_currentTreeNode,
|
||||
lambdaDefinition,
|
||||
_visitor.context.func_stack.top().scope.ScopeNum, lambdaDefinition);
|
||||
_visitor.context.func_stack.Peek().scope.ScopeNum, lambdaDefinition);
|
||||
|
||||
_currentTreeNode.LambdasDefinedInScope.Add(newTreeNode);
|
||||
_currentLambdaScopeNodeStack.Push(newTreeNode);
|
||||
|
|
@ -911,9 +911,9 @@ namespace TreeConverter.LambdaExpressions.Closure
|
|||
_classScope = (CapturedVariablesTreeNodeClassScope) _rootNode;
|
||||
}
|
||||
|
||||
if (_visitor.context.func_stack.top() != null)
|
||||
if (_visitor.context.func_stack.FirstOrDefault() != null)
|
||||
{
|
||||
var newTreeNode = new CapturedVariablesTreeNodeProcedureScope(_currentTreeNode, _visitor.context.func_stack.top(), _visitor.context.func_stack.top().scope.ScopeNum, null);
|
||||
var newTreeNode = new CapturedVariablesTreeNodeProcedureScope(_currentTreeNode, _visitor.context.func_stack.Peek(), _visitor.context.func_stack.Peek().scope.ScopeNum, null);
|
||||
|
||||
if (_rootNode == null)
|
||||
{
|
||||
|
|
@ -925,7 +925,7 @@ namespace TreeConverter.LambdaExpressions.Closure
|
|||
}
|
||||
_currentTreeNode = newTreeNode;
|
||||
|
||||
_scopesCapturedVarsNodesDictionary.Add(_visitor.context.func_stack.top().scope.ScopeNum, _currentTreeNode);
|
||||
_scopesCapturedVarsNodesDictionary.Add(_visitor.context.func_stack.Peek().scope.ScopeNum, _currentTreeNode);
|
||||
|
||||
_procedureScope = (CapturedVariablesTreeNodeProcedureScope) _currentTreeNode;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ namespace TreeConverter.LambdaExpressions
|
|||
if (stmtList.subnodes != null)
|
||||
foreach (var stmt in stmtList.subnodes)
|
||||
ProcessNode(stmt);
|
||||
syntaxTreeVisitor.convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
syntaxTreeVisitor.convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
}
|
||||
|
||||
public override void visit(var_def_statement varStmt)
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
// Copyright (c) Ivan Bondarev, Stanislav Mikhalkovich (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
using System;
|
||||
|
||||
using PascalABCCompiler.Collections;
|
||||
|
||||
namespace PascalABCCompiler.TreeRealization
|
||||
{
|
||||
[Serializable]
|
||||
public class common_function_node_stack : stack<common_function_node>
|
||||
{
|
||||
public common_function_node_stack Clone()
|
||||
{
|
||||
var s = new common_function_node_stack();
|
||||
s.internal_stack = this.CloneInternalStack();
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class var_definition_node_list : extendable_collection<var_definition_node>
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class statement_list_stack : stack<statements_list>
|
||||
{
|
||||
public statement_list_stack Clone()
|
||||
{
|
||||
var s = new statement_list_stack();
|
||||
s.internal_stack = this.CloneInternalStack();
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class lambda_stack : stack<lambda_node> //lroman//
|
||||
{
|
||||
public lambda_stack Clone()
|
||||
{
|
||||
var s = new lambda_stack();
|
||||
s.internal_stack = this.CloneInternalStack();
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -165,7 +165,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
forNode.body = convert_strong(_for_node.statements);
|
||||
context.leave_code_block();
|
||||
|
||||
slst = convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
slst = convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
if (slst.statements.Count > 0 || slst.local_variables.Count > 0)
|
||||
{
|
||||
slst.statements.AddElement(forNode.body);
|
||||
|
|
@ -174,7 +174,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
context.leave_cycle();
|
||||
context.loop_var_stack.Pop();
|
||||
head_stmts = convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
head_stmts = convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
head_stmts.statements.AddElement(forNode);
|
||||
|
||||
#region MikhailoMMX, обработка omp parallel for
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
context.loop_var_stack.Pop();
|
||||
context.leave_cycle();
|
||||
|
||||
sl = convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
sl = convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
|
||||
if (sl.statements.Count > 0 || sl.local_variables.Count > 0)
|
||||
{
|
||||
|
|
@ -88,7 +88,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
foreachNode.what_do = body;
|
||||
|
||||
convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
sl2.statements.AddElement(foreachNode);
|
||||
|
||||
return_value(sl2);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ namespace PascalABCCompiler.TreeConverter
|
|||
public common_namespace_node cmn; // текущий namespace
|
||||
public common_type_node ctn; // текущий разбираемый тип
|
||||
public common_function_node_stack func_stack;
|
||||
public lambda_stack lambda_stack;
|
||||
public Stack<code_block> block_stack;
|
||||
public Dictionary<int, short_string_type_node> ShortStringTypes;
|
||||
public List<var_definition_node> var_defs;
|
||||
|
|
@ -60,7 +59,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
// Из любого блока на глобальный уровень. Обнуляется _ctn.
|
||||
public void SaveContextAndUpToGlobalLevel()
|
||||
{
|
||||
if (!func_stack.Empty || SavedContext == null)
|
||||
if (func_stack.Count > 0 || SavedContext == null)
|
||||
SaveContextAndUpFromAllFunctionDefs();
|
||||
SavedContext.ctn = _ctn;
|
||||
_ctn = null;
|
||||
|
|
@ -68,7 +67,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
public void SaveContextAndUpFromAllFunctionDefs()
|
||||
{
|
||||
if (!convertion_data_and_alghoritms.statement_list_stack.Empty || SavedContext == null)
|
||||
if (convertion_data_and_alghoritms.statement_list_stack.Count > 0 || SavedContext == null)
|
||||
SaveContextAndUpToNearestDefSect();
|
||||
SavedContext.func_stack = func_stack;
|
||||
func_stack = new common_function_node_stack();
|
||||
|
|
@ -173,7 +172,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
public common_namespace_node _cmn;
|
||||
//TODO: Можно сделать возможность объявления вложенных типов.
|
||||
public common_type_node _ctn; // SSM - пытаюсь выходить из класса и входить заново
|
||||
private common_function_node_stack _func_stack=new common_function_node_stack();
|
||||
private common_function_node_stack _func_stack = new common_function_node_stack();
|
||||
private type_node _explicit_interface_type;
|
||||
internal bool WithSection = false;
|
||||
internal Dictionary<SymbolTable.Scope, expression_node> WithVariables = new Dictionary<SymbolTable.Scope, expression_node>();
|
||||
|
|
@ -311,11 +310,11 @@ namespace PascalABCCompiler.TreeConverter
|
|||
//CurrentHandlerListStack = new Stack<List<string>>(); // SSM 29/03/22 - не сработало
|
||||
_cmn = null;
|
||||
_ctn = null;
|
||||
_func_stack.clear();
|
||||
_func_stack.Clear();
|
||||
var_defs.Clear();
|
||||
_main_procedure = null;
|
||||
_last_created_function = null;
|
||||
_cycles_stack.clear();
|
||||
_cycles_stack.Clear();
|
||||
_num_of_for_cycles = 0;
|
||||
_fal = SemanticTree.field_access_level.fal_private;
|
||||
var_defs_stack.Clear();
|
||||
|
|
@ -377,9 +376,9 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
get
|
||||
{
|
||||
if (!syntax_tree_visitor.convertion_data_and_alghoritms.statement_list_stack.Empty)
|
||||
if (syntax_tree_visitor.convertion_data_and_alghoritms.statement_list_stack.Count > 0)
|
||||
{
|
||||
SymbolTable.Scope sc = syntax_tree_visitor.convertion_data_and_alghoritms.statement_list_stack.top().Scope;
|
||||
SymbolTable.Scope sc = syntax_tree_visitor.convertion_data_and_alghoritms.statement_list_stack.Peek().Scope;
|
||||
if (sc != null)
|
||||
{
|
||||
if (top_function != null && LambdaHelper.IsLambdaName(top_function.name)) //lroman
|
||||
|
|
@ -426,7 +425,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
public void push_function(common_function_node fn)
|
||||
{
|
||||
_func_stack.push(fn);
|
||||
_func_stack.Push(fn);
|
||||
}
|
||||
|
||||
public common_function_node get_method_to_realize(SyntaxTree.declaration dc)
|
||||
|
|
@ -510,7 +509,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
public void pop_top_function()
|
||||
{
|
||||
_func_stack.pop();
|
||||
_func_stack.Pop();
|
||||
}
|
||||
|
||||
private List<common_type_node> _types_predefined = new List<common_type_node>();
|
||||
|
|
@ -641,11 +640,11 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
get
|
||||
{
|
||||
if (_func_stack.size==0)
|
||||
if (_func_stack.Count==0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return (_func_stack.top());
|
||||
return _func_stack.Peek();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -765,7 +764,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
public bool func_stack_size_is_one()
|
||||
{
|
||||
return (_func_stack.size == 1);
|
||||
return (_func_stack.Count == 1);
|
||||
}
|
||||
|
||||
public block_type converting_block()
|
||||
|
|
@ -775,7 +774,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
if (_ctn != null && top_function!=null && _ctn.defined_in_scope == top_function.scope)
|
||||
return block_type.type_block;
|
||||
|
||||
if (_func_stack.size!=0)
|
||||
if (_func_stack.Count!=0)
|
||||
{
|
||||
return block_type.function_block;
|
||||
}
|
||||
|
|
@ -1201,10 +1200,10 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
if (converting_block() == block_type.function_block)
|
||||
{
|
||||
var top_func = func_stack.top();
|
||||
var top_func = func_stack.Peek();
|
||||
if (top_func.name == lambda_name)
|
||||
{
|
||||
_func_stack.pop();
|
||||
_func_stack.Pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1233,7 +1232,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
//lroman//
|
||||
public common_function_node create_lambda_function(string name, location def_loc, bool add_symbol_info, SymbolTable.Scope topScope)
|
||||
{
|
||||
var func_stack_as_array = _func_stack.CloneInternalStack().ToList();
|
||||
var func_stack_as_array = _func_stack.ToList();
|
||||
|
||||
var nestedFunc = func_stack_as_array.FirstOrDefault(func => func is common_in_function_function_node);
|
||||
if (nestedFunc != null)
|
||||
|
|
@ -1279,7 +1278,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
cfn = cnfnn;
|
||||
}
|
||||
|
||||
_func_stack.push(cfn);
|
||||
_func_stack.Push(cfn);
|
||||
return cfn;
|
||||
}
|
||||
//\lroman//
|
||||
|
|
@ -1300,7 +1299,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
case block_type.function_block:
|
||||
{
|
||||
common_function_node top_func = _func_stack.top();
|
||||
common_function_node top_func = _func_stack.Peek();
|
||||
SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateScope(top_func.scope, "function " + name);
|
||||
common_in_function_function_node ciffn =new common_in_function_function_node(name,def_loc,top_func,scope);
|
||||
top_func.functions_nodes_list.AddElement(ciffn);
|
||||
|
|
@ -1374,7 +1373,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
break;
|
||||
}
|
||||
}
|
||||
_func_stack.push(cfn);
|
||||
_func_stack.Push(cfn);
|
||||
return cfn;
|
||||
}
|
||||
|
||||
|
|
@ -1668,8 +1667,8 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
get
|
||||
{
|
||||
if (!syntax_tree_visitor.convertion_data_and_alghoritms.statement_list_stack.Empty)
|
||||
return syntax_tree_visitor.convertion_data_and_alghoritms.statement_list_stack.top();
|
||||
if (syntax_tree_visitor.convertion_data_and_alghoritms.statement_list_stack.Count > 0)
|
||||
return syntax_tree_visitor.convertion_data_and_alghoritms.statement_list_stack.Peek();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1837,7 +1836,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
case block_type.function_block:
|
||||
{
|
||||
common_function_node top_func = _func_stack.top();
|
||||
common_function_node top_func = _func_stack.Peek();
|
||||
local_variable lv=new local_variable(name,tn,top_func,loc);
|
||||
vdn=lv;
|
||||
top_func.var_definition_nodes_list.AddElement(lv);
|
||||
|
|
@ -1881,7 +1880,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
case block_type.function_block:
|
||||
{
|
||||
common_function_node top_func = _func_stack.top();
|
||||
common_function_node top_func = _func_stack.Peek();
|
||||
top_func.label_nodes_list.Add(lab);
|
||||
top_func.scope.AddSymbol(name, new SymbolInfo(lab));
|
||||
break;
|
||||
|
|
@ -1974,7 +1973,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
case block_type.function_block:
|
||||
{
|
||||
common_function_node top_func = _func_stack.top();
|
||||
common_function_node top_func = _func_stack.Peek();
|
||||
local_variable lv=new local_variable(name,type,top_func,loc);
|
||||
vdn=lv;
|
||||
top_func.var_definition_nodes_list.AddElement(lv);
|
||||
|
|
@ -2009,7 +2008,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
throw new CompilerInternalError("Parameters can be defined with functions only");
|
||||
}
|
||||
#endif
|
||||
common_function_node top_func = _func_stack.top();
|
||||
common_function_node top_func = _func_stack.Peek();
|
||||
common_parameter cp=new common_parameter(name,pt,top_func,cpt,loc);
|
||||
top_func.parameters.AddElement(cp);
|
||||
top_func.scope.AddSymbol(name,new SymbolInfo(cp));
|
||||
|
|
@ -2026,7 +2025,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
case block_type.function_block:
|
||||
{
|
||||
common_function_node top_func = _func_stack.top();
|
||||
common_function_node top_func = _func_stack.Peek();
|
||||
function_constant_definition fcd = new function_constant_definition(name, loc, top_func);
|
||||
top_func.scope.AddSymbol(name,new SymbolInfo(fcd));
|
||||
top_func.constants.AddElement(fcd);
|
||||
|
|
@ -2340,7 +2339,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
case block_type.function_block:
|
||||
{
|
||||
common_function_node top_func = _func_stack.top();
|
||||
common_function_node top_func = _func_stack.Peek();
|
||||
location loc;
|
||||
if (top_func.function_code == null)
|
||||
{
|
||||
|
|
@ -2381,7 +2380,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
}
|
||||
check_predefinition_defined();
|
||||
_func_stack.pop();
|
||||
_func_stack.Pop();
|
||||
break;
|
||||
}
|
||||
case block_type.type_block:
|
||||
|
|
@ -2545,7 +2544,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
}
|
||||
int num_of_defaults = default_params.Count-1;
|
||||
if (default_params.Count > 0 && converted_func_stack.size == 1)
|
||||
if (default_params.Count > 0 && converted_func_stack.Count == 1)
|
||||
while (num_of_defaults >= 0)
|
||||
{
|
||||
|
||||
|
|
@ -2607,7 +2606,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
private void close_function_params_without_body()
|
||||
{
|
||||
check_function_not_exists(_func_stack.top());
|
||||
check_function_not_exists(_func_stack.Peek());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -2616,7 +2615,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
/// <returns></returns>
|
||||
private bool close_function_params_with_body()
|
||||
{
|
||||
return check_unique_or_predefined(_func_stack.top());
|
||||
return check_unique_or_predefined(_func_stack.Peek());
|
||||
}
|
||||
|
||||
private List<string> CurrentHandlerList=null;
|
||||
|
|
@ -3093,7 +3092,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
case block_type.function_block:
|
||||
{
|
||||
foreach(common_function_node cfn in _func_stack.top().functions_nodes_list)
|
||||
foreach(common_function_node cfn in _func_stack.Peek().functions_nodes_list)
|
||||
{
|
||||
if (cfn.function_code==null)
|
||||
{
|
||||
|
|
@ -3101,7 +3100,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
AddError(new FunctionPredefinitionWithoutDefinition(cfn, cfn.loc));
|
||||
}
|
||||
}
|
||||
check_labels(_func_stack.top().label_nodes_list);
|
||||
check_labels(_func_stack.Peek().label_nodes_list);
|
||||
break;
|
||||
}
|
||||
case block_type.namespace_block:
|
||||
|
|
@ -3205,7 +3204,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
List<SymbolInfo> si_list = null;
|
||||
bool in_unit = false;
|
||||
if (_func_stack.size <= 1)
|
||||
if (_func_stack.Count <= 1)
|
||||
{
|
||||
if (_explicit_interface_type != null)
|
||||
{
|
||||
|
|
@ -3264,9 +3263,9 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
else
|
||||
{
|
||||
common_function_node temp = _func_stack.pop();
|
||||
si_list = _func_stack.top().scope.FindOnlyInScope(fn.name);
|
||||
_func_stack.push(temp);
|
||||
common_function_node temp = _func_stack.Pop();
|
||||
si_list = _func_stack.Peek().scope.FindOnlyInScope(fn.name);
|
||||
_func_stack.Push(temp);
|
||||
}
|
||||
bool predef_find = false;
|
||||
int overloads = 0;
|
||||
|
|
@ -3413,7 +3412,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
last_created_function.symbol_kind = symbol_kind.sk_overload_function;
|
||||
}
|
||||
|
||||
common_function_node cfn11 = _func_stack.pop();
|
||||
common_function_node cfn11 = _func_stack.Pop();
|
||||
compar.scope = cfn11.scope;
|
||||
|
||||
common_method_node cmnode = compar as common_method_node;
|
||||
|
|
@ -3432,8 +3431,8 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
case block_type.function_block:
|
||||
{
|
||||
_func_stack.top().functions_nodes_list.remove((common_in_function_function_node)fn);
|
||||
siint = _func_stack.top().scope.FindOnlyInScope(fn.name);
|
||||
_func_stack.Peek().functions_nodes_list.remove((common_in_function_function_node)fn);
|
||||
siint = _func_stack.Peek().scope.FindOnlyInScope(fn.name);
|
||||
break;
|
||||
}
|
||||
case block_type.namespace_block:
|
||||
|
|
@ -3547,7 +3546,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
}
|
||||
|
||||
_func_stack.push(compar);
|
||||
_func_stack.Push(compar);
|
||||
compar.attributes.AddRange(fn.attributes);
|
||||
//si_list.sym_info=fn;
|
||||
break;
|
||||
|
|
@ -3563,7 +3562,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
private void check_function_not_exists(common_function_node fn)
|
||||
{
|
||||
List<SymbolInfo> sil=null;
|
||||
if (_func_stack.size<=1)
|
||||
if (_func_stack.Count<=1)
|
||||
{
|
||||
if (_ctn!=null)
|
||||
{
|
||||
|
|
@ -3576,9 +3575,9 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
else
|
||||
{
|
||||
common_function_node temp=_func_stack.pop();
|
||||
sil=_func_stack.top().scope.FindOnlyInScope(fn.name);
|
||||
_func_stack.push(temp);
|
||||
common_function_node temp=_func_stack.Pop();
|
||||
sil=_func_stack.Peek().scope.FindOnlyInScope(fn.name);
|
||||
_func_stack.Push(temp);
|
||||
}
|
||||
if(sil != null)
|
||||
foreach(SymbolInfo si in sil)
|
||||
|
|
@ -3673,7 +3672,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
case block_type.function_block:
|
||||
{
|
||||
return _func_stack.top().function_code;
|
||||
return _func_stack.Peek().function_code;
|
||||
}
|
||||
case block_type.type_block:
|
||||
{
|
||||
|
|
@ -3692,7 +3691,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
case block_type.function_block:
|
||||
{
|
||||
_func_stack.top().function_code=value;
|
||||
_func_stack.Peek().function_code=value;
|
||||
break;
|
||||
}
|
||||
case block_type.type_block:
|
||||
|
|
@ -3716,7 +3715,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
case block_type.function_block:
|
||||
{
|
||||
return _func_stack.top().cycles_stack;
|
||||
return _func_stack.Peek().cycles_stack;
|
||||
}
|
||||
case block_type.type_block:
|
||||
{
|
||||
|
|
@ -4043,13 +4042,13 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
public void enter_in_cycle(statement_node stmt)
|
||||
{
|
||||
cycle_stack.push(stmt);
|
||||
cycle_stack.Push(stmt);
|
||||
disable_finally_control_break_check = true;
|
||||
}
|
||||
|
||||
public void leave_cycle()
|
||||
{
|
||||
cycle_stack.pop();
|
||||
cycle_stack.Pop();
|
||||
disable_finally_control_break_check = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
symtab.Clear();
|
||||
_type_constructor.reset();
|
||||
statement_list_stack.clear();
|
||||
statement_list_stack.Clear();
|
||||
//_current_operation_kind = special_operation_kind.none;
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
internal void statement_list_stack_push(statements_list sl)
|
||||
{
|
||||
sl.Scope = new SymbolTable.BlockScope(symbol_table, syntax_tree_visitor.context.CurrentScope);
|
||||
statement_list_stack.push(sl);
|
||||
statement_list_stack.Push(sl);
|
||||
}
|
||||
|
||||
internal SymbolTable.Scope create_block_scope()
|
||||
|
|
@ -94,17 +94,17 @@ namespace PascalABCCompiler.TreeConverter
|
|||
internal void statement_list_stack_push(statements_list sl, SymbolTable.Scope Scope)
|
||||
{
|
||||
sl.Scope = Scope;
|
||||
statement_list_stack.push(sl);
|
||||
statement_list_stack.Push(sl);
|
||||
}
|
||||
|
||||
internal statements_list statement_list_stack_pop()
|
||||
{
|
||||
return statement_list_stack.pop();
|
||||
return statement_list_stack.Pop();
|
||||
}
|
||||
|
||||
internal statements_list statement_list_stack_first()
|
||||
{
|
||||
return statement_list_stack.first();
|
||||
return statement_list_stack.Last();
|
||||
}
|
||||
|
||||
public type_constructor type_constructor
|
||||
|
|
@ -975,10 +975,10 @@ namespace PascalABCCompiler.TreeConverter
|
|||
if (factparams.Count > 0) loc = factparams[factparams.Count-1].location;
|
||||
//var_definition_node vdn=syntax_tree_visitor.context.add_var_definition_in_entry_scope(get_temp_arr_name(),loc);
|
||||
var_definition_node vdn = null;
|
||||
if (syntax_tree_visitor.context.converted_func_stack.size > 0)
|
||||
if (syntax_tree_visitor.context.converted_func_stack.Count > 0)
|
||||
{
|
||||
common_function_node cfn = syntax_tree_visitor.context.converted_func_stack.first();
|
||||
if (cfn.is_generic_function || !syntax_tree_visitor.context.has_nested_functions && syntax_tree_visitor.context.converted_func_stack.size == 1)
|
||||
common_function_node cfn = syntax_tree_visitor.context.converted_func_stack.Last();
|
||||
if (cfn.is_generic_function || !syntax_tree_visitor.context.has_nested_functions && syntax_tree_visitor.context.converted_func_stack.Count == 1)
|
||||
{
|
||||
vdn = syntax_tree_visitor.context.add_var_definition(get_temp_arr_name(), loc);
|
||||
|
||||
|
|
|
|||
|
|
@ -1881,7 +1881,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
return null;
|
||||
}
|
||||
if (context.cycle_stack.Empty)
|
||||
if (context.cycle_stack.Count == 0)
|
||||
{
|
||||
AddError(new BreakStatementWithoutComprehensiveCycle(call_location));
|
||||
}
|
||||
|
|
@ -1889,7 +1889,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
AddError(call_location, "EXIT_BREAK_CONTINUE_IN_FINALLY_BLOCK");
|
||||
}
|
||||
statement_node sn = context.cycle_stack.top();
|
||||
statement_node sn = context.cycle_stack.Peek();
|
||||
switch (sn.semantic_node_type)
|
||||
{
|
||||
case semantic_node_type.while_node:
|
||||
|
|
@ -1922,7 +1922,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
return null;
|
||||
}
|
||||
if (context.cycle_stack.Empty)
|
||||
if (context.cycle_stack.Count == 0)
|
||||
{
|
||||
AddError(new ContinueStatementWithoutComprehensiveCycle(call_location));
|
||||
}
|
||||
|
|
@ -1930,7 +1930,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
AddError(call_location, "EXIT_BREAK_CONTINUE_IN_FINALLY_BLOCK");
|
||||
}
|
||||
statement_node sn = context.cycle_stack.top();
|
||||
statement_node sn = context.cycle_stack.Peek();
|
||||
switch (sn.semantic_node_type)
|
||||
{
|
||||
case semantic_node_type.while_node:
|
||||
|
|
@ -2025,7 +2025,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
statement_node stm = convert_strong(eh.statements);
|
||||
context.leave_code_block();
|
||||
sl = convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
sl = convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
if (sl.statements.Count > 0 || sl.local_variables.Count > 0)
|
||||
{
|
||||
sl.statements.AddElement(stm);
|
||||
|
|
@ -2808,7 +2808,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
}
|
||||
}
|
||||
if (context.converting_block() == block_type.function_block && context.converted_func_stack.size == 1)
|
||||
if (context.converting_block() == block_type.function_block && context.converted_func_stack.Count == 1)
|
||||
{
|
||||
if (_block.defs != null)
|
||||
foreach (declaration decl in _block.defs.defs)
|
||||
|
|
@ -2821,7 +2821,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
}
|
||||
weak_node_test_and_visit(_block.defs);
|
||||
if (context.converting_block() == block_type.function_block && context.converted_func_stack.size == 1)
|
||||
if (context.converting_block() == block_type.function_block && context.converted_func_stack.Count == 1)
|
||||
context.has_nested_functions = false;
|
||||
//ssyy добавил генерацию вызова конструктора предка без параметров
|
||||
if (context.converting_block() == block_type.function_block)
|
||||
|
|
@ -2941,7 +2941,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
if (context.converting_block() == block_type.function_block)
|
||||
{
|
||||
if (context.func_stack.top().functions_nodes_list.Count > 0)
|
||||
if (context.func_stack.Peek().functions_nodes_list.Count > 0)
|
||||
{
|
||||
AddError(new LambdasNotAllowedWhenNestedSubprogrammesAreUsed(get_location(lambdaSearcher.FoundLambda)));
|
||||
}
|
||||
|
|
@ -2956,9 +2956,9 @@ namespace PascalABCCompiler.TreeConverter
|
|||
l.goto_statements.Clear();
|
||||
l.comprehensive_code_block = null;
|
||||
}
|
||||
if (context.func_stack.size > 0)
|
||||
if (context.func_stack.Count > 0)
|
||||
{
|
||||
var fun = context.func_stack.top();
|
||||
var fun = context.func_stack.Peek();
|
||||
foreach (var l in fun.label_nodes_list)
|
||||
{
|
||||
l.goto_statements.Clear();
|
||||
|
|
@ -9142,8 +9142,8 @@ namespace PascalABCCompiler.TreeConverter
|
|||
first_iteration = false;
|
||||
continue;
|
||||
}
|
||||
if (last_call != null && convertion_data_and_alghoritms.statement_list_stack.size > 0)
|
||||
convertion_data_and_alghoritms.statement_list_stack.top().statements.AddElement(last_call);
|
||||
if (last_call != null && convertion_data_and_alghoritms.statement_list_stack.Count > 0)
|
||||
convertion_data_and_alghoritms.statement_list_stack.Peek().statements.AddElement(last_call);
|
||||
expression_node en = convert_strong(ex);
|
||||
check_on_loop_variable(en);
|
||||
//if (en.type == null)
|
||||
|
|
@ -9260,8 +9260,8 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
if (!readln_string_file)
|
||||
{
|
||||
if (last_call != null && convertion_data_and_alghoritms.statement_list_stack.size > 0)
|
||||
convertion_data_and_alghoritms.statement_list_stack.top().statements.AddElement(last_call);
|
||||
if (last_call != null && convertion_data_and_alghoritms.statement_list_stack.Count > 0)
|
||||
convertion_data_and_alghoritms.statement_list_stack.Peek().statements.AddElement(last_call);
|
||||
exl.Clear();
|
||||
|
||||
if (read_from_file)
|
||||
|
|
@ -11990,7 +11990,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
assign_doc_info(cdn,_typed_const_definition);
|
||||
check_for_type_allowed(tn,get_location(_typed_const_definition.const_type));
|
||||
check_using_static_class(tn, get_location(_typed_const_definition.const_type));
|
||||
if (context.converted_type != null && context.converted_func_stack.Empty)
|
||||
if (context.converted_type != null && context.converted_func_stack.Count == 0)
|
||||
if (!constant_in_class_valid(tn))//proverka na primitivnost konstanty v klasse
|
||||
AddError(get_location(_typed_const_definition), "CLASS_CONSTANT_CAN_HAVE_ONLY_PRIMITIVE_VALUE");
|
||||
if (tn is common_type_node)
|
||||
|
|
@ -12055,7 +12055,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
cdn.const_value = convert_strong_to_constant_node(_simple_const_definition.const_value);
|
||||
cdn.const_value.SetType(DeduceType(cdn.const_value.type, cdn.const_value.location));
|
||||
assign_doc_info(cdn,_simple_const_definition);
|
||||
if (context.converted_type != null && context.converted_func_stack.Empty)
|
||||
if (context.converted_type != null && context.converted_func_stack.Count == 0)
|
||||
if (!constant_in_class_valid(cdn.const_value.type))
|
||||
AddError(get_location(_simple_const_definition), "CLASS_CONSTANT_CAN_HAVE_ONLY_PRIMITIVE_VALUE");
|
||||
|
||||
|
|
@ -12436,7 +12436,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
tn.type_special_kind == PascalABCCompiler.SemanticTree.type_special_kind.array_kind)// ||
|
||||
/*tn.type_special_kind == PascalABCCompiler.SemanticTree.type_special_kind.set_type*/
|
||||
{
|
||||
if (context.converted_func_stack.Empty)
|
||||
if (context.converted_func_stack.Count == 0)
|
||||
{
|
||||
type_synonym ts = new type_synonym(name, tn, loc);
|
||||
assign_doc_info(ts,_type_declaration);
|
||||
|
|
@ -13585,7 +13585,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
var proc_name = _procedure_definition.proc_header != null && _procedure_definition.proc_header.name != null
|
||||
? _procedure_definition.proc_header.name.meth_name
|
||||
: null;
|
||||
if (_procedure_definition.proc_header.attributes != null && context.converted_func_stack.size >= 1)
|
||||
if (_procedure_definition.proc_header.attributes != null && context.converted_func_stack.Count >= 1)
|
||||
AddError(get_location(_procedure_definition.proc_header), "ATTRIBUTES_FOR_NESTED_FUNCTIONS_NOT_ALLOWED");
|
||||
if (context.top_function != null && context.top_function.generic_params != null && !LambdaHelper.IsLambdaName(proc_name) && !(_procedure_definition.proc_header is SyntaxTree.constructor))
|
||||
AddError(get_location(_procedure_definition.proc_header), "NESTED_FUNCTIONS_IN_GENERIC_FUNCTIONS_NOT_ALLOWED");
|
||||
|
|
@ -13651,7 +13651,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
}
|
||||
//\ssyy
|
||||
if (context.converted_type != null && context.converted_type.IsStatic && !_procedure_definition.proc_header.class_keyword && context.func_stack.Empty)
|
||||
if (context.converted_type != null && context.converted_type.IsStatic && !_procedure_definition.proc_header.class_keyword && context.func_stack.Count == 0)
|
||||
AddError(get_location(_procedure_definition), "STATIC_CLASSES_CANNOT_NON_STATIC_MEMBERS");
|
||||
if (_procedure_definition.proc_body == null)
|
||||
{
|
||||
|
|
@ -16410,7 +16410,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
statement_node then_st = convert_strong(_if_node.then_body);
|
||||
context.leave_code_block();
|
||||
|
||||
sl = convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
sl = convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
if (sl.statements.Count > 0 || sl.local_variables.Count > 0)
|
||||
{
|
||||
sl.statements.AddElement(then_st);
|
||||
|
|
@ -16429,7 +16429,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
if (_if_node.else_body != null)
|
||||
{
|
||||
sl = convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
sl = convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
if (sl.statements.Count > 0 || sl.local_variables.Count > 0)
|
||||
{
|
||||
sl.statements.AddElement(else_st);
|
||||
|
|
@ -16462,7 +16462,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
statement_node st = convert_strong(_while_node.statements);
|
||||
context.leave_code_block();
|
||||
|
||||
sl = convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
sl = convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
if (sl.statements.Count > 0 || sl.local_variables.Count > 0)
|
||||
{
|
||||
sl.statements.AddElement(st);
|
||||
|
|
@ -16486,7 +16486,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
statement_node st = convert_strong(_repeat_node.statements);
|
||||
|
||||
sl = convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
sl = convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
//if (!(st is statements_list))
|
||||
if (sl.statements.Count > 0 || sl.local_variables.Count > 0)
|
||||
{
|
||||
|
|
@ -17888,7 +17888,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
AddError(get_location(ident), "NO_BASE_CLASS_DEFINED_BUT_INHERITED_MEET");
|
||||
}
|
||||
common_method_node cmn = context.converted_func_stack.first() as common_method_node;
|
||||
common_method_node cmn = context.converted_func_stack.Last() as common_method_node;
|
||||
if (cmn == null)
|
||||
{
|
||||
AddError(get_location(ident), "NAME_IN_BASE_CLASS_MUST_BE_METHOD");
|
||||
|
|
@ -17945,7 +17945,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
string name = ident.name;
|
||||
if (string.IsNullOrEmpty(name))
|
||||
name = context.converted_func_stack.first().name;
|
||||
name = context.converted_func_stack.Last().name;
|
||||
List<SymbolInfo> sil = context.converted_type.base_type.find_in_type(name, context.CurrentScope);
|
||||
if (sil == null)
|
||||
{
|
||||
|
|
@ -18081,8 +18081,8 @@ namespace PascalABCCompiler.TreeConverter
|
|||
location loc = get_location(_ident);
|
||||
function_node fn = sil.FirstOrDefault().sym_info as function_node;
|
||||
base_function_call bfc = null;
|
||||
common_function_node cfn = context.converted_func_stack.first();
|
||||
int depth = context.converted_func_stack.size-1;
|
||||
common_function_node cfn = context.converted_func_stack.Last();
|
||||
int depth = context.converted_func_stack.Count-1;
|
||||
if (!constr)
|
||||
{
|
||||
if (fn.polymorphic_state != SemanticTree.polymorphic_state.ps_static)
|
||||
|
|
@ -18547,7 +18547,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
base_function_call bfc = stl.statements[0] as basic_function_call;
|
||||
if (bfc.type != null && bfc.type.name.Contains("<>local_variables_class") && (semantic_statement is compiled_constructor_call || semantic_statement is common_constructor_call)
|
||||
&& !context.converted_func_stack.Empty && context.converted_func_stack.top() is common_method_node && (context.converted_func_stack.top() as common_method_node).is_constructor)
|
||||
&& context.converted_func_stack.Count > 0 && context.converted_func_stack.Peek() is common_method_node && (context.converted_func_stack.Peek() as common_method_node).is_constructor)
|
||||
stl.statements.AddElementFirst(semantic_statement);
|
||||
else
|
||||
stl.statements.AddElement(semantic_statement);
|
||||
|
|
@ -18616,7 +18616,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
if (for_intellisense)
|
||||
{
|
||||
if (syntax_statement is assign && !(context.converted_func_stack.top() != null && context.converted_func_stack.top().return_value_type is undefined_type)
|
||||
if (syntax_statement is assign && !(context.converted_func_stack.FirstOrDefault() != null && context.converted_func_stack.Peek().return_value_type is undefined_type)
|
||||
|| syntax_statement is procedure_call || syntax_statement is raise_statement)
|
||||
{
|
||||
|
||||
|
|
@ -18632,7 +18632,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
base_function_call bfc = stl.statements[0] as basic_function_call;
|
||||
if (bfc.type != null && bfc.type.name.Contains("<>local_variables_class") &&
|
||||
(semantic_statement is compiled_constructor_call && !(semantic_statement as compiled_constructor_call).new_obj_awaited() || semantic_statement is common_constructor_call && !(semantic_statement as common_constructor_call).new_obj_awaited())
|
||||
&& !context.converted_func_stack.Empty && context.converted_func_stack.top() is common_method_node && (context.converted_func_stack.top() as common_method_node).is_constructor)
|
||||
&& context.converted_func_stack.Count > 0 && context.converted_func_stack.Peek() is common_method_node && (context.converted_func_stack.Peek() as common_method_node).is_constructor)
|
||||
stl.statements.AddElementFirst(semantic_statement);
|
||||
else
|
||||
stl.statements.AddElement(semantic_statement);
|
||||
|
|
@ -18657,7 +18657,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
throw ex;
|
||||
}
|
||||
}
|
||||
convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
|
||||
#region MikhailoMMX, обработка omp parallel sections
|
||||
//флаг был установлен только если это самый внешний parallel sections и нужно сгенерировать обе ветки
|
||||
|
|
@ -18717,13 +18717,13 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
string module_name = "";
|
||||
string name = "";
|
||||
if (context.converted_func_stack.size > 1)
|
||||
if (context.converted_func_stack.Count > 1)
|
||||
AddError(context.top_function.loc, "EXTERNAL_METHOD_CANNOT_BE_NESTED");
|
||||
if (context.converted_func_stack.top() is common_method_node && (context.converted_func_stack.top() as common_method_node).polymorphic_state != SemanticTree.polymorphic_state.ps_static)
|
||||
if (context.converted_func_stack.Peek() is common_method_node && (context.converted_func_stack.Peek() as common_method_node).polymorphic_state != SemanticTree.polymorphic_state.ps_static)
|
||||
AddError(context.top_function.loc, "EXTERNAL_METHOD_SHOULD_BE_STATIC");
|
||||
if (context.converted_func_stack.top().is_generic_function)
|
||||
if (context.converted_func_stack.Peek().is_generic_function)
|
||||
AddError(context.top_function.loc, "EXTERNAL_METHOD_CANNOT_BE_GENERIC");
|
||||
if (context.converted_func_stack.top() is common_method_node && (context.converted_func_stack.top() as common_method_node).common_comprehensive_type.is_generic_type_definition)
|
||||
if (context.converted_func_stack.Peek() is common_method_node && (context.converted_func_stack.Peek() as common_method_node).common_comprehensive_type.is_generic_type_definition)
|
||||
AddError(context.top_function.loc, "EXTERNAL_METHOD_CANNOT_BE_DECLARED_IN_GENERIC_TYPE");
|
||||
|
||||
if (_external_directive.modulename == null)
|
||||
|
|
@ -18769,7 +18769,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
AddError(get_location(_external_directive.modulename), "DLLNAME_CANNOT_BE_EMPTY");
|
||||
if (_external_directive.name == null)
|
||||
{
|
||||
name = context.converted_func_stack.top().name;
|
||||
name = context.converted_func_stack.Peek().name;
|
||||
}
|
||||
else
|
||||
if (_external_directive.name is SyntaxTree.string_const)
|
||||
|
|
@ -20909,7 +20909,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
fn.body = convert_strong(node.stmt);
|
||||
context.leave_code_block();
|
||||
|
||||
slst = convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
slst = convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
if (slst.statements.Count > 0 || slst.local_variables.Count > 0)
|
||||
{
|
||||
slst.statements.AddElement(fn.body);
|
||||
|
|
@ -20918,7 +20918,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
context.leave_cycle();
|
||||
|
||||
head_stmts = convertion_data_and_alghoritms.statement_list_stack.pop();
|
||||
head_stmts = convertion_data_and_alghoritms.statement_list_stack.Pop();
|
||||
head_stmts.statements.AddElement(fn);
|
||||
return_value(head_stmts);
|
||||
|
||||
|
|
@ -21334,7 +21334,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
procDecl.proc_header.where_defs = whereSection;
|
||||
}
|
||||
|
||||
if (!context.func_stack.Empty && context.func_stack.top().polymorphic_state == SemanticTree.polymorphic_state.ps_static
|
||||
if (context.func_stack.Count > 0 && context.func_stack.Peek().polymorphic_state == SemanticTree.polymorphic_state.ps_static
|
||||
|| context.converted_type != null && context.converted_type.IsStatic)
|
||||
{
|
||||
procDecl.proc_header.class_keyword = true;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net40</TargetFramework>
|
||||
|
||||
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace PascalABCCompiler.TreeRealization
|
|||
return exprl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Serializable]
|
||||
public class attributes_list : extended_collection<attribute_node>
|
||||
{
|
||||
|
|
@ -210,7 +210,17 @@ namespace PascalABCCompiler.TreeRealization
|
|||
}
|
||||
|
||||
[Serializable]
|
||||
public class statement_node_stack : stack<statement_node>
|
||||
public class statement_node_stack : Stack<statement_node>
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class statement_list_stack: Stack<statements_list>
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class common_function_node_stack: Stack<common_function_node>
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue