lisette-stdlib 0.1.13

Little language inspired by Rust that compiles to Go
Documentation
// Generated by Lisette bindgen
// Source: debug/gosym (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.12

pub fn NewLineTable(data: Slice<uint8>, text: uint64) -> Ref<LineTable>

pub fn NewTable(symtab: Slice<uint8>, pcln: Ref<LineTable>) -> Result<Ref<Table>, error>

/// DecodingError represents an error during the decoding of
/// the symbol table.
pub type DecodingError

/// A Func collects information about a single function.
pub struct Func {
  pub Entry: uint64,
  pub Sym: Option<Ref<Sym>>,
  pub End: uint64,
  pub Params: Slice<Option<Ref<Sym>>>,
  pub Locals: Slice<Option<Ref<Sym>>>,
  pub FrameSize: int,
  pub LineTable: Option<Ref<LineTable>>,
  pub Obj: Option<Ref<Obj>>,
}

/// A LineTable is a data structure mapping program counters to line numbers.
/// 
/// In Go 1.1 and earlier, each function (represented by a [Func]) had its own LineTable,
/// and the line number corresponded to a numbering of all source lines in the
/// program, across all files. That absolute line number would then have to be
/// converted separately to a file name and line number within the file.
/// 
/// In Go 1.2, the format of the data changed so that there is a single LineTable
/// for the entire program, shared by all Funcs, and there are no absolute line
/// numbers, just line numbers within specific files.
/// 
/// For the most part, LineTable's methods should be treated as an internal
/// detail of the package; callers should use the methods on [Table] instead.
pub struct LineTable {
  pub Data: Slice<uint8>,
  pub PC: uint64,
  pub Line: int,
}

/// An Obj represents a collection of functions in a symbol table.
/// 
/// The exact method of division of a binary into separate Objs is an internal detail
/// of the symbol table format.
/// 
/// In early versions of Go each source file became a different Obj.
/// 
/// In Go 1 and Go 1.1, each package produced one Obj for all Go sources
/// and one Obj per C source file.
/// 
/// In Go 1.2, there is a single Obj for the entire program.
pub struct Obj {
  pub Funcs: Slice<Func>,
  pub Paths: Slice<Sym>,
}

/// A Sym represents a single symbol table entry.
pub struct Sym {
  pub Value: uint64,
  pub Type: uint8,
  pub Name: string,
  pub GoType: uint64,
  pub Func: Option<Ref<Func>>,
}

/// Table represents a Go symbol table. It stores all of the
/// symbols decoded from the program and provides methods to translate
/// between symbols, names, and addresses.
pub struct Table {
  pub Syms: Slice<Sym>,
  pub Funcs: Slice<Func>,
  pub Files: Map<string, Option<Ref<Obj>>>,
  pub Objs: Slice<Obj>,
}

/// UnknownFileError represents a failure to find the specific file in
/// the symbol table.
pub struct UnknownFileError(string)

/// UnknownLineError represents a failure to map a line to a program
/// counter, either because the line is beyond the bounds of the file
/// or because there is no code on the given line.
pub struct UnknownLineError {
  pub File: string,
  pub Line: int,
}

impl DecodingError {
  fn Error(self: Ref<DecodingError>) -> string
}

impl Func {
  /// BaseName returns the symbol name without the package or receiver name.
  fn BaseName(self) -> string

  /// PackageName returns the package part of the symbol name,
  /// or the empty string if there is none.
  fn PackageName(self) -> string

  /// ReceiverName returns the receiver type name of this symbol,
  /// or the empty string if there is none.  A receiver name is only detected in
  /// the case that s.Name is fully-specified with a package name.
  fn ReceiverName(self) -> string

  /// Static reports whether this symbol is static (not visible outside its file).
  fn Static(self) -> bool
}

impl LineTable {
  /// LineToPC returns the program counter for the given line number,
  /// considering only program counters before maxpc.
  /// 
  /// Deprecated: Use Table's LineToPC method instead.
  fn LineToPC(self: Ref<LineTable>, line: int, maxpc: uint64) -> uint64

  /// PCToLine returns the line number for the given program counter.
  /// 
  /// Deprecated: Use Table's PCToLine method instead.
  fn PCToLine(self: Ref<LineTable>, pc: uint64) -> int
}

impl Sym {
  /// BaseName returns the symbol name without the package or receiver name.
  fn BaseName(self: Ref<Sym>) -> string

  /// PackageName returns the package part of the symbol name,
  /// or the empty string if there is none.
  fn PackageName(self: Ref<Sym>) -> string

  /// ReceiverName returns the receiver type name of this symbol,
  /// or the empty string if there is none.  A receiver name is only detected in
  /// the case that s.Name is fully-specified with a package name.
  fn ReceiverName(self: Ref<Sym>) -> string

  /// Static reports whether this symbol is static (not visible outside its file).
  fn Static(self: Ref<Sym>) -> bool
}

impl Table {
  /// LineToPC looks up the first program counter on the given line in
  /// the named file. It returns [UnknownFileError] or [UnknownLineError] if
  /// there is an error looking up this line.
  fn LineToPC(self: Ref<Table>, file: string, line: int) -> Result<(uint64, Ref<Func>), error>

  /// LookupFunc returns the text, data, or bss symbol with the given name,
  /// or nil if no such symbol is found.
  fn LookupFunc(self: Ref<Table>, name: string) -> Option<Ref<Func>>

  /// LookupSym returns the text, data, or bss symbol with the given name,
  /// or nil if no such symbol is found.
  fn LookupSym(self: Ref<Table>, name: string) -> Option<Ref<Sym>>

  /// PCToFunc returns the function containing the program counter pc,
  /// or nil if there is no such function.
  fn PCToFunc(self: Ref<Table>, pc: uint64) -> Option<Ref<Func>>

  /// PCToLine looks up line number information for a program counter.
  /// If there is no information, it returns fn == nil.
  fn PCToLine(self: Ref<Table>, pc: uint64) -> (string, int, Ref<Func>)

  /// SymByAddr returns the text, data, or bss symbol starting at the given address.
  fn SymByAddr(self: Ref<Table>, addr: uint64) -> Option<Ref<Sym>>
}

impl UnknownFileError {
  fn Error(self) -> string
}

impl UnknownLineError {
  fn Error(self: Ref<UnknownLineError>) -> string
}