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