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,
|
||||
stRecord,
|
||||
stRecordSeries,
|
||||
stGenericRecord,
|
||||
// --- Pipeline Types ---
|
||||
stStreamProducer, // Source
|
||||
stStreamConverter, // Pipe (Source + Sink)
|
||||
stStreamConsumer // Sink
|
||||
stGenericRecord
|
||||
);
|
||||
|
||||
TStaticTypeKindHelper = record helper for TStaticTypeKind
|
||||
@@ -101,14 +97,6 @@ type
|
||||
class var
|
||||
FKeyword: IStaticType;
|
||||
|
||||
// Stream Types
|
||||
class var
|
||||
FStreamProducer: IStaticType;
|
||||
class var
|
||||
FStreamConverter: IStaticType;
|
||||
class var
|
||||
FStreamConsumer: IStaticType;
|
||||
|
||||
class constructor Create;
|
||||
public
|
||||
// Flyweight accessors
|
||||
@@ -121,11 +109,6 @@ type
|
||||
class property Text: IStaticType read FText;
|
||||
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
|
||||
class function CreateSeries(const AElementType: IStaticType): IStaticType; static;
|
||||
class function CreateMethod(const AParamTypes: TArray<IStaticType>; const AReturnType: IStaticType): IStaticType; static;
|
||||
@@ -188,10 +171,6 @@ begin
|
||||
stRecord: Result := 'Record';
|
||||
stRecordSeries: Result := 'RecordSeries';
|
||||
stGenericRecord: Result := 'GenericRecord';
|
||||
// New types
|
||||
stStreamProducer: Result := 'StreamProducer';
|
||||
stStreamConverter: Result := 'StreamConverter';
|
||||
stStreamConsumer: Result := 'StreamConsumer';
|
||||
else
|
||||
Result := 'ErrorType';
|
||||
end;
|
||||
@@ -682,11 +661,6 @@ begin
|
||||
FDateTime := TSimpleStaticType.Create(stDateTime);
|
||||
FText := TSimpleStaticType.Create(stText);
|
||||
FKeyword := TSimpleStaticType.Create(stKeyword);
|
||||
|
||||
// Initialize stream types
|
||||
FStreamProducer := TSimpleStaticType.Create(stStreamProducer);
|
||||
FStreamConverter := TSimpleStaticType.Create(stStreamConverter);
|
||||
FStreamConsumer := TSimpleStaticType.Create(stStreamConsumer);
|
||||
end;
|
||||
|
||||
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
|
||||
exit(True);
|
||||
|
||||
// Stream rules:
|
||||
// A Converter IS a Producer.
|
||||
if (Target.Kind = stStreamProducer) and (Source.Kind = stStreamConverter) then
|
||||
exit(True);
|
||||
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
|
||||
@@ -9,9 +9,7 @@ uses
|
||||
Myc.Utils,
|
||||
Myc.Data.Scalar,
|
||||
Myc.Data.Series,
|
||||
Myc.Data.Keyword,
|
||||
Myc.Trade.DataFeed,
|
||||
Myc.Ast.DataStream;
|
||||
Myc.Data.Keyword;
|
||||
|
||||
type
|
||||
TDataValueKind = (
|
||||
@@ -26,11 +24,7 @@ type
|
||||
vkMethod,
|
||||
vkInterface,
|
||||
vkPointer,
|
||||
vkGeneric,
|
||||
// --- Pipeline / Stream Extensions ---
|
||||
vkStreamProducer, // Pure Source (IProducer)
|
||||
vkStreamConverter, // Transformer (IConverter -> IProducer + IConsumer)
|
||||
vkStreamConsumer // Pure Sink (IConsumer)
|
||||
vkGeneric
|
||||
);
|
||||
|
||||
TDataValue = record
|
||||
@@ -72,11 +66,6 @@ type
|
||||
class operator Implicit(const AValue: String): 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 ---
|
||||
class function FromIntf<T: IInterface>(const AValue: T): TDataValue; static;
|
||||
function AsIntf<T: IInterface>: T; inline;
|
||||
@@ -97,11 +86,6 @@ type
|
||||
class function FromGenericRecord(const AValue: IKeywordMapping<TDataValue>): 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 ---
|
||||
function AsScalar: TScalar; inline;
|
||||
function AsMethod: TFunc; inline;
|
||||
@@ -112,11 +96,6 @@ type
|
||||
function AsSeries: ISeries; inline;
|
||||
function AsObject: TObject; overload; inline;
|
||||
|
||||
// --- Stream Accessors (NEW) ---
|
||||
function AsProducer: IStreamProducer; inline;
|
||||
function AsConverter: IStreamConverter; inline;
|
||||
function AsConsumer: IStreamConsumer; inline;
|
||||
|
||||
function ToString: String;
|
||||
property IsVoid: Boolean read GetIsVoid;
|
||||
property Kind: TDataValueKind read FKind;
|
||||
@@ -162,10 +141,6 @@ begin
|
||||
vkInterface: Result := 'Interface';
|
||||
vkPointer: Result := 'Pointer';
|
||||
vkGeneric: Result := 'Generic';
|
||||
// New types
|
||||
vkStreamProducer: Result := 'StreamProducer';
|
||||
vkStreamConverter: Result := 'StreamConverter';
|
||||
vkStreamConsumer: Result := 'StreamConsumer';
|
||||
else
|
||||
Result := 'Unknown';
|
||||
end;
|
||||
@@ -244,65 +219,6 @@ begin
|
||||
raise EInvalidCast.Create('Value is not a scalar');
|
||||
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 ---
|
||||
|
||||
class function TDataValue.FromIntf<T>(const AValue: T): TDataValue;
|
||||
@@ -531,11 +447,6 @@ begin
|
||||
vkMethod: Result := '<method>';
|
||||
vkGeneric: Result := '<generic>';
|
||||
vkManagedObject: Result := 'Object: ' + AsObject.ClassName;
|
||||
|
||||
// New Stream Types
|
||||
vkStreamProducer: Result := 'StreamProducer';
|
||||
vkStreamConverter: Result := 'StreamConverter';
|
||||
vkStreamConsumer: Result := 'StreamConsumer';
|
||||
else
|
||||
Result := '[Unknown DataValue]';
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user