Ast editor unit refactoring

This commit is contained in:
Michael Schimmel
2025-11-28 14:03:49 +01:00
parent 833ce8aada
commit 0b4201fe9b
6 changed files with 284 additions and 275 deletions
+2 -2
View File
@@ -113,7 +113,7 @@ type
FCurrUnboundAst: IAstNode; FCurrUnboundAst: IAstNode;
FCurrExec: TCompiledFunction; FCurrExec: TCompiledFunction;
FEnvironment: TAstEnvironment; FEnvironment: TAstEnvironment;
FWorkspace: TAuraWorkspace; FWorkspace: TAstWorkspace;
FScriptUpdate: Boolean; FScriptUpdate: Boolean;
FTriggerTest: TAstEnvironment; FTriggerTest: TAstEnvironment;
@@ -319,7 +319,7 @@ procedure TForm1.FormCreate(Sender: TObject);
begin begin
FEnvironment := TAstEnvironment.Construct(TAst.CreateScope(nil)); FEnvironment := TAstEnvironment.Construct(TAst.CreateScope(nil));
FWorkspace := TAuraWorkspace.Create(Panel2); FWorkspace := TAstWorkspace.Create(Panel2);
FWorkspace.Parent := Panel2; FWorkspace.Parent := Panel2;
FWorkspace.Align := TAlignLayout.Client; FWorkspace.Align := TAlignLayout.Client;
FWorkspace.ClipChildren := true; FWorkspace.ClipChildren := true;
+1
View File
@@ -0,0 +1 @@
T:\Myc\IntfExtract\Win64\Debug\ExtractPascalInterfaces.exe -c -dirs T:\Myc\dirs.txt -fc T:\Myc\Src\Ast\Myc.Fmx.*
+36 -36
View File
@@ -27,16 +27,16 @@ const
cMinNodeHeight = 10; cMinNodeHeight = 10;
type type
TAuraNode = class; // Forward declaration TAstViewNode = class; // Forward declaration
// This aggregate interface encapsulates all node-specific logic. // This aggregate interface encapsulates all node-specific logic.
IAuraNodeHandler = interface IAstViewNodeHandler = interface
// Gets the original logical AST node // Gets the original logical AST node
function GetAstNode: IAstNode; function GetAstNode: IAstNode;
// Creates the specific FMX UI for this node // Creates the specific FMX UI for this node
procedure BuildUI(OwnerNode: TAuraNode); procedure BuildUI(OwnerNode: TAstViewNode);
// Reconstructs the logical AST node from the FMX UI state // Reconstructs the logical AST node from the FMX UI state
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
// The original logical AST node // The original logical AST node
property Node: IAstNode read GetAstNode; property Node: IAstNode read GetAstNode;
end; end;
@@ -45,15 +45,15 @@ type
{$region 'private'} {$region 'private'}
function GetExprDepth: Integer; function GetExprDepth: Integer;
function GetParentControl: TControl; function GetParentControl: TControl;
function GetWorkspace: TAuraWorkspace; function GetWorkspace: TAstWorkspace;
{$endregion} {$endregion}
function Clone(ParentControl: TControl; ExprDepth: Integer): IAstVisualizer; function Clone(ParentControl: TControl; ExprDepth: Integer): IAstVisualizer;
function CallAccept(const Node: IAstNode): TAuraNode; function CallAccept(const Node: IAstNode): TAstViewNode;
property ExprDepth: Integer read GetExprDepth; property ExprDepth: Integer read GetExprDepth;
property ParentControl: TControl read GetParentControl; property ParentControl: TControl read GetParentControl;
property Workspace: TAuraWorkspace read GetWorkspace; property Workspace: TAstWorkspace read GetWorkspace;
end; end;
// Defines the layout direction for children within TAutoFitControl // Defines the layout direction for children within TAutoFitControl
@@ -88,7 +88,7 @@ type
end; end;
// A movable panel with a custom-painted border. Content (like title) is added externally. // A movable panel with a custom-painted border. Content (like title) is added externally.
TAuraNode = class(TAutoFitControl) TAstViewNode = class(TAutoFitControl)
private private
FBackgroundColor: TAlphaColor; FBackgroundColor: TAlphaColor;
FIsDragging: Boolean; FIsDragging: Boolean;
@@ -98,7 +98,7 @@ type
FBorderRadius: Single; FBorderRadius: Single;
FFrameless: Boolean; FFrameless: Boolean;
FVisualizer: IAstVisualizer; FVisualizer: IAstVisualizer;
FHandler: IAuraNodeHandler; FHandler: IAstViewNodeHandler;
// --- Visual State Fields --- // --- Visual State Fields ---
FErrorMessage: string; FErrorMessage: string;
@@ -124,14 +124,14 @@ type
procedure SetupNode; procedure SetupNode;
public public
constructor Create(const AVisualizer: IAstVisualizer; const AHandler: IAuraNodeHandler); reintroduce; constructor Create(const AVisualizer: IAstVisualizer; const AHandler: IAstViewNodeHandler); reintroduce;
destructor Destroy; override; destructor Destroy; override;
procedure AfterConstruction; override; procedure AfterConstruction; override;
function AddLabel(Parent: TControl; const Txt: String): TLabel; function AddLabel(Parent: TControl; const Txt: String): TLabel;
function AddContainer(Parent: TControl; Orientation: TLayoutOrientation; Alignment: TLayoutAlignment): TAutoFitControl; function AddContainer(Parent: TControl; Orientation: TLayoutOrientation; Alignment: TLayoutAlignment): TAutoFitControl;
function AddExpr(Parent: TControl; const Title: String; const Node: IAstNode): TAuraNode; function AddExpr(Parent: TControl; const Title: String; const Node: IAstNode): TAstViewNode;
function CreateAst: IAstNode; function CreateAst: IAstNode;
@@ -181,14 +181,14 @@ type
end; end;
// Helper base class to reduce boilerplate in specific handlers // Helper base class to reduce boilerplate in specific handlers
TBaseNodeHandler<T: IAstNode> = class(TInterfacedObject, IAuraNodeHandler) TBaseNodeHandler<T: IAstNode> = class(TInterfacedObject, IAstViewNodeHandler)
protected protected
FNode: T; FNode: T;
function GetAstNode: IAstNode; function GetAstNode: IAstNode;
public public
constructor Create(const ANode: T); constructor Create(const ANode: T);
procedure BuildUI(OwnerNode: TAuraNode); virtual; abstract; procedure BuildUI(OwnerNode: TAstViewNode); virtual; abstract;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; virtual; abstract; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; virtual; abstract;
end; end;
implementation implementation
@@ -383,9 +383,9 @@ begin
end; end;
end; end;
{ TAuraNode } { TAstViewNode }
constructor TAuraNode.Create(const AVisualizer: IAstVisualizer; const AHandler: IAuraNodeHandler); constructor TAstViewNode.Create(const AVisualizer: IAstVisualizer; const AHandler: IAstViewNodeHandler);
begin begin
inherited Create(AVisualizer.Workspace); inherited Create(AVisualizer.Workspace);
@@ -423,13 +423,13 @@ begin
BackgroundColor := c; BackgroundColor := c;
end; end;
destructor TAuraNode.Destroy; destructor TAstViewNode.Destroy;
begin begin
FHandler := nil; FHandler := nil;
inherited; inherited;
end; end;
function TAuraNode.AddContainer(Parent: TControl; Orientation: TLayoutOrientation; Alignment: TLayoutAlignment): TAutoFitControl; function TAstViewNode.AddContainer(Parent: TControl; Orientation: TLayoutOrientation; Alignment: TLayoutAlignment): TAutoFitControl;
begin begin
Result := TAutoFitControl.Create(Self); Result := TAutoFitControl.Create(Self);
Result.Parent := Parent; Result.Parent := Parent;
@@ -438,7 +438,7 @@ begin
Result.HitTest := False; Result.HitTest := False;
end; end;
function TAuraNode.AddExpr(Parent: TControl; const Title: String; const Node: IAstNode): TAuraNode; function TAstViewNode.AddExpr(Parent: TControl; const Title: String; const Node: IAstNode): TAstViewNode;
begin begin
var cont := AddContainer(Parent, loHorizontal, laCenter); var cont := AddContainer(Parent, loHorizontal, laCenter);
@@ -448,7 +448,7 @@ begin
Result := FVisualizer.Clone(cont, FVisualizer.ExprDepth + 1).CallAccept(Node); Result := FVisualizer.Clone(cont, FVisualizer.ExprDepth + 1).CallAccept(Node);
end; end;
function TAuraNode.AddLabel(Parent: TControl; const Txt: String): TLabel; function TAstViewNode.AddLabel(Parent: TControl; const Txt: String): TLabel;
begin begin
Result := TLabel.Create(Self); Result := TLabel.Create(Self);
Result.Parent := Parent; Result.Parent := Parent;
@@ -468,13 +468,13 @@ begin
Result.ApplyStyleLookup; Result.ApplyStyleLookup;
end; end;
procedure TAuraNode.AfterConstruction; procedure TAstViewNode.AfterConstruction;
begin begin
inherited; inherited;
SetupNode; SetupNode;
end; end;
function TAuraNode.CreateAst: IAstNode; function TAstViewNode.CreateAst: IAstNode;
begin begin
if Assigned(FHandler) then if Assigned(FHandler) then
Result := FHandler.ReconstructAst(Self) Result := FHandler.ReconstructAst(Self)
@@ -482,7 +482,7 @@ begin
Result := TAst.Nop; Result := TAst.Nop;
end; end;
function TAuraNode.GetNode: IAstNode; function TAstViewNode.GetNode: IAstNode;
begin begin
if Assigned(FHandler) then if Assigned(FHandler) then
Result := FHandler.Node Result := FHandler.Node
@@ -490,7 +490,7 @@ begin
Result := nil; Result := nil;
end; end;
procedure TAuraNode.SetErrorMessage(const Value: string); procedure TAstViewNode.SetErrorMessage(const Value: string);
begin begin
if FErrorMessage <> Value then if FErrorMessage <> Value then
begin begin
@@ -500,7 +500,7 @@ begin
end; end;
end; end;
procedure TAuraNode.SetTypeInfoText(const Value: string); procedure TAstViewNode.SetTypeInfoText(const Value: string);
begin begin
if FTypeInfoText <> Value then if FTypeInfoText <> Value then
begin begin
@@ -510,7 +510,7 @@ begin
end; end;
end; end;
procedure TAuraNode.UpdateVisualState; procedure TAstViewNode.UpdateVisualState;
begin begin
if FErrorMessage <> '' then if FErrorMessage <> '' then
begin begin
@@ -529,7 +529,7 @@ begin
end; end;
end; end;
procedure TAuraNode.Paint; procedure TAstViewNode.Paint;
var var
rect: TRectF; rect: TRectF;
effBorderColor: TAlphaColor; effBorderColor: TAlphaColor;
@@ -595,7 +595,7 @@ begin
end; end;
end; end;
procedure TAuraNode.SetBorderColor(const Value: TAlphaColor); procedure TAstViewNode.SetBorderColor(const Value: TAlphaColor);
begin begin
if FBorderColor <> Value then if FBorderColor <> Value then
begin begin
@@ -604,7 +604,7 @@ begin
end; end;
end; end;
procedure TAuraNode.SetBorderRadius(const Value: Single); procedure TAstViewNode.SetBorderRadius(const Value: Single);
begin begin
if FBorderRadius <> Value then if FBorderRadius <> Value then
begin begin
@@ -613,7 +613,7 @@ begin
end; end;
end; end;
procedure TAuraNode.SetBorderWidth(const Value: Single); procedure TAstViewNode.SetBorderWidth(const Value: Single);
begin begin
if FBorderWidth <> Value then if FBorderWidth <> Value then
begin begin
@@ -622,7 +622,7 @@ begin
end; end;
end; end;
procedure TAuraNode.SetFrameless(const Value: Boolean); procedure TAstViewNode.SetFrameless(const Value: Boolean);
begin begin
if FFrameless <> Value then if FFrameless <> Value then
begin begin
@@ -631,7 +631,7 @@ begin
end; end;
end; end;
procedure TAuraNode.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single); procedure TAstViewNode.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin begin
inherited; inherited;
if Button = TMouseButton.mbLeft then if Button = TMouseButton.mbLeft then
@@ -649,7 +649,7 @@ begin
end; end;
end; end;
procedure TAuraNode.MouseMove(Shift: TShiftState; X, Y: Single); procedure TAstViewNode.MouseMove(Shift: TShiftState; X, Y: Single);
begin begin
inherited; inherited;
@@ -666,7 +666,7 @@ begin
end; end;
end; end;
procedure TAuraNode.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single); procedure TAstViewNode.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin begin
inherited; inherited;
if (Button = TMouseButton.mbLeft) and (FIsDragging) then if (Button = TMouseButton.mbLeft) and (FIsDragging) then
@@ -678,13 +678,13 @@ begin
end; end;
end; end;
procedure TAuraNode.SetBackgroundColor(const Value: TAlphaColor); procedure TAstViewNode.SetBackgroundColor(const Value: TAlphaColor);
begin begin
FBackgroundColor := Value; FBackgroundColor := Value;
Repaint; Repaint;
end; end;
procedure TAuraNode.SetupNode; procedure TAstViewNode.SetupNode;
begin begin
if Assigned(FHandler) then if Assigned(FHandler) then
FHandler.BuildUI(Self); FHandler.BuildUI(Self);
+130 -130
View File
@@ -5,9 +5,9 @@ interface
uses uses
System.SysUtils, System.SysUtils,
System.Classes, System.Classes,
System.Types,
System.UITypes, System.UITypes,
System.Generics.Collections, System.Generics.Collections,
System.Types,
FMX.Types, FMX.Types,
FMX.Controls, FMX.Controls,
FMX.StdCtrls, FMX.StdCtrls,
@@ -24,213 +24,213 @@ type
TConstantNodeHandler = class(TBaseNodeHandler<IConstantNode>) TConstantNodeHandler = class(TBaseNodeHandler<IConstantNode>)
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TIdentifierNodeHandler = class(TBaseNodeHandler<IIdentifierNode>) TIdentifierNodeHandler = class(TBaseNodeHandler<IIdentifierNode>)
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TKeywordNodeHandler = class(TBaseNodeHandler<IKeywordNode>) TKeywordNodeHandler = class(TBaseNodeHandler<IKeywordNode>)
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TNopNodeHandler = class(TBaseNodeHandler<INopNode>) TNopNodeHandler = class(TBaseNodeHandler<INopNode>)
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
// --- Logic & Control Flow --- // --- Logic & Control Flow ---
TBlockExpressionNodeHandler = class(TBaseNodeHandler<IBlockExpressionNode>) TBlockExpressionNodeHandler = class(TBaseNodeHandler<IBlockExpressionNode>)
private private
FChildNodes: TList<TAuraNode>; FChildNodes: TList<TAstViewNode>;
public public
constructor Create(const ANode: IBlockExpressionNode); constructor Create(const ANode: IBlockExpressionNode);
destructor Destroy; override; destructor Destroy; override;
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TIfExpressionNodeHandler = class(TBaseNodeHandler<IIfExpressionNode>) TIfExpressionNodeHandler = class(TBaseNodeHandler<IIfExpressionNode>)
private private
FConditionNode: TAuraNode; FConditionNode: TAstViewNode;
FThenNode: TAuraNode; FThenNode: TAstViewNode;
FElseNode: TAuraNode; FElseNode: TAstViewNode;
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TTernaryExpressionNodeHandler = class(TBaseNodeHandler<ITernaryExpressionNode>) TTernaryExpressionNodeHandler = class(TBaseNodeHandler<ITernaryExpressionNode>)
private private
FConditionNode: TAuraNode; FConditionNode: TAstViewNode;
FThenNode: TAuraNode; FThenNode: TAstViewNode;
FElseNode: TAuraNode; FElseNode: TAstViewNode;
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
// --- Functions & Calls --- // --- Functions & Calls ---
TLambdaExpressionNodeHandler = class(TBaseNodeHandler<ILambdaExpressionNode>) TLambdaExpressionNodeHandler = class(TBaseNodeHandler<ILambdaExpressionNode>)
private private
FBodyNode: TAuraNode; FBodyNode: TAstViewNode;
FParamLabels: TList<TLabel>; FParamLabels: TList<TLabel>;
public public
constructor Create(const ANode: ILambdaExpressionNode); constructor Create(const ANode: ILambdaExpressionNode);
destructor Destroy; override; destructor Destroy; override;
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TFunctionCallNodeHandler = class(TBaseNodeHandler<IFunctionCallNode>) TFunctionCallNodeHandler = class(TBaseNodeHandler<IFunctionCallNode>)
private private
FCalleeNode: TAuraNode; FCalleeNode: TAstViewNode;
FArgumentNodes: TList<TAuraNode>; FArgumentNodes: TList<TAstViewNode>;
public public
constructor Create(const ANode: IFunctionCallNode); constructor Create(const ANode: IFunctionCallNode);
destructor Destroy; override; destructor Destroy; override;
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TMacroExpansionNodeHandler = class(TBaseNodeHandler<IMacroExpansionNode>) TMacroExpansionNodeHandler = class(TBaseNodeHandler<IMacroExpansionNode>)
private private
FExpandedBodyNode: TAuraNode; FExpandedBodyNode: TAstViewNode;
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TRecurNodeHandler = class(TBaseNodeHandler<IRecurNode>) TRecurNodeHandler = class(TBaseNodeHandler<IRecurNode>)
private private
FArgumentNodes: TList<TAuraNode>; FArgumentNodes: TList<TAstViewNode>;
public public
constructor Create(const ANode: IRecurNode); constructor Create(const ANode: IRecurNode);
destructor Destroy; override; destructor Destroy; override;
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
// --- Declarations & Assignments --- // --- Declarations & Assignments ---
TVariableDeclarationNodeHandler = class(TBaseNodeHandler<IVariableDeclarationNode>) TVariableDeclarationNodeHandler = class(TBaseNodeHandler<IVariableDeclarationNode>)
private private
FTargetNode: TAuraNode; FTargetNode: TAstViewNode;
FInitializerNode: TAuraNode; FInitializerNode: TAstViewNode;
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TAssignmentNodeHandler = class(TBaseNodeHandler<IAssignmentNode>) TAssignmentNodeHandler = class(TBaseNodeHandler<IAssignmentNode>)
private private
FTargetNode: TAuraNode; FTargetNode: TAstViewNode;
FValueNode: TAuraNode; FValueNode: TAstViewNode;
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TMacroDefinitionNodeHandler = class(TBaseNodeHandler<IMacroDefinitionNode>) TMacroDefinitionNodeHandler = class(TBaseNodeHandler<IMacroDefinitionNode>)
private private
FBodyNode: TAuraNode; FBodyNode: TAstViewNode;
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
// --- Metaprogramming --- // --- Metaprogramming ---
TQuasiquoteNodeHandler = class(TBaseNodeHandler<IQuasiquoteNode>) TQuasiquoteNodeHandler = class(TBaseNodeHandler<IQuasiquoteNode>)
private private
FExpressionNode: TAuraNode; FExpressionNode: TAstViewNode;
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TUnquoteNodeHandler = class(TBaseNodeHandler<IUnquoteNode>) TUnquoteNodeHandler = class(TBaseNodeHandler<IUnquoteNode>)
private private
FExpressionNode: TAuraNode; FExpressionNode: TAstViewNode;
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TUnquoteSplicingNodeHandler = class(TBaseNodeHandler<IUnquoteSplicingNode>) TUnquoteSplicingNodeHandler = class(TBaseNodeHandler<IUnquoteSplicingNode>)
private private
FExpressionNode: TAuraNode; FExpressionNode: TAstViewNode;
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
// --- Data Access & Structures --- // --- Data Access & Structures ---
TIndexerNodeHandler = class(TBaseNodeHandler<IIndexerNode>) TIndexerNodeHandler = class(TBaseNodeHandler<IIndexerNode>)
private private
FBaseNode: TAuraNode; FBaseNode: TAstViewNode;
FIndexNode: TAuraNode; FIndexNode: TAstViewNode;
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TMemberAccessNodeHandler = class(TBaseNodeHandler<IMemberAccessNode>) TMemberAccessNodeHandler = class(TBaseNodeHandler<IMemberAccessNode>)
private private
FBaseNode: TAuraNode; FBaseNode: TAstViewNode;
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TRecordLiteralNodeHandler = class(TBaseNodeHandler<IRecordLiteralNode>) TRecordLiteralNodeHandler = class(TBaseNodeHandler<IRecordLiteralNode>)
private private
FFieldNodes: TDictionary<IKeyword, TAuraNode>; FFieldNodes: TDictionary<IKeyword, TAstViewNode>;
public public
constructor Create(const ANode: IRecordLiteralNode); constructor Create(const ANode: IRecordLiteralNode);
destructor Destroy; override; destructor Destroy; override;
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
// --- Series Operations --- // --- Series Operations ---
TCreateSeriesNodeHandler = class(TBaseNodeHandler<ICreateSeriesNode>) TCreateSeriesNodeHandler = class(TBaseNodeHandler<ICreateSeriesNode>)
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TAddSeriesItemNodeHandler = class(TBaseNodeHandler<IAddSeriesItemNode>) TAddSeriesItemNodeHandler = class(TBaseNodeHandler<IAddSeriesItemNode>)
private private
FValueNode: TAuraNode; FValueNode: TAstViewNode;
FLookbackNode: TAuraNode; FLookbackNode: TAstViewNode;
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
TSeriesLengthNodeHandler = class(TBaseNodeHandler<ISeriesLengthNode>) TSeriesLengthNodeHandler = class(TBaseNodeHandler<ISeriesLengthNode>)
public public
procedure BuildUI(OwnerNode: TAuraNode); override; procedure BuildUI(OwnerNode: TAstViewNode); override;
function ReconstructAst(OwnerNode: TAuraNode): IAstNode; override; function ReconstructAst(OwnerNode: TAstViewNode): IAstNode; override;
end; end;
implementation implementation
{ TConstantNodeHandler } { TConstantNodeHandler }
procedure TConstantNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TConstantNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
valueStr: string; valueStr: string;
isConcise: Boolean; isConcise: Boolean;
@@ -264,14 +264,14 @@ begin
end; end;
end; end;
function TConstantNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TConstantNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := TAst.Constant(FNode.Identity.AsConstant, FNode.StaticType); Result := TAst.Constant(FNode.Identity.AsConstant, FNode.StaticType);
end; end;
{ TIdentifierNodeHandler } { TIdentifierNodeHandler }
procedure TIdentifierNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TIdentifierNodeHandler.BuildUI(OwnerNode: TAstViewNode);
begin begin
OwnerNode.BeginUpdate; OwnerNode.BeginUpdate;
try try
@@ -282,14 +282,14 @@ begin
end; end;
end; end;
function TIdentifierNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TIdentifierNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := TAst.Identifier(FNode.Identity.AsNamed, FNode.Address, FNode.StaticType); Result := TAst.Identifier(FNode.Identity.AsNamed, FNode.Address, FNode.StaticType);
end; end;
{ TKeywordNodeHandler } { TKeywordNodeHandler }
procedure TKeywordNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TKeywordNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
lbl: TLabel; lbl: TLabel;
begin begin
@@ -304,14 +304,14 @@ begin
end; end;
end; end;
function TKeywordNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TKeywordNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := TAst.Keyword(FNode.Identity.AsKeyword); Result := TAst.Keyword(FNode.Identity.AsKeyword);
end; end;
{ TNopNodeHandler } { TNopNodeHandler }
procedure TNopNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TNopNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
lbl: TLabel; lbl: TLabel;
begin begin
@@ -328,7 +328,7 @@ begin
end; end;
end; end;
function TNopNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TNopNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := FNode; Result := FNode;
end; end;
@@ -338,7 +338,7 @@ end;
constructor TBlockExpressionNodeHandler.Create(const ANode: IBlockExpressionNode); constructor TBlockExpressionNodeHandler.Create(const ANode: IBlockExpressionNode);
begin begin
inherited Create(ANode); inherited Create(ANode);
FChildNodes := TList<TAuraNode>.Create; FChildNodes := TList<TAstViewNode>.Create;
end; end;
destructor TBlockExpressionNodeHandler.Destroy; destructor TBlockExpressionNodeHandler.Destroy;
@@ -347,10 +347,10 @@ begin
inherited; inherited;
end; end;
procedure TBlockExpressionNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TBlockExpressionNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
childNode: TAuraNode; childNode: TAstViewNode;
expr: IAstNode; expr: IAstNode;
titleLabel: TLabel; titleLabel: TLabel;
i: Integer; i: Integer;
@@ -388,10 +388,10 @@ begin
end; end;
end; end;
function TBlockExpressionNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TBlockExpressionNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
var var
exprs: TArray<IAstNode>; exprs: TArray<IAstNode>;
childNode: TAuraNode; childNode: TAstViewNode;
i: Integer; i: Integer;
begin begin
SetLength(exprs, FChildNodes.Count); SetLength(exprs, FChildNodes.Count);
@@ -409,7 +409,7 @@ end;
{ TIfExpressionNodeHandler } { TIfExpressionNodeHandler }
procedure TIfExpressionNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TIfExpressionNodeHandler.BuildUI(OwnerNode: TAstViewNode);
begin begin
OwnerNode.BeginUpdate; OwnerNode.BeginUpdate;
try try
@@ -426,7 +426,7 @@ begin
end; end;
end; end;
function TIfExpressionNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TIfExpressionNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
var var
elseAst: IAstNode; elseAst: IAstNode;
begin begin
@@ -440,7 +440,7 @@ end;
{ TTernaryExpressionNodeHandler } { TTernaryExpressionNodeHandler }
procedure TTernaryExpressionNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TTernaryExpressionNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
begin begin
@@ -459,7 +459,7 @@ begin
end; end;
end; end;
function TTernaryExpressionNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TTernaryExpressionNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := TAst.TernaryExpr(FNode.Identity, FConditionNode.CreateAst, FThenNode.CreateAst, FElseNode.CreateAst, FNode.StaticType); Result := TAst.TernaryExpr(FNode.Identity, FConditionNode.CreateAst, FThenNode.CreateAst, FElseNode.CreateAst, FNode.StaticType);
end; end;
@@ -478,7 +478,7 @@ begin
inherited; inherited;
end; end;
procedure TLambdaExpressionNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TLambdaExpressionNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
titleContainer: TAutoFitControl; titleContainer: TAutoFitControl;
@@ -525,7 +525,7 @@ begin
end; end;
end; end;
function TLambdaExpressionNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TLambdaExpressionNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := Result :=
TAst.LambdaExpr( TAst.LambdaExpr(
@@ -546,7 +546,7 @@ end;
constructor TFunctionCallNodeHandler.Create(const ANode: IFunctionCallNode); constructor TFunctionCallNodeHandler.Create(const ANode: IFunctionCallNode);
begin begin
inherited Create(ANode); inherited Create(ANode);
FArgumentNodes := TList<TAuraNode>.Create; FArgumentNodes := TList<TAstViewNode>.Create;
end; end;
destructor TFunctionCallNodeHandler.Destroy; destructor TFunctionCallNodeHandler.Destroy;
@@ -555,11 +555,11 @@ begin
inherited; inherited;
end; end;
procedure TFunctionCallNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TFunctionCallNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
i: Integer; i: Integer;
argNode: TAuraNode; argNode: TAstViewNode;
callLabel: TLabel; callLabel: TLabel;
begin begin
visu := OwnerNode.Visualizer.Clone(OwnerNode, OwnerNode.Visualizer.ExprDepth + 1); visu := OwnerNode.Visualizer.Clone(OwnerNode, OwnerNode.Visualizer.ExprDepth + 1);
@@ -590,7 +590,7 @@ begin
end; end;
end; end;
function TFunctionCallNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TFunctionCallNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
var var
args: TArray<IAstNode>; args: TArray<IAstNode>;
i: Integer; i: Integer;
@@ -613,7 +613,7 @@ end;
{ TMacroExpansionNodeHandler } { TMacroExpansionNodeHandler }
procedure TMacroExpansionNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TMacroExpansionNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
titleLabel: TLabel; titleLabel: TLabel;
@@ -631,7 +631,7 @@ begin
end; end;
end; end;
function TMacroExpansionNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TMacroExpansionNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := TAst.MacroExpansionNode(FNode.Identity, FNode.CallNode, FExpandedBodyNode.CreateAst.AsTypedNode); Result := TAst.MacroExpansionNode(FNode.Identity, FNode.CallNode, FExpandedBodyNode.CreateAst.AsTypedNode);
end; end;
@@ -641,7 +641,7 @@ end;
constructor TRecurNodeHandler.Create(const ANode: IRecurNode); constructor TRecurNodeHandler.Create(const ANode: IRecurNode);
begin begin
inherited Create(ANode); inherited Create(ANode);
FArgumentNodes := TList<TAuraNode>.Create; FArgumentNodes := TList<TAstViewNode>.Create;
end; end;
destructor TRecurNodeHandler.Destroy; destructor TRecurNodeHandler.Destroy;
@@ -650,11 +650,11 @@ begin
inherited; inherited;
end; end;
procedure TRecurNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TRecurNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
i: Integer; i: Integer;
argNode: TAuraNode; argNode: TAstViewNode;
titleLabel: TLabel; titleLabel: TLabel;
begin begin
visu := OwnerNode.Visualizer.Clone(OwnerNode, OwnerNode.Visualizer.ExprDepth + 1); visu := OwnerNode.Visualizer.Clone(OwnerNode, OwnerNode.Visualizer.ExprDepth + 1);
@@ -680,7 +680,7 @@ begin
end; end;
end; end;
function TRecurNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TRecurNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
var var
args: TArray<IAstNode>; args: TArray<IAstNode>;
i: Integer; i: Integer;
@@ -693,7 +693,7 @@ end;
{ TVariableDeclarationNodeHandler } { TVariableDeclarationNodeHandler }
procedure TVariableDeclarationNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TVariableDeclarationNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
varLabel: TLabel; varLabel: TLabel;
@@ -721,7 +721,7 @@ begin
end; end;
end; end;
function TVariableDeclarationNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TVariableDeclarationNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
var var
initAst: IAstNode; initAst: IAstNode;
begin begin
@@ -734,7 +734,7 @@ end;
{ TAssignmentNodeHandler } { TAssignmentNodeHandler }
procedure TAssignmentNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TAssignmentNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
begin begin
@@ -751,14 +751,14 @@ begin
end; end;
end; end;
function TAssignmentNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TAssignmentNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := TAst.Assign(FNode.Identity, FTargetNode.CreateAst, FValueNode.CreateAst, FNode.StaticType); Result := TAst.Assign(FNode.Identity, FTargetNode.CreateAst, FValueNode.CreateAst, FNode.StaticType);
end; end;
{ TMacroDefinitionNodeHandler } { TMacroDefinitionNodeHandler }
procedure TMacroDefinitionNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TMacroDefinitionNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
titleLabel: TLabel; titleLabel: TLabel;
@@ -788,14 +788,14 @@ begin
end; end;
end; end;
function TMacroDefinitionNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TMacroDefinitionNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := TAst.MacroDef(FNode.Identity, FNode.Name, FNode.Parameters, FBodyNode.CreateAst); Result := TAst.MacroDef(FNode.Identity, FNode.Name, FNode.Parameters, FBodyNode.CreateAst);
end; end;
{ TQuasiquoteNodeHandler } { TQuasiquoteNodeHandler }
procedure TQuasiquoteNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TQuasiquoteNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
titleLabel: TLabel; titleLabel: TLabel;
@@ -813,14 +813,14 @@ begin
end; end;
end; end;
function TQuasiquoteNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TQuasiquoteNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := TAst.Quasiquote(FNode.Identity, FExpressionNode.CreateAst); Result := TAst.Quasiquote(FNode.Identity, FExpressionNode.CreateAst);
end; end;
{ TUnquoteNodeHandler } { TUnquoteNodeHandler }
procedure TUnquoteNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TUnquoteNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
leftBracket, rightBracket: TLabel; leftBracket, rightBracket: TLabel;
@@ -845,14 +845,14 @@ begin
end; end;
end; end;
function TUnquoteNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TUnquoteNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := TAst.Unquote(FNode.Identity, FExpressionNode.CreateAst); Result := TAst.Unquote(FNode.Identity, FExpressionNode.CreateAst);
end; end;
{ TUnquoteSplicingNodeHandler } { TUnquoteSplicingNodeHandler }
procedure TUnquoteSplicingNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TUnquoteSplicingNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
titleLabel: TLabel; titleLabel: TLabel;
@@ -870,14 +870,14 @@ begin
end; end;
end; end;
function TUnquoteSplicingNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TUnquoteSplicingNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := TAst.UnquoteSplicing(FNode.Identity, FExpressionNode.CreateAst.AsQuasiquote); Result := TAst.UnquoteSplicing(FNode.Identity, FExpressionNode.CreateAst.AsQuasiquote);
end; end;
{ TIndexerNodeHandler } { TIndexerNodeHandler }
procedure TIndexerNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TIndexerNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
begin begin
@@ -895,14 +895,14 @@ begin
end; end;
end; end;
function TIndexerNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TIndexerNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := TAst.Indexer(FNode.Identity, FBaseNode.CreateAst, FIndexNode.CreateAst, FNode.StaticType); Result := TAst.Indexer(FNode.Identity, FBaseNode.CreateAst, FIndexNode.CreateAst, FNode.StaticType);
end; end;
{ TMemberAccessNodeHandler } { TMemberAccessNodeHandler }
procedure TMemberAccessNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TMemberAccessNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
begin begin
@@ -919,7 +919,7 @@ begin
end; end;
end; end;
function TMemberAccessNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TMemberAccessNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
// Reuse Identifier, Reuse Member Keyword (via TAst.Keyword with Identity) // Reuse Identifier, Reuse Member Keyword (via TAst.Keyword with Identity)
Result := TAst.MemberAccess(FNode.Identity, FBaseNode.CreateAst, TAst.Keyword(FNode.Member.Identity.AsKeyword), FNode.StaticType); Result := TAst.MemberAccess(FNode.Identity, FBaseNode.CreateAst, TAst.Keyword(FNode.Member.Identity.AsKeyword), FNode.StaticType);
@@ -930,7 +930,7 @@ end;
constructor TRecordLiteralNodeHandler.Create(const ANode: IRecordLiteralNode); constructor TRecordLiteralNodeHandler.Create(const ANode: IRecordLiteralNode);
begin begin
inherited Create(ANode); inherited Create(ANode);
FFieldNodes := TDictionary<IKeyword, TAuraNode>.Create; FFieldNodes := TDictionary<IKeyword, TAstViewNode>.Create;
end; end;
destructor TRecordLiteralNodeHandler.Destroy; destructor TRecordLiteralNodeHandler.Destroy;
@@ -939,11 +939,11 @@ begin
inherited; inherited;
end; end;
procedure TRecordLiteralNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TRecordLiteralNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
field: TRecordFieldLiteral; field: TRecordFieldLiteral;
fieldContainer: TAutoFitControl; fieldContainer: TAutoFitControl;
valueNode: TAuraNode; valueNode: TAstViewNode;
keyLabel: TLabel; keyLabel: TLabel;
begin begin
OwnerNode.BeginUpdate; OwnerNode.BeginUpdate;
@@ -975,12 +975,12 @@ begin
end; end;
end; end;
function TRecordLiteralNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TRecordLiteralNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
var var
fields: TArray<TRecordFieldLiteral>; fields: TArray<TRecordFieldLiteral>;
i: Integer; i: Integer;
valueNode: TAuraNode; valueNode: TAstViewNode;
pair: TPair<IKeyword, TAuraNode>; pair: TPair<IKeyword, TAstViewNode>;
begin begin
SetLength(fields, FFieldNodes.Count); SetLength(fields, FFieldNodes.Count);
i := 0; i := 0;
@@ -995,7 +995,7 @@ end;
{ TCreateSeriesNodeHandler } { TCreateSeriesNodeHandler }
procedure TCreateSeriesNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TCreateSeriesNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
titleLabel: TLabel; titleLabel: TLabel;
begin begin
@@ -1010,14 +1010,14 @@ begin
end; end;
end; end;
function TCreateSeriesNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TCreateSeriesNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := TAst.CreateSeries(FNode.Identity.AsDefinition, FNode.StaticType); Result := TAst.CreateSeries(FNode.Identity.AsDefinition, FNode.StaticType);
end; end;
{ TAddSeriesItemNodeHandler } { TAddSeriesItemNodeHandler }
procedure TAddSeriesItemNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TAddSeriesItemNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
visu: IAstVisualizer; visu: IAstVisualizer;
titleLabel: TLabel; titleLabel: TLabel;
@@ -1041,7 +1041,7 @@ begin
end; end;
end; end;
function TAddSeriesItemNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TAddSeriesItemNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
var var
lookbackAst: IAstNode; lookbackAst: IAstNode;
begin begin
@@ -1062,7 +1062,7 @@ end;
{ TSeriesLengthNodeHandler } { TSeriesLengthNodeHandler }
procedure TSeriesLengthNodeHandler.BuildUI(OwnerNode: TAuraNode); procedure TSeriesLengthNodeHandler.BuildUI(OwnerNode: TAstViewNode);
var var
titleLabel: TLabel; titleLabel: TLabel;
begin begin
@@ -1077,7 +1077,7 @@ begin
end; end;
end; end;
function TSeriesLengthNodeHandler.ReconstructAst(OwnerNode: TAuraNode): IAstNode; function TSeriesLengthNodeHandler.ReconstructAst(OwnerNode: TAstViewNode): IAstNode;
begin begin
Result := TAst.SeriesLength(FNode.Identity, FNode.Series, FNode.StaticType); Result := TAst.SeriesLength(FNode.Identity, FNode.Series, FNode.StaticType);
end; end;
+80 -80
View File
@@ -14,60 +14,60 @@ uses
Myc.Fmx.AstEditor.Handlers; Myc.Fmx.AstEditor.Handlers;
type type
// Inherits from the generic TAstVisitor<TAuraNode> // Inherits from the generic TAstVisitor<TAstViewNode>
TAstVisualizer = class(TAstVisitor<TAuraNode>, IAstVisualizer) TAstVisualizer = class(TAstVisitor<TAstViewNode>, IAstVisualizer)
private private
FExprDepth: Integer; FExprDepth: Integer;
FParentControl: TControl; FParentControl: TControl;
FWorkspace: TAuraWorkspace; FWorkspace: TAstWorkspace;
function CallAccept(const Node: IAstNode): TAuraNode; function CallAccept(const Node: IAstNode): TAstViewNode;
function GetExprDepth: Integer; function GetExprDepth: Integer;
function GetParentControl: TControl; function GetParentControl: TControl;
function GetWorkspace: TAuraWorkspace; function GetWorkspace: TAstWorkspace;
procedure SetExprDepth(const Value: Integer); procedure SetExprDepth(const Value: Integer);
procedure SetParentControl(const Value: TControl); procedure SetParentControl(const Value: TControl);
protected protected
// Visitor implementations for each AST node type. // Visitor implementations for each AST node type.
function VisitConstant(const Node: IConstantNode): TAuraNode; override; function VisitConstant(const Node: IConstantNode): TAstViewNode; override;
function VisitIdentifier(const Node: IIdentifierNode): TAuraNode; override; function VisitIdentifier(const Node: IIdentifierNode): TAstViewNode; override;
function VisitKeyword(const Node: IKeywordNode): TAuraNode; override; function VisitKeyword(const Node: IKeywordNode): TAstViewNode; override;
function VisitIfExpression(const Node: IIfExpressionNode): TAuraNode; override; function VisitIfExpression(const Node: IIfExpressionNode): TAstViewNode; override;
function VisitTernaryExpression(const Node: ITernaryExpressionNode): TAuraNode; override; function VisitTernaryExpression(const Node: ITernaryExpressionNode): TAstViewNode; override;
function VisitLambdaExpression(const Node: ILambdaExpressionNode): TAuraNode; override; function VisitLambdaExpression(const Node: ILambdaExpressionNode): TAstViewNode; override;
function VisitFunctionCall(const Node: IFunctionCallNode): TAuraNode; override; function VisitFunctionCall(const Node: IFunctionCallNode): TAstViewNode; override;
function VisitMacroExpansionNode(const Node: IMacroExpansionNode): TAuraNode; override; function VisitMacroExpansionNode(const Node: IMacroExpansionNode): TAstViewNode; override;
function VisitBlockExpression(const Node: IBlockExpressionNode): TAuraNode; override; function VisitBlockExpression(const Node: IBlockExpressionNode): TAstViewNode; override;
function VisitVariableDeclaration(const Node: IVariableDeclarationNode): TAuraNode; override; function VisitVariableDeclaration(const Node: IVariableDeclarationNode): TAstViewNode; override;
function VisitAssignment(const Node: IAssignmentNode): TAuraNode; override; function VisitAssignment(const Node: IAssignmentNode): TAstViewNode; override;
function VisitMacroDefinition(const Node: IMacroDefinitionNode): TAuraNode; override; function VisitMacroDefinition(const Node: IMacroDefinitionNode): TAstViewNode; override;
function VisitQuasiquote(const Node: IQuasiquoteNode): TAuraNode; override; function VisitQuasiquote(const Node: IQuasiquoteNode): TAstViewNode; override;
function VisitUnquote(const Node: IUnquoteNode): TAuraNode; override; function VisitUnquote(const Node: IUnquoteNode): TAstViewNode; override;
function VisitUnquoteSplicing(const Node: IUnquoteSplicingNode): TAuraNode; override; function VisitUnquoteSplicing(const Node: IUnquoteSplicingNode): TAstViewNode; override;
function VisitIndexer(const Node: IIndexerNode): TAuraNode; override; function VisitIndexer(const Node: IIndexerNode): TAstViewNode; override;
function VisitMemberAccess(const Node: IMemberAccessNode): TAuraNode; override; function VisitMemberAccess(const Node: IMemberAccessNode): TAstViewNode; override;
function VisitRecordLiteral(const Node: IRecordLiteralNode): TAuraNode; override; function VisitRecordLiteral(const Node: IRecordLiteralNode): TAstViewNode; override;
function VisitCreateSeries(const Node: ICreateSeriesNode): TAuraNode; override; function VisitCreateSeries(const Node: ICreateSeriesNode): TAstViewNode; override;
function VisitAddSeriesItem(const Node: IAddSeriesItemNode): TAuraNode; override; function VisitAddSeriesItem(const Node: IAddSeriesItemNode): TAstViewNode; override;
function VisitSeriesLength(const Node: ISeriesLengthNode): TAuraNode; override; function VisitSeriesLength(const Node: ISeriesLengthNode): TAstViewNode; override;
function VisitRecurNode(const Node: IRecurNode): TAuraNode; override; function VisitRecurNode(const Node: IRecurNode): TAstViewNode; override;
function VisitNop(const Node: INopNode): TAuraNode; override; function VisitNop(const Node: INopNode): TAstViewNode; override;
public public
constructor Create(AWorkspace: TAuraWorkspace; AParentControl: TControl; AExprDepth: Integer); constructor Create(AWorkspace: TAstWorkspace; AParentControl: TControl; AExprDepth: Integer);
destructor Destroy; override; destructor Destroy; override;
function Clone(ParentControl: TControl; ExprDepth: Integer): IAstVisualizer; function Clone(ParentControl: TControl; ExprDepth: Integer): IAstVisualizer;
property ExprDepth: Integer read GetExprDepth write SetExprDepth; property ExprDepth: Integer read GetExprDepth write SetExprDepth;
property ParentControl: TControl read GetParentControl write SetParentControl; property ParentControl: TControl read GetParentControl write SetParentControl;
property Workspace: TAuraWorkspace read GetWorkspace; property Workspace: TAstWorkspace read GetWorkspace;
end; end;
implementation implementation
{ TAstVisualizer } { TAstVisualizer }
constructor TAstVisualizer.Create(AWorkspace: TAuraWorkspace; AParentControl: TControl; AExprDepth: Integer); constructor TAstVisualizer.Create(AWorkspace: TAstWorkspace; AParentControl: TControl; AExprDepth: Integer);
begin begin
inherited Create; inherited Create;
FWorkspace := AWorkspace; FWorkspace := AWorkspace;
@@ -80,7 +80,7 @@ begin
inherited; inherited;
end; end;
function TAstVisualizer.CallAccept(const Node: IAstNode): TAuraNode; function TAstVisualizer.CallAccept(const Node: IAstNode): TAstViewNode;
var var
dataValue: TDataValue; dataValue: TDataValue;
begin begin
@@ -91,7 +91,7 @@ begin
if dataValue.Kind = TDataValueKind.vkGeneric then if dataValue.Kind = TDataValueKind.vkGeneric then
begin begin
Result := dataValue.AsGeneric<TAuraNode>; Result := dataValue.AsGeneric<TAstViewNode>;
end end
else else
begin begin
@@ -114,7 +114,7 @@ begin
Result := FParentControl; Result := FParentControl;
end; end;
function TAstVisualizer.GetWorkspace: TAuraWorkspace; function TAstVisualizer.GetWorkspace: TAstWorkspace;
begin begin
Result := FWorkspace; Result := FWorkspace;
end; end;
@@ -131,119 +131,119 @@ end;
// --- Visitor Implementations --- // --- Visitor Implementations ---
function TAstVisualizer.VisitConstant(const Node: IConstantNode): TAuraNode; function TAstVisualizer.VisitConstant(const Node: IConstantNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TConstantNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TConstantNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitIdentifier(const Node: IIdentifierNode): TAuraNode; function TAstVisualizer.VisitIdentifier(const Node: IIdentifierNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TIdentifierNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TIdentifierNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitKeyword(const Node: IKeywordNode): TAuraNode; function TAstVisualizer.VisitKeyword(const Node: IKeywordNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TKeywordNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TKeywordNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitBlockExpression(const Node: IBlockExpressionNode): TAuraNode; function TAstVisualizer.VisitBlockExpression(const Node: IBlockExpressionNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TBlockExpressionNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TBlockExpressionNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitIfExpression(const Node: IIfExpressionNode): TAuraNode; function TAstVisualizer.VisitIfExpression(const Node: IIfExpressionNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TIfExpressionNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TIfExpressionNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitTernaryExpression(const Node: ITernaryExpressionNode): TAuraNode; function TAstVisualizer.VisitTernaryExpression(const Node: ITernaryExpressionNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TTernaryExpressionNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TTernaryExpressionNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitLambdaExpression(const Node: ILambdaExpressionNode): TAuraNode; function TAstVisualizer.VisitLambdaExpression(const Node: ILambdaExpressionNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TLambdaExpressionNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TLambdaExpressionNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitFunctionCall(const Node: IFunctionCallNode): TAuraNode; function TAstVisualizer.VisitFunctionCall(const Node: IFunctionCallNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TFunctionCallNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TFunctionCallNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitMacroExpansionNode(const Node: IMacroExpansionNode): TAuraNode; function TAstVisualizer.VisitMacroExpansionNode(const Node: IMacroExpansionNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TMacroExpansionNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TMacroExpansionNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitVariableDeclaration(const Node: IVariableDeclarationNode): TAuraNode; function TAstVisualizer.VisitVariableDeclaration(const Node: IVariableDeclarationNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TVariableDeclarationNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TVariableDeclarationNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitAssignment(const Node: IAssignmentNode): TAuraNode; function TAstVisualizer.VisitAssignment(const Node: IAssignmentNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TAssignmentNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TAssignmentNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitMacroDefinition(const Node: IMacroDefinitionNode): TAuraNode; function TAstVisualizer.VisitMacroDefinition(const Node: IMacroDefinitionNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TMacroDefinitionNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TMacroDefinitionNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitQuasiquote(const Node: IQuasiquoteNode): TAuraNode; function TAstVisualizer.VisitQuasiquote(const Node: IQuasiquoteNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TQuasiquoteNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TQuasiquoteNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitUnquote(const Node: IUnquoteNode): TAuraNode; function TAstVisualizer.VisitUnquote(const Node: IUnquoteNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TUnquoteNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TUnquoteNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitUnquoteSplicing(const Node: IUnquoteSplicingNode): TAuraNode; function TAstVisualizer.VisitUnquoteSplicing(const Node: IUnquoteSplicingNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TUnquoteSplicingNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TUnquoteSplicingNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitIndexer(const Node: IIndexerNode): TAuraNode; function TAstVisualizer.VisitIndexer(const Node: IIndexerNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TIndexerNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TIndexerNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitMemberAccess(const Node: IMemberAccessNode): TAuraNode; function TAstVisualizer.VisitMemberAccess(const Node: IMemberAccessNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TMemberAccessNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TMemberAccessNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitRecordLiteral(const Node: IRecordLiteralNode): TAuraNode; function TAstVisualizer.VisitRecordLiteral(const Node: IRecordLiteralNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TRecordLiteralNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TRecordLiteralNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitCreateSeries(const Node: ICreateSeriesNode): TAuraNode; function TAstVisualizer.VisitCreateSeries(const Node: ICreateSeriesNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TCreateSeriesNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TCreateSeriesNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitAddSeriesItem(const Node: IAddSeriesItemNode): TAuraNode; function TAstVisualizer.VisitAddSeriesItem(const Node: IAddSeriesItemNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TAddSeriesItemNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TAddSeriesItemNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitSeriesLength(const Node: ISeriesLengthNode): TAuraNode; function TAstVisualizer.VisitSeriesLength(const Node: ISeriesLengthNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TSeriesLengthNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TSeriesLengthNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitRecurNode(const Node: IRecurNode): TAuraNode; function TAstVisualizer.VisitRecurNode(const Node: IRecurNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TRecurNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TRecurNodeHandler.Create(Node));
end; end;
function TAstVisualizer.VisitNop(const Node: INopNode): TAuraNode; function TAstVisualizer.VisitNop(const Node: INopNode): TAstViewNode;
begin begin
Result := TAuraNode.Create(Self, TNopNodeHandler.Create(Node)); Result := TAstViewNode.Create(Self, TNopNodeHandler.Create(Node));
end; end;
end. end.
+35 -27
View File
@@ -13,10 +13,7 @@ uses
FMX.Controls, FMX.Controls,
FMX.Graphics, FMX.Graphics,
FMX.Objects, FMX.Objects,
Myc.Ast, Myc.Ast.Nodes;
Myc.Ast.Nodes,
Myc.Ast.Scope,
Myc.Ast.Compiler.Binder;
const const
cDataPinColor = TAlphaColors.Dodgerblue; cDataPinColor = TAlphaColors.Dodgerblue;
@@ -29,7 +26,7 @@ type
constructor Create(AOutputPin, AInputPin: TControl); constructor Create(AOutputPin, AInputPin: TControl);
end; end;
TAuraWorkspace = class(TStyledControl) TAstWorkspace = class(TStyledControl)
private private
FConnections: TArray<TPinConnection>; FConnections: TArray<TPinConnection>;
FPanning: TSizeF; FPanning: TSizeF;
@@ -91,8 +88,8 @@ implementation
uses uses
System.Math, System.Math,
FMX.Platform, FMX.Platform,
Myc.Fmx.AstEditor.Core, Myc.Fmx.AstEditor.Core, // Enthält TAstViewNode Interfaces
Myc.Fmx.AstEditor.Visualizer; Myc.Fmx.AstEditor.Visualizer; // Enthält TAstVisualizer
{ TPinConnection } { TPinConnection }
@@ -102,37 +99,40 @@ begin
InputPin := AInputPin; InputPin := AInputPin;
end; end;
{ TAuraWorkspace } { TAstWorkspace }
constructor TAuraWorkspace.Create(AOwner: TComponent); constructor TAstWorkspace.Create(AOwner: TComponent);
begin begin
inherited; inherited;
FZoom := 1.0; FZoom := 1.0;
end; end;
procedure TAuraWorkspace.Build(const RootNode: IAstNode; const Position: TPointF); procedure TAstWorkspace.Build(const RootNode: IAstNode; const Position: TPointF);
var
visu: IAstVisualizer;
node: TAstViewNode;
begin begin
var visu := TAstVisualizer.Create(Self, Self, 0) as IAstVisualizer; // Erstelle den Visualizer mit diesem Workspace als Kontext
var node := visu.CallAccept(RootNode); visu := TAstVisualizer.Create(Self, Self, 0);
node := visu.CallAccept(RootNode);
if Assigned(node) then if Assigned(node) then
node.Position.Point := Position; node.Position.Point := Position;
end; end;
procedure TAuraWorkspace.DoDeleteChildren; procedure TAstWorkspace.DoDeleteChildren;
begin begin
FConnections := nil; FConnections := nil;
inherited; inherited;
end; end;
function TAuraWorkspace.GetChildrenMatrix(var Matrix: TMatrix; var Simple: Boolean): Boolean; function TAstWorkspace.GetChildrenMatrix(var Matrix: TMatrix; var Simple: Boolean): Boolean;
begin begin
Matrix := TMatrix.CreateScaling(FZoom, FZoom) * TMatrix.CreateTranslation(FPanning.cx, FPanning.cy); Matrix := TMatrix.CreateScaling(FZoom, FZoom) * TMatrix.CreateTranslation(FPanning.cx, FPanning.cy);
Simple := (FZoom = 1.0) and (FPanning.cx = 0) and (FPanning.cy = 0); Simple := (FZoom = 1.0) and (FPanning.cx = 0) and (FPanning.cy = 0);
Result := True; Result := True;
end; end;
procedure TAuraWorkspace.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single); procedure TAstWorkspace.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin begin
inherited; inherited;
if (Button = TMouseButton.mbLeft) and (ObjectAtPoint(LocalToScreen(TPointF.Create(X, Y))) = Self as IControl) then if (Button = TMouseButton.mbLeft) and (ObjectAtPoint(LocalToScreen(TPointF.Create(X, Y))) = Self as IControl) then
@@ -143,7 +143,7 @@ begin
end; end;
end; end;
procedure TAuraWorkspace.MouseMove(Shift: TShiftState; X, Y: Single); procedure TAstWorkspace.MouseMove(Shift: TShiftState; X, Y: Single);
var var
delta: TPointF; delta: TPointF;
begin begin
@@ -161,7 +161,7 @@ begin
end; end;
end; end;
procedure TAuraWorkspace.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single); procedure TAstWorkspace.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin begin
inherited; inherited;
if (Button = TMouseButton.mbLeft) and (FIsPanning) then if (Button = TMouseButton.mbLeft) and (FIsPanning) then
@@ -171,25 +171,27 @@ begin
end; end;
end; end;
procedure TAuraWorkspace.MouseWheel(Shift: TShiftState; WheelDelta: Integer; var Handled: Boolean); procedure TAstWorkspace.MouseWheel(Shift: TShiftState; WheelDelta: Integer; var Handled: Boolean);
begin begin
inherited; inherited;
Handled := Zoom(IfThen(WheelDelta > 0, FZoom * 1.1, FZoom / 1.1)); Handled := Zoom(IfThen(WheelDelta > 0, FZoom * 1.1, FZoom / 1.1));
end; end;
procedure TAuraWorkspace.DblClick; procedure TAstWorkspace.DblClick;
begin begin
inherited; inherited;
Zoom(1.0); Zoom(1.0);
end; end;
procedure TAuraWorkspace.Paint; procedure TAstWorkspace.Paint;
var var
connection: TPinConnection; connection: TPinConnection;
startPoint, endPoint, pinCenter: TPointF; startPoint, endPoint, pinCenter: TPointF;
path: TPathData; path: TPathData;
controlPoint1, controlPoint2: TPointF; controlPoint1, controlPoint2: TPointF;
controlOffset: Single; controlOffset: Single;
absoluteStart, absoluteEnd: TPointF;
str: string;
begin begin
inherited; inherited;
@@ -198,24 +200,29 @@ begin
for connection in FConnections do for connection in FConnections do
begin begin
// Output Pin Calculation
pinCenter := TPointF.Create(connection.OutputPin.Width / 2, connection.OutputPin.Height / 2); pinCenter := TPointF.Create(connection.OutputPin.Width / 2, connection.OutputPin.Height / 2);
var absoluteStart := connection.OutputPin.LocalToAbsolute(pinCenter); absoluteStart := connection.OutputPin.LocalToAbsolute(pinCenter);
// Input Pin Calculation
pinCenter := TPointF.Create(connection.InputPin.Width / 2, connection.InputPin.Height / 2); pinCenter := TPointF.Create(connection.InputPin.Width / 2, connection.InputPin.Height / 2);
var absoluteEnd := connection.InputPin.LocalToAbsolute(pinCenter); absoluteEnd := connection.InputPin.LocalToAbsolute(pinCenter);
// Convert to Workspace Local Coordinates
startPoint := AbsoluteToLocal(absoluteStart); startPoint := AbsoluteToLocal(absoluteStart);
endPoint := AbsoluteToLocal(absoluteEnd); endPoint := AbsoluteToLocal(absoluteEnd);
var str := connection.InputPin.TagString; // Determine Color based on TagString (naive check)
str := connection.InputPin.TagString;
if Pos('data', str) = 0 then if Pos('data', str) = 0 then
Canvas.Stroke.Color := cExecPinColor Canvas.Stroke.Color := cExecPinColor
else else
Canvas.Stroke.Color := cDataPinColor; Canvas.Stroke.Color := cDataPinColor;
// Draw Curve
path := TPathData.Create; path := TPathData.Create;
try try
controlOffset := max(25, 0.5 * endPoint.Distance(startPoint)); controlOffset := Max(25, 0.5 * endPoint.Distance(startPoint));
controlPoint1 := TPointF.Create(startPoint.X + controlOffset, startPoint.Y); controlPoint1 := TPointF.Create(startPoint.X + controlOffset, startPoint.Y);
controlPoint2 := TPointF.Create(endPoint.X - controlOffset, endPoint.Y); controlPoint2 := TPointF.Create(endPoint.X - controlOffset, endPoint.Y);
path.MoveTo(startPoint); path.MoveTo(startPoint);
@@ -227,14 +234,15 @@ begin
end; end;
end; end;
function TAuraWorkspace.Zoom(Factor: Single): Boolean; function TAstWorkspace.Zoom(Factor: Single): Boolean;
var var
mouseService: IFMXMouseService; mouseService: IFMXMouseService;
mousePos: TPointF;
begin begin
Result := TPlatformServices.Current.SupportsPlatformService(IFMXMouseService, mouseService); Result := TPlatformServices.Current.SupportsPlatformService(IFMXMouseService, mouseService);
if Result then if Result then
begin begin
var mousePos := ScreenToLocal(mouseService.GetMousePos); mousePos := ScreenToLocal(mouseService.GetMousePos);
Factor := Max(0.2, Min(3.0, Factor)); Factor := Max(0.2, Min(3.0, Factor));
FPanning.cx := mousePos.X * (1 - Factor / FZoom) + FPanning.cx * (Factor / FZoom); FPanning.cx := mousePos.X * (1 - Factor / FZoom) + FPanning.cx * (Factor / FZoom);
FPanning.cy := mousePos.Y * (1 - Factor / FZoom) + FPanning.cy * (Factor / FZoom); FPanning.cy := mousePos.Y * (1 - Factor / FZoom) + FPanning.cy * (Factor / FZoom);