diff --git a/Src/AST/Myc.Ast.Evaluator.pas b/Src/AST/Myc.Ast.Evaluator.pas index 5bb458d..6a2f533 100644 --- a/Src/AST/Myc.Ast.Evaluator.pas +++ b/Src/AST/Myc.Ast.Evaluator.pas @@ -504,7 +504,7 @@ var begin // The binder has identified the upvalues. Capture the cells from the current scope // using the original source addresses provided by the binder. - sourceAddresses := Node.UpvalueSourceAddresses; + sourceAddresses := Node.Upvalues; SetLength(capturedCells, Length(sourceAddresses)); for i := 0 to High(sourceAddresses) do begin diff --git a/Src/AST/Myc.Ast.Nodes.pas b/Src/AST/Myc.Ast.Nodes.pas index 68a337c..49b1f5c 100644 --- a/Src/AST/Myc.Ast.Nodes.pas +++ b/Src/AST/Myc.Ast.Nodes.pas @@ -241,14 +241,12 @@ type function GetParameters: TArray; function GetBody: IExpressionNode; function GetScopeDescriptor: IScopeDescriptor; - function GetUpvalues: TArray; - function GetUpvalueSourceAddresses: TArray; + function GetUpvalues: TArray; {$endregion} property Parameters: TArray read GetParameters; property Body: IExpressionNode read GetBody; property ScopeDescriptor: IScopeDescriptor read GetScopeDescriptor; - property Upvalues: TArray read GetUpvalues; - property UpvalueSourceAddresses: TArray read GetUpvalueSourceAddresses; + property Upvalues: TArray read GetUpvalues; end; IFunctionCallNode = interface(IExpressionNode) diff --git a/Src/AST/Myc.Ast.pas b/Src/AST/Myc.Ast.pas index 7e6c2fa..7d0fbe9 100644 --- a/Src/AST/Myc.Ast.pas +++ b/Src/AST/Myc.Ast.pas @@ -187,19 +187,15 @@ type FParameters: TArray; FBody: IExpressionNode; FScopeDescriptor: IScopeDescriptor; - FUpvalues: TArray; - FUpvalueSourceAddresses: TArray; + FUpvalues: TArray; function GetParameters: TArray; function GetBody: IExpressionNode; function GetScopeDescriptor: IScopeDescriptor; - function GetUpvalues: TArray; - function GetUpvalueSourceAddresses: TArray; + function GetUpvalues: TArray; public constructor Create(const AParameters: TArray; const ABody: IExpressionNode); function Accept(const Visitor: IAstVisitor): TAstValue; override; - procedure SetUpvalueData(const AUpvalues: TArray; const ASourceAddresses: TArray); property ScopeDescriptor: IScopeDescriptor read GetScopeDescriptor; - property Upvalues: TArray read GetUpvalues; end; { TFunctionCallNode } @@ -583,19 +579,12 @@ begin FBody := ABody; FParameters := AParameters; FScopeDescriptor := nil; - FUpvalues := []; - FUpvalueSourceAddresses := []; // Initialize new field + FUpvalues := []; // Initialize new field end; -function TLambdaExpressionNode.GetUpvalueSourceAddresses: TArray; +function TLambdaExpressionNode.GetUpvalues: TArray; begin - Result := FUpvalueSourceAddresses; -end; - -procedure TLambdaExpressionNode.SetUpvalueData(const AUpvalues: TArray; const ASourceAddresses: TArray); -begin - FUpvalues := AUpvalues; - FUpvalueSourceAddresses := ASourceAddresses; + Result := FUpvalues; end; function TLambdaExpressionNode.Accept(const Visitor: IAstVisitor): TAstValue; @@ -618,11 +607,6 @@ begin Result := FScopeDescriptor; end; -function TLambdaExpressionNode.GetUpvalues: TArray; -begin - Result := FUpvalues; -end; - { TFunctionCallNode } constructor TFunctionCallNode.Create(const ACallee: IExpressionNode; const AArguments: array of IExpressionNode); @@ -962,7 +946,7 @@ begin for var i := 0 to High(sortedPairs) do sourceAddresses[i] := sortedPairs[i].Key; - (Node as TLambdaExpressionNode).SetUpvalueData(upvalueNodes.ToArray, sourceAddresses); + (Node as TLambdaExpressionNode).FUpvalues := sourceAddresses; upvalueMap.Free; upvalueNodes.Free;