Scope cells refactoring

This commit is contained in:
Michael Schimmel
2025-09-05 12:46:24 +02:00
parent edf8329b28
commit 100646c7d8
5 changed files with 61 additions and 117 deletions
+22 -4
View File
@@ -116,13 +116,14 @@ type
Kind: TAddressKind;
ScopeDepth: Integer;
SlotIndex: Integer;
Name: String;
constructor Create(AKind: TAddressKind; AScopeDepth, ASlotIndex: Integer; const AName: String);
class operator Initialize(out Dest: TResolvedAddress);
end;
IExecutionScope = interface
{$region 'private'}
function GetParent: IExecutionScope;
function GetValues(const Address: TResolvedAddress): TAstValue;
procedure SetValues(const Address: TResolvedAddress; const Value: TAstValue);
function GetCell(const Address: TResolvedAddress): IValueCell;
{$endregion}
@@ -130,8 +131,7 @@ type
function Dump: string;
procedure Clear;
property Cell[const Address: TResolvedAddress]: IValueCell read GetCell;
property Values[const Address: TResolvedAddress]: TAstValue read GetValues write SetValues; default;
property Cell[const Address: TResolvedAddress]: IValueCell read GetCell; default;
property Parent: IExecutionScope read GetParent;
end;
@@ -484,6 +484,24 @@ begin
Result := Default(TAstValue);
end;
{ TResolvedAddress }
constructor TResolvedAddress.Create(AKind: TAddressKind; AScopeDepth, ASlotIndex: Integer; const AName: String);
begin
Kind := AKind;
ScopeDepth := AScopeDepth;
SlotIndex := ASlotIndex;
Name := AName;
end;
class operator TResolvedAddress.Initialize(out Dest: TResolvedAddress);
begin
Dest.Kind := akUnresolved;
Dest.ScopeDepth := -1;
Dest.SlotIndex := -1;
Dest.Name := 'unresolved';
end;
{ TBinaryOperatorHelper }
function TBinaryOperatorHelper.ToString: string;