Next: , Previous: , Up: Compiling to Wasm   [Contents][Index]


2.2 Reflection

The (hoot reflect) module provides an interface for inspecting and manipulating Scheme values that live within Wasm modules. This is the primary interface for testing compiler output directly from Guile.

Procedure: hoot-instantiate scheme-wasm [imports '()] [reflector]

Instantiate and return a new Hoot module using the compiled Scheme Wasm module scheme-wasm and the reflection module reflector. If reflector is not specified, a new reflector instance will be created.

Optionally, imports may contain a 2-tier association list structure of imported functions, globals, tables, and memories:

`(("math" . (("random" . ,(lambda (x) (random x))))))
Procedure: hoot-load module

Invoke the load thunk of module and return the reflected result values.

The following procedures, compile-value and compile-call, are convenience procedures for when you just want to quickly compile something and see the result and you don’t care about the intermediary Wasm binary.

Procedure: compile-value exp [imports %default-program-imports] [load-path '()] [wasm-imports '()]

Compile exp and return the result.

Optionally, imports may specify a list of Scheme module names to import. If unspecified, a default set of modules providing a basic Scheme environment will be imported. load-path is a list of file system directories to search for additional user modules.

Optionally, wasm-imports may contain a 2-tier association list structure of imported Wasm functions, globals, tables, and memories. See hoot-instantiate for an example of such a structure.

Procedure: compile-call proc-exp arg-exps ... [imports %default-program-imports] [load-path '()] [wasm-imports '()]

Compile proc-exp and all arg-exps, call the procedure with the arguments, then return the results.

See compile-value for an explanation of the keyword arguments.

Procedure: hoot-module? obj

Return #t if obj is a Hoot module.

Procedure: hoot-module-reflector module

Return the reflection module for module.

Procedure: hoot-module-instance module

Return the Wasm instance for module.

Procedure: reflector? obj

Return #t if obj is a reflector.

Procedure: reflector-instance reflector

Return the Wasm instance of reflector.

Procedure: reflector-abi reflector

Return the association list of ABI imports for reflector.

Below are the predicates and accessors for various Hoot heap types:

Procedure: hoot-object? obj

Return #t if obj is a Hoot object.

Procedure: hoot-complex? obj

Return #t if obj is a Hoot complex number.

Procedure: hoot-complex-real complex

Return the real part of complex.

Procedure: hoot-complex-imag complex

Return the imaginary part of complex.

Procedure: hoot-fraction? obj

Return #t if obj is a Hoot fraction.

Procedure: hoot-fraction-num fraction

Return the numerator of fraction

Procedure: hoot-fraction-denom fraction

Return the denominator of fraction.

Procedure: hoot-pair? obj

Return #t if obj is a Hoot pair.

Procedure: mutable-hoot-pair? obj

Return #t if obj is a mutable Hoot pair.

Procedure: hoot-pair-car pair

Return the first element of pair.

Procedure: hoot-pair-cdr pair

Return the second element of pair.

Procedure: hoot-vector? obj

Return #t if obj is a Hoot vector.

Procedure: mutable-hoot-vector? obj

Return #t if obj is a mutable Hoot vector.

Procedure: hoot-vector-length vec

Return the length of vec.

Procedure: hoot-vector-ref vec i

Return the ith element of vec.

Procedure: hoot-bytevector? obj

Return #t if obj is a Hoot bytevector.

Procedure: mutable-hoot-bytevector? obj

Return #t if obj is a mutable Hoot bytevector.

Procedure: hoot-bytevector-length bv

Return the length of bv.

Procedure: hoot-bytevector-ref bv i

Return the ith byte of bv.

Procedure: hoot-bitvector? obj

Return #t if obj is a Hoot bitvector.

Procedure: mutable-hoot-bitvector? obj

Return #t if obj is a mutable Hoot bitvector.

Procedure: hoot-bitvector-length bv

Return the length of bv.

Procedure: hoot-bitvector-ref bv i

Return the ith bit of bv.

Procedure: hoot-symbol? obj

Return #t if obj is a Hoot symbol.

Procedure: hoot-symbol-name sym

Return the string name of sym.

Procedure: hoot-keyword? obj

Return #t if obj is a Hoot keyword.

Procedure: hoot-keyword-name keyword

Return the name string of keyword.

Procedure: mutable-hoot-string? obj

Return #t if obj is a mutable Hoot string.

Procedure: mutable-hoot-string->string str

Return the underlying string for str.

Procedure: hoot-procedure? obj

Return #t if obj is a Hoot procedure.

Procedure: hoot-apply proc . args

Apply the Hoot procedure proc with args.

Procedure: hoot-apply-async proc . args

Apply the Hoot procedure proc in an asynchronous context.

proc should be a procedure that accepts two additional arguments (arguments 0 and 1) in addition to args:

  • resolved: An opaque external value representing the successful completion of the async operation.
  • rejected: An opaque external value representing the failure of the async operation.

You almost certainly want to be using this procedure with call-with-async-result in the (fibers promises) module.

Procedure: hoot-variable? obj

Return #t if obj is a Hoot variable.

Procedure: hoot-atomic-box? obj

Return #t if obj is a Hoot atomic box.

Procedure: hoot-hash-table? obj

Return #t if obj is a Hoot hash table.

Procedure: hoot-weak-table? obj

Return #t if obj is a Hoot weak table.

Procedure: hoot-fluid? obj

Return #t if obj is a Hoot fluid.

Procedure: hoot-dynamic-state? obj

Return #t if obj is a Hoot dynamic state.

Procedure: hoot-syntax? obj

Return #t if obj is a Hoot syntax object.

Procedure: hoot-port? obj

Return #t if obj is a Hoot port.

Procedure: hoot-struct? obj

Return #t if obj is a Hoot struct.


Next: REPL commands, Previous: Invoking the compiler, Up: Compiling to Wasm   [Contents][Index]