Class: Dentaku::AST::Function

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

Direct Known Subclasses

Count, Duration, Enum, If, Reduce, RubyMath, StringFunctions::Base, Xor

Constant Summary collapse

DIG =

Returns with the number of significant decimal digits to use.

Returns:

  • (Integer)

    with the number of significant decimal digits to use.

Float::DIG + 1

Constants inherited from Node

Node::STATIC_CONTEXT, Node::STATIC_MODE_KEY

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Node

arity, #name, precedence, #pure?, resolve_class, #type

Constructor Details

#initialize(*args) ⇒ Function

Returns a new instance of Function.



12
13
14
# File 'lib/dentaku/ast/function.rb', line 12

def initialize(*args)
  @args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



7
8
9
# File 'lib/dentaku/ast/function.rb', line 7

def args
  @args
end

Class Method Details

.get(name) ⇒ Object



32
33
34
# File 'lib/dentaku/ast/function.rb', line 32

def self.get(name)
  registry.get(name)
end

.register(name, type, implementation, volatile: false) ⇒ Object



36
37
38
# File 'lib/dentaku/ast/function.rb', line 36

def self.register(name, type, implementation, volatile: false)
  registry.register(name, type, implementation, volatile: volatile)
end

.register_class(name, function_class) ⇒ Object



40
41
42
# File 'lib/dentaku/ast/function.rb', line 40

def self.register_class(name, function_class)
  registry.register_class(name, function_class)
end

.registryObject



44
45
46
# File 'lib/dentaku/ast/function.rb', line 44

def self.registry
  @registry ||= FunctionRegistry.new
end

.volatile?Boolean

volatile functions may not be evaluated during dependency resolution; registry-generated classes override this per the volatile: option passed at registration

Returns:

  • (Boolean)


28
29
30
# File 'lib/dentaku/ast/function.rb', line 28

def self.volatile?
  false
end

Instance Method Details

#accept(visitor) ⇒ Object



16
17
18
# File 'lib/dentaku/ast/function.rb', line 16

def accept(visitor)
  visitor.visit_function(self)
end

#dependencies(context = {}) ⇒ Object



20
21
22
23
# File 'lib/dentaku/ast/function.rb', line 20

def dependencies(context = {})
  @args.each_with_index
       .flat_map { |a, _| a.dependencies(context) }
end