From 315be6985110f6d916d9bd50df6320d0b0b50816 Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 18 Apr 2018 20:09:22 +0300 Subject: [PATCH] fix vool method updating a start, should do code too --- assets/css/app.css.sass | 4 +-- lib/views/vool_view.rb | 54 +++++++++++++++-------------------------- 2 files changed, 22 insertions(+), 36 deletions(-) diff --git a/assets/css/app.css.sass b/assets/css/app.css.sass index 1a2f45e..10c8c63 100644 --- a/assets/css/app.css.sass +++ b/assets/css/app.css.sass @@ -18,11 +18,11 @@ body margin-left: 1% .vool_view - width: 18% + width: 14% margin-left: 1% .mom_view - width: 20% + width: 24% margin-left: 1% .risc_view diff --git a/lib/views/vool_view.rb b/lib/views/vool_view.rb index 6c9faca..3e2ddfd 100644 --- a/lib/views/vool_view.rb +++ b/lib/views/vool_view.rb @@ -17,45 +17,31 @@ class VoolView < ElementView def instruction_changed i = @interpreter.instruction return "" unless i - update_method - case i.source - when Mom::Instruction - @ticker.text = i.source.class.name - # if e = @text.at_css("#i#{id}") - # if (old = @text.at_css(".fade_in")) - # old.remove_class("fade_in") - # end - # e.add_class "fade_in" - # end - when String - @ticker.text = i.source - when Risc::Instruction - @ticker.text = i.source.to_s - else - raise "Unrecognized source #{i.source.class.name} for #{i}" - end - end - - def update_method - i = @interpreter.instruction if i.is_a?(Risc::FunctionReturn) link = @interpreter.get_register( i.register ) - #puts "Link #{link}" + puts "Link #{link}:#{link.source}" raise "No link method" unless link i = link end - return unless (i.is_a? Risc::Label) - return unless i.is_method - puts i.name - return - cl_t_name , method_name = *i.name.split(".") - class_name = cl_t_name.split(" ").last.split("_").first - clazz = Parfait.object_space.get_class_by_name class_name - raise "No class for #{cl_name} , #{i.name}" unless clazz - type = clazz.instance_type - method = type.get_method( method_name ) - @element.at_css(".source").text = i.name - @text.inner_html = HtmlConverter.new.process( method.source ) + method = nil + case i.source + when Mom::Instruction + if(i.source.is_a?(Mom::SimpleCall)) + method = i.source.method + end + #TODO, give mom a source + when Parfait::TypedMethod + method = i.source + when String + return + else + raise "Unrecognized source #{i.source.class.name} for #{i}" + end + update_method(method) if method + end + + def update_method(method) + @text.inner_html = method.name end end