Reverting Ast Stream
This commit is contained in:
@@ -1,25 +0,0 @@
|
|||||||
unit Myc.Ast.DataStream;
|
|
||||||
|
|
||||||
interface
|
|
||||||
|
|
||||||
uses
|
|
||||||
Myc.Data.Pipeline,
|
|
||||||
Myc.Data.Scalar;
|
|
||||||
|
|
||||||
type
|
|
||||||
// 1. IStreamProducer (Source)
|
|
||||||
// Provides data. Corresponds to IProducer<T>.
|
|
||||||
IStreamProducer = IProducer<IScalarRecordSeries>;
|
|
||||||
|
|
||||||
// 2. IStreamConsumer (Sink)
|
|
||||||
// Consumes data. Corresponds to IConsumer<T>.
|
|
||||||
IStreamConsumer = IConsumer<IScalarRecordSeries>;
|
|
||||||
|
|
||||||
// 3. IStreamConverter (Transform/Pipe)
|
|
||||||
// Consumes AND provides data.
|
|
||||||
// IMPORTANT: Inherits from IProducer, allowing safe hard-casts to IStreamProducer.
|
|
||||||
IStreamConverter = IConverter<IScalarRecordSeries, IScalarRecordSeries>;
|
|
||||||
|
|
||||||
implementation
|
|
||||||
|
|
||||||
end.
|
|
||||||
@@ -25,11 +25,7 @@ type
|
|||||||
stSeries,
|
stSeries,
|
||||||
stRecord,
|
stRecord,
|
||||||
stRecordSeries,
|
stRecordSeries,
|
||||||
stGenericRecord,
|
stGenericRecord
|
||||||
// --- Pipeline Types ---
|
|
||||||
stStreamProducer, // Source
|
|
||||||
stStreamConverter, // Pipe (Source + Sink)
|
|
||||||
stStreamConsumer // Sink
|
|
||||||
);
|
);
|
||||||
|
|
||||||
TStaticTypeKindHelper = record helper for TStaticTypeKind
|
TStaticTypeKindHelper = record helper for TStaticTypeKind
|
||||||
@@ -101,14 +97,6 @@ type
|
|||||||
class var
|
class var
|
||||||
FKeyword: IStaticType;
|
FKeyword: IStaticType;
|
||||||
|
|
||||||
// Stream Types
|
|
||||||
class var
|
|
||||||
FStreamProducer: IStaticType;
|
|
||||||
class var
|
|
||||||
FStreamConverter: IStaticType;
|
|
||||||
class var
|
|
||||||
FStreamConsumer: IStaticType;
|
|
||||||
|
|
||||||
class constructor Create;
|
class constructor Create;
|
||||||
public
|
public
|
||||||
// Flyweight accessors
|
// Flyweight accessors
|
||||||
@@ -121,11 +109,6 @@ type
|
|||||||
class property Text: IStaticType read FText;
|
class property Text: IStaticType read FText;
|
||||||
class property Keyword: IStaticType read FKeyword;
|
class property Keyword: IStaticType read FKeyword;
|
||||||
|
|
||||||
// Stream Accessors
|
|
||||||
class property StreamProducer: IStaticType read FStreamProducer;
|
|
||||||
class property StreamConverter: IStaticType read FStreamConverter;
|
|
||||||
class property StreamConsumer: IStaticType read FStreamConsumer;
|
|
||||||
|
|
||||||
// Factory functions
|
// Factory functions
|
||||||
class function CreateSeries(const AElementType: IStaticType): IStaticType; static;
|
class function CreateSeries(const AElementType: IStaticType): IStaticType; static;
|
||||||
class function CreateMethod(const AParamTypes: TArray<IStaticType>; const AReturnType: IStaticType): IStaticType; static;
|
class function CreateMethod(const AParamTypes: TArray<IStaticType>; const AReturnType: IStaticType): IStaticType; static;
|
||||||
@@ -188,10 +171,6 @@ begin
|
|||||||
stRecord: Result := 'Record';
|
stRecord: Result := 'Record';
|
||||||
stRecordSeries: Result := 'RecordSeries';
|
stRecordSeries: Result := 'RecordSeries';
|
||||||
stGenericRecord: Result := 'GenericRecord';
|
stGenericRecord: Result := 'GenericRecord';
|
||||||
// New types
|
|
||||||
stStreamProducer: Result := 'StreamProducer';
|
|
||||||
stStreamConverter: Result := 'StreamConverter';
|
|
||||||
stStreamConsumer: Result := 'StreamConsumer';
|
|
||||||
else
|
else
|
||||||
Result := 'ErrorType';
|
Result := 'ErrorType';
|
||||||
end;
|
end;
|
||||||
@@ -682,11 +661,6 @@ begin
|
|||||||
FDateTime := TSimpleStaticType.Create(stDateTime);
|
FDateTime := TSimpleStaticType.Create(stDateTime);
|
||||||
FText := TSimpleStaticType.Create(stText);
|
FText := TSimpleStaticType.Create(stText);
|
||||||
FKeyword := TSimpleStaticType.Create(stKeyword);
|
FKeyword := TSimpleStaticType.Create(stKeyword);
|
||||||
|
|
||||||
// Initialize stream types
|
|
||||||
FStreamProducer := TSimpleStaticType.Create(stStreamProducer);
|
|
||||||
FStreamConverter := TSimpleStaticType.Create(stStreamConverter);
|
|
||||||
FStreamConsumer := TSimpleStaticType.Create(stStreamConsumer);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TTypes.CreateMethod(const AParamTypes: TArray<IStaticType>; const AReturnType: IStaticType): IStaticType;
|
class function TTypes.CreateMethod(const AParamTypes: TArray<IStaticType>; const AReturnType: IStaticType): IStaticType;
|
||||||
@@ -767,11 +741,6 @@ begin
|
|||||||
if (Target.Kind = stOrdinal) and (Source.Kind = stKeyword) then
|
if (Target.Kind = stOrdinal) and (Source.Kind = stKeyword) then
|
||||||
exit(True);
|
exit(True);
|
||||||
|
|
||||||
// Stream rules:
|
|
||||||
// A Converter IS a Producer.
|
|
||||||
if (Target.Kind = stStreamProducer) and (Source.Kind = stStreamConverter) then
|
|
||||||
exit(True);
|
|
||||||
|
|
||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,7 @@ uses
|
|||||||
Myc.Utils,
|
Myc.Utils,
|
||||||
Myc.Data.Scalar,
|
Myc.Data.Scalar,
|
||||||
Myc.Data.Series,
|
Myc.Data.Series,
|
||||||
Myc.Data.Keyword,
|
Myc.Data.Keyword;
|
||||||
Myc.Trade.DataFeed,
|
|
||||||
Myc.Ast.DataStream;
|
|
||||||
|
|
||||||
type
|
type
|
||||||
TDataValueKind = (
|
TDataValueKind = (
|
||||||
@@ -26,11 +24,7 @@ type
|
|||||||
vkMethod,
|
vkMethod,
|
||||||
vkInterface,
|
vkInterface,
|
||||||
vkPointer,
|
vkPointer,
|
||||||
vkGeneric,
|
vkGeneric
|
||||||
// --- Pipeline / Stream Extensions ---
|
|
||||||
vkStreamProducer, // Pure Source (IProducer)
|
|
||||||
vkStreamConverter, // Transformer (IConverter -> IProducer + IConsumer)
|
|
||||||
vkStreamConsumer // Pure Sink (IConsumer)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
TDataValue = record
|
TDataValue = record
|
||||||
@@ -72,11 +66,6 @@ type
|
|||||||
class operator Implicit(const AValue: String): TDataValue; overload; inline;
|
class operator Implicit(const AValue: String): TDataValue; overload; inline;
|
||||||
class operator Implicit(const AValue: TDataValue.TFunc): TDataValue; overload; inline;
|
class operator Implicit(const AValue: TDataValue.TFunc): TDataValue; overload; inline;
|
||||||
|
|
||||||
// --- Stream Implicits (NEW) ---
|
|
||||||
class operator Implicit(const AValue: IStreamProducer): TDataValue; overload; inline;
|
|
||||||
class operator Implicit(const AValue: IStreamConsumer): TDataValue; overload; inline;
|
|
||||||
// Note: IStreamConverter is covered by IStreamProducer implicit or explicit factory
|
|
||||||
|
|
||||||
// --- Existing Factories ---
|
// --- Existing Factories ---
|
||||||
class function FromIntf<T: IInterface>(const AValue: T): TDataValue; static;
|
class function FromIntf<T: IInterface>(const AValue: T): TDataValue; static;
|
||||||
function AsIntf<T: IInterface>: T; inline;
|
function AsIntf<T: IInterface>: T; inline;
|
||||||
@@ -97,11 +86,6 @@ type
|
|||||||
class function FromGenericRecord(const AValue: IKeywordMapping<TDataValue>): TDataValue; static; inline;
|
class function FromGenericRecord(const AValue: IKeywordMapping<TDataValue>): TDataValue; static; inline;
|
||||||
class function FromSeries(const AValue: ISeries): TDataValue; static; inline;
|
class function FromSeries(const AValue: ISeries): TDataValue; static; inline;
|
||||||
|
|
||||||
// --- Stream Factories (NEW) ---
|
|
||||||
class function FromProducer(const AValue: IStreamProducer): TDataValue; static; inline;
|
|
||||||
class function FromConverter(const AValue: IStreamConverter): TDataValue; static; inline;
|
|
||||||
class function FromConsumer(const AValue: IStreamConsumer): TDataValue; static; inline;
|
|
||||||
|
|
||||||
// --- Existing Accessors ---
|
// --- Existing Accessors ---
|
||||||
function AsScalar: TScalar; inline;
|
function AsScalar: TScalar; inline;
|
||||||
function AsMethod: TFunc; inline;
|
function AsMethod: TFunc; inline;
|
||||||
@@ -112,11 +96,6 @@ type
|
|||||||
function AsSeries: ISeries; inline;
|
function AsSeries: ISeries; inline;
|
||||||
function AsObject: TObject; overload; inline;
|
function AsObject: TObject; overload; inline;
|
||||||
|
|
||||||
// --- Stream Accessors (NEW) ---
|
|
||||||
function AsProducer: IStreamProducer; inline;
|
|
||||||
function AsConverter: IStreamConverter; inline;
|
|
||||||
function AsConsumer: IStreamConsumer; inline;
|
|
||||||
|
|
||||||
function ToString: String;
|
function ToString: String;
|
||||||
property IsVoid: Boolean read GetIsVoid;
|
property IsVoid: Boolean read GetIsVoid;
|
||||||
property Kind: TDataValueKind read FKind;
|
property Kind: TDataValueKind read FKind;
|
||||||
@@ -162,10 +141,6 @@ begin
|
|||||||
vkInterface: Result := 'Interface';
|
vkInterface: Result := 'Interface';
|
||||||
vkPointer: Result := 'Pointer';
|
vkPointer: Result := 'Pointer';
|
||||||
vkGeneric: Result := 'Generic';
|
vkGeneric: Result := 'Generic';
|
||||||
// New types
|
|
||||||
vkStreamProducer: Result := 'StreamProducer';
|
|
||||||
vkStreamConverter: Result := 'StreamConverter';
|
|
||||||
vkStreamConsumer: Result := 'StreamConsumer';
|
|
||||||
else
|
else
|
||||||
Result := 'Unknown';
|
Result := 'Unknown';
|
||||||
end;
|
end;
|
||||||
@@ -244,65 +219,6 @@ begin
|
|||||||
raise EInvalidCast.Create('Value is not a scalar');
|
raise EInvalidCast.Create('Value is not a scalar');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// --- Implicit Operators (Streams) ---
|
|
||||||
|
|
||||||
class operator TDataValue.Implicit(const AValue: IStreamProducer): TDataValue;
|
|
||||||
begin
|
|
||||||
Result := FromProducer(AValue);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class operator TDataValue.Implicit(const AValue: IStreamConsumer): TDataValue;
|
|
||||||
begin
|
|
||||||
Result := FromConsumer(AValue);
|
|
||||||
end;
|
|
||||||
|
|
||||||
// --- Factories (Streams) ---
|
|
||||||
|
|
||||||
class function TDataValue.FromProducer(const AValue: IStreamProducer): TDataValue;
|
|
||||||
begin
|
|
||||||
Result.FKind := vkStreamProducer;
|
|
||||||
Result.FInterface := AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TDataValue.FromConverter(const AValue: IStreamConverter): TDataValue;
|
|
||||||
begin
|
|
||||||
Result.FKind := vkStreamConverter;
|
|
||||||
Result.FInterface := AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
class function TDataValue.FromConsumer(const AValue: IStreamConsumer): TDataValue;
|
|
||||||
begin
|
|
||||||
Result.FKind := vkStreamConsumer;
|
|
||||||
Result.FInterface := AValue;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// --- Accessors (Streams) ---
|
|
||||||
|
|
||||||
function TDataValue.AsProducer: IStreamProducer;
|
|
||||||
begin
|
|
||||||
// Safe Hard-Cast: We know FInterface is compatible via FKind.
|
|
||||||
if FKind in [vkStreamProducer, vkStreamConverter] then
|
|
||||||
Result := IStreamProducer(Pointer(FInterface))
|
|
||||||
else
|
|
||||||
raise EInvalidCast.Create('Value is not a StreamProducer');
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDataValue.AsConverter: IStreamConverter;
|
|
||||||
begin
|
|
||||||
if FKind = vkStreamConverter then
|
|
||||||
Result := IStreamConverter(Pointer(FInterface))
|
|
||||||
else
|
|
||||||
raise EInvalidCast.Create('Value is not a StreamConverter');
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TDataValue.AsConsumer: IStreamConsumer;
|
|
||||||
begin
|
|
||||||
if FKind = vkStreamConsumer then
|
|
||||||
Result := IStreamConsumer(Pointer(FInterface))
|
|
||||||
else
|
|
||||||
raise EInvalidCast.Create('Value is not a StreamConsumer');
|
|
||||||
end;
|
|
||||||
|
|
||||||
// --- Existing Factories & Accessors ---
|
// --- Existing Factories & Accessors ---
|
||||||
|
|
||||||
class function TDataValue.FromIntf<T>(const AValue: T): TDataValue;
|
class function TDataValue.FromIntf<T>(const AValue: T): TDataValue;
|
||||||
@@ -531,11 +447,6 @@ begin
|
|||||||
vkMethod: Result := '<method>';
|
vkMethod: Result := '<method>';
|
||||||
vkGeneric: Result := '<generic>';
|
vkGeneric: Result := '<generic>';
|
||||||
vkManagedObject: Result := 'Object: ' + AsObject.ClassName;
|
vkManagedObject: Result := 'Object: ' + AsObject.ClassName;
|
||||||
|
|
||||||
// New Stream Types
|
|
||||||
vkStreamProducer: Result := 'StreamProducer';
|
|
||||||
vkStreamConverter: Result := 'StreamConverter';
|
|
||||||
vkStreamConsumer: Result := 'StreamConsumer';
|
|
||||||
else
|
else
|
||||||
Result := '[Unknown DataValue]';
|
Result := '[Unknown DataValue]';
|
||||||
end;
|
end;
|
||||||
|
|||||||
Reference in New Issue
Block a user