mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-07-09 17:36:09 +02:00
pastojs: filer: fixed AddRef
git-svn-id: trunk@38536 -
This commit is contained in:
parent
9ce56107d8
commit
b51a63766c
@ -1190,12 +1190,11 @@ begin
|
||||
writeln('TPas2jsCachedFile.Load ENCODE ',Filename,' FFileEncoding=',FFileEncoding);
|
||||
{$ENDIF}
|
||||
if Binary then
|
||||
FSource:=ConvertTextToUTF8(NewSource,FFileEncoding)
|
||||
else
|
||||
begin
|
||||
FSource:=NewSource;
|
||||
FFileEncoding:=EncodingBinary;
|
||||
end;
|
||||
end else
|
||||
FSource:=ConvertTextToUTF8(NewSource,FFileEncoding);
|
||||
FLoaded:=true;
|
||||
FCacheStamp:=Cache.ResetStamp;
|
||||
FLoadedFileAge:=Cache.DirectoryCache.FileAge(Filename);
|
||||
|
@ -3683,7 +3683,10 @@ var
|
||||
El: TPasVariable absolute Data;
|
||||
begin
|
||||
if RefEl is TPasType then
|
||||
El.VarType:=TPasType(RefEl)
|
||||
begin
|
||||
El.VarType:=TPasType(RefEl);
|
||||
RefEl.AddRef;
|
||||
end
|
||||
else
|
||||
RaiseMsg(20180211121809,El,GetObjName(RefEl));
|
||||
end;
|
||||
@ -3693,7 +3696,10 @@ var
|
||||
El: TPasAliasType absolute Data;
|
||||
begin
|
||||
if RefEl is TPasType then
|
||||
El.DestType:=TPasType(RefEl)
|
||||
begin
|
||||
El.DestType:=TPasType(RefEl);
|
||||
RefEl.AddRef;
|
||||
end
|
||||
else
|
||||
RaiseMsg(20180211121801,El,GetObjName(RefEl));
|
||||
end;
|
||||
@ -3704,7 +3710,10 @@ var
|
||||
El: TPasPointerType absolute Data;
|
||||
begin
|
||||
if RefEl is TPasType then
|
||||
El.DestType:=TPasType(RefEl)
|
||||
begin
|
||||
El.DestType:=TPasType(RefEl);
|
||||
RefEl.AddRef;
|
||||
end
|
||||
else
|
||||
RaiseMsg(20180211121757,El,GetObjName(RefEl));
|
||||
end;
|
||||
@ -3715,7 +3724,10 @@ var
|
||||
El: TInlineTypeExpr absolute Data;
|
||||
begin
|
||||
if RefEl is TPasType then
|
||||
El.DestType:=TPasType(RefEl)
|
||||
begin
|
||||
El.DestType:=TPasType(RefEl);
|
||||
RefEl.AddRef;
|
||||
end
|
||||
else
|
||||
RaiseMsg(20180211121750,El,GetObjName(RefEl));
|
||||
end;
|
||||
@ -3725,7 +3737,10 @@ var
|
||||
El: TPasArrayType absolute Data;
|
||||
begin
|
||||
if RefEl is TPasType then
|
||||
El.ElType:=TPasType(RefEl)
|
||||
begin
|
||||
El.ElType:=TPasType(RefEl);
|
||||
RefEl.AddRef;
|
||||
end
|
||||
else
|
||||
RaiseMsg(20180211121732,El,GetObjName(RefEl));
|
||||
end;
|
||||
@ -3735,7 +3750,10 @@ var
|
||||
El: TPasFileType absolute Data;
|
||||
begin
|
||||
if RefEl is TPasType then
|
||||
El.ElType:=TPasType(RefEl)
|
||||
begin
|
||||
El.ElType:=TPasType(RefEl);
|
||||
RefEl.AddRef;
|
||||
end
|
||||
else
|
||||
RaiseMsg(20180211121726,El,GetObjName(RefEl));
|
||||
end;
|
||||
@ -3745,7 +3763,10 @@ var
|
||||
El: TPasSetType absolute Data;
|
||||
begin
|
||||
if RefEl is TPasType then
|
||||
El.EnumType:=TPasType(RefEl)
|
||||
begin
|
||||
El.EnumType:=TPasType(RefEl);
|
||||
RefEl.AddRef;
|
||||
end
|
||||
else
|
||||
RaiseMsg(20180211121714,El,GetObjName(RefEl));
|
||||
end;
|
||||
@ -3755,7 +3776,10 @@ var
|
||||
El: TPasVariant absolute Data;
|
||||
begin
|
||||
if RefEl is TPasRecordType then
|
||||
El.Members:=TPasRecordType(RefEl)
|
||||
begin
|
||||
El.Members:=TPasRecordType(RefEl);
|
||||
RefEl.AddRef;
|
||||
end
|
||||
else
|
||||
RaiseMsg(20180211121657,El,GetObjName(RefEl));
|
||||
end;
|
||||
@ -3766,7 +3790,10 @@ var
|
||||
El: TPasRecordType absolute Data;
|
||||
begin
|
||||
if (RefEl is TPasType) or (RefEl.ClassType=TPasVariable) then
|
||||
El.VariantEl:=RefEl
|
||||
begin
|
||||
El.VariantEl:=RefEl;
|
||||
RefEl.AddRef;
|
||||
end
|
||||
else
|
||||
RaiseMsg(20180210205031,El,GetObjName(RefEl));
|
||||
end;
|
||||
@ -3776,7 +3803,10 @@ var
|
||||
El: TPasArgument absolute Data;
|
||||
begin
|
||||
if RefEl is TPasType then
|
||||
El.ArgType:=TPasType(RefEl)
|
||||
begin
|
||||
El.ArgType:=TPasType(RefEl);
|
||||
RefEl.AddRef;
|
||||
end
|
||||
else
|
||||
RaiseMsg(20180211121643,El,GetObjName(RefEl));
|
||||
end;
|
||||
@ -3829,7 +3859,10 @@ var
|
||||
El: TPasClassType absolute Data;
|
||||
begin
|
||||
if RefEl is TPasType then
|
||||
El.AncestorType:=TPasType(RefEl)
|
||||
begin
|
||||
El.AncestorType:=TPasType(RefEl);
|
||||
RefEl.AddRef;
|
||||
end
|
||||
else
|
||||
RaiseMsg(20180211121632,El,GetObjName(RefEl));
|
||||
end;
|
||||
@ -3840,7 +3873,10 @@ var
|
||||
El: TPasClassType absolute Data;
|
||||
begin
|
||||
if RefEl is TPasType then
|
||||
El.HelperForType:=TPasType(RefEl)
|
||||
begin
|
||||
El.HelperForType:=TPasType(RefEl);
|
||||
RefEl.AddRef;
|
||||
end
|
||||
else
|
||||
RaiseMsg(20180211121612,El,GetObjName(RefEl));
|
||||
end;
|
||||
@ -3851,7 +3887,10 @@ var
|
||||
El: TPasResultElement absolute Data;
|
||||
begin
|
||||
if RefEl is TPasType then
|
||||
El.ResultType:=TPasType(RefEl)
|
||||
begin
|
||||
El.ResultType:=TPasType(RefEl);
|
||||
RefEl.AddRef;
|
||||
end
|
||||
else
|
||||
RaiseMsg(20180211121537,El,GetObjName(RefEl));
|
||||
end;
|
||||
@ -3925,7 +3964,10 @@ var
|
||||
Scope: TPasPropertyScope absolute Data;
|
||||
begin
|
||||
if RefEl is TPasProperty then
|
||||
Scope.AncestorProp:=TPasProperty(RefEl)
|
||||
begin
|
||||
Scope.AncestorProp:=TPasProperty(RefEl);
|
||||
RefEl.AddRef;
|
||||
end
|
||||
else
|
||||
RaiseMsg(20180213214723,Scope.Element,GetObjName(RefEl));
|
||||
end;
|
||||
@ -5985,7 +6027,8 @@ end;
|
||||
procedure TPCUReader.ReadEnumTypeScope(Obj: TJSONObject;
|
||||
Scope: TPasEnumTypeScope; aContext: TPCUReaderContext);
|
||||
begin
|
||||
Scope.CanonicalSet:=TPasSetType(ReadElementProperty(Obj,Scope.Element,'CanonicalSet',TPasSetType,aContext));
|
||||
Scope.CanonicalSet:=TPasSetType(ReadElementProperty(
|
||||
Obj,Scope.Element,'CanonicalSet',TPasSetType,aContext));
|
||||
ReadIdentifierScope(Obj,Scope,aContext);
|
||||
end;
|
||||
|
||||
@ -6626,7 +6669,8 @@ begin
|
||||
DefProcMods:=GetDefaultProcModifiers(El);
|
||||
El.Modifiers:=ReadProcedureModifiers(Obj,El,'PMods',DefProcMods);
|
||||
// read ProcType after El.Modifiers
|
||||
El.ProcType:=TPasProcedureType(ReadElementProperty(Obj,El,'ProcType',TPasProcedureType,aContext));
|
||||
El.ProcType:=TPasProcedureType(ReadElementProperty(
|
||||
Obj,El,'ProcType',TPasProcedureType,aContext));
|
||||
|
||||
ReadProcedureScope(Obj,Scope,aContext);
|
||||
end;
|
||||
|
@ -50,7 +50,7 @@ type
|
||||
FModule: TPasModule;
|
||||
FOnFindUnit: TOnFindUnit;
|
||||
FParser: TTestPasParser;
|
||||
FResolver: TStreamResolver;
|
||||
FStreamResolver: TStreamResolver;
|
||||
FScanner: TPascalScanner;
|
||||
FSource: string;
|
||||
procedure SetModule(AValue: TPasModule);
|
||||
@ -61,7 +61,7 @@ type
|
||||
procedure UsedInterfacesFinished(Section: TPasSection); override;
|
||||
property OnFindUnit: TOnFindUnit read FOnFindUnit write FOnFindUnit;
|
||||
property Filename: string read FFilename write FFilename;
|
||||
property Resolver: TStreamResolver read FResolver write FResolver;
|
||||
property StreamResolver: TStreamResolver read FStreamResolver write FStreamResolver;
|
||||
property Scanner: TPascalScanner read FScanner write FScanner;
|
||||
property Parser: TTestPasParser read FParser write FParser;
|
||||
property Source: string read FSource write FSource;
|
||||
@ -828,11 +828,11 @@ end;
|
||||
|
||||
destructor TTestEnginePasResolver.Destroy;
|
||||
begin
|
||||
FreeAndNil(FResolver);
|
||||
FreeAndNil(FStreamResolver);
|
||||
Module:=nil;
|
||||
FreeAndNil(FParser);
|
||||
FreeAndNil(FScanner);
|
||||
FreeAndNil(FResolver);
|
||||
FreeAndNil(FStreamResolver);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
@ -912,13 +912,13 @@ begin
|
||||
//writeln('TTestModule.FindUnit PARSING unit "',CurEngine.Filename,'"');
|
||||
FileResolver.FindSourceFile(aUnitName);
|
||||
|
||||
CurEngine.Resolver:=TStreamResolver.Create;
|
||||
CurEngine.Resolver.OwnsStreams:=True;
|
||||
CurEngine.StreamResolver:=TStreamResolver.Create;
|
||||
CurEngine.StreamResolver.OwnsStreams:=True;
|
||||
//writeln('TTestModule.FindUnit SOURCE=',CurEngine.Source);
|
||||
CurEngine.Resolver.AddStream(CurEngine.FileName,TStringStream.Create(CurEngine.Source));
|
||||
CurEngine.Scanner:=TPascalScanner.Create(CurEngine.Resolver);
|
||||
CurEngine.StreamResolver.AddStream(CurEngine.FileName,TStringStream.Create(CurEngine.Source));
|
||||
CurEngine.Scanner:=TPascalScanner.Create(CurEngine.StreamResolver);
|
||||
InitScanner(CurEngine.Scanner);
|
||||
CurEngine.Parser:=TTestPasParser.Create(CurEngine.Scanner,CurEngine.Resolver,CurEngine);
|
||||
CurEngine.Parser:=TTestPasParser.Create(CurEngine.Scanner,CurEngine.StreamResolver,CurEngine);
|
||||
CurEngine.Parser.Options:=po_tcmodules;
|
||||
if CompareText(CurUnitName,'System')=0 then
|
||||
CurEngine.Parser.ImplicitUses.Clear;
|
||||
|
@ -50,6 +50,7 @@ type
|
||||
TTestCLI_Precompile = class(TCustomTestCLI_Precompile)
|
||||
published
|
||||
procedure TestPCU_EmptyUnit;
|
||||
procedure TestPCU_UTF8BOM;
|
||||
procedure TestPCU_ParamNS;
|
||||
procedure TestPCU_Overloads;
|
||||
procedure TestPCU_UnitCycle;
|
||||
@ -136,6 +137,25 @@ begin
|
||||
CheckPrecompile('test1.pas','src');
|
||||
end;
|
||||
|
||||
procedure TTestCLI_Precompile.TestPCU_UTF8BOM;
|
||||
var
|
||||
aFile: TCLIFile;
|
||||
begin
|
||||
aFile:=AddUnit('src/system.pp',
|
||||
['var',
|
||||
' s: string = ''aaaäö'';',
|
||||
' s2: string = ''😊'';', // 1F60A
|
||||
''],
|
||||
['']);
|
||||
aFile.Source:=UTF8BOM+aFile.Source;
|
||||
aFile:=AddFile('test1.pas',[
|
||||
'begin',
|
||||
' s:=''ö😊'';',
|
||||
'end.']);
|
||||
aFile.Source:=UTF8BOM+aFile.Source;
|
||||
CheckPrecompile('test1.pas','src');
|
||||
end;
|
||||
|
||||
procedure TTestCLI_Precompile.TestPCU_ParamNS;
|
||||
begin
|
||||
AddUnit('src/system.pp',[''],['']);
|
||||
@ -168,19 +188,19 @@ begin
|
||||
'procedure DoIt(s: string); overload;'],
|
||||
['procedure DoIt(s: string);',
|
||||
'begin',
|
||||
' unit1.i:=j;',
|
||||
' unit1.i:=length(s);',
|
||||
'end;']);
|
||||
AddFile('test1.pas',[
|
||||
'uses unit1;',
|
||||
'uses unit1, unit2;',
|
||||
'procedure DoIt(d: double); overload;',
|
||||
'begin',
|
||||
' unit1.i:=j;',
|
||||
' unit1.i:=4;',
|
||||
'end;',
|
||||
'begin',
|
||||
' DoIt(3);',
|
||||
' DoIt(''abc'');',
|
||||
' Do1(true);',
|
||||
' Do1(3.3);',
|
||||
' DoIt(true);',
|
||||
' DoIt(3.3);',
|
||||
'end.']);
|
||||
CheckPrecompile('test1.pas','src');
|
||||
end;
|
||||
|
@ -471,7 +471,8 @@ begin
|
||||
Result:=FindFile(Filename);
|
||||
if Result<>nil then
|
||||
raise Exception.Create('[20180224001050] TCustomTestCLI.AddFile already exists: '+Filename);
|
||||
FFiles.Add(TCLIFile.Create(Filename,Source,DefaultFileAge,faNormal));
|
||||
Result:=TCLIFile.Create(Filename,Source,DefaultFileAge,faNormal);
|
||||
FFiles.Add(Result);
|
||||
AddDir(ExtractFilePath(Filename));
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user