runtime

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2025 License: EPL-1.0 Imports: 24 Imported by: 1

Documentation

Index

Constants

View Source
const VERSION = "0.3.0"

The current version of Glojure

Variables

View Source
var (
	SymbolUnquote       = lang.NewSymbol("clojure.core/unquote") // TODO: rename to glojure.core/unquote
	SymbolSpliceUnquote = lang.NewSymbol("splice-unquote")
	SymbolNamespace     = lang.NewSymbol("ns")
	SymbolInNamespace   = lang.NewSymbol("in-ns")
	SymbolUserNamespace = lang.NewSymbol("user")
	SymbolDot           = lang.NewSymbol(".")
)
View Source
var (
	Debug = false

	SymNS   = lang.NewSymbol("ns")
	SymInNS = lang.NewSymbol("in-ns")
)
View Source
var (
	Compiler = &evalCompiler{}
)
View Source
var (
	// TODO: don't use a global RT instance; incurs overhead from dynamic lookup
	// of methods. Instead, generate direct calls to functions in this package.
	RT = &RTMethods{}
)

Functions

func AddLoadPath

func AddLoadPath(fs fs.FS)

AddLoadPath adds a filesystem to the load path.

func GetNSLoader added in v0.4.0

func GetNSLoader(nsResource string) func()

GetNSLoader retrieves the loader function for a namespace given its resource name.

func NewEnvironment

func NewEnvironment(opts ...EvalOption) lang.Environment

func ParseVersion added in v0.4.0

func ParseVersion(version string) lang.IPersistentMap

ParseVersion parses the VERSION string and returns a map with major, minor, incremental, and qualifier

func RTReadString

func RTReadString(s string) any

func ReadEval

func ReadEval(code string, options ...ReadEvalOption) interface{}

ReadEval reads and evaluates a string that may contain one or more forms in the global environment.

func RegisterNSLoader added in v0.4.0

func RegisterNSLoader(nsResource string, loader func())

RegisterNSLoader registers a loader function for a namespace given its resource name (i.e. root path with slashes, no extension).

Types

type EvalOption

type EvalOption func(*evalOptions)

func WithLoadPath

func WithLoadPath(path []string) EvalOption

func WithStderr

func WithStderr(w io.Writer) EvalOption

func WithStdout

func WithStdout(w io.Writer) EvalOption

type Fn

type Fn struct {
	// contains filtered or unexported fields
}

func NewFn

func NewFn(astNode *ast.Node, env lang.Environment) *Fn

func (*Fn) ASTNode added in v0.4.0

func (fn *Fn) ASTNode() *ast.Node

func (*Fn) ApplyTo

func (fn *Fn) ApplyTo(args lang.ISeq) interface{}

func (*Fn) GetEnvironment added in v0.4.0

func (fn *Fn) GetEnvironment() lang.Environment

GetEnvironment returns the captured environment for this function. This is used by the codegen system to access captured values.

func (*Fn) Invoke

func (fn *Fn) Invoke(args ...interface{}) interface{}

func (*Fn) Meta

func (fn *Fn) Meta() lang.IPersistentMap

func (*Fn) WithMeta

func (fn *Fn) WithMeta(meta lang.IPersistentMap) interface{}

type Generator added in v0.4.0

type Generator struct {
	// contains filtered or unexported fields
}

Generator handles the conversion of AST nodes to Go code

func NewGenerator added in v0.4.0

func NewGenerator(w io.Writer) *Generator

NewGenerator creates a new code generator

func (*Generator) Generate added in v0.4.0

func (g *Generator) Generate(ns *lang.Namespace) error

Generate takes a namespace and generates Go code that populates the same namespace

type RTEvalError added in v0.4.0

type RTEvalError struct {
	Err      error
	GLJStack []string
	GoStack  string
}

func (*RTEvalError) Error added in v0.4.0

func (e *RTEvalError) Error() string

func (*RTEvalError) Is added in v0.4.0

func (e *RTEvalError) Is(err error) bool

func (*RTEvalError) Unwrap added in v0.4.0

func (e *RTEvalError) Unwrap() error

type RTMethods

type RTMethods struct {
	// contains filtered or unexported fields
}

RT is a struct with methods that map to Clojure's RT class' static methods. This approach is used to make translation of core.clj to Glojure easier.

func (*RTMethods) Alength

func (rt *RTMethods) Alength(x any) int

func (*RTMethods) BooleanCast

func (rt *RTMethods) BooleanCast(x any) bool

func (*RTMethods) ByteCast

func (rt *RTMethods) ByteCast(x any) byte

func (*RTMethods) CharCast

func (rt *RTMethods) CharCast(x any) Char

func (*RTMethods) Contains

func (rt *RTMethods) Contains(coll, key any) bool

func (*RTMethods) Dissoc

func (rt *RTMethods) Dissoc(x any, k any) any

func (*RTMethods) Find

func (rt *RTMethods) Find(coll, key any) any

func (*RTMethods) FindVar

func (rt *RTMethods) FindVar(qualifiedSym *Symbol) *Var

func (*RTMethods) IntCast

func (rt *RTMethods) IntCast(x any) int

func (*RTMethods) Load

func (rt *RTMethods) Load(scriptBase string)

func (*RTMethods) Munge

func (rt *RTMethods) Munge(name string) string

func (*RTMethods) NextID

func (rt *RTMethods) NextID() int

func (*RTMethods) Nth

func (rt *RTMethods) Nth(x any, i int) any

func (*RTMethods) NthDefault

func (rt *RTMethods) NthDefault(x any, i int, def any) any

func (*RTMethods) Peek added in v0.2.1

func (rt *RTMethods) Peek(x any) any

func (*RTMethods) Pop

func (rt *RTMethods) Pop(x any) any

func (*RTMethods) Subvec

func (rt *RTMethods) Subvec(v IPersistentVector, start, end int) IPersistentVector

func (*RTMethods) ToArray

func (rt *RTMethods) ToArray(coll any) any

func (*RTMethods) UncheckedCharCast

func (rt *RTMethods) UncheckedCharCast(x any) Char

type ReadEvalOption

type ReadEvalOption func(*readEvalOptions)

ReadEvalOption is an option for ReadEval.

func WithEnv

func WithEnv(env lang.Environment) ReadEvalOption

WithEnv sets the environment to use for evaluation.

func WithFilename

func WithFilename(filename string) ReadEvalOption

WithFilename sets the filename to use for evaluation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL