Small refactorings
This commit is contained in:
@@ -44,9 +44,6 @@ type
|
|||||||
private
|
private
|
||||||
FCurrentContext: TTypeContext;
|
FCurrentContext: TTypeContext;
|
||||||
FLog: ICompilerLog;
|
FLog: ICompilerLog;
|
||||||
FRootScope: IExecutionScope;
|
|
||||||
|
|
||||||
function CreateContextChain(L: IScopeLayout): TTypeContext;
|
|
||||||
|
|
||||||
// Helpers for Null Propagation
|
// Helpers for Null Propagation
|
||||||
function PrepareBaseType(const BaseNode: IAstNode; out IsOptional: Boolean): IStaticType;
|
function PrepareBaseType(const BaseNode: IAstNode; out IsOptional: Boolean): IStaticType;
|
||||||
@@ -174,34 +171,28 @@ begin
|
|||||||
FSlotTypes[SlotIndex] := AType;
|
FSlotTypes[SlotIndex] := AType;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TTypeChecker }
|
constructor TTypeChecker.Create(const RootLayout: IScopeLayout; const RootScope: IExecutionScope; const ALog: ICompilerLog);
|
||||||
|
|
||||||
function TTypeChecker.CreateContextChain(L: IScopeLayout): TTypeContext;
|
function CreateChain(L: IScopeLayout): TTypeContext;
|
||||||
var
|
begin
|
||||||
p: TTypeContext;
|
|
||||||
desc: IScopeDescriptor;
|
|
||||||
begin
|
|
||||||
if L = nil then
|
if L = nil then
|
||||||
exit(nil);
|
exit(nil);
|
||||||
|
|
||||||
p := CreateContextChain(L.Parent);
|
Result :=
|
||||||
|
TTypeContext.Create(
|
||||||
desc := nil;
|
CreateChain(L.Parent),
|
||||||
if (L.Parent = nil) and Assigned(FRootScope) then
|
L,
|
||||||
begin
|
[],
|
||||||
desc := FRootScope.Descriptor;
|
if (L.Parent = nil) and Assigned(RootScope) then RootScope.Descriptor
|
||||||
|
else nil
|
||||||
|
);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result := TTypeContext.Create(p, L, [], desc);
|
|
||||||
end;
|
|
||||||
|
|
||||||
constructor TTypeChecker.Create(const RootLayout: IScopeLayout; const RootScope: IExecutionScope; const ALog: ICompilerLog);
|
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FLog := ALog;
|
FLog := ALog;
|
||||||
FRootScope := RootScope;
|
|
||||||
|
|
||||||
FCurrentContext := CreateContextChain(RootLayout);
|
FCurrentContext := CreateChain(RootLayout);
|
||||||
if FCurrentContext = nil then
|
if FCurrentContext = nil then
|
||||||
FCurrentContext := TTypeContext.Create(nil, nil, [], nil);
|
FCurrentContext := TTypeContext.Create(nil, nil, [], nil);
|
||||||
end;
|
end;
|
||||||
|
|||||||
@@ -151,8 +151,6 @@ begin
|
|||||||
akLambdaExpression: Result := 'FN';
|
akLambdaExpression: Result := 'FN';
|
||||||
akRecordLiteral: Result := 'RECORD';
|
akRecordLiteral: Result := 'RECORD';
|
||||||
akPipe: Result := 'PIPE';
|
akPipe: Result := 'PIPE';
|
||||||
|
|
||||||
// NEW:
|
|
||||||
akIndexer: Result := 'INDEXER';
|
akIndexer: Result := 'INDEXER';
|
||||||
akMemberAccess: Result := 'MEMBER';
|
akMemberAccess: Result := 'MEMBER';
|
||||||
akTuple: Result := 'TUPLE';
|
akTuple: Result := 'TUPLE';
|
||||||
|
|||||||
@@ -488,7 +488,6 @@ end;
|
|||||||
|
|
||||||
function TAstDumper.VisitCreateSeries(const Node: IAstNode): TVoid;
|
function TAstDumper.VisitCreateSeries(const Node: IAstNode): TVoid;
|
||||||
begin
|
begin
|
||||||
// REFACTORED: Log the structure of the definition
|
|
||||||
Log('CreateSeries', Node);
|
Log('CreateSeries', Node);
|
||||||
Indent;
|
Indent;
|
||||||
Log('Definition:');
|
Log('Definition:');
|
||||||
|
|||||||
Reference in New Issue
Block a user