opal scope problems

opal eval is in object scope it seems
This commit is contained in:
Torsten Ruger 2015-10-27 12:47:17 +02:00
parent 922ec10f93
commit 17fb7fbf74

View File

@ -9,9 +9,11 @@ class SwitchView < ListView
super(".classes") super(".classes")
end end
end end
# opal eval seems to get the scope wrong and evals in object (not where its called)
include AST::Sexp
class SelectView < ElementView class SelectView < ElementView
include AST::Sexp
def initialize interpreter def initialize interpreter
@interpreter = interpreter @interpreter = interpreter
@codes = nil @codes = nil
@ -45,20 +47,24 @@ class SelectView < ElementView
@element.at_css(".code_list") << list @element.at_css(".code_list") << list
end end
def decode code
begin
return Kernel.eval(code)
rescue => e
@element.at_css(".selected").text = "error, #{e}"
puts e
end
s(:statements, s(:class, :Foo, s(:derives, nil), s(:statements, s(:class_field, :Integer, :x))))
end
def select code def select code
@interpreter.set_state :stopped @interpreter.set_state :stopped
@element.at_css(".selected").text = code @element.at_css(".selected").text = code
promise = Browser::HTTP.get "/#{code}.json" promise = Browser::HTTP.get "/#{code}.json"
promise.then do |response| promise.then do |response|
code = nil code = decode( response.text)
begin machine = Register.machine.boot
code = Kernel.eval response.text Soml::Compiler.compile( code )
rescue => e
@element.at_css(".selected").text = "error, see console"
puts e
end
machine = Virtual.machine.boot
Phisol::Compiler.compile( code )
machine.collect machine.collect
@interpreter.start machine.init @interpreter.start machine.init
end end