Class: P2::RenderNode
- Inherits:
-
Object
- Object
- P2::RenderNode
- Includes:
- Prism::DSL
- Defined in:
- lib/p2/compiler/nodes.rb
Overview
Represents a render call
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#call_node ⇒ Object
readonly
Returns the value of attribute call_node.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #ad_hoc_string_location(str) ⇒ Object
-
#initialize(call_node, translator) ⇒ RenderNode
constructor
A new instance of RenderNode.
- #transform(node) ⇒ Object
- #transform_array(array) ⇒ Object
Constructor Details
#initialize(call_node, translator) ⇒ RenderNode
Returns a new instance of RenderNode.
67 68 69 70 71 72 73 74 |
# File 'lib/p2/compiler/nodes.rb', line 67 def initialize(call_node, translator) @call_node = call_node @location = call_node.location @translator = translator @block = call_node.block && translator.visit(call_node.block) lambda = call_node.arguments && call_node.arguments.arguments[0] end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
63 64 65 |
# File 'lib/p2/compiler/nodes.rb', line 63 def block @block end |
#call_node ⇒ Object (readonly)
Returns the value of attribute call_node.
63 64 65 |
# File 'lib/p2/compiler/nodes.rb', line 63 def call_node @call_node end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
63 64 65 |
# File 'lib/p2/compiler/nodes.rb', line 63 def location @location end |
Instance Method Details
#accept(visitor) ⇒ Object
89 90 91 |
# File 'lib/p2/compiler/nodes.rb', line 89 def accept(visitor) visitor.visit_render_node(self) end |
#ad_hoc_string_location(str) ⇒ Object
76 77 78 79 |
# File 'lib/p2/compiler/nodes.rb', line 76 def ad_hoc_string_location(str) src = source(str) Prism::DSL.location(source: src, start_offset: 0, length: str.bytesize) end |
#transform(node) ⇒ Object
81 82 83 |
# File 'lib/p2/compiler/nodes.rb', line 81 def transform(node) node && @translator.visit(node) end |
#transform_array(array) ⇒ Object
85 86 87 |
# File 'lib/p2/compiler/nodes.rb', line 85 def transform_array(array) array ? array.map { @translator.visit(it) } : [] end |