diff --git a/cmd/lambda/lambda.go b/cmd/lambda/lambda.go index 999e722..843897d 100644 --- a/cmd/lambda/lambda.go +++ b/cmd/lambda/lambda.go @@ -34,7 +34,7 @@ func main() { logger.Info("compiled λ expression", "tree", compiled.String()) // Create reducer with the compiled expression. - reducer := lambda.NewNormalOrderReducer(compiled) + reducer := lambda.NewNormalOrderReducer(&compiled) // If the user selected to track CPU performance, attach a profiler. if options.Profile != "" { diff --git a/cmd/lambda/lambda_test.go b/cmd/lambda/lambda_test.go index 73bdb85..8f671d9 100644 --- a/cmd/lambda/lambda_test.go +++ b/cmd/lambda/lambda_test.go @@ -30,7 +30,7 @@ func runSample(samplePath string) (string, error) { compiled := convert.SaccharineToLambda(ast) // Create and run the reducer. - reducer := lambda.NewNormalOrderReducer(compiled) + reducer := lambda.NewNormalOrderReducer(&compiled) reducer.Reduce() return reducer.Expression().String() + "\n", nil diff --git a/internal/plugins/performance.go b/internal/plugins/performance.go index 08cc46b..857eca7 100644 --- a/internal/plugins/performance.go +++ b/internal/plugins/performance.go @@ -1,4 +1,4 @@ -// Package "performance" provides a tracker to observe CPU performance during +// Package "performance" provides a tracker to observer CPU performance during // execution. package plugins @@ -19,10 +19,10 @@ type Performance struct { } // Create a performance tracker that outputs a profile to "file". -func NewPerformance(file string, r reducer.Reducer) *Performance { +func NewPerformance(file string, process reducer.Reducer) *Performance { plugin := &Performance{File: file} - r.On(reducer.StartEvent, plugin.Start) - r.On(reducer.StopEvent, plugin.Stop) + process.On(reducer.StartEvent, plugin.Start) + process.On(reducer.StopEvent, plugin.Stop) return plugin } diff --git a/pkg/lambda/reducer.go b/pkg/lambda/reducer.go index 4117096..b4df0e6 100644 --- a/pkg/lambda/reducer.go +++ b/pkg/lambda/reducer.go @@ -10,11 +10,11 @@ import ( // for lambda calculus expressions. type NormalOrderReducer struct { emitter.BaseEmitter[reducer.Event] - expression Expression + expression *Expression } // NewNormalOrderReducer creates a new normal order reducer. -func NewNormalOrderReducer(expression Expression) *NormalOrderReducer { +func NewNormalOrderReducer(expression *Expression) *NormalOrderReducer { return &NormalOrderReducer{ BaseEmitter: *emitter.New[reducer.Event](), expression: expression, @@ -23,7 +23,7 @@ func NewNormalOrderReducer(expression Expression) *NormalOrderReducer { // Expression returns the current expression state. func (r *NormalOrderReducer) Expression() expr.Expression { - return r.expression + return *r.expression } func isViable(e *Expression) (*Abstraction, Expression, bool) { @@ -42,7 +42,7 @@ func isViable(e *Expression) (*Abstraction, Expression, bool) { // The expression must be a lambda.Expression; other types are returned unchanged. func (r *NormalOrderReducer) Reduce() { r.Emit(reducer.StartEvent) - it := NewIterator(&r.expression) + it := NewIterator(r.expression) for !it.Done() { if fn, arg, ok := isViable(it.Current()); !ok {