Static specialization

This commit is contained in:
Michael Schimmel
2025-11-11 11:58:08 +01:00
parent 8a6c866a9c
commit c129c1a3ae
4 changed files with 67 additions and 38 deletions
+2
View File
@@ -252,10 +252,12 @@ type
function GetCallee: IAstNode;
function GetArguments: TArray<IAstNode>;
function GetIsTailCall: Boolean;
function GetStaticTarget: TDataValue.TFunc;
{$endregion}
property Callee: IAstNode read GetCallee;
property Arguments: TArray<IAstNode> read GetArguments;
property IsTailCall: Boolean read GetIsTailCall;
property StaticTarget: TDataValue.TFunc read GetStaticTarget;
end;
// A node representing a macro call.
+1 -2
View File
@@ -546,7 +546,6 @@ var
newCallee: IAstNode;
newArgs: TArray<IAstNode>;
begin
// No longer cast to concrete class, use interface
newCallee := Accept(Node.Callee);
newArgs := AcceptNodes(Node.Arguments);
@@ -555,7 +554,7 @@ begin
else
begin
// Use TAst factory and copy properties via interface getters
Result := TAst.FunctionCall(newCallee, newArgs, Node.StaticType, Node.IsTailCall);
Result := TAst.FunctionCall(newCallee, newArgs, Node.StaticType, Node.IsTailCall, Node.StaticTarget);
end;
end;
+18 -6
View File
@@ -87,7 +87,8 @@ type
const ACallee: IAstNode;
const AArguments: TArray<IAstNode>;
const AStaticType: IStaticType = nil;
const AIsTailCall: Boolean = False
const AIsTailCall: Boolean = False;
const AStaticTarget: TDataValue.TFunc = nil
): IFunctionCallNode; static;
class function MacroExpansionNode(
@@ -227,16 +228,19 @@ type
FCallee: IAstNode;
FArguments: TArray<IAstNode>;
FIsTailCall: Boolean;
FStaticTarget: TDataValue.TFunc;
function GetCallee: IAstNode;
function GetArguments: TArray<IAstNode>;
function GetIsTailCall: Boolean;
function GetStaticTarget: TDataValue.TFunc;
function GetKind: TAstNodeKind; override;
public
constructor Create(
const ACallee: IAstNode;
const AArguments: TArray<IAstNode>;
const AStaticType: IStaticType;
const AIsTailCall: Boolean
const AIsTailCall: Boolean;
const AStaticTarget: TDataValue.TFunc
);
function Accept(const Visitor: IAstVisitor): TDataValue; override;
function AsFunctionCall: IFunctionCallNode; override;
@@ -734,17 +738,18 @@ class function TAst.FunctionCall(
const ACallee: IAstNode;
const AArguments: TArray<IAstNode>;
const AStaticType: IStaticType = nil;
const AIsTailCall: Boolean = False
const AIsTailCall: Boolean = False;
const AStaticTarget: TDataValue.TFunc = nil
): IFunctionCallNode;
begin
// Updated to call new constructor
Result :=
TFunctionCallNode.Create(
ACallee,
AArguments,
if AStaticType <> nil then AStaticType
else TTypes.Unknown,
AIsTailCall
AIsTailCall,
AStaticTarget
);
end;
@@ -1593,13 +1598,15 @@ constructor TFunctionCallNode.Create(
const ACallee: IAstNode;
const AArguments: TArray<IAstNode>;
const AStaticType: IStaticType;
const AIsTailCall: Boolean
const AIsTailCall: Boolean;
const AStaticTarget: TDataValue.TFunc
);
begin
inherited Create(AStaticType);
FCallee := ACallee;
FArguments := AArguments;
FIsTailCall := AIsTailCall;
FStaticTarget := AStaticTarget;
end;
function TFunctionCallNode.Accept(const Visitor: IAstVisitor): TDataValue;
@@ -1632,6 +1639,11 @@ begin
Result := akFunctionCall;
end;
function TFunctionCallNode.GetStaticTarget: TDataValue.TFunc;
begin
Result := FStaticTarget;
end;
{ TMacroExpansionNode }
constructor TMacroExpansionNode.Create(const ACallNode: IFunctionCallNode; const AExpandedBody: IAstTypedNode);