Ast environments
This commit is contained in:
@@ -26,7 +26,6 @@ type
|
||||
type
|
||||
TUpvalueMapping = TDictionary<TResolvedAddress, Integer>;
|
||||
private
|
||||
FInitialScope: IExecutionScope;
|
||||
FCurrentDescriptor: IScopeDescriptor;
|
||||
FUpvalueStack: TStack<TUpvalueMapping>;
|
||||
FNestedLambdaCount: Integer;
|
||||
@@ -54,12 +53,12 @@ type
|
||||
function VisitSeriesLength(const Node: ISeriesLengthNode): IAstNode; override;
|
||||
|
||||
public
|
||||
constructor Create(const AInitialScope: IExecutionScope);
|
||||
constructor Create(const AInitialDescriptor: IScopeDescriptor);
|
||||
destructor Destroy; override;
|
||||
function Execute(const RootNode: IAstNode; out Descriptor: IScopeDescriptor): IAstNode;
|
||||
|
||||
class function Bind(
|
||||
const InitialScope: IExecutionScope;
|
||||
const InitialDescriptor: IScopeDescriptor;
|
||||
const RootNode: IAstNode;
|
||||
out Descriptor: IScopeDescriptor
|
||||
): IAstNode; static;
|
||||
@@ -96,13 +95,12 @@ end;
|
||||
|
||||
{ TAstBinder }
|
||||
|
||||
constructor TAstBinder.Create(const AInitialScope: IExecutionScope);
|
||||
constructor TAstBinder.Create(const AInitialDescriptor: IScopeDescriptor);
|
||||
begin
|
||||
inherited Create;
|
||||
Assert(Assigned(AInitialScope));
|
||||
Assert(Assigned(AInitialDescriptor));
|
||||
|
||||
FInitialScope := AInitialScope;
|
||||
FCurrentDescriptor := AInitialScope.CreateDescriptor;
|
||||
FCurrentDescriptor := AInitialDescriptor;
|
||||
FUpvalueStack := TObjectStack<TUpvalueMapping>.Create(True); // Use Comparer
|
||||
FNestedLambdaCount := 0;
|
||||
FBoxedDeclarations := nil;
|
||||
@@ -115,9 +113,13 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
class function TAstBinder.Bind(const InitialScope: IExecutionScope; const RootNode: IAstNode; out Descriptor: IScopeDescriptor): IAstNode;
|
||||
class function TAstBinder.Bind(
|
||||
const InitialDescriptor: IScopeDescriptor;
|
||||
const RootNode: IAstNode;
|
||||
out Descriptor: IScopeDescriptor
|
||||
): IAstNode;
|
||||
begin
|
||||
var binder := TAstBinder.Create(InitialScope) as IAstBinder;
|
||||
var binder := TAstBinder.Create(InitialDescriptor) as IAstBinder;
|
||||
Result := binder.Execute(RootNode, Descriptor);
|
||||
end;
|
||||
|
||||
@@ -155,7 +157,6 @@ begin
|
||||
try
|
||||
EnterScope;
|
||||
try
|
||||
// Main pass: Run the mutator
|
||||
Result := Accept(RootNode); // Accept returns IAstNode
|
||||
if not Assigned(Result) then
|
||||
Result := TAst.Block([]);
|
||||
|
||||
Reference in New Issue
Block a user