put the classes back on the screen
This commit is contained in:
parent
1f7c06d626
commit
87c649c622
@ -1,17 +1,13 @@
|
||||
class ClassView < ListView
|
||||
class ClassView < ElementView
|
||||
|
||||
def initialize
|
||||
|
||||
# page._classes!.clear
|
||||
all = []
|
||||
def initialize interpreter
|
||||
@interpreter = interpreter
|
||||
@classes = []
|
||||
Virtual.machine.space.classes.each do |name , claz|
|
||||
next if [:Kernel,:Module,:MetaClass,:BinaryCode].index name
|
||||
all << name
|
||||
end
|
||||
all.sort.each do |name|
|
||||
# c = Volt::Model.new :name => name
|
||||
# page._classes << c
|
||||
@classes << name
|
||||
end
|
||||
@classes.sort!
|
||||
end
|
||||
|
||||
def variables(clas_model)
|
||||
@ -24,12 +20,19 @@ class ClassView < ListView
|
||||
end
|
||||
|
||||
def draw
|
||||
div.classes do
|
||||
h4 {"Classes"}
|
||||
ul.nav do
|
||||
#{{page._classes.each do |clas| }}
|
||||
li do
|
||||
a { "me "}
|
||||
DOM do |dom|
|
||||
dom.div.classes do
|
||||
dom.h4 {"Classes"}
|
||||
dom.ul.nav! do
|
||||
@classes.each do |cl|
|
||||
dom.li do
|
||||
dom.a { cl }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
# <a href="#">{{ clas._name }}</a>
|
||||
# {{ unless variables(clas).empty? }}
|
||||
# <ul>
|
||||
@ -39,9 +42,5 @@ class ClassView < ListView
|
||||
# </li>
|
||||
# {{ end }}
|
||||
# </ul>
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -3,4 +3,5 @@ require "opal"
|
||||
require "opal-parser"
|
||||
require "main_view"
|
||||
|
||||
MainView.new()
|
||||
view = MainView.new()
|
||||
view.draw.append_to($document.body)
|
||||
|
@ -3,4 +3,8 @@ class ElementView
|
||||
def initialize
|
||||
@element = nil
|
||||
end
|
||||
|
||||
def draw
|
||||
raise "implement me to return an Element"
|
||||
end
|
||||
end
|
||||
|
@ -2,8 +2,19 @@ require "element_view"
|
||||
|
||||
class ListView < ElementView
|
||||
|
||||
def initialize
|
||||
def initialize children
|
||||
@children = children
|
||||
@elements = []
|
||||
@container_element = nil
|
||||
end
|
||||
|
||||
def draw on
|
||||
@container_element = $document.create_element('div')
|
||||
@elements = @children.collect do | c |
|
||||
elem = c.draw(@container_element)
|
||||
elem.append_to(@container_element)
|
||||
elem
|
||||
end
|
||||
@container_element
|
||||
end
|
||||
end
|
||||
|
@ -16,29 +16,30 @@ class MainView < ListView
|
||||
|
||||
# compile_main includes the parse
|
||||
# parsing generates an ast as seen below and then compiles it.
|
||||
machine.compile_main "2 + 5"
|
||||
# machine.compile_main "2 + 5"
|
||||
|
||||
# so the code above is functionally equivalent to the one below, minus the parse
|
||||
# When the ast expression is given all works, so pretty sure it is the parse that fails
|
||||
|
||||
# code = Ast::OperatorExpression.new("+", Ast::IntegerExpression.new(2),Ast::IntegerExpression.new(5))
|
||||
# Virtual::Compiler.compile( code , machine.space.get_main )
|
||||
code = Ast::OperatorExpression.new("+", Ast::IntegerExpression.new(2),Ast::IntegerExpression.new(5))
|
||||
Virtual::Compiler.compile( code , machine.space.get_main )
|
||||
|
||||
machine.run_before "Register::CallImplementation"
|
||||
@interpreter = Interpreter::Interpreter.new
|
||||
@parent = $document.body
|
||||
puts @parent.parent.name
|
||||
draw
|
||||
super( [ClassView.new(@interpreter)] )
|
||||
end
|
||||
|
||||
def draw
|
||||
node = DOM {
|
||||
div.info {
|
||||
span.red "Ready to start."
|
||||
def draww
|
||||
node = DOM { |m|
|
||||
Kernel.puts "DOM #{self.class}"
|
||||
m.div.info {
|
||||
Kernel.puts "div #{self.class}" ; ""
|
||||
m.span.red @interpreter.state
|
||||
}
|
||||
}
|
||||
node.append_to(@parent)
|
||||
end
|
||||
|
||||
def no
|
||||
|
||||
body = Native(`window.document.body`)
|
||||
|
Loading…
Reference in New Issue
Block a user