- Timestamp:
- Jul 3, 2020, 7:19:17 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/asp3_dcre/tecsgen/tecslib/core/types.rb
r321 r429 4 4 # Generator for TOPPERS Embedded Component System 5 5 # 6 # Copyright (C) 2008-201 5by TOPPERS Project6 # Copyright (C) 2008-2017 by TOPPERS Project 7 7 #-- 8 8 # 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ … … 629 629 630 630 class FloatType < Type 631 # @bit_size:: 32, 64, (80), -32, -64 631 # @bit_size:: 32, 64, (80), -32, -64, -128 632 632 633 633 def initialize( bit_size ) … … 684 684 when -64 685 685 str = "#{str}double" 686 when -128 687 str = "#{str}long double" 686 688 end 687 689 return str … … 734 736 # @b_has_sized_pointer_member:: bool : メンバにポインタ型がある 735 737 # @b_has_unsized_string_member:: bool : メンバにポインタ型がある 738 # @b_hasTag:: bool : タグがある 736 739 # @member_types_symbol:: Symbol : tag が無い時のみ設定 (それ以外では nil) 737 740 … … 746 749 super() 747 750 @tag = tag 751 if tag then 752 @b_hasTag = true 753 else 754 @b_hasTag = false 755 end 748 756 @@structtype_current_sp += 1 749 757 @@structtype_current_stack[@@structtype_current_sp] = self … … 918 926 str = super 919 927 920 if @ tag then928 if @b_hasTag then 921 929 # typedef struct tag StructType; の形式の場合 922 930 # struct の本体は、別に生成される 923 return "#{str}struct #{@tag} 931 return "#{str}struct #{@tag}" 924 932 925 933 else 926 934 # typedef struct { int a; } StructType; の形式の場合 927 str += "struct { \n"935 str += "struct {" 928 936 @members_decl.get_items.each{ |i| 929 str += sprintf( " %-8s %s%s;\n", "#{i.get_type.get_type_str}", "#{i.get_name}", "#{i.get_type.get_type_str_post}" )937 str += sprintf( "%s %s%s;", "#{i.get_type.get_type_str}", "#{i.get_name}", "#{i.get_type.get_type_str_post}" ) 930 938 } 931 939 str += "} " … … 1267 1275 def check_init( locale, ident, initializer, kind, attribute = nil ) 1268 1276 if ( initializer.instance_of?( Array ) ) then 1277 # 要素数が指定されている場合、初期化要素数をチェック 1278 if @subscript then 1279 n_sub = @subscript.eval_const( nil ) 1280 if n_sub then 1281 if initializer.length > n_sub then 1282 cdl_error2( locale, "T9999 $1: too many initializer, $2 for $3" , ident, initializer.length, n_sub ) 1283 end 1284 end 1285 end 1269 1286 index = 0 1270 1287 initializer.each{ |i| … … 1543 1560 # 動的結合で渡すデスクリプタ型 1544 1561 class DescriptorType < Type 1545 # @sinagure_nsp::NamespacePath 1562 # @sinagure_nsp::NamespacePath 1563 1564 @@descriptors = {} 1546 1565 1547 1566 def initialize( signature_nsp ) 1548 1567 @signature_nsp = signature_nsp 1549 obj = Namespace.find signature_nsp 1550 if ! obj.kind_of? Signature then 1551 cdl_error( "T9999 '$1': not signature or not found", signature_nsp.to_s ) 1552 else 1553 if obj.has_descriptor? then 1554 cdl_error( "T9999 '$1': has Desicrptor in function parameter", signature_nsp.to_s ) 1555 end 1556 end 1568 # check_signature ## 1569 @@descriptors[ self ] = false 1557 1570 end 1558 1571 1559 1572 def get_type_str 1560 "Descriptor( #{@signature_nsp. to_s} )"1573 "Descriptor( #{@signature_nsp.get_global_name} )" 1561 1574 end 1562 1575 … … 1581 1594 end 1582 1595 1596 def self.check_signature 1597 @@descriptors.each{ |desc, val| 1598 if val != true then 1599 desc.check_signature 1600 @@descriptors[ desc ] = true 1601 end 1602 } 1603 end 1604 1605 def check_signature 1606 # p "Desc #{@signature_nsp.to_s}" 1607 obj = Namespace.find @signature_nsp 1608 if ! obj.kind_of? Signature then 1609 cdl_error( "T9999 '$1': not signature or not found", @signature_nsp.to_s ) 1610 else 1611 if obj.has_descriptor? then 1612 # cdl_error( "T9999 '$1': has Descriptor in function parameter", @signature_nsp.to_s ) 1613 end 1614 # @signature_nsp = obj.get_namespace_path 1615 end 1616 end 1617 1583 1618 #== DescriptorType# 1584 # 意味解析段階では nil が返される可能性に注意1585 1619 def get_signature 1586 1620 Namespace.find @signature_nsp
Note:
See TracChangeset
for help on using the changeset viewer.