Refactoring
This commit is contained in:
@@ -34,7 +34,7 @@ type
|
||||
implementation
|
||||
|
||||
uses
|
||||
Myc.Ast.Types; // Added for TTypes.Unknown
|
||||
Myc.Ast.Types;
|
||||
|
||||
{ TUpvalueAnalyzer }
|
||||
|
||||
|
||||
@@ -993,12 +993,12 @@ var
|
||||
valNode: IAstNode;
|
||||
valType: IStaticType;
|
||||
scalarKind: TScalar.TKind;
|
||||
allScalar: Boolean; // Added
|
||||
allScalar: Boolean;
|
||||
begin
|
||||
FNextIsTail := False;
|
||||
SetLength(boundFields, Length(Node.Fields));
|
||||
SetLength(scalarDefFields, Length(Node.Fields)); // Renamed
|
||||
allScalar := True; // Added
|
||||
allScalar := True;
|
||||
|
||||
for i := 0 to High(Node.Fields) do
|
||||
begin
|
||||
|
||||
@@ -780,7 +780,7 @@ var
|
||||
paramArray: TJSONArray;
|
||||
i: Integer;
|
||||
begin
|
||||
// Added deserialization for macro definitions.
|
||||
|
||||
name := JsonToIdentifierNode(AObj.GetValue('Name') as TJSONObject);
|
||||
|
||||
paramArray := AObj.GetValue<TJSONArray>('Parameters');
|
||||
|
||||
@@ -143,7 +143,7 @@ begin
|
||||
stSeries: Result := 'Series';
|
||||
stRecord: Result := 'Record';
|
||||
stRecordSeries: Result := 'RecordSeries';
|
||||
stGenericRecord: Result := 'GenericRecord'; // Added
|
||||
stGenericRecord: Result := 'GenericRecord';
|
||||
else
|
||||
Result := 'ErrorType';
|
||||
end;
|
||||
@@ -159,7 +159,7 @@ type
|
||||
function GetElementType: IStaticType; virtual;
|
||||
function GetSignature: IMethodSignature; virtual;
|
||||
function GetDefinition: IScalarRecordDefinition; virtual;
|
||||
function GetGenericDefinition: IGenericRecordDefinition; virtual; // Added
|
||||
function GetGenericDefinition: IGenericRecordDefinition; virtual;
|
||||
function IsEqual(const Other: IStaticType): Boolean; virtual;
|
||||
function ToString: string; override;
|
||||
end;
|
||||
@@ -180,7 +180,6 @@ begin
|
||||
Result := Default(IScalarRecordDefinition);
|
||||
end;
|
||||
|
||||
// Added
|
||||
function TAbstractStaticType.GetGenericDefinition: IGenericRecordDefinition;
|
||||
begin
|
||||
Result := nil;
|
||||
@@ -433,7 +432,6 @@ begin
|
||||
end;
|
||||
|
||||
// ---
|
||||
// Added: Represents stGenericRecord
|
||||
type
|
||||
TGenericRecordType = class(TAbstractStaticType)
|
||||
private
|
||||
@@ -532,7 +530,6 @@ begin
|
||||
Result := TRecordType.Create(stRecordSeries, ADef);
|
||||
end;
|
||||
|
||||
// Added
|
||||
class function TTypes.CreateGenericRecord(const ADef: IGenericRecordDefinition): IStaticType;
|
||||
begin
|
||||
Result := TGenericRecordType.Create(ADef);
|
||||
|
||||
@@ -633,7 +633,7 @@ type
|
||||
implementation
|
||||
|
||||
uses
|
||||
System.Math, // Added for Power function
|
||||
System.Math,
|
||||
Myc.Data.Types.Void,
|
||||
Myc.Data.Types.Ordinal,
|
||||
Myc.Data.Types.Float,
|
||||
|
||||
@@ -5,7 +5,7 @@ interface
|
||||
uses
|
||||
System.SysUtils,
|
||||
System.SyncObjs,
|
||||
System.Generics.Collections, // Added for TDictionary
|
||||
System.Generics.Collections,
|
||||
Myc.Utils,
|
||||
Myc.Data.Scalar,
|
||||
Myc.Data.Series,
|
||||
@@ -19,7 +19,7 @@ type
|
||||
vkSeries,
|
||||
vkRecordSeries,
|
||||
vkRecord,
|
||||
vkGenericRecord, // Added
|
||||
vkGenericRecord,
|
||||
vkManagedObject,
|
||||
vkMethod,
|
||||
vkInterface,
|
||||
@@ -194,7 +194,6 @@ begin
|
||||
Result := (FInterface as TVal<TScalarRecord>).Value;
|
||||
end;
|
||||
|
||||
// Added
|
||||
function TDataValue.AsGenericRecord: IKeywordMapping<TDataValue>;
|
||||
begin
|
||||
if (FKind <> vkGenericRecord) then
|
||||
@@ -265,7 +264,6 @@ begin
|
||||
TInterlocked.CompareExchange(FScalar.Value.AsInt64, NewValue.AsScalar.Value.AsInt64, Expected.AsScalar.Value.AsInt64)
|
||||
= Expected.AsScalar.Value.AsInt64;
|
||||
|
||||
// Added vkGenericRecord
|
||||
vkText, vkSeries, vkRecordSeries, vkRecord, vkGenericRecord, vkManagedObject, vkMethod, vkInterface, vkGeneric:
|
||||
Result := IntfCompareExchange(FInterface, NewValue.FInterface, Expected.FInterface) = Expected.FInterface;
|
||||
end;
|
||||
@@ -302,7 +300,6 @@ begin
|
||||
Result.FInterface := TVal<TScalarRecord>.Create(AValue);
|
||||
end;
|
||||
|
||||
// Added
|
||||
class function TDataValue.FromGenericRecord(const AValue: IKeywordMapping<TDataValue>): TDataValue;
|
||||
begin
|
||||
Result.FKind := vkGenericRecord;
|
||||
@@ -367,7 +364,6 @@ begin
|
||||
end;
|
||||
vkPointer: Result := TInterlocked.Exchange(FScalar.Value.AsInt64, NewValue.AsScalar.Value.AsInt64);
|
||||
|
||||
// Added vkGenericRecord
|
||||
vkText, vkSeries, vkRecordSeries, vkRecord, vkGenericRecord, vkManagedObject, vkMethod, vkInterface, vkGeneric:
|
||||
begin
|
||||
Result.FKind := FKind;
|
||||
@@ -380,7 +376,7 @@ function TDataValue.ToString: String;
|
||||
var
|
||||
sb: TStringBuilder;
|
||||
field: TScalarRecordField;
|
||||
genField: TPair<IKeyword, TDataValue>; // Added
|
||||
genField: TPair<IKeyword, TDataValue>;
|
||||
first: Boolean;
|
||||
begin
|
||||
case FKind of
|
||||
@@ -434,7 +430,7 @@ begin
|
||||
sb.Free;
|
||||
end;
|
||||
end;
|
||||
// Added
|
||||
|
||||
vkGenericRecord:
|
||||
begin
|
||||
var rec := AsGenericRecord;
|
||||
@@ -513,7 +509,7 @@ begin
|
||||
vkSeries: Result := 'Series';
|
||||
vkRecordSeries: Result := 'RecordSeries';
|
||||
vkRecord: Result := 'Record';
|
||||
vkGenericRecord: Result := 'GenericRecord'; // Added
|
||||
vkGenericRecord: Result := 'GenericRecord';
|
||||
vkMethod: Result := 'Method';
|
||||
vkInterface: Result := 'Interface';
|
||||
vkPointer: Result := 'Pointer';
|
||||
|
||||
@@ -5,7 +5,7 @@ interface
|
||||
uses
|
||||
DUnitX.TestFramework,
|
||||
System.SysUtils,
|
||||
System.Generics.Collections, // Added for TObjectList if needed, not strictly for this
|
||||
System.Generics.Collections,
|
||||
System.SyncObjs,
|
||||
Myc.Signals, // For IMycLatch, TMycLatch, IMycState, IMycSubscriber [cite: 62, 68, 53, 45]
|
||||
Myc.Core.Tasks, // For IMycTaskFactory, TMycTaskFactory [cite: 97, 113]
|
||||
|
||||
Reference in New Issue
Block a user