feat: stuff
This commit is contained in:
@@ -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 != "" {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user