<commit_before>unit dbgUtils;

{$ifdef fpc}{$mode delphi}{$h+}{$endif}

interface

uses
  Classes, SysUtils, dbgTypes;

type
  TDbgDataBytes = class(TDbgData)
  private
    fData     : array of Byte;
    fisFloat    : Boolean;
    fisReadOnly : Boolean;
    fBitSize    : Integer;
    fName       : string;
  protected
    procedure SetValue(const Value; ValueBitSize: Integer); override;
    procedure GetValue(var Value; ValueBitSize: Integer); override;
    function GetName: String; override;
  public
    function isFloatPoint: Boolean; override;
    function isReadOnly: Boolean; override;
    function BitSize: Integer; override;
  end;

  TDbgDataBytesList = class(TDbgDataList)
  private
    fItems   : TStringList;
  protected
    function GetCount: Integer; override;
    function GetRegister(const Name: String): TDbgData; override;
  public
    constructor Create;
    destructor Destroy; override;
    property Count: Integer read GetCount;
    function RegByIndex(idx: Integer): TDbgData; override;
    procedure Clear;
  end;


function Max(a,b: Integer): Integer;
function Min(a,b: Integer): Integer;

implementation

function Max(a,b: Integer): Integer;
begin
  if a < b then Result := b else Result := a;
end;

function Min(a,b: Integer): Integer;
begin
  if a < b then Result := a else Result := b;
end;

{ TDbgDataBytes }

function TDbgDataBytes.BitSize: Integer;
begin
  Result := fBitSize;
end;

function TDbgDataBytes.GetName: String;
begin
  Result := fName;
end;

procedure TDbgDataBytes.GetValue(var Value; ValueBitSize: Integer);
begin
  if fBitSize > 0 then
    Move(fData[0], Value, Min(fBitSize, ValueBitSize) div 8);
end;

function TDbgDataBytes.isFloatPoint: Boolean;
begin
  Result := fisFloat;
end;

function TDbgDataBytes.isReadOnly: Boolean;
begin
  Result := fisReadOnly;
end;

procedure TDbgDataBytes.SetValue(const Value; ValueBitSize: Integer);
begin
  fBitSize := ValueBitSize;
  if Length(fData) < fBitSize div 8 then SetLength(fData, fBitsize div 8);
end;

{ TDbgDataBytesList }

procedure TDbgDataBytesList.Clear;
var
  i : Integer;
begin
  for i := 0 to fItems.Count - 1 do
    TDbgDataBytes(fItems.Objects[i]).Free;
  fItems.Clear;
end;

constructor TDbgDataBytesList.Create;
begin
  fItems := TStringList.Create;
end;

destructor TDbgDataBytesList.Destroy;
begin
  Clear;
  fItems.Free;
  inherited;
end;

function TDbgDataBytesList.GetCount: Integer;
begin
  Result := fItems.Count;<commit_msg>fix for setting data in TDbgDataBytesList<commit_after>unit dbgUtils;

{$ifdef fpc}{$mode delphi}{$h+}{$endif}

interface

uses
  Classes, SysUtils, dbgTypes;

type
  TDbgDataBytes = class(TDbgData)
  private
    fData     : array of Byte;
    fisFloat    : Boolean;
    fisReadOnly : Boolean;
    fBitSize    : Integer;
    fName       : string;
  protected
    procedure SetValue(const Value; ValueBitSize: Integer); override;
    procedure GetValue(var Value; ValueBitSize: Integer); override;
    function GetName: String; override;
  public
    function isFloatPoint: Boolean; override;
    function isReadOnly: Boolean; override;
    function BitSize: Integer; override;
  end;

  TDbgDataBytesList = class(TDbgDataList)
  private
    fItems   : TStringList;
  protected
    function GetCount: Integer; override;
    function GetRegister(const Name: String): TDbgData; override;
  public
    constructor Create;
    destructor Destroy; override;
    property Count: Integer read GetCount;
    function RegByIndex(idx: Integer): TDbgData; override;
    procedure Clear;
  end;


function Max(a,b: Integer): Integer;
function Min(a,b: Integer): Integer;

implementation

function Max(a,b: Integer): Integer;
begin
  if a < b then Result := b else Result := a;
end;

function Min(a,b: Integer): Integer;
begin
  if a < b then Result := a else Result := b;
end;

{ TDbgDataBytes }

function TDbgDataBytes.BitSize: Integer;
begin
  Result := fBitSize;
end;

function TDbgDataBytes.GetName: String;
begin
  Result := fName;
end;

procedure TDbgDataBytes.GetValue(var Value; ValueBitSize: Integer);
begin
  if fBitSize > 0 then
    Move(fData[0], Value, Min(fBitSize, ValueBitSize) div 8);
end;

function TDbgDataBytes.isFloatPoint: Boolean;
begin
  Result := fisFloat;
end;

function TDbgDataBytes.isReadOnly: Boolean;
begin
  Result := fisReadOnly;
end;

procedure TDbgDataBytes.SetValue(const Value; ValueBitSize: Integer);
begin
  fBitSize := ValueBitSize;
  if Length(fData) < fBitSize div 8 then
    SetLength(fData, fBitsize div 8);
  if fBitSize > 0 then Move(Value, fdata[0], ValueBitSize div 8);

end;

{ TDbgDataBytesList }

procedure TDbgDataBytesList.Clear;
var
  i : Integer;
begin
  for i := 0 to fItems.Count - 1 do
    TDbgDataBytes(fItems.Objects[i]).Free;
  fItems.Clear;
end;

constructor TDbgDataBytesList.Create;
begin
  fItems := TStringList.Create;
end;

destructor TDbgDataBytesList.Destroy;
begin
  Clear;
  fItems.Free;
  inherited;
end;

function TDbgDataBytesList.GetCount: Integer;
begin
  Result := fItems.Count;
{'fraction_non_alphanumeric': 0.09348044132397192, 'fraction_numerical': 0.0034102306920762286, 'mean_word_length': 4.298618490967057, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1263745', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1617, 'n_words': 477}