Access
Extends: FunctionAccess
Source: detlef.mjs:358
Borrowed context access for host setup and lazy Controls.
Includes the value/object methods of FunctionAccess. Must not be constructed, disposed, or used after its callback returns. An ancestor access must not be used while a nested operation is executing.
Alias: Access
Instance Methods
execute(source: string): Value
Evaluate source in the current context and return its last evaluation. Earlier side effects remain if a later expression fails.
Parameters
source(string) — DETLEF source.
Returns
Value— Result wrapper; must be disposed in host setup, but is temporary in a Control callback.
Throws
Error— Parsing/evaluation failure or expired/busy access.
getVariable(name: string): Value
Read an existing mutable variable. This operation does not look up a callable. The result must be disposed in host setup, but is temporary in a Control callback.
Parameters
name(string) — Variable name.
Returns
Value— Current value wrapper.
Throws
Error— Unknown/uninitialized variable or expired access.
setVariable(name: string, value: HostValue): undefined
Assign an existing mutable variable after checking its declared type. The supplied Value is borrowed and not consumed.
Parameters
name(string) — Variable name.value(HostValue) — Replacement value.
Returns
undefined— No value.
Throws
Error— Unknown variable, type mismatch, or expired access.
installStdlib(options?: IOOptions): undefined
Install stdlib operations using synchronous I/O callbacks. Output is passed through without an added newline. Input returns a line or EOF.
Parameters
options(IOOptions, optional) — Synchronous input and output callbacks.
Returns
undefined— No value.
Throws
Error— Installation failure or invalid callback use.
registerFunction(
name: string,
types: Array.<TypeSpec>,
callback: FunctionCallback,
options?: Object,
): undefined
Register an eager Function with limited value/object access. Arguments are evaluated before the host callback is invoked.
Parameters
name(string) — Callable name.types(Array.<TypeSpec>) — Fixed parameter types in declaration order.callback(FunctionCallback) — Synchronous host implementation.options(Object, optional) — Signature options.options.variadic(TypeSpec, optional) — Type accepted by each additional argument.
Returns
undefined— No value.
Throws
Error— Invalid types, signature conflicts, expired access, or an unavailable runtime.
registerRecord(
name: string,
fields: Array.<RecordField>,
): undefined
Define a record type. Records must be registered before signatures that use them.
Parameters
name(string) — Record type name.fields(Array.<RecordField>) — Fields in declaration order; field types are named types.
Returns
undefined— No value.
Throws
Error— Invalid fields, unknown field types, or an already defined record.
registerControl(
name: string,
callback: ControlCallback,
): undefined
Register a lazy Control. Its callback chooses which expressions to evaluate.
Parameters
name(string) — Callable name.callback(ControlCallback) — Synchronous host implementation.
Returns
undefined— No value.
Throws
Error— Invalid registration, expired access, or an unavailable runtime.
value(value: HostValue): Value
Inherited from FunctionAccess#value
Wrap a JavaScript primitive as a DETLEF value, or borrow an existing Value.
Numbers become floats; integers require BigInt within the signed 64-bit range. A new wrapper is temporary inside a registered callback. Otherwise it must be disposed explicitly. Existing wrappers keep their original ownership.
Parameters
value(HostValue) — Primitive or Value from this runtime.
Returns
Value— New primitive wrapper, or the supplied Value unchanged.
Throws
Error— Unsupported input, out-of-range integer, disposed handle, or expired access.
array(elementType: TypeSpec, items?: Array.<HostValue>): Value
Inherited from FunctionAccess#array
Create an array by copying the supplied values. Input wrappers are not consumed. The result follows the same temporary/host-owned lifetime as value().
Parameters
elementType(TypeSpec) — Element type, not the enclosing array type.items(Array.<HostValue>, optional, default: "[]") — Elements to copy.
Returns
Value— Array wrapper.
Throws
Error— Invalid type, non-array items, element type mismatch, or expired access.
record(type: string, fields?: Array.<HostValue>): Value
Inherited from FunctionAccess#record
Create an instance of an existing record type. Input wrappers are not consumed. The result follows the same temporary/host-owned lifetime as value().
Parameters
type(string) — Name of a defined record type.fields(Array.<HostValue>, optional, default: "[]") — Values in field declaration order.
Returns
Value— Record wrapper.
Throws
Error— Unknown record, field count/type mismatch, or expired access.