Class: CodeTools::AST::And

Inherits:
Node
  • Object
show all
Defined in:
lib/rubinius/code/ast/operators.rb

Direct Known Subclasses

Or

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#ascii_graph, #attributes, #children, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, #or_bytecode, #pos, #set_child, transform, #transform, transform_comment, transform_kind, transform_kind=, transform_name, #value_defined, #visit, #walk

Constructor Details

#initialize(line, left, right) ⇒ And

Returns a new instance of And.



8
9
10
11
12
# File 'lib/rubinius/code/ast/operators.rb', line 8

def initialize(line, left, right)
  @line = line
  @left = left
  @right = right
end

Instance Attribute Details

#leftObject

Returns the value of attribute left.



6
7
8
# File 'lib/rubinius/code/ast/operators.rb', line 6

def left
  @left
end

#rightObject

Returns the value of attribute right.



6
7
8
# File 'lib/rubinius/code/ast/operators.rb', line 6

def right
  @right
end

Instance Method Details

#bytecode(g, use_gif = true) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rubinius/code/ast/operators.rb', line 14

def bytecode(g, use_gif=true)
  @left.bytecode(g)
  g.dup
  lbl = g.new_label

  if use_gif
    g.goto_if_false lbl
  else
    g.goto_if_true lbl
  end

  g.pop
  @right.bytecode(g)
  lbl.set!
end

#defined(g) ⇒ Object



30
31
32
33
# File 'lib/rubinius/code/ast/operators.rb', line 30

def defined(g)
  g.push_literal "expression"
  g.string_dup
end

#sexp_nameObject



35
36
37
# File 'lib/rubinius/code/ast/operators.rb', line 35

def sexp_name
  :and
end

#to_sexpObject



39
40
41
# File 'lib/rubinius/code/ast/operators.rb', line 39

def to_sexp
  [sexp_name, @left.to_sexp, @right.to_sexp]
end