Class: BOAST::Dimension
- Inherits:
-
Object
- Object
- BOAST::Dimension
- Extended by:
- Functor
- Includes:
- Inspectable, PrivateStateAccessor
- Defined in:
- lib/BOAST/Language/Variable.rb
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#val1 ⇒ Object
readonly
Returns the value of attribute val1.
-
#val2 ⇒ Object
readonly
Returns the value of attribute val2.
Instance Method Summary collapse
-
#finish ⇒ Object
Returns the end of the Dimension if the size is known.
-
#initialize(v1 = nil, v2 = nil) ⇒ Dimension
constructor
Creates a new Dimension.
-
#start ⇒ Object
Returns the start of the Dimension as given at initialization or as computed get_array_start.
-
#to_s ⇒ Object
Returns a String representation of the Dimension.
Methods included from Functor
Methods included from Inspectable
Methods included from PrivateStateAccessor
#address_size, #address_size=, #annotate, #annotate=, #annotate?, #annotate_indepth_list, #annotate_indepth_list=, #annotate_level, #annotate_level=, #annotate_list, #annotate_list=, #architecture, #architecture=, #array_start, #array_start=, #chain_code, #chain_code=, #chain_code?, #debug, #debug=, #debug?, #debug_source, #debug_source=, #debug_source?, #decl_module, #decl_module=, #decl_module?, #default_align, #default_align=, #default_int_signed, #default_int_signed=, #default_int_signed?, #default_int_size, #default_int_size=, #default_real_size, #default_real_size=, #disable_openmp, #disable_openmp=, #disable_openmp?, #ffi, #ffi=, #ffi?, #fortran_line_length, #fortran_line_length=, #get_address_size, #get_annotate, #get_annotate_indepth_list, #get_annotate_level, #get_annotate_list, #get_architecture, #get_array_start, #get_chain_code, #get_debug, #get_debug_source, #get_decl_module, #get_default_align, #get_default_int_signed, #get_default_int_size, #get_default_real_size, #get_disable_openmp, #get_ffi, #get_fortran_line_length, #get_indent_increment, #get_indent_level, #get_keep_temp, #get_lang, #get_model, #get_optimizer_log, #get_optimizer_log_file, #get_output, #get_replace_constants, #get_use_vla, #get_verbose, #indent_increment, #indent_increment=, #indent_level, #indent_level=, #keep_temp, #keep_temp=, #keep_temp?, #lang, #lang=, #model, #model=, #optimizer_log, #optimizer_log=, #optimizer_log?, #optimizer_log_file, #optimizer_log_file=, #output, #output=, #replace_constants, #replace_constants=, #replace_constants?, #set_address_size, #set_annotate, #set_annotate_indepth_list, #set_annotate_level, #set_annotate_list, #set_architecture, #set_array_start, #set_chain_code, #set_debug, #set_debug_source, #set_decl_module, #set_default_align, #set_default_int_signed, #set_default_int_size, #set_default_real_size, #set_disable_openmp, #set_ffi, #set_fortran_line_length, #set_indent_increment, #set_indent_level, #set_keep_temp, #set_lang, #set_model, #set_optimizer_log, #set_optimizer_log_file, #set_output, #set_replace_constants, #set_use_vla, #set_verbose, #use_vla, #use_vla=, #use_vla?, #verbose, #verbose=, #verbose?
Constructor Details
#initialize ⇒ Dimension #initialize(size) ⇒ Dimension #initialize(lower, upper) ⇒ Dimension
Creates a new BOAST::Dimension.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/BOAST/Language/Variable.rb', line 23 def initialize(v1=nil,v2=nil) if v1 then if v2 then begin @size = v2-v1+1 rescue @size = Expression::new(Substraction, v2, v1) + 1 end else @size = v1 end else @size = nil end @val1 = v1 @val2 = v2 end |
Instance Attribute Details
#size ⇒ Object (readonly)
Returns the value of attribute size.
11 12 13 |
# File 'lib/BOAST/Language/Variable.rb', line 11 def size @size end |
#val1 ⇒ Object (readonly)
Returns the value of attribute val1.
9 10 11 |
# File 'lib/BOAST/Language/Variable.rb', line 9 def val1 @val1 end |
#val2 ⇒ Object (readonly)
Returns the value of attribute val2.
10 11 12 |
# File 'lib/BOAST/Language/Variable.rb', line 10 def val2 @val2 end |
Instance Method Details
#finish ⇒ Object
Returns the end of the BOAST::Dimension if the size is known.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/BOAST/Language/Variable.rb', line 64 def finish if @val2 then return @val2 elsif @size if 0.equal?(get_array_start) then return @size - 1 else if 1.equal?(get_array_start) then return @size else begin return @size + get_array_start - 1 rescue return Expression::new(Addition, @size, get_array_start) - 1 end end end else return nil end end |
#start ⇒ Object
Returns the start of the BOAST::Dimension as given at initialization or as computed BOAST.get_array_start.
55 56 57 58 59 60 61 |
# File 'lib/BOAST/Language/Variable.rb', line 55 def start if @val2 then return @val1 else return get_array_start end end |
#to_s ⇒ Object
Returns a String representation of the BOAST::Dimension
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/BOAST/Language/Variable.rb', line 42 def to_s if lang == FORTRAN and @val2 then return "#{@val1}:#{@val2}" elsif lang == FORTRAN and size.nil? return "*" elsif lang == FORTRAN and get_array_start != 1 then return "#{get_array_start}:#{@size-(1+get_array_start)}" else return @size.to_s end end |