Nop-Node
This commit is contained in:
@@ -51,6 +51,8 @@ type
|
||||
function JsonToCreateSeriesNode(const AObj: TJSONObject): ICreateSeriesNode;
|
||||
function JsonToAddSeriesItemNode(const AObj: TJSONObject): IAddSeriesItemNode;
|
||||
function JsonToSeriesLengthNode(const AObj: TJSONObject): ISeriesLengthNode;
|
||||
function JsonToNopNode(const AObj: TJSONObject): INopNode;
|
||||
|
||||
protected
|
||||
// IAstVisitor implementation for serialization (T = TJSONObject)
|
||||
function VisitConstant(const Node: IConstantNode): TJSONObject; override;
|
||||
@@ -77,6 +79,7 @@ type
|
||||
function VisitCreateSeries(const Node: ICreateSeriesNode): TJSONObject; override;
|
||||
function VisitAddSeriesItem(const Node: IAddSeriesItemNode): TJSONObject; override;
|
||||
function VisitSeriesLength(const Node: ISeriesLengthNode): TJSONObject; override;
|
||||
function VisitNop(const Node: INopNode): TJSONObject; override;
|
||||
|
||||
function Serialize(const RootNode: IAstNode): TJSONObject;
|
||||
function Deserialize(const AJson: TJSONObject): IAstNode;
|
||||
@@ -456,6 +459,13 @@ begin
|
||||
Result.AddPair('Series', seriesObj);
|
||||
end;
|
||||
|
||||
function TJsonAstConverter.VisitNop(const Node: INopNode): TJSONObject;
|
||||
begin
|
||||
Result := TJSONObject.Create;
|
||||
Result.AddPair('NodeType', TJSONString.Create('Nop'));
|
||||
// No other properties needed, as it is stateless
|
||||
end;
|
||||
|
||||
{ TJsonAstConverter - Deserialization }
|
||||
|
||||
function TJsonAstConverter.JsonToDataValue(const AObj: TJSONObject; const AName: string): TDataValue;
|
||||
@@ -761,6 +771,11 @@ begin
|
||||
Result := TAst.SeriesLength(JsonToIdentifierNode(AObj.GetValue('Series') as TJSONObject));
|
||||
end;
|
||||
|
||||
function TJsonAstConverter.JsonToNopNode(const AObj: TJSONObject): INopNode;
|
||||
begin
|
||||
Result := TAst.Nop.AsNop;
|
||||
end;
|
||||
|
||||
function TJsonAstConverter.JsonToNode(const AJson: TJSONValue; const ExpectedType: String = ''): IAstNode;
|
||||
var
|
||||
obj: TJSONObject;
|
||||
@@ -823,6 +838,8 @@ begin
|
||||
Result := JsonToAddSeriesItemNode(obj)
|
||||
else if nodeType = 'SeriesLength' then
|
||||
Result := JsonToSeriesLengthNode(obj)
|
||||
else if nodeType = 'Nop' then // Added Nop Deserialization logic
|
||||
Result := JsonToNopNode(obj)
|
||||
else
|
||||
raise ENotSupportedException.CreateFmt('Unsupported NodeType "%s" for JSON deserialization.', [nodeType]);
|
||||
end;
|
||||
|
||||
Reference in New Issue
Block a user