-
Notifications
You must be signed in to change notification settings - Fork 22
/
eval.fy
31 lines (23 loc) · 831 Bytes
/
eval.fy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require: "compiler"
def Fancy eval: code binding: bnd (nil) file: file ("(fancy-eval)") line: line (1) {
bnd if_nil: {
bnd = Binding setup(Rubinius VariableScope of_sender(),
Rubinius CompiledMethod of_sender(),
Rubinius StaticScope of_sender())
}
# The compiled method
cm = Fancy Compiler compile_code: code vars: (bnd variables()) file: file line: line
cm scope=(bnd static_scope() dup())
cm name=('__fancy_eval__)
script = Rubinius CompiledMethod Script new(cm, file, true)
script eval_binding=(bnd)
script eval_source=(code)
cm scope() script=(script)
be = Rubinius BlockEnvironment new()
be under_context(bnd variables(), cm)
if: (bnd from_proc?()) then: {
be proc_environment=(bnd proc_environment)
}
be from_eval!()
be call()
}