class BOAST::While

@!parse module Functors; functorize While; end

Constants

ANNOTATIONS

Attributes

condition[R]

Public Class Methods

new(condition, &block) click to toggle source

Creates a new instance of the While construct. @param [Expression] condition @param [Proc,nil] block if given, will be evaluated when {pr} is called

Calls superclass method BOAST::ControlStructure::new
# File lib/BOAST/Language/While.rb, line 13
def initialize(condition, &block)
  super()
  @condition = condition
  @block = block
end

Public Instance Methods

close() click to toggle source

Closes the While construct (keyword, closing bracket in C like languages). The result is printed to the BOAST output. @return [self]

# File lib/BOAST/Language/While.rb, line 71
def close
  decrement_indent_level      
  s = ""
  s << indent
  s << end_string
  output.puts s
  return self
end
get_cl_strings()
Alias for: get_c_strings
get_cuda_strings()
Alias for: get_c_strings
open() click to toggle source

Opens the While construct (keyword, condition, opening bracket in C like languages). The result is printed to the BOAST output. @return [self]

# File lib/BOAST/Language/While.rb, line 44
def open
  s=""
  s << indent
  s << to_s
  output.puts s
  increment_indent_level
  return self
end
pr(*args, &block) click to toggle source

Prints the While construct to the BOAST output (see {open}). If a block is provided during initialization, it will be printed and the construct will be closed (see {close}). @param [Array<Object>] args any number of arguments to pass to the block @param [Proc] block an optional block to be evaluated. Supersede the one given at initialization @return [self]

# File lib/BOAST/Language/While.rb, line 58
def pr(*args, &block)
  args = @args if args.length == 0 and @args
  block = @block unless block
  open
  if block then
    block.call(*args)
    close
  end
  return self
end
to_s() click to toggle source

Returns a string representation of the While construct.

# File lib/BOAST/Language/While.rb, line 38
def to_s
  return while_string(@condition)
end

Private Instance Methods

get_c_strings() click to toggle source
# File lib/BOAST/Language/While.rb, line 19
def get_c_strings
  return { :while => '"while (#{cond}) {"',
           :end => '"}"' }
end
Also aliased as: get_cl_strings, get_cuda_strings
get_fortran_strings() click to toggle source
# File lib/BOAST/Language/While.rb, line 24
def get_fortran_strings
  return { :while => '"do while (#{cond})"',
           :end => '"end do"' }
end