Class: Dentaku::AST::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/dentaku/ast/node.rb

Constant Summary collapse

STATIC_MODE_KEY =

reserved context key (double-underscore prefix, like __evaluation_mode) that switches dependencies() into static mode: guards are never evaluated and every branch is reported

"__static_dependencies".freeze
STATIC_CONTEXT =
{ STATIC_MODE_KEY => true }.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.arityObject



14
15
16
# File 'lib/dentaku/ast/node.rb', line 14

def self.arity
  nil
end

.precedenceObject



10
11
12
# File 'lib/dentaku/ast/node.rb', line 10

def self.precedence
  0
end

.resolve_classObject



18
19
20
# File 'lib/dentaku/ast/node.rb', line 18

def self.resolve_class(*)
  self
end

Instance Method Details

#dependencies(context = {}) ⇒ Object



22
23
24
# File 'lib/dentaku/ast/node.rb', line 22

def dependencies(context = {})
  []
end

#nameObject



39
40
41
# File 'lib/dentaku/ast/node.rb', line 39

def name
  self.class.name.to_s.split("::").last.upcase
end

#pure?Boolean

whether this subtree may be evaluated during dependency resolution without running volatile user code; a property of the parsed AST, computed once and memoized

Returns:

  • (Boolean)


29
30
31
32
33
# File 'lib/dentaku/ast/node.rb', line 29

def pure?
  return @pure if defined?(@pure)

  @pure = compute_pure?
end

#typeObject



35
36
37
# File 'lib/dentaku/ast/node.rb', line 35

def type
  nil
end