EncodeNode encodes an arbitrary AST node and its descendants into the binary format. The sourceFile is needed to provide the source text for efficient string encoding. When encoding a non-SourceFile node, the header hash and parse options fields will be zero. Returns the encoded bytes and a NodeInde
(node *ast.Node, sourceFile *ast.SourceFile)
| 410 | // When encoding a non-SourceFile node, the header hash and parse options fields will be zero. |
| 411 | // Returns the encoded bytes and a NodeIndexTable mapping encoder indices to AST nodes. |
| 412 | func EncodeNode(node *ast.Node, sourceFile *ast.SourceFile) ([]byte, *NodeIndexTable, error) { |
| 413 | return encodeTree(node, sourceFile) |
| 414 | } |
| 415 | |
| 416 | func encodeTree(rootNode *ast.Node, sourceFile *ast.SourceFile) ([]byte, *NodeIndexTable, error) { |
| 417 | var parentIndex, nodeCount, prevIndex uint32 |