commit
79dacd5f37
24
TestSuite/lambda_capture_local_vs_field.pas
Normal file
24
TestSuite/lambda_capture_local_vs_field.pas
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
type
|
||||
t1 = class
|
||||
|
||||
static a: integer := 1;//не обязательно статичное поле
|
||||
|
||||
procedure p1;
|
||||
begin
|
||||
var a := 2;
|
||||
var p: procedure := ()->begin
|
||||
|
||||
Assert(a=2);
|
||||
|
||||
end;
|
||||
|
||||
p;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
|
||||
(new t1).p1;
|
||||
|
||||
end.
|
||||
24
TestSuite/lambda_nonstatic_from_static.pas.pas
Normal file
24
TestSuite/lambda_nonstatic_from_static.pas.pas
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
type
|
||||
t1 = class
|
||||
|
||||
b: byte;
|
||||
|
||||
static procedure p1(b: byte);
|
||||
begin
|
||||
|
||||
var p: procedure;
|
||||
p := ()->
|
||||
begin
|
||||
p := ()->
|
||||
begin
|
||||
b := b;
|
||||
end;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
begin
|
||||
Assert(1=1);
|
||||
end.
|
||||
|
|
@ -1035,8 +1035,17 @@ namespace SymbolTable
|
|||
// Нет. Как-то найти глобальное ПИ модуля
|
||||
while (scope != null && !(scope is UnitInterfaceScope))
|
||||
{
|
||||
if (scope is ClassMethodScope)
|
||||
scope = (scope as ClassMethodScope).DefScope;
|
||||
if (scope is ClassMethodScope)
|
||||
{
|
||||
// aab 17.05.19 begin
|
||||
// Поправил приоритет поиска для ?System
|
||||
var classMethodScope = scope as ClassMethodScope;
|
||||
if (classMethodScope.DefScope != null)
|
||||
scope = classMethodScope.DefScope;
|
||||
else
|
||||
scope = classMethodScope.CurrentLambdaDefScope;
|
||||
// aab 17.05.19 end
|
||||
}
|
||||
else scope = scope.TopScope;
|
||||
}
|
||||
if (scope != null)
|
||||
|
|
@ -1155,12 +1164,8 @@ namespace SymbolTable
|
|||
var defScope = (CurrentArea as ClassMethodScope).DefScope;
|
||||
if (defScope != null)
|
||||
{
|
||||
var defScopeRes = FindAll(defScope, Name, OnlyInType, OnlyInThisClass, defScope);
|
||||
|
||||
if (defScopeRes != null && defScopeRes.Count > 0)
|
||||
{
|
||||
return defScopeRes;
|
||||
}
|
||||
CurrentArea = defScope;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1179,7 +1179,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
// aab 26.04.19
|
||||
// Здесь topScope записывается именно в CurrentLambdaDefScope, а не в DefScope
|
||||
// Во всех остальных случаях записывается в DefScope
|
||||
SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_ctn.Scope, topScope, null, "lambda " + name); // aab 09.05.19 Временно вернул обратно
|
||||
SymbolTable.Scope scope = convertion_data_and_alghoritms.symbol_table.CreateClassMethodScope(_ctn.Scope, null, topScope, "lambda " + name);
|
||||
|
||||
//TODO:сделать static и virtual.
|
||||
//TODO: interface and implementation scopes.
|
||||
|
|
|
|||
Loading…
Reference in a new issue