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