Documentation
¶
Index ¶
- Constants
- Variables
- func AddLoadPath(fs fs.FS)
- func GetNSLoader(nsResource string) func()
- func NewEnvironment(opts ...EvalOption) lang.Environment
- func ParseVersion(version string) lang.IPersistentMap
- func RTReadString(s string) any
- func ReadEval(code string, options ...ReadEvalOption) interface{}
- func RegisterNSLoader(nsResource string, loader func())
- type EvalOption
- type Fn
- type Generator
- type RTEvalError
- type RTMethods
- func (rt *RTMethods) Alength(x any) int
- func (rt *RTMethods) BooleanCast(x any) bool
- func (rt *RTMethods) ByteCast(x any) byte
- 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) 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) Peek(x any) any
- func (rt *RTMethods) Pop(x any) any
- func (rt *RTMethods) Subvec(v IPersistentVector, start, end int) IPersistentVector
- func (rt *RTMethods) ToArray(coll any) any
- func (rt *RTMethods) UncheckedCharCast(x any) Char
- type ReadEvalOption
Constants ¶
const VERSION = "0.3.0"
The current version of Glojure
Variables ¶
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(".") )
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{} )
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 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 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 (*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 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) 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.