Class: FloatVal
Overview
Instance Method Summary
collapse
Methods inherited from BaseVal
#&, #<<, #>>, #^, #lAND, #lOR, #not, #unsupport, #|, #~@
Methods inherited from Node
#cdl_error, #cdl_error2, #cdl_error3, #cdl_info, #cdl_info2, #cdl_warning, #cdl_warning2, #get_locale, #locale_str, #set_locale
Constructor Details
#initialize(val) ⇒ FloatVal
517
518
519
520
|
# File 'lib/tecsgen/core/value.rb', line 517
def initialize(val)
super()
@val = val.to_f
end
|
Instance Method Details
543
544
545
546
547
548
549
550
|
# File 'lib/tecsgen/core/value.rb', line 543
def %(val)
v2 = val.to_f
if v2 == 0.0
cdl_error("V1018 % : divieded by zero")
return FloatVal.new(1.0)
end
return FloatVal.new(@val.to_f % v2)
end
|
530
531
532
|
# File 'lib/tecsgen/core/value.rb', line 530
def *(val)
FloatVal.new(@val * val.to_f)
end
|
552
553
554
|
# File 'lib/tecsgen/core/value.rb', line 552
def +(val)
FloatVal.new(@val + val.to_f)
end
|
526
527
528
|
# File 'lib/tecsgen/core/value.rb', line 526
def +@
self
end
|
556
557
558
|
# File 'lib/tecsgen/core/value.rb', line 556
def -(val)
FloatVal.new(@val - val.to_f)
end
|
522
523
524
|
# File 'lib/tecsgen/core/value.rb', line 522
def -@
FloatVal.new(- @val)
end
|
534
535
536
537
538
539
540
541
|
# File 'lib/tecsgen/core/value.rb', line 534
def /(val)
v2 = val.to_f
if v2 == 0.0
cdl_error("V1017 / : divieded by zero")
return FloatVal.new(1.0)
end
return FloatVal.new(@val.to_f / v2)
end
|
564
565
566
|
# File 'lib/tecsgen/core/value.rb', line 564
def <(val)
BoolVal.new(@val < val.to_f)
end
|
572
573
574
|
# File 'lib/tecsgen/core/value.rb', line 572
def <=(val)
BoolVal.new(@val <= val.to_f)
end
|
560
561
562
|
# File 'lib/tecsgen/core/value.rb', line 560
def >(val)
BoolVal.new(@val > val.to_f)
end
|
568
569
570
|
# File 'lib/tecsgen/core/value.rb', line 568
def >=(val)
BoolVal.new(@val >= val.to_f)
end
|
#cast(type) ⇒ Object
584
585
586
587
588
589
590
591
592
593
594
595
|
# File 'lib/tecsgen/core/value.rb', line 584
def cast(type)
t = type.get_original_type
if t.is_a? IntType
val = t.check_and_clip(@val, :FloatType)
return IntegerVal.new(val)
elsif t.is_a? FloatType
return self
else
cdl_error("V1019 floating value cannot cast to $1", type)
return self
end
end
|
576
577
578
|
# File 'lib/tecsgen/core/value.rb', line 576
def eq(val)
BoolVal.new(@val == val.to_f)
end
|
580
581
582
|
# File 'lib/tecsgen/core/value.rb', line 580
def neq(val)
BoolVal.new(@val != val.to_f)
end
|
597
598
599
600
|
# File 'lib/tecsgen/core/value.rb', line 597
def to_b
cdl_error("V1020 convert floating value to bool without cast")
@val.to_i
end
|
611
612
613
|
# File 'lib/tecsgen/core/value.rb', line 611
def to_f
@val
end
|
602
603
604
605
|
# File 'lib/tecsgen/core/value.rb', line 602
def to_i
cdl_error("V1021 convert floating value to integer without cast")
@val.to_i
end
|
607
608
609
|
# File 'lib/tecsgen/core/value.rb', line 607
def to_s
@val.to_s
end
|