Operator-Visualization in Ast editor
This commit is contained in:
@@ -87,6 +87,31 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
// Helper to identify standard operators
|
||||
function IsStandardOperator(const Name: string): Boolean;
|
||||
begin
|
||||
// You can extend this list based on your RTL
|
||||
Result :=
|
||||
(Name = '+')
|
||||
or (Name = '-')
|
||||
or (Name = '*')
|
||||
or (Name = '/')
|
||||
or (Name = 'div')
|
||||
or (Name = 'mod')
|
||||
or (Name = '=')
|
||||
or (Name = '<>')
|
||||
or (Name = '<')
|
||||
or (Name = '>')
|
||||
or (Name = '<=')
|
||||
or (Name = '>=')
|
||||
or (Name = 'and')
|
||||
or (Name = 'or')
|
||||
or (Name = 'xor')
|
||||
or (Name = 'not')
|
||||
or (Name = 'shl')
|
||||
or (Name = 'shr');
|
||||
end;
|
||||
|
||||
{ TAstVisualizer }
|
||||
|
||||
constructor TAstVisualizer.Create(AWorkspace: TWorkspace; AParentNode: TVisualNode; AExprDepth: Integer);
|
||||
@@ -217,8 +242,28 @@ begin
|
||||
end;
|
||||
|
||||
function TAstVisualizer.VisitFunctionCall(const Node: IFunctionCallNode): TAstViewNode;
|
||||
var
|
||||
calleeName: string;
|
||||
isOp: Boolean;
|
||||
begin
|
||||
Result := TAstViewNode.Create(Self, TFunctionCallNodeHandler.Create(Node));
|
||||
isOp := False;
|
||||
|
||||
// Check if callee is a simple identifier or keyword that matches an operator
|
||||
if Node.Callee.Kind = akIdentifier then
|
||||
begin
|
||||
calleeName := Node.Callee.AsIdentifier.Name;
|
||||
isOp := IsStandardOperator(calleeName);
|
||||
end
|
||||
else if Node.Callee.Kind = akKeyword then
|
||||
begin
|
||||
calleeName := Node.Callee.AsKeyword.Value.Name;
|
||||
isOp := IsStandardOperator(calleeName);
|
||||
end;
|
||||
|
||||
if isOp then
|
||||
Result := TAstViewNode.Create(Self, TOperatorCallHandler.Create(Node))
|
||||
else
|
||||
Result := TAstViewNode.Create(Self, TFunctionCallNodeHandler.Create(Node));
|
||||
end;
|
||||
|
||||
function TAstVisualizer.VisitMacroExpansionNode(const Node: IMacroExpansionNode): TAstViewNode;
|
||||
|
||||
Reference in New Issue
Block a user