Documentation
¶
Index ¶
- Variables
- func AddLoadPath(fs fs.FS)
- func GetNSLoader(nsResource string) func()
- func GetUseAOT() bool
- func IsDefaultCoreVar(vr *lang.Var) bool
- func NewEnvironment(opts ...EvalOption) lang.Environment
- func OpenURL(u *url.URL) (io.ReadCloser, error)
- func RTReadString(s string) any
- func ReadEval(code string, options ...ReadEvalOption) interface{}
- func ReduceInt64Pipeline(initial int64, coll interface{}, transforms []ReducePipelineTransformKind, ...) interface{}
- func RegisterNSLoader(nsResource string, loader func())
- func RegisterURLOpener(opener URLOpener)
- type EvalOption
- type Fn
- func (fn *Fn) ASTNode() *ast.Node
- func (fn *Fn) ApplyTo(args lang.ISeq) interface{}
- func (fn *Fn) GetEnvironment() lang.Environment
- func (fn *Fn) Invoke(args ...interface{}) interface{}
- func (fn *Fn) Invoke0() interface{}
- func (fn *Fn) Invoke1(a0 interface{}) interface{}
- func (fn *Fn) Invoke2(a0, a1 interface{}) interface{}
- func (fn *Fn) Invoke3(a0, a1, a2 interface{}) interface{}
- func (fn *Fn) Invoke4(a0, a1, a2, a3 interface{}) interface{}
- func (fn *Fn) Meta() lang.IPersistentMap
- func (fn *Fn) WithMeta(meta lang.IPersistentMap) interface{}
- type Generator
- type Promise
- type RTEvalError
- type RTMethods
- func (rt *RTMethods) Aclone(x any) any
- func (rt *RTMethods) Alength(x any) int
- func (rt *RTMethods) BooleanCast(x any) bool
- func (rt *RTMethods) ByteCast(x any) int8
- func (rt *RTMethods) CharCast(x any) Char
- func (rt *RTMethods) Contains(coll, key any) bool
- func (rt *RTMethods) Dissoc(x any, k any) any
- func (rt *RTMethods) Find(coll, key any) any
- func (rt *RTMethods) FindVar(qualifiedSym *Symbol) *Var
- func (rt *RTMethods) Get(coll, key any, notFound ...any) any
- func (rt *RTMethods) IntCast(x any) int
- func (rt *RTMethods) Load(scriptBase string)
- func (rt *RTMethods) Munge(name string) string
- func (rt *RTMethods) NextID() int
- func (rt *RTMethods) Nth(x any, i int) any
- func (rt *RTMethods) NthDefault(x any, i int, def any) any
- func (rt *RTMethods) ObjectArray(sizeOrSeq any) any
- func (rt *RTMethods) Peek(x any) any
- func (rt *RTMethods) Pop(x any) any
- func (rt *RTMethods) ResolveFieldOrMethod(name string) (interface{}, bool)
- func (rt *RTMethods) Subs(s string, start int) string
- func (rt *RTMethods) SubsEnd(s string, start, end int) string
- func (rt *RTMethods) Subvec(v IPersistentVector, start, end any) IPersistentVector
- func (rt *RTMethods) ToArray(coll any) any
- func (rt *RTMethods) UncheckedCharCast(x any) Char
- type ReadEvalOption
- type ReducePipelineTransformKind
- type URLOpener
Constants ¶
This section is empty.
Variables ¶
var ( SymbolUnquote = lang.NewSymbol("clojure.core/unquote") SymbolSpliceUnquote = lang.NewSymbol("splice-unquote") SymbolNamespace = lang.NewSymbol("ns") SymbolInNamespace = lang.NewSymbol("in-ns") SymbolUserNamespace = lang.NewSymbol("user") SymbolDot = lang.NewSymbol(".") )
var (
Compiler = &evalCompiler{}
)
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{} )
var ( // The current version of Glojure Version = func() string { if version != "" { return strings.TrimPrefix(version, "v") } info, ok := debug.ReadBuildInfo() if !ok { return "0.0.0" } if info.Main.Version == "" || info.Main.Version == "(devel)" { return "0.0.0" } return strings.TrimPrefix(info.Main.Version, "v") }() )
Functions ¶
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 IsDefaultCoreVar ¶ added in v0.7.0
IsDefaultCoreVar reports whether vr still has the standard root installed during runtime initialization. Generated optimizations use this guard before replacing higher-order core operations whose Vars remain redefinable.
func NewEnvironment ¶
func NewEnvironment(opts ...EvalOption) lang.Environment
func OpenURL ¶ added in v0.7.0
func OpenURL(u *url.URL) (io.ReadCloser, error)
OpenURL opens a non-file URL using the registered implementation.
func RTReadString ¶
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 ReduceInt64Pipeline ¶ added in v0.7.0
func ReduceInt64Pipeline( initial int64, coll interface{}, transforms []ReducePipelineTransformKind, takeLimit int64, ) interface{}
ReduceInt64Pipeline applies an ephemeral, proven-int64 sequence pipeline directly while summing its source. The analyzer calls it only for a constant integer range after guarding every participating core Var.
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).
func RegisterURLOpener ¶ added in v0.7.0
func RegisterURLOpener(opener URLOpener)
RegisterURLOpener installs the process-wide implementation used by glojure.go.io for non-file URLs. The most recent registration wins.
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 (*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) 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
NewGenerator creates a new code generator
type Promise ¶ added in v0.6.5
type Promise struct {
// contains filtered or unexported fields
}
Promise implements Clojure's promise semantics using Go sync primitives.
func NewPromise ¶ added in v0.6.5
func NewPromise() *Promise
func (*Promise) DerefWithTimeout ¶ added in v0.6.5
func (*Promise) IsRealized ¶ added in v0.6.5
type RTEvalError ¶ added in v0.4.0
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) BooleanCast ¶
func (*RTMethods) Get ¶ added in v0.7.0
Get provides the clojure.lang.RT-compatible entry point referenced by the inherited inline definition of clojure.core/get.
func (*RTMethods) ObjectArray ¶ added in v0.6.0
ObjectArray creates an array of objects ([]any)
func (*RTMethods) ResolveFieldOrMethod ¶ added in v0.7.0
ResolveFieldOrMethod keeps the collection accessors used by rewritten clojure.core forms on direct Go calls instead of reflected bound methods.
func (*RTMethods) UncheckedCharCast ¶
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.
type ReducePipelineTransformKind ¶ added in v0.7.0
type ReducePipelineTransformKind uint8
const ( ReducePipelineMapIdentity ReducePipelineTransformKind = iota ReducePipelineMapInc ReducePipelineMapDec ReducePipelineMapSquare ReducePipelineFilterOdd ReducePipelineFilterEven ReducePipelineFilterPos ReducePipelineFilterNeg ReducePipelineFilterZero )
Source Files
¶
- aot_compile.go
- ast_helpers.go
- codegen.go
- codegen_direct.go
- codegen_float64.go
- codegen_fusion.go
- codegen_int64.go
- codegen_int64_range.go
- codegen_primitive.go
- compile_eval.go
- compile_eval_pipeline.go
- compile_loop.go
- compile_numeric.go
- core_roots.go
- direct_reduce_pipeline.go
- envinit.go
- environment.go
- eval.go
- evalast.go
- fn.go
- native_core.go
- native_core_overrides.go
- nsloaders.go
- promise.go
- readeval.go
- reduce_pipeline.go
- reduce_pipeline_analysis.go
- rtcompat.go
- scope.go
- url.go