pulumi/pkg/eval/hooks.go
joeduffy 24fd8e8f4a Add cancellation to interpreter
This properly unwinds the interpreter should something happen that
results in cancellation.  This occurs, for example, when the planning
engine encounters an error and decides that it doesn't need to proceed
further with evaluation before it simply goes ahead and exits.
2017-06-27 11:31:17 -07:00

26 lines
1.2 KiB
Go

// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
package eval
import (
"github.com/pulumi/lumi/pkg/compiler/symbols"
"github.com/pulumi/lumi/pkg/diag"
"github.com/pulumi/lumi/pkg/eval/rt"
)
// Hooks is a set of callbacks that can be used to hook into interesting interpreter events.
type Hooks interface {
// OnStart is invoked just before interpretation begins.
OnStart() *rt.Unwind
// OnEnterPackage is invoked whenever we enter a package.
OnEnterPackage(pkg *symbols.Package) (*rt.Unwind, func())
// OnEnterModule is invoked whenever we enter a module.
OnEnterModule(sym *symbols.Module) (*rt.Unwind, func())
// OnEnterFunction is invoked whenever we enter a function.
OnEnterFunction(fnc symbols.Function, args []*rt.Object) (*rt.Unwind, func())
// OnObjectInit is invoked after an object has been allocated and initialized. This means that its constructor, if
// any, has been run to completion. The diagnostics tree is the AST node responsible for the allocation.
OnObjectInit(tree diag.Diagable, o *rt.Object) *rt.Unwind
// OnDone is invoked after interpretation has completed. It is given access to the final unwind information.
OnDone(uw *rt.Unwind) *rt.Unwind
}