Merge branch 'master' of https://github.com/pascalabcnet/pascalabcnet
This commit is contained in:
commit
92a8d17a22
|
|
@ -578,7 +578,18 @@ namespace CodeCompletion
|
|||
}
|
||||
|
||||
public document doc;
|
||||
|
||||
|
||||
public location get_location(SourceContext sc)
|
||||
{
|
||||
if (sc == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new location(sc.begin_position.line_num, sc.begin_position.column_num,
|
||||
sc.end_position.line_num, sc.end_position.column_num, doc);
|
||||
}
|
||||
|
||||
|
||||
public location get_location(syntax_tree_node tn)
|
||||
{
|
||||
if (tn.source_context==null)
|
||||
|
|
@ -2021,7 +2032,7 @@ namespace CodeCompletion
|
|||
SymScope tmp = cur_scope;
|
||||
SymScope stmt_scope = new BlockScope(cur_scope);
|
||||
cur_scope.AddName("$block_scope",stmt_scope);
|
||||
stmt_scope.loc = get_location(_unit_module.initialization_part);
|
||||
stmt_scope.loc = get_location(_unit_module.initialization_part.left_logical_bracket.source_context.Merge(_unit_module.initialization_part.right_logical_bracket.source_context));
|
||||
cur_scope = stmt_scope;
|
||||
_unit_module.initialization_part.visit(this);
|
||||
cur_scope = tmp;
|
||||
|
|
@ -2031,8 +2042,8 @@ namespace CodeCompletion
|
|||
SymScope tmp = cur_scope;
|
||||
SymScope stmt_scope = new BlockScope(cur_scope);
|
||||
cur_scope.AddName("$block_scope",stmt_scope);
|
||||
stmt_scope.loc = get_location(_unit_module.finalization_part);
|
||||
cur_scope = stmt_scope;
|
||||
stmt_scope.loc = get_location(_unit_module.finalization_part.left_logical_bracket.source_context.Merge(_unit_module.finalization_part.right_logical_bracket.source_context));
|
||||
cur_scope = stmt_scope;
|
||||
_unit_module.finalization_part.visit(this);
|
||||
cur_scope = tmp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -478,7 +478,7 @@ namespace CodeCompletion
|
|||
|
||||
public void AddUsedUnit(SymScope unit)
|
||||
{
|
||||
if (this.si.name != "PABCSystem")
|
||||
if (this.si.name != "PABCSystem" || unit is NamespaceScope)
|
||||
used_units.Add(unit);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -394,6 +394,7 @@ namespace GPPGParserScanner
|
|||
scanner.parsertools = parsertools;// передали parsertools в объект сканера
|
||||
GPPGParser parser = new GPPGParser(scanner);
|
||||
parsertools.build_tree_for_formatter = false;
|
||||
parser.lambdaHelper = this.lambdaHelper;
|
||||
parser.parsertools = parsertools;
|
||||
if (!parser.Parse())
|
||||
if (parsertools.errors.Count == 0)
|
||||
|
|
|
|||
5
TestSuite/formatstring4.pas
Normal file
5
TestSuite/formatstring4.pas
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
begin
|
||||
var p: procedure := procedure()->exit;
|
||||
var s := $'{Seq(0).Select(i->i).First}';
|
||||
assert(s = '0');
|
||||
end.
|
||||
|
|
@ -441,17 +441,18 @@ namespace SymbolTable
|
|||
}
|
||||
//\ssyy owns
|
||||
|
||||
public class ClassMethodScope:Scope
|
||||
//В ClassMethodScope TopScope должен быть классом
|
||||
public class ClassMethodScope:Scope
|
||||
{
|
||||
public Scope MyClass;
|
||||
public Scope DefScope;
|
||||
|
||||
public ClassMethodScope(DSSymbolTable vSymbolTable,Scope TopScope,Scope MyClass, string Name):
|
||||
public ClassMethodScope(DSSymbolTable vSymbolTable, Scope TopScope, Scope DefScope, string Name):
|
||||
base(vSymbolTable,TopScope, Name)
|
||||
{
|
||||
this.Name = Name;
|
||||
this.MyClass = null;
|
||||
if (MyClass != null)
|
||||
this.MyClass = MyClass;
|
||||
this.DefScope = null;
|
||||
if (DefScope != null)
|
||||
this.DefScope = DefScope;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
@ -554,8 +555,21 @@ namespace SymbolTable
|
|||
private Scope real_scope;
|
||||
public PrimaryScope(Scope sc)
|
||||
{
|
||||
ScopeName = sc.Name;
|
||||
real_scope = sc;
|
||||
if(real_scope is BlockScope)
|
||||
{
|
||||
int deep = 0;
|
||||
Scope Top = real_scope.TopScope;
|
||||
while(Top != null && (Top is BlockScope))
|
||||
{
|
||||
deep++;
|
||||
Top = Top.TopScope;
|
||||
}
|
||||
ScopeName = "Begin—End;(Deep = " + deep + ")";
|
||||
}
|
||||
else
|
||||
ScopeName = sc.Name;
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
@ -666,9 +680,9 @@ namespace SymbolTable
|
|||
{
|
||||
return new UnitImplementationScope(this, InterfaceScope, UsedUnits, Name);
|
||||
}
|
||||
public ClassMethodScope CreateClassMethodScope(Scope TopScope,Scope MyClass, string Name = "")
|
||||
public ClassMethodScope CreateClassMethodScope(Scope TopScope, Scope DefScope, string Name = "")
|
||||
{
|
||||
return new ClassMethodScope(this, TopScope, MyClass, Name);
|
||||
return new ClassMethodScope(this, TopScope, DefScope, Name);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
@ -828,7 +842,7 @@ namespace SymbolTable
|
|||
{
|
||||
while (scope != null && !(scope is ClassScope))
|
||||
if(scope is ClassMethodScope)
|
||||
scope = ((ClassMethodScope)scope).MyClass;
|
||||
scope = scope.TopScope;
|
||||
else
|
||||
scope = scope.TopScope;
|
||||
return scope;
|
||||
|
|
@ -1077,10 +1091,12 @@ namespace SymbolTable
|
|||
}
|
||||
if (CurrentArea is ClassMethodScope)//мы очутились в методе класса
|
||||
{
|
||||
FindAllInClass(Name, (CurrentArea as ClassMethodScope).MyClass, OnlyInThisClass, Result);//надо сделать поиск по его классу
|
||||
FindAllInClass(Name, (CurrentArea as ClassMethodScope).TopScope, OnlyInThisClass, Result);//надо сделать поиск по его классу
|
||||
|
||||
if (Result.Count > 0) //если что-то нашли то заканчиваем
|
||||
return Result;
|
||||
CurrentArea = (CurrentArea as ClassMethodScope).DefScope;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
CurrentArea = CurrentArea.TopScope;//Пошли вверх
|
||||
|
|
@ -1175,9 +1191,9 @@ namespace SymbolTable
|
|||
if (an is ClassMethodScope)
|
||||
{
|
||||
//ssyy
|
||||
NextUnitArea = an.TopScope;
|
||||
NextUnitArea = (an as ClassMethodScope).DefScope;
|
||||
//\ssyy
|
||||
Area = (an as ClassMethodScope).MyClass;
|
||||
Area = an.TopScope;
|
||||
}
|
||||
else
|
||||
Area = Area.TopScope;
|
||||
|
|
|
|||
|
|
@ -1022,7 +1022,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
SymbolInfo si = _ctn.find_first_in_type(compiler_string_consts.noteq_name);
|
||||
if (si.sym_info is common_method_node)
|
||||
return;
|
||||
SymbolTable.ClassMethodScope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_cmn.scope,_ctn.scope, si.ToString());
|
||||
SymbolTable.ClassMethodScope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_ctn.scope, _cmn.scope, si.ToString());
|
||||
common_method_node cmn = new common_method_node(compiler_string_consts.GetNETOperName(compiler_string_consts.noteq_name),SystemLibrary.SystemLibrary.bool_type,null,_ctn,
|
||||
SemanticTree.polymorphic_state.ps_static,SemanticTree.field_access_level.fal_public,scope);
|
||||
cmn.IsOperator = true;
|
||||
|
|
@ -1056,7 +1056,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
SymbolInfo si = _ctn.find_first_in_type(compiler_string_consts.eq_name);
|
||||
if (si.sym_info is common_method_node)
|
||||
return;
|
||||
SymbolTable.ClassMethodScope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_cmn.scope,_ctn.scope, si.ToString());
|
||||
SymbolTable.ClassMethodScope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope( _ctn.scope, _cmn.scope, si.ToString());
|
||||
common_method_node cmn = new common_method_node(compiler_string_consts.GetNETOperName(compiler_string_consts.eq_name),SystemLibrary.SystemLibrary.bool_type,null,_ctn,
|
||||
SemanticTree.polymorphic_state.ps_static,SemanticTree.field_access_level.fal_public,scope);
|
||||
cmn.IsOperator = true;
|
||||
|
|
@ -1175,7 +1175,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
if (_ctn != null)
|
||||
{
|
||||
common_method_node cmmn;
|
||||
SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(topScope, _ctn.Scope, "lambda " + name);
|
||||
SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_ctn.Scope, topScope, "lambda " + name);
|
||||
//TODO:сделать static и virtual.
|
||||
//TODO: interface and implementation scopes.
|
||||
cmmn = new common_method_node(name, def_loc, _ctn, SemanticTree.polymorphic_state.ps_common, _fal, scope);
|
||||
|
|
@ -1235,7 +1235,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
if (!extension_method)
|
||||
{
|
||||
common_method_node cmmn;
|
||||
SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_cmn.scope, _ctn.Scope, name=="create"? "constructor " + _ctn.Scope : "method " + name + " from " + _ctn.Scope);
|
||||
SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_ctn.Scope, _cmn.scope, name=="create"? "constructor " + _ctn.Scope : "method " + name);
|
||||
//TODO:сделать static и virtual.
|
||||
//TODO: interface and implementation scopes.
|
||||
cmmn = new common_method_node(name, def_loc, _ctn, SemanticTree.polymorphic_state.ps_common, _fal, scope);
|
||||
|
|
@ -1250,7 +1250,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
else
|
||||
{
|
||||
common_namespace_function_node cnfnn;
|
||||
SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_cmn.scope, _ctn.scope, name);
|
||||
SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_ctn.scope, _cmn.scope, name);
|
||||
cnfnn = new common_namespace_function_node(name, def_loc, _cmn, scope);
|
||||
//_cmn.functions.AddElement(cnfnn);
|
||||
syntax_tree_visitor.compiled_unit.namespaces[0].functions.AddElement(cnfnn);
|
||||
|
|
@ -1266,7 +1266,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
//string cname = compiler_string_consts.GetConnectedFunctionName(_compiled_tn.name, name);
|
||||
common_namespace_function_node cnfnn;
|
||||
SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_cmn.scope, _compiled_tn.scope, name);
|
||||
SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_compiled_tn.scope, _cmn.scope, name);
|
||||
cnfnn = new common_namespace_function_node(name, def_loc, _cmn, scope);
|
||||
//_cmn.functions.AddElement(cnfnn);
|
||||
syntax_tree_visitor.compiled_unit.namespaces[0].functions.AddElement(cnfnn);
|
||||
|
|
@ -2149,9 +2149,9 @@ namespace PascalABCCompiler.TreeConverter
|
|||
|
||||
List<SymbolInfo> sil = curscope.Find(name, curscope);
|
||||
List<SymbolInfo> si2 = null;
|
||||
if (sil != null && sil.FirstOrDefault().scope is SymbolTable.ClassScope && curscope.TopScope is SymbolTable.BlockScope && curscope.TopScope.TopScope is SymbolTable.ClassMethodScope && curscope.TopScope.TopScope.TopScope is SymbolTable.BlockScope)
|
||||
if (sil != null && sil.FirstOrDefault().scope is SymbolTable.ClassScope && curscope.TopScope is SymbolTable.BlockScope && curscope.TopScope.TopScope is SymbolTable.ClassMethodScope && ((SymbolTable.ClassMethodScope)curscope.TopScope.TopScope).DefScope is SymbolTable.BlockScope)
|
||||
{
|
||||
si2 = curscope.TopScope.TopScope.TopScope.Find(name, curscope.TopScope.TopScope.TopScope);
|
||||
si2 = ((SymbolTable.ClassMethodScope)curscope.TopScope.TopScope).DefScope.Find(name, ((SymbolTable.ClassMethodScope)curscope.TopScope.TopScope).DefScope);
|
||||
if (si2 != null && si2.FirstOrDefault().scope is SymbolTable.ClassMethodScope)
|
||||
{
|
||||
sil = si2;
|
||||
|
|
@ -3634,7 +3634,12 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
pn = si.sym_info as property_node;
|
||||
//(ssyy) Сверяем как параметры функций, так и типы возвращаемых значений
|
||||
if (convertion_data_and_alghoritms.function_eq_params_and_result(cpn.get_function, pn.get_function))
|
||||
if (cpn.get_function == null && pn.get_function == null && pn.property_type == cpn.property_type)
|
||||
{
|
||||
find_property = si;
|
||||
break;
|
||||
}
|
||||
else if (cpn.get_function != null && pn.get_function != null && convertion_data_and_alghoritms.function_eq_params_and_result(cpn.get_function, pn.get_function))
|
||||
{
|
||||
find_property = si;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -52,6 +52,16 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
}
|
||||
|
||||
public SymbolTable.PrimaryScope CurrentScope
|
||||
{
|
||||
get
|
||||
{
|
||||
if(context.CurrentScope != null)
|
||||
return new SymbolTable.PrimaryScope(context.CurrentScope);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public convertion_data_and_alghoritms convertion_data_and_alghoritms;
|
||||
|
||||
internal returner ret;
|
||||
|
|
|
|||
|
|
@ -562,7 +562,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
}
|
||||
|
||||
//= operation
|
||||
SymbolTable.ClassMethodScope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_cmn.scope,ctn.scope, "= operator from " + ctn.scope);
|
||||
SymbolTable.ClassMethodScope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(ctn.scope, _cmn.scope, "= operator from " + ctn.scope);
|
||||
common_method_node cmn_eq = new common_method_node(compiler_string_consts.GetNETOperName(compiler_string_consts.eq_name),SystemLibrary.SystemLibrary.bool_type,null,ctn,
|
||||
SemanticTree.polymorphic_state.ps_static,SemanticTree.field_access_level.fal_public,scope);
|
||||
cmn_eq.IsOperator = true;
|
||||
|
|
@ -597,7 +597,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
ctn.Scope.AddSymbol(compiler_string_consts.eq_name,new SymbolInfo(cmn_eq));
|
||||
|
||||
//<> operation
|
||||
scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_cmn.scope,ctn.scope, "<> operator from " + ctn.scope);
|
||||
scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(ctn.scope, _cmn.scope, "<> operator from " + ctn.scope);
|
||||
common_method_node cmn_noteq = new common_method_node(compiler_string_consts.GetNETOperName(compiler_string_consts.noteq_name),SystemLibrary.SystemLibrary.bool_type,null,ctn,
|
||||
SemanticTree.polymorphic_state.ps_static,SemanticTree.field_access_level.fal_public,scope);
|
||||
cmn_noteq.IsOperator = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue