Class: Dhallish::Ast::ListConcatNode
- Inherits:
-
Object
- Object
- Dhallish::Ast::ListConcatNode
- Defined in:
- lib/ast.rb
Instance Method Summary collapse
- #compute_type(ctx) ⇒ Object
- #evaluate(ctx) ⇒ Object
-
#initialize(lhs, rhs) ⇒ ListConcatNode
constructor
A new instance of ListConcatNode.
Constructor Details
#initialize(lhs, rhs) ⇒ ListConcatNode
Returns a new instance of ListConcatNode.
260 261 262 263 |
# File 'lib/ast.rb', line 260 def initialize(lhs, rhs) @lhs = lhs @rhs = rhs end |
Instance Method Details
#compute_type(ctx) ⇒ Object
265 266 267 268 269 270 271 272 273 |
# File 'lib/ast.rb', line 265 def compute_type(ctx) lhs_type = @lhs.compute_type(ctx) rhs_type = @rhs.compute_type(ctx) assert ("List Concat: left operand not a list but #{lhs_type}") { lhs_type.is_a? Types::List } assert ("List Concatenation operands type mismatch. Left: #{lhs_type}, Right: #{rhs_type}") { rhs_type == lhs_type } lhs_type end |
#evaluate(ctx) ⇒ Object
275 276 277 278 279 |
# File 'lib/ast.rb', line 275 def evaluate(ctx) lhs = @lhs.evaluate(ctx) rhs = @rhs.evaluate(ctx) lhs + rhs end |