Compiler exceptions

This commit is contained in:
Michael Schimmel
2025-11-25 15:51:04 +01:00
parent 4e508d90a5
commit 0a1df4e9fe
9 changed files with 194 additions and 303 deletions
+61 -38
View File
@@ -77,14 +77,13 @@ type
class function Unquote(const AExpression: IAstNode): IUnquoteNode; static;
class function UnquoteSplicing(const AExpression: IQuasiquoteNode): IUnquoteSplicingNode; static;
// (* UPDATED Factory: Added AIsTargetPure *)
class function FunctionCall(
const ACallee: IAstNode;
const AArguments: TArray<IAstNode>;
const AStaticType: IStaticType = nil;
const AIsTailCall: Boolean = False;
const AStaticTarget: TDataValue.TFunc = nil;
const AIsTargetPure: Boolean = False // (* ADDED *)
const AIsTargetPure: Boolean = False
): IFunctionCallNode; static;
class function MacroExpansionNode(
@@ -193,7 +192,7 @@ type
FDescriptor: IScopeDescriptor;
FUpvalues: TArray<TResolvedAddress>;
FHasNestedLambdas: Boolean;
FIsPure: Boolean; // (* ADDED *)
FIsPure: Boolean;
function GetParameters: TArray<IIdentifierNode>;
function GetBody: IAstNode;
@@ -201,7 +200,7 @@ type
function GetDescriptor: IScopeDescriptor;
function GetUpvalues: TArray<TResolvedAddress>;
function GetHasNestedLambdas: Boolean;
function GetIsPure: Boolean; // (* ADDED *)
function GetIsPure: Boolean;
function GetKind: TAstNodeKind; override;
public
constructor Create(
@@ -212,7 +211,7 @@ type
const ADescriptor: IScopeDescriptor;
const AUpvalues: TArray<TResolvedAddress>;
const AHasNestedLambdas: Boolean;
const AIsPure: Boolean // (* ADDED *)
const AIsPure: Boolean
);
destructor Destroy; override;
function Accept(const Visitor: IAstVisitor): TDataValue; override;
@@ -225,12 +224,12 @@ type
FArguments: TArray<IAstNode>;
FIsTailCall: Boolean;
FStaticTarget: TDataValue.TFunc;
FIsTargetPure: Boolean; // (* ADDED *)
FIsTargetPure: Boolean;
function GetCallee: IAstNode;
function GetArguments: TArray<IAstNode>;
function GetIsTailCall: Boolean;
function GetStaticTarget: TDataValue.TFunc;
function GetIsTargetPure: Boolean; // (* ADDED *)
function GetIsTargetPure: Boolean;
function GetKind: TAstNodeKind; override;
public
constructor Create(
@@ -239,7 +238,7 @@ type
const AStaticType: IStaticType;
const AIsTailCall: Boolean;
const AStaticTarget: TDataValue.TFunc;
const AIsTargetPure: Boolean // (* ADDED *)
const AIsTargetPure: Boolean
);
function Accept(const Visitor: IAstVisitor): TDataValue; override;
function AsFunctionCall: IFunctionCallNode; override;
@@ -677,7 +676,7 @@ class function TAst.FunctionCall(
const AStaticType: IStaticType = nil;
const AIsTailCall: Boolean = False;
const AStaticTarget: TDataValue.TFunc = nil;
const AIsTargetPure: Boolean = False // (* ADDED *)
const AIsTargetPure: Boolean = False
): IFunctionCallNode;
begin
Result :=
@@ -753,7 +752,7 @@ class function TAst.LambdaExpr(
const ADescriptor: IScopeDescriptor = nil;
const AUpvalues: TArray<TResolvedAddress> = nil;
const AHasNestedLambdas: Boolean = False;
const AIsPure: Boolean = False; // (* ADDED *)
const AIsPure: Boolean = False;
const AStaticType: IStaticType = nil
): ILambdaExpressionNode;
begin
@@ -917,122 +916,146 @@ end;
function TAstNode.AsAddSeriesItem: IAddSeriesItemNode;
begin
raise ETypeException.Create('Node is not an AddSeriesItem');
Assert(False, 'Node is not an AddSeriesItem');
Result := nil;
end;
function TAstNode.AsAssignment: IAssignmentNode;
begin
raise ETypeException.Create('Node is not an Assignment');
Assert(False, 'Node is not an Assignment');
Result := nil;
end;
function TAstNode.AsBlockExpression: IBlockExpressionNode;
begin
raise ETypeException.Create('Node is not a BlockExpression');
Assert(False, 'Node is not a BlockExpression');
Result := nil;
end;
function TAstNode.AsConstant: IConstantNode;
begin
raise ETypeException.Create('Node is not a Constant');
Assert(False, 'Node is not a Constant');
Result := nil;
end;
function TAstNode.AsCreateSeries: ICreateSeriesNode;
begin
raise ETypeException.Create('Node is not a CreateSeries');
Assert(False, 'Node is not a CreateSeries');
Result := nil;
end;
function TAstNode.AsFunctionCall: IFunctionCallNode;
begin
raise ETypeException.Create('Node is not a FunctionCall');
Assert(False, 'Node is not a FunctionCall');
Result := nil;
end;
function TAstNode.AsIdentifier: IIdentifierNode;
begin
raise ETypeException.Create('Node is not an Identifier');
Assert(False, 'Node is not an Identifier');
Result := nil;
end;
function TAstNode.AsIfExpression: IIfExpressionNode;
begin
raise ETypeException.Create('Node is not an IfExpression');
Assert(False, 'Node is not an IfExpression');
Result := nil;
end;
function TAstNode.AsIndexer: IIndexerNode;
begin
raise ETypeException.Create('Node is not an Indexer');
Assert(False, 'Node is not an Indexer');
Result := nil;
end;
function TAstNode.AsKeyword: IKeywordNode;
begin
raise ETypeException.Create('Node is not a Keyword');
Assert(False, 'Node is not a Keyword');
Result := nil;
end;
function TAstNode.AsLambdaExpression: ILambdaExpressionNode;
begin
raise ETypeException.Create('Node is not a LambdaExpression');
Assert(False, 'Node is not a LambdaExpression');
Result := nil;
end;
function TAstNode.AsMacroDefinition: IMacroDefinitionNode;
begin
raise ETypeException.Create('Node is not a MacroDefinition');
Assert(False, 'Node is not a MacroDefinition');
Result := nil;
end;
function TAstNode.AsMacroExpansion: IMacroExpansionNode;
begin
raise ETypeException.Create('Node is not a MacroExpansion');
Assert(False, 'Node is not a MacroExpansion');
Result := nil;
end;
function TAstNode.AsMemberAccess: IMemberAccessNode;
begin
raise ETypeException.Create('Node is not a MemberAccess');
Assert(False, 'Node is not a MemberAccess');
Result := nil;
end;
function TAstNode.AsNop: INopNode;
begin
raise ETypeException.Create('Node is not a Nop');
Assert(False, 'Node is not a Nop');
Result := nil;
end;
function TAstNode.AsQuasiquote: IQuasiquoteNode;
begin
raise ETypeException.Create('Node is not a Quasiquote');
Assert(False, 'Node is not a Quasiquote');
Result := nil;
end;
function TAstNode.AsRecordLiteral: IRecordLiteralNode;
begin
raise ETypeException.Create('Node is not a RecordLiteral');
Assert(False, 'Node is not a RecordLiteral');
Result := nil;
end;
function TAstNode.AsRecur: IRecurNode;
begin
raise ETypeException.Create('Node is not a Recur');
Assert(False, 'Node is not a Recur');
Result := nil;
end;
function TAstNode.AsSeriesLength: ISeriesLengthNode;
begin
raise ETypeException.Create('Node is not a SeriesLength');
Assert(False, 'Node is not a SeriesLength');
Result := nil;
end;
function TAstNode.AsTernaryExpression: ITernaryExpressionNode;
begin
raise ETypeException.Create('Node is not a TernaryExpression');
Assert(False, 'Node is not a TernaryExpression');
Result := nil;
end;
function TAstNode.AsTypedNode: IAstTypedNode;
begin
raise ETypeException.Create('Node has no type');
Assert(False, 'Node has no type');
Result := nil;
end;
function TAstNode.AsUnquote: IUnquoteNode;
begin
raise ETypeException.Create('Node is not an Unquote');
Assert(False, 'Node is not an Unquote');
Result := nil;
end;
function TAstNode.AsUnquoteSplicing: IUnquoteSplicingNode;
begin
raise ETypeException.Create('Node is not an UnquoteSplicing');
Assert(False, 'Node is not an UnquoteSplicing');
Result := nil;
end;
function TAstNode.AsVariableDeclaration: IVariableDeclarationNode;
begin
raise ETypeException.Create('Node is not a VariableDeclaration');
Assert(False, 'Node is not a VariableDeclaration');
Result := nil;
end;
function TAstNode.GetIsTyped: Boolean;
@@ -1244,7 +1267,7 @@ constructor TLambdaExpressionNode.Create(
const ADescriptor: IScopeDescriptor;
const AUpvalues: TArray<TResolvedAddress>;
const AHasNestedLambdas: Boolean;
const AIsPure: Boolean // (* ADDED *)
const AIsPure: Boolean
);
begin
inherited Create(AStaticType);
@@ -1306,7 +1329,7 @@ begin
Result := FHasNestedLambdas;
end;
function TLambdaExpressionNode.GetIsPure: Boolean; // (* ADDED *)
function TLambdaExpressionNode.GetIsPure: Boolean;
begin
Result := FIsPure;
end;
@@ -1448,7 +1471,7 @@ constructor TFunctionCallNode.Create(
const AStaticType: IStaticType;
const AIsTailCall: Boolean;
const AStaticTarget: TDataValue.TFunc;
const AIsTargetPure: Boolean // (* ADDED *)
const AIsTargetPure: Boolean
);
begin
inherited Create(AStaticType);
@@ -1494,7 +1517,7 @@ begin
Result := FStaticTarget;
end;
function TFunctionCallNode.GetIsTargetPure: Boolean; // (* ADDED *)
function TFunctionCallNode.GetIsTargetPure: Boolean;
begin
Result := FIsTargetPure;
end;