Class: Rubycc::Type::FloatType
- Inherits:
-
Data
- Object
- Data
- Rubycc::Type::FloatType
- Defined in:
- lib/rubycc/type.rb
Overview
A floating type: float (4 bytes, IEEE754 single precision) or double
(8 bytes, IEEE754 double precision). A single shared instance stands for
each (Type::Float, Type::Double); being a Data, identity and value
comparison coincide, so two doubles name the very same type. long double normalizes to double at parse time (same width here), so no
separate instance exists. #arithmetic? is true — a floating type mixes with
the integer types under the usual arithmetic conversions — while #integer?
is false and #float? true, which is how the generator tells a floating
operand apart to emit the f-prefixed IR (:fadd, :flt, ...) and the
integer/float conversions (:itof / :ftoi / :ftof).
Value representation (see Backend::X86_64): a float value lives in its
virtual-register slot's low 4 bytes as an IEEE754 single-precision bit
pattern, a double in the whole 8-byte slot as a double-precision one; a
float's spare bits 32..63 follow the same indeterminate rule a narrow
integer's do.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
-
#alignment ⇒ Object
A floating type is aligned to its own width: float 4, double 8.
- #arithmetic? ⇒ Boolean
- #array? ⇒ Boolean
- #bool? ⇒ Boolean
- #char? ⇒ Boolean
- #float? ⇒ Boolean
- #function? ⇒ Boolean
- #int? ⇒ Boolean
- #integer? ⇒ Boolean
- #pointer? ⇒ Boolean
- #struct? ⇒ Boolean
- #to_s ⇒ Object
- #void? ⇒ Boolean
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name
234 235 236 |
# File 'lib/rubycc/type.rb', line 234 def name @name end |
#size ⇒ Object (readonly)
Returns the value of attribute size
234 235 236 |
# File 'lib/rubycc/type.rb', line 234 def size @size end |
Instance Method Details
#alignment ⇒ Object
A floating type is aligned to its own width: float 4, double 8.
280 281 282 |
# File 'lib/rubycc/type.rb', line 280 def alignment size end |
#arithmetic? ⇒ Boolean
255 256 257 |
# File 'lib/rubycc/type.rb', line 255 def arithmetic? true end |
#array? ⇒ Boolean
267 268 269 |
# File 'lib/rubycc/type.rb', line 267 def array? false end |
#bool? ⇒ Boolean
263 264 265 |
# File 'lib/rubycc/type.rb', line 263 def bool? false end |
#char? ⇒ Boolean
243 244 245 |
# File 'lib/rubycc/type.rb', line 243 def char? false end |
#float? ⇒ Boolean
259 260 261 |
# File 'lib/rubycc/type.rb', line 259 def float? true end |
#function? ⇒ Boolean
275 276 277 |
# File 'lib/rubycc/type.rb', line 275 def function? false end |
#int? ⇒ Boolean
239 240 241 |
# File 'lib/rubycc/type.rb', line 239 def int? false end |
#integer? ⇒ Boolean
251 252 253 |
# File 'lib/rubycc/type.rb', line 251 def integer? false end |
#pointer? ⇒ Boolean
235 236 237 |
# File 'lib/rubycc/type.rb', line 235 def pointer? false end |
#struct? ⇒ Boolean
271 272 273 |
# File 'lib/rubycc/type.rb', line 271 def struct? false end |
#to_s ⇒ Object
284 285 286 |
# File 'lib/rubycc/type.rb', line 284 def to_s name end |
#void? ⇒ Boolean
247 248 249 |
# File 'lib/rubycc/type.rb', line 247 def void? false end |