2015-07-22 15:22:54 +02:00
|
|
|
class SourceView
|
|
|
|
|
|
|
|
include React::Component
|
|
|
|
|
2015-07-27 11:09:35 +02:00
|
|
|
required_param :source
|
2015-07-22 15:22:54 +02:00
|
|
|
|
2015-07-27 11:09:35 +02:00
|
|
|
define_state :sources => []
|
|
|
|
|
|
|
|
before_update do
|
|
|
|
text = source_text(source)
|
|
|
|
return if sources.last == text
|
|
|
|
sources << text
|
|
|
|
sources.shift if sources.length > 5
|
|
|
|
end
|
2015-07-22 15:22:54 +02:00
|
|
|
def render
|
2015-07-23 16:26:48 +02:00
|
|
|
div.row do
|
2015-07-24 09:15:58 +02:00
|
|
|
"Virtual Machine Instruction".br
|
2015-07-27 11:09:35 +02:00
|
|
|
sources.each do |s|
|
|
|
|
s.br
|
|
|
|
end
|
2015-07-22 15:22:54 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-07-27 11:09:35 +02:00
|
|
|
def source_text
|
|
|
|
if source.is_a? Virtual::Instruction
|
|
|
|
return source.class.name
|
|
|
|
else
|
|
|
|
return "Method: #{source.name}"
|
|
|
|
end
|
|
|
|
end
|
2015-07-22 15:22:54 +02:00
|
|
|
end
|