feat: stuff
This commit is contained in:
@@ -34,7 +34,7 @@ func main() {
|
|||||||
logger.Info("compiled λ expression", "tree", compiled.String())
|
logger.Info("compiled λ expression", "tree", compiled.String())
|
||||||
|
|
||||||
// Create reducer with the compiled expression.
|
// 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 the user selected to track CPU performance, attach a profiler.
|
||||||
if options.Profile != "" {
|
if options.Profile != "" {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func runSample(samplePath string) (string, error) {
|
|||||||
compiled := convert.SaccharineToLambda(ast)
|
compiled := convert.SaccharineToLambda(ast)
|
||||||
|
|
||||||
// Create and run the reducer.
|
// Create and run the reducer.
|
||||||
reducer := lambda.NewNormalOrderReducer(compiled)
|
reducer := lambda.NewNormalOrderReducer(&compiled)
|
||||||
reducer.Reduce()
|
reducer.Reduce()
|
||||||
|
|
||||||
return reducer.Expression().String() + "\n", nil
|
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.
|
// execution.
|
||||||
package plugins
|
package plugins
|
||||||
|
|
||||||
@@ -19,10 +19,10 @@ type Performance struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a performance tracker that outputs a profile to "file".
|
// 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}
|
plugin := &Performance{File: file}
|
||||||
r.On(reducer.StartEvent, plugin.Start)
|
process.On(reducer.StartEvent, plugin.Start)
|
||||||
r.On(reducer.StopEvent, plugin.Stop)
|
process.On(reducer.StopEvent, plugin.Stop)
|
||||||
|
|
||||||
return plugin
|
return plugin
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import (
|
|||||||
// for lambda calculus expressions.
|
// for lambda calculus expressions.
|
||||||
type NormalOrderReducer struct {
|
type NormalOrderReducer struct {
|
||||||
emitter.BaseEmitter[reducer.Event]
|
emitter.BaseEmitter[reducer.Event]
|
||||||
expression Expression
|
expression *Expression
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNormalOrderReducer creates a new normal order reducer.
|
// NewNormalOrderReducer creates a new normal order reducer.
|
||||||
func NewNormalOrderReducer(expression Expression) *NormalOrderReducer {
|
func NewNormalOrderReducer(expression *Expression) *NormalOrderReducer {
|
||||||
return &NormalOrderReducer{
|
return &NormalOrderReducer{
|
||||||
BaseEmitter: *emitter.New[reducer.Event](),
|
BaseEmitter: *emitter.New[reducer.Event](),
|
||||||
expression: expression,
|
expression: expression,
|
||||||
@@ -23,7 +23,7 @@ func NewNormalOrderReducer(expression Expression) *NormalOrderReducer {
|
|||||||
|
|
||||||
// Expression returns the current expression state.
|
// Expression returns the current expression state.
|
||||||
func (r *NormalOrderReducer) Expression() expr.Expression {
|
func (r *NormalOrderReducer) Expression() expr.Expression {
|
||||||
return r.expression
|
return *r.expression
|
||||||
}
|
}
|
||||||
|
|
||||||
func isViable(e *Expression) (*Abstraction, Expression, bool) {
|
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.
|
// The expression must be a lambda.Expression; other types are returned unchanged.
|
||||||
func (r *NormalOrderReducer) Reduce() {
|
func (r *NormalOrderReducer) Reduce() {
|
||||||
r.Emit(reducer.StartEvent)
|
r.Emit(reducer.StartEvent)
|
||||||
it := NewIterator(&r.expression)
|
it := NewIterator(r.expression)
|
||||||
|
|
||||||
for !it.Done() {
|
for !it.Done() {
|
||||||
if fn, arg, ok := isViable(it.Current()); !ok {
|
if fn, arg, ok := isViable(it.Current()); !ok {
|
||||||
|
|||||||
Reference in New Issue
Block a user