Method: FloatType#check_init
- Defined in:
- lib/tecsgen/core/types.rb
#check_init(locale, ident, initializer, kind, attribute = nil) ⇒ Object
mikan Float 型の C_EXP 対応 (generate.rb にも変更必要)
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 |
# File 'lib/tecsgen/core/types.rb', line 640 def check_init(locale, ident, initializer, kind, attribute = nil) # 型に対する初期値に誤りがあれば、エラー文字列を返す val = initializer if val.instance_of?(Expression) val = val.eval_const2(nil, attribute) # 評価の結果 C_EXP や Array となる可能性がある end if val.instance_of? Token # val が Token の場合 == の右辺が String だとエラーを起こす cdl_error2(locale, "T1018 $1: $2: not number", ident, val) return elsif val.instance_of? Array cdl_error2(locale, "T1020 $1: unsuitable initializer for scalar type", ident) return elsif val.instance_of? C_EXP return elsif val.nil? cdl_error2(locale, "T1019 $1: initializer is not constant", ident) return elsif !val.is_a?(IntegerVal) && !val.is_a?(FloatVal) cdl_error2(locale, "T1037 $1: not number", ident) return end # else # cdl_error2( locale, "T1020 $1: unsuitable initializer for scalar type" , ident ) # return # end return end |