mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-04-05 21:47:47 +02:00
pastojs: filer: restore global shortref names
This commit is contained in:
parent
f8c8b1f0a2
commit
2ef1ac3d83
@ -7531,8 +7531,11 @@ var
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=0 to length(PrecompiledVars)-1 do
|
||||
if PrecompiledVars[i].Name=aName then
|
||||
exit(PrecompiledVars[i]);
|
||||
begin
|
||||
Result:=PrecompiledVars[i];
|
||||
if Result.Name=aName then
|
||||
exit;
|
||||
end;
|
||||
if not WithParents then
|
||||
exit(nil);
|
||||
Result:=inherited FindPrecompiledVar(aName,WithParents);
|
||||
@ -7544,8 +7547,11 @@ var
|
||||
i: Integer;
|
||||
begin
|
||||
for i:=0 to length(PrecompiledVars)-1 do
|
||||
if PrecompiledVars[i].Element=El then
|
||||
exit(PrecompiledVars[i]);
|
||||
begin
|
||||
Result:=PrecompiledVars[i];
|
||||
if Result.Element=El then
|
||||
exit;
|
||||
end;
|
||||
if not WithParents then
|
||||
exit(nil);
|
||||
Result:=inherited FindPrecompiledVar(El, WithParents);
|
||||
@ -7578,6 +7584,7 @@ function TFunctionContext.AddLocalVar(aName: string; El: TPasElement;
|
||||
var
|
||||
l: Integer;
|
||||
Ident, V: TFCLocalIdentifier;
|
||||
PV: TPas2JSStoredLocalVar;
|
||||
begin
|
||||
Ident:=FindLocalVar(aName,true);
|
||||
if Ident<>nil then
|
||||
@ -7599,7 +7606,15 @@ begin
|
||||
raise EPas2JS.Create('[20200608131330] "'+aName+'" El='+GetObjPath(El));
|
||||
end;
|
||||
end;
|
||||
end
|
||||
else if aKind=cvkGlobal then
|
||||
begin
|
||||
// check precompiled names
|
||||
PV:=FindPrecompiledVar(El,true);
|
||||
if PV<>nil then
|
||||
aName:=PV.Name;
|
||||
end;
|
||||
// add
|
||||
l:=length(LocalVars);
|
||||
SetLength(LocalVars,l+1);
|
||||
Result:=TFCLocalIdentifier.Create(aName,El,aKind);
|
||||
@ -16963,6 +16978,7 @@ begin
|
||||
AddToSourceElements(ConstSrcElems,Lit);
|
||||
end;
|
||||
end;
|
||||
|
||||
if coShortRefGlobals in Options then
|
||||
CreateGlobalAlias_List(ImplJS.ShortRefs,AContext);
|
||||
// precompiled body
|
||||
|
Loading…
Reference in New Issue
Block a user