Class: Yadriggy::ASTreeTable

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

Overview

A table of reified abstract syntax trees. It is used for guaranteeing the uniqueness of ASTree objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeASTreeTable

Returns a new instance of ASTreeTable.



1664
1665
1666
# File 'lib/yadriggy/ast.rb', line 1664

def initialize()
  @trees = {}
end

Instance Attribute Details

#treesHash (readonly)

Returns all the elements.

Returns:

  • (Hash)

    all the elements.



1662
1663
1664
# File 'lib/yadriggy/ast.rb', line 1662

def trees
  @trees
end

Instance Method Details

#[](context) ⇒ Object

Gets the value associated with the key.

Parameters:

  • context (Proc|Method|UnboundMethod)

    the key.



1683
1684
1685
# File 'lib/yadriggy/ast.rb', line 1683

def [](context)
  @trees[context]
end

#[]=(context, ast) ⇒ Object

Records a key-value pair.

Parameters:

  • context (Proc|Method|UnboundMethod)

    the key.

  • ast (ASTnode)

    the value.



1671
1672
1673
# File 'lib/yadriggy/ast.rb', line 1671

def []=(context, ast)
  @trees[context] = ast
end

#delete(context) ⇒ Object

Deletes a key-value pair.

Parameters:

  • context (Proc|Method|UnboundMethod)

    the key.



1677
1678
1679
# File 'lib/yadriggy/ast.rb', line 1677

def delete(context)
  @trees.delete(context)
end

#each(&blk) ⇒ Object

Executes a block once for each element.



1688
1689
1690
# File 'lib/yadriggy/ast.rb', line 1688

def each(&blk)
  @trees.each_value(&blk)
end