type
XetoEnv
@Js
abstract const class XetoEnv : Obj
Environment for the Xeto data and spec handling. There is one instance for the VM accessed via XetoEnv.cur
.
methods
compileData |
Compile a Xeto data file into an in-memory value. |
---|---|
compileLib |
Compile Xeto source code into a temp library. |
cur |
Current default environment for the VM |
derive |
Derive a new spec from the given base type, additional meta, and slots. |
dict |
Coerce one of the following values to a dict |
fits |
Return if the given instance fits the spec via structural typing. |
instance |
Get or load instance by the given qualified name |
instantiate |
Create default instance for the given spec. |
isRemote |
Is this a remote environment loaded over a network transport. |
lib |
Get or load library by the given library name. |
libAsync |
Get or load library asynchronously by the given library name. |
marker |
Marker singleton value |
na |
NA singleton value |
none |
None singleton value |
ref |
Construct instance of |
reload |
Reload the entire data env. |
spec |
Get or load spec by the given qualified name |
specOf |
Spec for Fantom |
type |
Get or load type by the given qualified name |
writeData |
Write instance data in Xeto text format to an output stream. |
Slot Details
compileData
abstract Obj? compileData(Str src, Dict? opts := null)
Compile a Xeto data file into an in-memory value. Raise exception if there are any syntax or semantic errors. If the file contains a scalar value or one dict, then it is returned as the value. If the file contains two or more dicts then return a Dict[] of the instances. Also see writeData
to encode data back to Xeto text format.
Options
- externRefs: marker to allow unresolved refs to compile
compileLib
cur
static XetoEnv cur()
Current default environment for the VM
derive
dict
fits
abstract Bool fits(XetoContext cx, Obj? val, Spec spec, Dict? opts := null)
Return if the given instance fits the spec via structural typing.
instance
instantiate
abstract Obj? instantiate(Spec spec, Dict? opts := null)
Create default instance for the given spec. Raise exception if spec is abstract.
Options:
graph
: marker tag to instantiate graph of recs (will auto-generate ids)abstract
: marker to supress error if spec is abstractid
: Ref tag to include in new instance
isRemote
abstract Bool isRemote()
Is this a remote environment loaded over a network transport. Remote environments must load libraries asynchronously and do not support the full feature set.
lib
libAsync
marker
abstract Obj marker()
Marker singleton value
na
abstract Obj na()
NA singleton value
none
abstract Obj none()
None singleton value
ref
reload
static Void reload()
Reload the entire data env. This creates a new environment, rescans the local file system for installed libs, and all previously loaded libraries with be reloaded on first access. Any references to Lib or Specs must no longer be used.
spec
specOf
type
writeData
abstract Void writeData(OutStream out, Obj val, Dict? opts := null)
Write instance data in Xeto text format to an output stream. If the value is a Dict[], then it is flattened in the output. Use compileData
to read data from Xeto text format.