From a47cd3f1f48492114d06691d330a846222587ac7 Mon Sep 17 00:00:00 2001 From: Michael Schimmel Date: Sun, 26 Oct 2025 21:43:11 +0100 Subject: [PATCH] New visualizer --- ASTPlayground/Myc.Fmx.AstEditor.Node.pas | 8 +------- ASTPlayground/Myc.Fmx.AstVisualizer.pas | 15 +++------------ Src/AST/Myc.Ast.Binding.pas | 8 -------- 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/ASTPlayground/Myc.Fmx.AstEditor.Node.pas b/ASTPlayground/Myc.Fmx.AstEditor.Node.pas index bbf7783..f878c3b 100644 --- a/ASTPlayground/Myc.Fmx.AstEditor.Node.pas +++ b/ASTPlayground/Myc.Fmx.AstEditor.Node.pas @@ -123,7 +123,6 @@ end; procedure TAuraNode.Paint; var rect: TRectF; - effectiveBorderWidth: Single; begin inherited; // Allow styled painting to occur first (if any) @@ -142,7 +141,6 @@ begin Canvas.Stroke.Thickness := 1; Canvas.Stroke.Dash := TStrokeDash.Dot; Canvas.DrawRect(TRectF.Create(0, 0, Width, Height), 0, 0, [], 1.0); - effectiveBorderWidth := 0; end else begin @@ -167,11 +165,7 @@ begin Canvas.Stroke.Thickness := FBorderWidth; Canvas.Stroke.Dash := TStrokeDash.Solid; Canvas.DrawRect(rect, FBorderRadius, FBorderRadius, AllCorners, 1.0, TCornerType.Round); - - effectiveBorderWidth := FBorderWidth; - end - else - effectiveBorderWidth := 0; + end; end; // Title drawing removed, handled by external labels now. end; diff --git a/ASTPlayground/Myc.Fmx.AstVisualizer.pas b/ASTPlayground/Myc.Fmx.AstVisualizer.pas index b80e254..6b1f7bf 100644 --- a/ASTPlayground/Myc.Fmx.AstVisualizer.pas +++ b/ASTPlayground/Myc.Fmx.AstVisualizer.pas @@ -272,7 +272,6 @@ var savedPos: TPointF; child: IAstNode; titleLabelHeight: Single; - childNode: TAuraNode; // To potentially use the return value begin auraNode := CreateNode(ANode); // Create node without title auraNode.BeginUpdate; @@ -290,7 +289,8 @@ begin for child in AChildren do begin if Assigned(child) then // Ensure child node exists - childNode := CallAccept(child); // Use CallAccept, store result + {childNode :=} + CallAccept(child); // Use CallAccept, store result // childNode is not explicitly used here for layout *after* the call, // but its creation and positioning happened *within* CallAccept. end; @@ -395,8 +395,6 @@ begin currentX := cNodePadding; yPos := cNodePadding; // Initial Y position maxHeightInRow := 0; - leftNode := nil; - rightNode := nil; // 1. Left Expression Node (Visited Recursively) savedParent := FParentControl; @@ -508,9 +506,6 @@ begin currentX := cNodePadding; yPos := cNodePadding; // Initial Y position maxHeightInRow := 0; - conditionNode := nil; - thenNode := nil; - elseNode := nil; // 1. Condition Node savedParent := FParentControl; @@ -664,7 +659,6 @@ begin var closeParen := AddLabel(auraNode, ')'); closeParen.Font.Style := closeParen.Font.Style - [TFontStyle.fsBold]; // Normal style closeParen.Position.Point := TPointF.Create(currentX, yPos); - currentX := closeParen.Position.X + closeParen.Width + closeParen.Margins.Right + cNodePadding / 2; // Add final gap maxHeightInTitleRow := Max(maxHeightInTitleRow, closeParen.Height + closeParen.Margins.Top + closeParen.Margins.Bottom); end else @@ -673,7 +667,6 @@ begin var emptyParens := AddLabel(auraNode, '()'); emptyParens.Font.Style := emptyParens.Font.Style - [TFontStyle.fsBold]; emptyParens.Position.Point := TPointF.Create(currentX, yPos); - currentX := emptyParens.Position.X + emptyParens.Width + emptyParens.Margins.Right + cNodePadding / 2; maxHeightInTitleRow := Max(maxHeightInTitleRow, emptyParens.Height + emptyParens.Margins.Top + emptyParens.Margins.Bottom); end; @@ -740,7 +733,6 @@ begin yPos := cNodePadding; // Start directly with padding currentX := cNodePadding; maxHeightInRow := 0; - calleeNode := nil; // --- Visit Callee --- savedParent := FParentControl; @@ -877,7 +869,6 @@ begin FParentControl := auraNode; // Start position for children inside the node yPos := cNodePadding; - prefixWidth := 0; maxChildWidth := 0; // Max width including prefix + expression // --- Determine width needed for 'return ' prefix --- @@ -1009,6 +1000,7 @@ begin currentX := nameLabel.Position.X + nameLabel.Width + nameLabel.Margins.Right + cNodePadding; maxHeightInRow := Max(maxHeightInRow, nameLabel.Height + nameLabel.Margins.Top + nameLabel.Margins.Bottom); + opLabel := nil; if Assigned(Node.Initializer) then begin // 3. Operator Label (only if initializer exists) @@ -1085,7 +1077,6 @@ begin currentX := cNodePadding; labelYPos := cNodePadding; // Initial Y position for labels maxHeightInRow := 0; - valueNode := nil; // 1. Identifier Label identifierLabel := AddLabel(auraNode, Node.Identifier.Name); diff --git a/Src/AST/Myc.Ast.Binding.pas b/Src/AST/Myc.Ast.Binding.pas index 26d7dd1..dccead8 100644 --- a/Src/AST/Myc.Ast.Binding.pas +++ b/Src/AST/Myc.Ast.Binding.pas @@ -65,8 +65,6 @@ type procedure EnterScope; procedure ExitScope; function IsValidIdentifier(const Name: string): Boolean; - // Helper to set and return the static type of a node - function SetType(const Node: IAstNode; const AType: IStaticType): IAstNode; overload; function SetType(const NodeData: TDataValue; const AType: IStaticType): TDataValue; overload; protected @@ -387,12 +385,6 @@ begin inherited; end; -function TAstBinder.SetType(const Node: IAstNode; const AType: IStaticType): IAstNode; -begin - (Node as TAstNode).StaticType := AType; - Result := Node; -end; - function TAstBinder.SetType(const NodeData: TDataValue; const AType: IStaticType): TDataValue; begin if (not NodeData.IsVoid) and (NodeData.Kind = vkInterface) then