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
|
def initialize interpreter
|
||||||
|
@interpreter = interpreter
|
||||||
# page._classes!.clear
|
@classes = []
|
||||||
all = []
|
|
||||||
Virtual.machine.space.classes.each do |name , claz|
|
Virtual.machine.space.classes.each do |name , claz|
|
||||||
next if [:Kernel,:Module,:MetaClass,:BinaryCode].index name
|
next if [:Kernel,:Module,:MetaClass,:BinaryCode].index name
|
||||||
all << name
|
@classes << name
|
||||||
end
|
|
||||||
all.sort.each do |name|
|
|
||||||
# c = Volt::Model.new :name => name
|
|
||||||
# page._classes << c
|
|
||||||
end
|
end
|
||||||
|
@classes.sort!
|
||||||
end
|
end
|
||||||
|
|
||||||
def variables(clas_model)
|
def variables(clas_model)
|
||||||
@ -24,24 +20,27 @@ class ClassView < ListView
|
|||||||
end
|
end
|
||||||
|
|
||||||
def draw
|
def draw
|
||||||
div.classes do
|
DOM do |dom|
|
||||||
h4 {"Classes"}
|
dom.div.classes do
|
||||||
ul.nav do
|
dom.h4 {"Classes"}
|
||||||
#{{page._classes.each do |clas| }}
|
dom.ul.nav! do
|
||||||
li do
|
@classes.each do |cl|
|
||||||
a { "me "}
|
dom.li do
|
||||||
# <a href="#">{{ clas._name }}</a>
|
dom.a { cl }
|
||||||
# {{ unless variables(clas).empty? }}
|
end
|
||||||
# <ul>
|
end
|
||||||
# {{variables(clas).each do |var| }}
|
|
||||||
# <li>
|
|
||||||
# <a href="#">{{var}}</a>
|
|
||||||
# </li>
|
|
||||||
# {{ end }}
|
|
||||||
# </ul>
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
# <a href="#">{{ clas._name }}</a>
|
||||||
|
# {{ unless variables(clas).empty? }}
|
||||||
|
# <ul>
|
||||||
|
# {{variables(clas).each do |var| }}
|
||||||
|
# <li>
|
||||||
|
# <a href="#">{{var}}</a>
|
||||||
|
# </li>
|
||||||
|
# {{ end }}
|
||||||
|
# </ul>
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -3,4 +3,5 @@ require "opal"
|
|||||||
require "opal-parser"
|
require "opal-parser"
|
||||||
require "main_view"
|
require "main_view"
|
||||||
|
|
||||||
MainView.new()
|
view = MainView.new()
|
||||||
|
view.draw.append_to($document.body)
|
||||||
|
@ -3,4 +3,8 @@ class ElementView
|
|||||||
def initialize
|
def initialize
|
||||||
@element = nil
|
@element = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def draw
|
||||||
|
raise "implement me to return an Element"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,8 +2,19 @@ require "element_view"
|
|||||||
|
|
||||||
class ListView < ElementView
|
class ListView < ElementView
|
||||||
|
|
||||||
def initialize
|
def initialize children
|
||||||
|
@children = children
|
||||||
@elements = []
|
@elements = []
|
||||||
|
@container_element = nil
|
||||||
end
|
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
|
end
|
||||||
|
@ -16,29 +16,30 @@ class MainView < ListView
|
|||||||
|
|
||||||
# compile_main includes the parse
|
# compile_main includes the parse
|
||||||
# parsing generates an ast as seen below and then compiles it.
|
# 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
|
# 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
|
# 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))
|
code = Ast::OperatorExpression.new("+", Ast::IntegerExpression.new(2),Ast::IntegerExpression.new(5))
|
||||||
# Virtual::Compiler.compile( code , machine.space.get_main )
|
Virtual::Compiler.compile( code , machine.space.get_main )
|
||||||
|
|
||||||
machine.run_before "Register::CallImplementation"
|
machine.run_before "Register::CallImplementation"
|
||||||
@interpreter = Interpreter::Interpreter.new
|
@interpreter = Interpreter::Interpreter.new
|
||||||
@parent = $document.body
|
super( [ClassView.new(@interpreter)] )
|
||||||
puts @parent.parent.name
|
|
||||||
draw
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def draw
|
def draww
|
||||||
node = DOM {
|
node = DOM { |m|
|
||||||
div.info {
|
Kernel.puts "DOM #{self.class}"
|
||||||
span.red "Ready to start."
|
m.div.info {
|
||||||
|
Kernel.puts "div #{self.class}" ; ""
|
||||||
|
m.span.red @interpreter.state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
node.append_to(@parent)
|
node.append_to(@parent)
|
||||||
end
|
end
|
||||||
|
|
||||||
def no
|
def no
|
||||||
|
|
||||||
body = Native(`window.document.body`)
|
body = Native(`window.document.body`)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user