{"modulePath":"github.com/go-python/gpython","version":"v0.0.0","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package compile\n\ncompile python code\n\n## Functions\n\n```go\nfunc Compile(str, filename, mode string, futureFlags int, dont_inherit bool) (py.Object, error)\n```\nCompile(source, filename, mode, flags, dont\\_inherit) -\u003e code object\n\nCompile the source string (a Python module, statement or expression) into a code object that can be executed by exec() or eval(). The filename will be used for run-time error messages. The mode must be 'exec' to compile a module, 'single' to compile a single (interactive) statement, or 'eval' to compile an expression. The flags argument, if present, controls which future statements influence the compilation of the code. The dont\\_inherit argument, if non-zero, stops the compilation inheriting the effects of any future statements in effect in the code calling compile; if absent or zero these statements do influence the compilation, in addition to any features explicitly specified.\n\n```go\nfunc LegacyCompile(str, filename, mode string, flags int, dont_inherit bool) py.Object\n```\nCompile(source, filename, mode, flags, dont\\_inherit) -\u003e code object\n\nCompile the source string (a Python module, statement or expression) into a code object that can be executed by exec() or eval(). The filename will be used for run-time error messages. The mode must be 'exec' to compile a module, 'single' to compile a single (interactive) statement, or 'eval' to compile an expression. The flags argument, if present, controls which future statements influence the compilation of the code. The dont\\_inherit argument, if non-zero, stops the compilation inheriting the effects of any future statements in effect in the code calling compile; if absent or zero these statements do influence the compilation, in addition to any features explicitly specified.\n\n## Types\n\n```go\ntype Instruction interface {\n\tPos() uint32\n\tNumber() int\n\tLineno() int\n\tSetLineno(int)\n\tSetPos(int, uint32) bool\n\tSize() uint32\n\tOutput() []byte\n\tStackEffect() int\n}\n```\n\n```go\ntype Instructions []Instruction\n```\nResolved or unresolved instruction stream\n\n```go\nfunc (is *Instructions) Add(i Instruction)\n```\nAdd an instruction to the instructions\n\n```go\nfunc (is Instructions) Assemble() string\n```\nAssemble the instructions into an Opcode string\n\n```go\nfunc (is Instructions) EndsWithReturn() bool\n```\nEndsWithReturn returns true if the instruction stream ends with a RETURN\\_VALUE\n\n```go\nfunc (is Instructions) Lnotab() []byte\n```\nCreates the lnotab from the instruction stream\n\nSee Objects/lnotab\\_notes.txt for the description of the line number table.\n\n```go\nfunc (is Instructions) Pass(pass int) bool\n```\nDo a pass of assembly\n\nReturns a boolean as to whether the stream changed\n\n```go\nfunc (is Instructions) StackDepth() int\n```\nFind the flow path that needs the largest stack.  We assume that cycles in the flow graph have no net effect on the stack depth.\n\n```go\ntype JumpAbs struct {\n\tOpArg\n\tDest *Label\n\t// contains filtered or unexported fields\n}\n```\nAn absolute JUMP with destination label\n\n```go\nfunc (p *JumpAbs) Lineno() int\n```\nRead lineno\n\n```go\nfunc (p *JumpAbs) Number() int\n```\nRead instruction number\n\n```go\nfunc (p *JumpAbs) Pos() uint32\n```\nRead position\n\n```go\nfunc (o *JumpAbs) Resolve()\n```\nSet the Arg from the Jump Label\n\n```go\nfunc (p *JumpAbs) SetLineno(lineno int)\n```\nSet lineno\n\n```go\nfunc (p *JumpAbs) SetPos(number int, newPos uint32) bool\n```\nSet Position - returns changed\n\n```go\ntype JumpRel struct {\n\tOpArg\n\tDest *Label\n\t// contains filtered or unexported fields\n}\n```\nA relative JUMP with destination label\n\n```go\nfunc (p *JumpRel) Lineno() int\n```\nRead lineno\n\n```go\nfunc (p *JumpRel) Number() int\n```\nRead instruction number\n\n```go\nfunc (p *JumpRel) Pos() uint32\n```\nRead position\n\n```go\nfunc (o *JumpRel) Resolve()\n```\nSet the Arg from the Jump Label\n\n```go\nfunc (p *JumpRel) SetLineno(lineno int)\n```\nSet lineno\n\n```go\nfunc (p *JumpRel) SetPos(number int, newPos uint32) bool\n```\nSet Position - returns changed\n\n```go\ntype Label struct {\n\t// contains filtered or unexported fields\n}\n```\nA label\n\n```go\nfunc (p *Label) Lineno() int\n```\nRead lineno\n\n```go\nfunc (p *Label) Number() int\n```\nRead instruction number\n\n```go\nfunc (o Label) Output() []byte\n```\nOutput\n\n```go\nfunc (p *Label) Pos() uint32\n```\nRead position\n\n```go\nfunc (p *Label) SetLineno(lineno int)\n```\nSet lineno\n\n```go\nfunc (p *Label) SetPos(number int, newPos uint32) bool\n```\nSet Position - returns changed\n\n```go\nfunc (o *Label) Size() uint32\n```\nUses 0 bytes in the output stream\n\n```go\nfunc (o *Label) StackEffect() int\n```\nStackEffect\n\n```go\ntype Op struct {\n\tOp vm.OpCode\n\t// contains filtered or unexported fields\n}\n```\nA plain opcode\n\n```go\nfunc (p *Op) Lineno() int\n```\nRead lineno\n\n```go\nfunc (p *Op) Number() int\n```\nRead instruction number\n\n```go\nfunc (o *Op) Output() []byte\n```\nOutput\n\n```go\nfunc (p *Op) Pos() uint32\n```\nRead position\n\n```go\nfunc (p *Op) SetLineno(lineno int)\n```\nSet lineno\n\n```go\nfunc (p *Op) SetPos(number int, newPos uint32) bool\n```\nSet Position - returns changed\n\n```go\nfunc (o *Op) Size() uint32\n```\nUses 1 byte in the output stream\n\n```go\nfunc (o *Op) StackEffect() int\n```\nStackEffect\n\n```go\ntype OpArg struct {\n\tOp  vm.OpCode\n\tArg uint32\n\t// contains filtered or unexported fields\n}\n```\nAn opcode with argument\n\n```go\nfunc (p *OpArg) Lineno() int\n```\nRead lineno\n\n```go\nfunc (p *OpArg) Number() int\n```\nRead instruction number\n\n```go\nfunc (o *OpArg) Output() []byte\n```\nOutput\n\n```go\nfunc (p *OpArg) Pos() uint32\n```\nRead position\n\n```go\nfunc (p *OpArg) SetLineno(lineno int)\n```\nSet lineno\n\n```go\nfunc (p *OpArg) SetPos(number int, newPos uint32) bool\n```\nSet Position - returns changed\n\n```go\nfunc (o *OpArg) Size() uint32\n```\nUses 1 byte in the output stream\n\n```go\nfunc (o *OpArg) StackEffect() int\n```\nStackEffect\n\n```go\ntype Resolver interface {\n\tResolve()\n}\n```\n\n","path":"github.com/go-python/gpython/compile","name":"compile","synopsis":"compile python code","isRedistributable":true}
