Class: Dhallish::Ast::RecordNode
- Inherits:
-
Object
- Object
- Dhallish::Ast::RecordNode
- Defined in:
- lib/ast.rb
Overview
‘hash` shall map Keys to Ast-Nodes
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
Instance Method Summary collapse
- #compute_type(ctx) ⇒ Object
- #evaluate(ctx) ⇒ Object
-
#initialize(hash) ⇒ RecordNode
constructor
A new instance of RecordNode.
Constructor Details
#initialize(hash) ⇒ RecordNode
Returns a new instance of RecordNode.
378 379 380 |
# File 'lib/ast.rb', line 378 def initialize(hash) @hash = hash end |
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
377 378 379 |
# File 'lib/ast.rb', line 377 def hash @hash end |
Instance Method Details
#compute_type(ctx) ⇒ Object
382 383 384 385 386 387 388 |
# File 'lib/ast.rb', line 382 def compute_type(ctx) types = {} @hash.each { |name, expr| types[name] = expr.compute_type ctx } Types::Record.new types end |
#evaluate(ctx) ⇒ Object
390 391 392 393 394 395 396 |
# File 'lib/ast.rb', line 390 def evaluate(ctx) vals = {} @hash.each { |key, node| vals[key] = node.evaluate ctx } vals end |