Class: BOAST::While

Inherits:
ControlStructure show all
Includes:
Annotation
Defined in:
lib/BOAST/Language/While.rb

Constant Summary collapse

ANNOTATIONS =
[ :condition ]

Instance Attribute Summary collapse

Attributes inherited from ControlStructure

#args

Instance Method Summary collapse

Methods included from Annotation

#annotate_array, #annotate_indepth?, #annotate_scalar, #annotate_var, #annotation, #annotation_identifier

Methods included from PrivateStateAccessor

private_boolean_state_accessor, private_state_accessor

Methods inherited from ControlStructure

#[], #get_strings, inherited, token_string_generator

Methods included from Inspectable

#inspect

Constructor Details

#initialize(condition, &block) ⇒ While

Returns a new instance of While.



9
10
11
12
# File 'lib/BOAST/Language/While.rb', line 9

def initialize(condition, &block)
  @condition = condition
  @block = block
end

Instance Attribute Details

#conditionObject (readonly)

Returns the value of attribute condition.



7
8
9
# File 'lib/BOAST/Language/While.rb', line 7

def condition
  @condition
end

Instance Method Details

#closeObject



53
54
55
56
57
58
59
60
# File 'lib/BOAST/Language/While.rb', line 53

def close
  decrement_indent_level      
  s = ""
  s += indent
  s += end_string
  output.puts s
  return self
end

#get_c_stringsObject Also known as: get_cl_strings, get_cuda_strings



14
15
16
17
# File 'lib/BOAST/Language/While.rb', line 14

def get_c_strings
  return { :while => '"while (#{cond}) {"',
           :end => '"}"' }
end

#get_fortran_stringsObject



19
20
21
22
# File 'lib/BOAST/Language/While.rb', line 19

def get_fortran_strings
  return { :while => '"do while (#{cond})"',
           :end => '"end do"' }
end

#openObject



34
35
36
37
38
39
40
41
# File 'lib/BOAST/Language/While.rb', line 34

def open
  s=""
  s += indent
  s += to_s
  output.puts s
  increment_indent_level
  return self
end

#pr(*args) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/BOAST/Language/While.rb', line 43

def pr(*args)
  args = @args if args.length == 0 and @args
  open
  if @block then
    @block.call(*args)
    close
  end
  return self
end

#to_sObject



30
31
32
# File 'lib/BOAST/Language/While.rb', line 30

def to_s
  return while_string(@condition)
end