pastojs: library: export var

This commit is contained in:
mattias 2021-10-21 22:57:42 +02:00
parent f4580ff612
commit d2a091ef85
2 changed files with 21 additions and 8 deletions

View File

@ -4915,6 +4915,7 @@ var
ResolvedEl: TPasResolverResult; ResolvedEl: TPasResolverResult;
DeclEl: TPasElement; DeclEl: TPasElement;
Proc: TPasProcedure; Proc: TPasProcedure;
V: TPasVariable;
begin begin
if El.Parent is TLibrarySection then if El.Parent is TLibrarySection then
// ok // ok
@ -4930,14 +4931,22 @@ begin
DeclEl:=ResolvedEl.IdentEl; DeclEl:=ResolvedEl.IdentEl;
if DeclEl=nil then if DeclEl=nil then
RaiseMsg(20210106223620,nSymbolCannotBeExportedFromALibrary, RaiseMsg(20210106223620,nSymbolCannotBeExportedFromALibrary,
sSymbolCannotBeExportedFromALibrary,[],El) sSymbolCannotBeExportedFromALibrary,[],El);
else if DeclEl is TPasProcedure then if not (DeclEl.Parent is TPasSection) then
RaiseMsg(20210106224436,nSymbolCannotBeExportedFromALibrary,
sSymbolCannotBeExportedFromALibrary,[],El);
if DeclEl is TPasProcedure then
begin begin
Proc:=TPasProcedure(DeclEl); Proc:=TPasProcedure(DeclEl);
if Proc.Parent is TPasSection then if Proc.IsExternal or Proc.IsAbstract then
// ok RaiseMsg(20211021225630,nSymbolCannotBeExportedFromALibrary,
else sSymbolCannotBeExportedFromALibrary,[],El);
RaiseMsg(20210106224436,nSymbolCannotBeExportedFromALibrary, end
else if DeclEl is TPasVariable then
begin
V:=TPasVariable(DeclEl);
if vmExternal in V.VarModifiers then
RaiseMsg(20211021225634,nSymbolCannotBeExportedFromALibrary,
sSymbolCannotBeExportedFromALibrary,[],El); sSymbolCannotBeExportedFromALibrary,[],El);
end end
else else

View File

@ -913,6 +913,7 @@ type
Procedure TestLibrary_ExportFunc; Procedure TestLibrary_ExportFunc;
Procedure TestLibrary_Export_Index_Fail; Procedure TestLibrary_Export_Index_Fail;
Procedure TestLibrary_ExportVar; // ToDo Procedure TestLibrary_ExportVar; // ToDo
Procedure TestLibrary_ExportUnitFunc;
// ToDo: test delayed specialization init // ToDo: test delayed specialization init
// ToDo: analyzer // ToDo: analyzer
end; end;
@ -33836,8 +33837,6 @@ end;
procedure TTestModule.TestLibrary_ExportVar; procedure TTestModule.TestLibrary_ExportVar;
begin begin
exit;
StartLibrary(false); StartLibrary(false);
Add([ Add([
'var Wing: word;', 'var Wing: word;',
@ -33855,6 +33854,11 @@ begin
CheckResolverUnexpectedHints(); CheckResolverUnexpectedHints();
end; end;
procedure TTestModule.TestLibrary_ExportUnitFunc;
begin
end;
Initialization Initialization
RegisterTests([TTestModule]); RegisterTests([TTestModule]);
end. end.