MCPcopy Index your code
hub / github.com/google/mtail / CodeGen

Function CodeGen

internal/runtime/compiler/codegen/codegen.go:36–44  ·  view source on GitHub ↗

CodeGen is the function that compiles the program to bytecode and data.

(name string, n ast.Node)

Source from the content-addressed store, hash-verified

34
35// CodeGen is the function that compiles the program to bytecode and data.
36func CodeGen(name string, n ast.Node) (*code.Object, error) {
37 c := &codegen{name: name}
38 _ = ast.Walk(c, n)
39 c.writeJumps()
40 if len(c.errors) > 0 {
41 return nil, c.errors
42 }
43 return &c.obj, nil
44}
45
46func (c *codegen) errorf(pos *position.Position, format string, args ...interface{}) {
47 e := "Internal compiler error, aborting compilation: " + fmt.Sprintf(format, args...)

Callers 3

CompileMethod · 0.92
TestCodeGenFromSourceFunction · 0.92
TestCodeGenFromASTFunction · 0.92

Calls 2

writeJumpsMethod · 0.95
WalkFunction · 0.92

Tested by 2

TestCodeGenFromSourceFunction · 0.74
TestCodeGenFromASTFunction · 0.74