Class: Duby::AST::WhileLoop

Inherits:
Loop show all
Defined in:
lib/duby/ast/flow.rb,
lib/duby/compiler.rb

Instance Attribute Summary collapse

Attributes inherited from Loop

#redo

Attributes inherited from Node

#children, #inferred_type, #newline, #parent, #position

Instance Method Summary collapse

Methods inherited from Loop

#expr?, #infer, #precompile

Methods inherited from Node

#[], #each, #expr?, #inspect, #line_number, #log, #precompile, #resolve_if, #resolved!, #resolved?, #simple_name, #temp

Constructor Details

#initialize(parent, line_number, check_first, negative, &block) ⇒ WhileLoop

Returns a new instance of WhileLoop.



116
117
118
119
120
121
# File 'lib/duby/ast/flow.rb', line 116

def initialize(parent, line_number, check_first, negative, &block)
  super(parent, line_number, &block)
  @condition, @body = children
  @check_first = check_first
  @negative = negative
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



114
115
116
# File 'lib/duby/ast/flow.rb', line 114

def body
  @body
end

#check_firstObject

Returns the value of attribute check_first.



114
115
116
# File 'lib/duby/ast/flow.rb', line 114

def check_first
  @check_first
end

#conditionObject

Returns the value of attribute condition.



114
115
116
# File 'lib/duby/ast/flow.rb', line 114

def condition
  @condition
end

#negativeObject

Returns the value of attribute negative.



114
115
116
# File 'lib/duby/ast/flow.rb', line 114

def negative
  @negative
end

Instance Method Details

#check_first?Boolean

Returns:



123
# File 'lib/duby/ast/flow.rb', line 123

def check_first?; @check_first; end

#compile(compiler, expression) ⇒ Object



153
154
155
156
# File 'lib/duby/compiler.rb', line 153

def compile(compiler, expression)
  compiler.line(line_number)
  compiler.while_loop(self, expression)
end

#has_redo?Boolean

Returns:



125
# File 'lib/duby/ast/flow.rb', line 125

def has_redo?; @redo; end

#negative?Boolean

Returns:



124
# File 'lib/duby/ast/flow.rb', line 124

def negative?; @negative; end

#to_sObject



127
128
129
# File 'lib/duby/ast/flow.rb', line 127

def to_s
  "WhileLoop(check_first = #{check_first?}, negative = #{negative?})"
end