Resolved cyclic dependencies between environment and compiler stages
This commit is contained in:
@@ -39,24 +39,15 @@ type
|
|||||||
procedure SetExecutionStrategy(const AStrategy: IExecutionStrategy);
|
procedure SetExecutionStrategy(const AStrategy: IExecutionStrategy);
|
||||||
|
|
||||||
function ExpandMacros(const Node: IAstNode): IAstNode;
|
function ExpandMacros(const Node: IAstNode): IAstNode;
|
||||||
|
|
||||||
// Updated: Returns Layout, not Descriptor. Performs Binding AND TypeChecking.
|
|
||||||
function Bind(const Node: IAstNode; out Layout: IScopeLayout; const AArgTypes: TArray<IStaticType> = []): IAstNode;
|
function Bind(const Node: IAstNode; out Layout: IScopeLayout; const AArgTypes: TArray<IStaticType> = []): IAstNode;
|
||||||
|
|
||||||
// Updated: Removed Descriptor parameter.
|
|
||||||
function Specialize(const Node: IAstNode): IAstNode;
|
function Specialize(const Node: IAstNode): IAstNode;
|
||||||
|
|
||||||
function Compile(
|
function Compile(const Node: IFunctionDefinition; const ArgTypes: TArray<IStaticType> = []): TCompiledFunction;
|
||||||
const ANode: IAstNode;
|
|
||||||
const Params: TArray<IIdentifierNode> = [];
|
|
||||||
const AArgTypes: TArray<IStaticType> = []
|
|
||||||
): TCompiledFunction; overload;
|
|
||||||
|
|
||||||
function Compile(const Node: IFunctionDefinition; const ArgTypes: TArray<IStaticType> = []): TCompiledFunction; overload;
|
|
||||||
|
|
||||||
function CreateEnvironment: IEnvironment;
|
function CreateEnvironment: IEnvironment;
|
||||||
|
|
||||||
property RootScope: IExecutionScope read GetRootScope;
|
property RootScope: IExecutionScope read GetRootScope;
|
||||||
|
|
||||||
property MacroRegistry: IMacroRegistry read GetMacroRegistry;
|
property MacroRegistry: IMacroRegistry read GetMacroRegistry;
|
||||||
property MonomorphCache: IMonomorphCache read GetMonomorphCache;
|
property MonomorphCache: IMonomorphCache read GetMonomorphCache;
|
||||||
property FunctionRegistry: IFunctionDefinitionRegistry read GetFunctionRegistry;
|
property FunctionRegistry: IFunctionDefinitionRegistry read GetFunctionRegistry;
|
||||||
@@ -174,11 +165,6 @@ type
|
|||||||
function Bind(const Node: IAstNode; out Layout: IScopeLayout; const ArgTypes: TArray<IStaticType>): IAstNode;
|
function Bind(const Node: IAstNode; out Layout: IScopeLayout; const ArgTypes: TArray<IStaticType>): IAstNode;
|
||||||
function Specialize(const Node: IAstNode): IAstNode;
|
function Specialize(const Node: IAstNode): IAstNode;
|
||||||
|
|
||||||
function Compile(
|
|
||||||
const Node: IAstNode;
|
|
||||||
const Params: TArray<IIdentifierNode>;
|
|
||||||
const ArgTypes: TArray<IStaticType>
|
|
||||||
): TCompiledFunction; overload;
|
|
||||||
function Compile(const Node: IFunctionDefinition; const ArgTypes: TArray<IStaticType>): TCompiledFunction; overload;
|
function Compile(const Node: IFunctionDefinition; const ArgTypes: TArray<IStaticType>): TCompiledFunction; overload;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -215,7 +201,7 @@ function TAstEnvironment.Compile(
|
|||||||
const ArgTypes: TArray<IStaticType> = []
|
const ArgTypes: TArray<IStaticType> = []
|
||||||
): TCompiledFunction;
|
): TCompiledFunction;
|
||||||
begin
|
begin
|
||||||
Result := FEnvironment.Compile(Node, Params, ArgTypes);
|
Result := FEnvironment.Compile(TAst.LambdaExpr(Params, Node), ArgTypes);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TAstEnvironment.Compile(const Node: IFunctionDefinition; const ArgTypes: TArray<IStaticType> = []): TCompiledFunction;
|
function TAstEnvironment.Compile(const Node: IFunctionDefinition; const ArgTypes: TArray<IStaticType> = []): TCompiledFunction;
|
||||||
@@ -361,16 +347,6 @@ begin
|
|||||||
Result := TEnvironment.Create(TAst.CreateScope(FRootScope), TMacroRegistry.Create(FMacroRegistry), FExecutionStrategy);
|
Result := TEnvironment.Create(TAst.CreateScope(FRootScope), TMacroRegistry.Create(FMacroRegistry), FExecutionStrategy);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TEnvironment.Compile(
|
|
||||||
const Node: IAstNode;
|
|
||||||
const Params: TArray<IIdentifierNode>;
|
|
||||||
const ArgTypes: TArray<IStaticType>
|
|
||||||
): TCompiledFunction;
|
|
||||||
begin
|
|
||||||
// Wrap in Lambda to create an isolatable compilation unit (scope)
|
|
||||||
Result := Compile(TAst.LambdaExpr(Params, Node).AsLambdaExpression, ArgTypes);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function TEnvironment.Compile(const Node: IFunctionDefinition; const ArgTypes: TArray<IStaticType>): TCompiledFunction;
|
function TEnvironment.Compile(const Node: IFunctionDefinition; const ArgTypes: TArray<IStaticType>): TCompiledFunction;
|
||||||
var
|
var
|
||||||
layout: IScopeLayout;
|
layout: IScopeLayout;
|
||||||
|
|||||||
Reference in New Issue
Block a user