Class: Spade::Runtime::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/spade/runtime/compiler.rb

Overview

Compiler plugin for the default context. Know how to create a new isolated context for the object

Instance Method Summary collapse

Constructor Details

#initialize(ctx) ⇒ Compiler

Returns a new instance of Compiler.



13
14
15
# File 'lib/spade/runtime/compiler.rb', line 13

def initialize(ctx)
  @ctx = ctx
end

Instance Method Details

#compile(data, sandbox, filename) ⇒ Object



23
24
25
26
# File 'lib/spade/runtime/compiler.rb', line 23

def compile(data, sandbox, filename)
  ctx = sandbox['ctx'] || @ctx
  ctx.eval("(#{data})", filename)
end

#setup(sandbox) ⇒ Object



17
18
19
20
21
# File 'lib/spade/runtime/compiler.rb', line 17

def setup(sandbox)
  if sandbox['isIsolated']
    sandbox['ctx'] = Context.new :reactor => @ctx.reactor
  end
end

#teardown(sandbox) ⇒ Object



28
29
30
# File 'lib/spade/runtime/compiler.rb', line 28

def teardown(sandbox)
  sandbox['ctx'] = nil
end