MCPcopy Index your code
hub / github.com/uber-go/nilaway / backpropAcrossBlock

Function backpropAcrossBlock

assertion/function/assertiontree/backprop.go:40–58  ·  view source on GitHub ↗

backpropAcrossBlock iterates over all nodes in the CFG block in _reverse_ order, writes logs, and delegates the handling of each node to backpropAcrossNode.

(rootNode *RootAssertionNode, block *cfg.Block)

Source from the content-addressed store, hash-verified

38// backpropAcrossBlock iterates over all nodes in the CFG block in _reverse_ order, writes logs,
39// and delegates the handling of each node to backpropAcrossNode.
40func backpropAcrossBlock(rootNode *RootAssertionNode, block *cfg.Block) error {
41 // Iterate over all blocks in _reverse_ order
42 for i := len(block.Nodes) - 1; i >= 0; i-- {
43 node := block.Nodes[i]
44
45 err := backpropAcrossNode(rootNode, node)
46 if err != nil {
47 pos := rootNode.Pass().Fset.Position(node.Pos())
48 // If any error occurs when back-propagating a node, we wrap the error with more
49 // information such as file name and positions for easier debugging.
50 return fmt.Errorf(
51 "backpropagation across node (%s:%d:%d) of type %T failed for reason: %w",
52 pos.Filename, pos.Line, pos.Column, node, err,
53 )
54 }
55 }
56
57 return nil
58}
59
60// backpropAcrossNode is the main driver function for the backpropagation of each node of
61// different types. For some complicated cases, it further delegates the handling to other

Callers 1

BackpropAcrossFuncFunction · 0.85

Calls 5

backpropAcrossNodeFunction · 0.85
PassMethod · 0.80
PositionMethod · 0.65
ErrorfMethod · 0.65
PosMethod · 0.45

Tested by

no test coverage detected