load parfait code over the net too
some very painful promise debugging solved weird string issue
This commit is contained in:
parent
0f7fb9e70f
commit
3681b4b5d7
@ -22,6 +22,7 @@ class SelectView < ElementView
|
||||
def draw
|
||||
@element = div("h4", "Code") << (list = div("ul.nav!"))
|
||||
list << (div("li.code_list") << div("a.selected" , "none selected"))
|
||||
get_parfait unless @parfait
|
||||
get_codes unless @codes
|
||||
@element << div("br")
|
||||
@element << div("br")
|
||||
@ -35,6 +36,13 @@ class SelectView < ElementView
|
||||
end
|
||||
end
|
||||
|
||||
def get_parfait
|
||||
promise = Browser::HTTP.get "/parfait.json"
|
||||
promise.then do |response|
|
||||
@parfait = decode response.text
|
||||
end
|
||||
end
|
||||
|
||||
def add_selection
|
||||
list = div "ul"
|
||||
@codes << @codes.first if @codes.length == 1
|
||||
@ -49,10 +57,11 @@ class SelectView < ElementView
|
||||
|
||||
def decode code
|
||||
begin
|
||||
return Kernel.eval(code)
|
||||
val = Kernel.eval(code)
|
||||
return val
|
||||
rescue => e
|
||||
@element.at_css(".selected").text = "error, #{e}"
|
||||
puts e
|
||||
puts e.backtrace
|
||||
end
|
||||
s(:statements, s(:class, :Foo, s(:derives, nil), s(:statements, s(:class_field, :Integer, :x))))
|
||||
end
|
||||
@ -64,8 +73,21 @@ class SelectView < ElementView
|
||||
promise.then do |response|
|
||||
code = decode( response.text)
|
||||
machine = Register.machine.boot
|
||||
Soml.compile( code )
|
||||
@parfait.each do |part|
|
||||
begin
|
||||
Soml.compile( part )
|
||||
rescue => e
|
||||
puts e.backtrace
|
||||
end
|
||||
end
|
||||
begin
|
||||
Soml.compile( code )
|
||||
rescue => e
|
||||
puts e.backtrace
|
||||
raise e
|
||||
end
|
||||
machine.collect
|
||||
puts "starting"
|
||||
@interpreter.start machine.init
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user