Class: Kumi::Syntax::Root

Inherits:
Struct
  • Object
show all
Includes:
Node
Defined in:
lib/kumi/syntax/root.rb

Overview

Represents the root of the Abstract Syntax Tree. It holds all the top-level declarations parsed from the source.

Instance Attribute Summary collapse

Attributes included from Node

#hints, #loc

Instance Method Summary collapse

Methods included from Node

#==, #initialize

Instance Attribute Details

#importsObject

Returns the value of attribute imports

Returns:

  • (Object)

    the current value of imports



7
8
9
# File 'lib/kumi/syntax/root.rb', line 7

def imports
  @imports
end

#inputsObject

Returns the value of attribute inputs

Returns:

  • (Object)

    the current value of inputs



7
8
9
# File 'lib/kumi/syntax/root.rb', line 7

def inputs
  @inputs
end

#traitsObject

Returns the value of attribute traits

Returns:

  • (Object)

    the current value of traits



7
8
9
# File 'lib/kumi/syntax/root.rb', line 7

def traits
  @traits
end

#valuesObject

Returns the value of attribute values

Returns:

  • (Object)

    the current value of values



7
8
9
# File 'lib/kumi/syntax/root.rb', line 7

def values
  @values
end

Instance Method Details

#childrenObject



10
# File 'lib/kumi/syntax/root.rb', line 10

def children = [inputs, values, traits, imports]

#digestObject



12
13
14
15
16
17
18
19
20
# File 'lib/kumi/syntax/root.rb', line 12

def digest
  # The digest must be stable and depend on anything that could change the
  # compiled output. This includes the AST, the Kumi version (compiler changes),
  # and the Ruby version (runtime behavior changes).
  digest_input = "#{Kumi::VERSION}-#{RUBY_VERSION}-#{self}"

  # Ruby constants cannot start with a number, so we add a prefix.
  "KUMI_#{Digest::SHA256.hexdigest(digest_input)}"
end