Class: Dhallish::Ast::VariableNode
- Inherits:
-
Object
- Object
- Dhallish::Ast::VariableNode
- Defined in:
- lib/ast.rb
Instance Attribute Summary collapse
-
#varname ⇒ Object
Returns the value of attribute varname.
Instance Method Summary collapse
-
#compute_type(ctx) ⇒ Object
returns a Type for a defined Variable @varname that does not have Type ‘Type’ returns a Value of Type ‘Type’ if @varname is a Typevariable.
- #evaluate(ctx) ⇒ Object
-
#initialize(varname) ⇒ VariableNode
constructor
A new instance of VariableNode.
Constructor Details
#initialize(varname) ⇒ VariableNode
Returns a new instance of VariableNode.
104 105 106 |
# File 'lib/ast.rb', line 104 def initialize(varname) @varname = varname end |
Instance Attribute Details
#varname ⇒ Object
Returns the value of attribute varname.
103 104 105 |
# File 'lib/ast.rb', line 103 def varname @varname end |
Instance Method Details
#compute_type(ctx) ⇒ Object
returns a Type for a defined Variable @varname that does not have Type ‘Type’ returns a Value of Type ‘Type’ if @varname is a Typevariable
110 111 112 113 114 115 |
# File 'lib/ast.rb', line 110 def compute_type(ctx) assert ("Undefined Variable \"#{@varname}\"") { !ctx[@varname].nil? } type = ctx[@varname] assert ("WTF?!") { Types::is_a_type? type } ctx[@varname] end |
#evaluate(ctx) ⇒ Object
117 118 119 |
# File 'lib/ast.rb', line 117 def evaluate(ctx) ctx[@varname] end |