Skip to content

Commit

Permalink
Parser: Non-object methods cannot be properties
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Oct 16, 2024
1 parent 6295bd4 commit dd984c3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 32 deletions.
1 change: 0 additions & 1 deletion Source/ide/codetools/simba.ide_codetools_parser.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,6 @@ procedure TCodeParser.Method;
tokFunction: Decl.FMethodType := mtFunc;
tokProcedure: Decl.FMethodType := mtProc;
tokOperator: Decl.FMethodType := mtOperator;
tokProperty: Decl.FMethodType := mtProperty;
end;

inherited;
Expand Down
70 changes: 39 additions & 31 deletions Source/simba.baseclass.pas
Original file line number Diff line number Diff line change
Expand Up @@ -55,56 +55,50 @@ implementation

procedure PrintUnfreedObjects;
var
NeedHeader: Boolean = True;
I: Integer;
begin
for I := 0 to TrackedObjects.Count - 1 do
if not TrackedObjects[I].FreeOnTerminate then
begin
DebugLn([EDebugLn.YELLOW], 'The following objects were not freed:');
Break;
end;
if NeedHeader then
DebugLn([EDebugLn.YELLOW], 'The following objects were not freed:');
NeedHeader := False;

while (TrackedObjects.Count > 0) do
begin
if not TrackedObjects[0].FreeOnTerminate then
TrackedObjects[0].NotifyUnfreed();
TrackedObjects[0].Free();
end;
TrackedObjects[I].NotifyUnfreed();
end;
end;

procedure PrintUnfinishedThreads;
var
NeedHeader: Boolean = True;
I: Integer;
begin
for I := 0 to TrackedThreads.Count - 1 do
if not TrackedThreads[I].Finished then
if (not TrackedThreads[I].Finished) then
begin
DebugLn([EDebugLn.YELLOW], 'The following threads were still running:');
Break;
end;
if NeedHeader then
DebugLn([EDebugLn.YELLOW], 'The following threads were still running:');
NeedHeader := False;

for I := 0 to TrackedThreads.Count - 1 do
if not TrackedThreads[I].Finished then
TrackedThreads[I].NotifyUnfreed();
end;
end;

procedure PrintUnfreedThreads;
var
NeedHeader: Boolean = True;
I: Integer;
begin
for I := 0 to TrackedThreads.Count - 1 do
if TrackedThreads[I].Finished and (not TrackedThreads[I].FreeOnTerminate) then
begin
DebugLn([EDebugLn.YELLOW], 'The following threads were not freed:');
Break;
end;
if NeedHeader then
DebugLn([EDebugLn.YELLOW], 'The following threads were not freed:');
NeedHeader := False;

while (TrackedThreads.Count > 0) do
begin
if not TrackedThreads[0].FreeOnTerminate then
TrackedThreads[0].NotifyUnfreed();
TrackedThreads[0].Free();
end;
TrackedThreads[I].NotifyUnfreed();
end;
end;

procedure TSimbaBaseClass.NotifyUnfreed;
Expand Down Expand Up @@ -164,18 +158,32 @@ destructor TSimbaBaseThread.Destroy;
TrackedThreads.Delete(Self);
end;

procedure FreeObjects;
var
Obj: TSimbaBaseClass;
begin
for Obj in TrackedObjects.ToArray() do // use ToArray so not to worry about when Free removes from TrackedObjects list.
Obj.Free();
end;

procedure FreeThreads;
var
Thread: TSimbaBaseThread;
begin
for Thread in TrackedThreads.ToArray() do // ..
if Thread.FreeOnTerminate then
Thread.Terminate()
else
Thread.Free();
end;

initialization
TrackedObjects := specialize TSimbaObjectList<TSimbaBaseClass>.Create();
TrackedThreads := specialize TSimbaObjectList<TSimbaBaseThread>.Create();

finalization
while (TrackedObjects.Count > 0) do
TrackedObjects[0].Free();
TrackedObjects.Free();

while (TrackedThreads.Count > 0) do
TrackedThreads[0].Free();
TrackedThreads.Free();
FreeObjects();
FreeThreads();

end.

0 comments on commit dd984c3

Please sign in to comment.