lisette-stdlib 0.1.21

Little language inspired by Rust that compiles to Go
Documentation
// Generated by Lisette bindgen
// Source: go/constant (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.20

import "go:go/token"

pub enum Kind: int {
  Bool = 1,
  Complex = 5,
  Float = 4,
  Int = 3,
  String = 2,
  Unknown = 0,
}

pub const Bool: Kind = 1

pub const Complex: Kind = 5

pub const Float: Kind = 4

pub const Int: Kind = 3

pub const String: Kind = 2

pub const Unknown: Kind = 0

pub fn BinaryOp(x_: Value, op: token.Token, y_: Value) -> Value

/// BitLen returns the number of bits required to represent
/// the absolute value x in binary representation; x must be an [Int] or an [Unknown].
/// If x is [Unknown], the result is 0.
pub fn BitLen(x: Value) -> int

/// BoolVal returns the Go boolean value of x, which must be a [Bool] or an [Unknown].
/// If x is [Unknown], the result is false.
pub fn BoolVal(x: Value) -> bool

/// Bytes returns the bytes for the absolute value of x in little-
/// endian binary representation; x must be an [Int].
pub fn Bytes(x: Value) -> Slice<uint8>

/// Compare returns the result of the comparison x op y.
/// The comparison must be defined for the operands.
/// If one of the operands is [Unknown], the result is
/// false.
pub fn Compare(x_: Value, op: token.Token, y_: Value) -> bool

pub fn Denom(x: Value) -> Value

/// Float32Val is like [Float64Val] but for float32 instead of float64.
pub fn Float32Val(x: Value) -> (float32, bool)

/// Float64Val returns the nearest Go float64 value of x and whether the result is exact;
/// x must be numeric or an [Unknown], but not [Complex]. For values too small (too close to 0)
/// to represent as float64, [Float64Val] silently underflows to 0. The result sign always
/// matches the sign of x, even for 0.
/// If x is [Unknown], the result is (0, false).
pub fn Float64Val(x: Value) -> (float64, bool)

pub fn Imag(x: Value) -> Value

/// Int64Val returns the Go int64 value of x and whether the result is exact;
/// x must be an [Int] or an [Unknown]. If the result is not exact, its value is undefined.
/// If x is [Unknown], the result is (0, false).
pub fn Int64Val(x: Value) -> (int64, bool)

pub fn Make(x: Unknown) -> Value

pub fn MakeBool(b: bool) -> Value

pub fn MakeFloat64(x: float64) -> Value

pub fn MakeFromBytes(bytes: Slice<uint8>) -> Value

pub fn MakeFromLiteral(lit: string, tok: token.Token, zero: uint) -> Value

pub fn MakeImag(x: Value) -> Value

pub fn MakeInt64(x: int64) -> Value

pub fn MakeString(s: string) -> Value

pub fn MakeUint64(x: uint64) -> Value

pub fn MakeUnknown() -> Value

pub fn Num(x: Value) -> Value

pub fn Real(x: Value) -> Value

pub fn Shift(x: Value, op: token.Token, s: uint) -> Value

/// Sign returns -1, 0, or 1 depending on whether x < 0, x == 0, or x > 0;
/// x must be numeric or [Unknown]. For complex values x, the sign is 0 if x == 0,
/// otherwise it is != 0. If x is [Unknown], the result is 1.
pub fn Sign(x: Value) -> int

/// StringVal returns the Go string value of x, which must be a [String] or an [Unknown].
/// If x is [Unknown], the result is "".
pub fn StringVal(x: Value) -> string

pub fn ToComplex(x: Value) -> Value

pub fn ToFloat(x: Value) -> Value

pub fn ToInt(x: Value) -> Value

/// Uint64Val returns the Go uint64 value of x and whether the result is exact;
/// x must be an [Int] or an [Unknown]. If the result is not exact, its value is undefined.
/// If x is [Unknown], the result is (0, false).
pub fn Uint64Val(x: Value) -> (uint64, bool)

pub fn UnaryOp(op: token.Token, y: Value, prec: uint) -> Value

/// Val returns the underlying value for a given constant. Since it returns an
/// interface, it is up to the caller to type assert the result to the expected
/// type. The possible dynamic return types are:
/// 
/// 	x Kind             type of result
/// 	-----------------------------------------
/// 	Bool               bool
/// 	String             string
/// 	Int                int64 or *big.Int
/// 	Float              *big.Float or *big.Rat
/// 	everything else    nil
pub fn Val(x: Value) -> Unknown

/// A Value represents the value of a Go constant.
pub interface Value {
  fn ExactString() -> string
  fn Kind() -> Kind
  fn String() -> string
}

impl Kind {
  fn String(self) -> string
}