EExpr

From Erights

Jump to: navigation, search

A parsed Kernel-E expression.

Protocol

compile/1

Signature: compile(env :Scope) :CompiledE

Compile the expression to an internal form (currently transformed E, but could be Java bytecode). The result is a Thunk which can be invoked to evaluate the code in the given environment.

The CompiledE is also useful if you want to debug the optimiser:

 ? def expr := e`def double (x) { return 2*x }`
 # value: e`def double {
 #            
 #            method run(x) {
 #                escape __return {
 #                    __return.run(2.multiply(x))
 #                    null
 #                }
 #            }
 #        }`
 
 ? expr.compile(safeScope)
 # value: compiled-e`def double {
 #            
 #            method run(x) {
 #                2.multiply(x)
 #            }
 #        }`

eval/1

Signature: eval(env :Scope) :any

Convenience method to compile and evaluate the expression in one go.

Personal tools
more tools