StructType

The type of a derived type object.

Declaration

Syntax

StructType(ttype* data_member_types, ttype* member_function_types,
    bool is_cstruct, bool is_unlimited_polymorphic)

Arguments

Argument

Description

data_member_types

the types of the data components, in the order the Struct lists them in members.

member_function_types

the types of the type-bound procedures.

is_cstruct

true for a type that must be laid out the way C would lay it out, as for bind(c).

is_unlimited_polymorphic

true for class(*), which may hold a value of any type.

Return values

None. A type is not evaluated.

Description

The definition of a derived type is the Struct symbol; StructType is what a variable of that type has. It carries the component types so that most of what a backend needs is available without following the symbol, and the type_declaration member of the Variable is what names the definition when it is needed.

A polymorphic variable, class(t), has the StructType of t: the dynamic type is a run time property, and SelectType is what examines it.

Examples

(StructType
  :data_member_types [
    (Integer
      :kind 4
    )
    (Real
      :kind 4
    )
  ]
  :member_function_types []
  :is_cstruct false
  :is_unlimited_polymorphic false
)

It comes from this complete ASR text document:

(TranslationUnit
  :symtab (SymbolTable
    :id 0
    :symbols {
      "m" (Module
        :symtab (SymbolTable
          :id 1
          :symbols {
            "point" (Struct
              :symtab (SymbolTable
                :id 2
                :symbols {
                  "x" (Variable
                    :parent_symtab 2
                    :name "x"
                    :dependencies []
                    :intent :Local
                    :symbolic_value nil
                    :value nil
                    :storage :Default
                    :type (Integer
                      :kind 4
                    )
                    :type_declaration nil
                    :abi :Source
                    :access :Public
                    :presence :Required
                    :value_attr false
                    :target_attr false
                    :contiguous_attr false
                    :bindc_name nil
                    :is_volatile false
                    :is_protected false
                    :pass_attr :NotMethod
                    :self_argument nil
                    :codims []
                  )
                  "y" (Variable
                    :parent_symtab 2
                    :name "y"
                    :dependencies []
                    :intent :Local
                    :symbolic_value nil
                    :value nil
                    :storage :Default
                    :type (Real
                      :kind 4
                    )
                    :type_declaration nil
                    :abi :Source
                    :access :Public
                    :presence :Required
                    :value_attr false
                    :target_attr false
                    :contiguous_attr false
                    :bindc_name nil
                    :is_volatile false
                    :is_protected false
                    :pass_attr :NotMethod
                    :self_argument nil
                    :codims []
                  )
                }
              )
              :name "point"
              :struct_signature (StructType
                :data_member_types [
                  (Integer
                    :kind 4
                  )
                  (Real
                    :kind 4
                  )
                ]
                :member_function_types []
                :is_cstruct false
                :is_unlimited_polymorphic false
              )
              :dependencies []
              :members [
                "x"
                "y"
              ]
              :member_functions []
              :abi :Source
              :access :Public
              :is_packed false
              :is_abstract false
              :is_sequence false
              :initializers []
              :alignment nil
              :parent nil
              :kind_params []
            )
          }
        )
        :name "m"
        :parent_module nil
        :dependencies []
        :loaded_from_mod false
        :intrinsic false
        :has_submodules false
      )
      "main" (Program
        :symtab (SymbolTable
          :id 3
          :symbols {
            "i" (Variable
              :parent_symtab 3
              :name "i"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Integer
                :kind 4
              )
              :type_declaration nil
              :abi :Source
              :access :Public
              :presence :Required
              :value_attr false
              :target_attr false
              :contiguous_attr false
              :bindc_name nil
              :is_volatile false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims []
            )
            "p" (Variable
              :parent_symtab 3
              :name "p"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (StructType
                :data_member_types [
                  (Integer
                    :kind 4
                  )
                  (Real
                    :kind 4
                  )
                ]
                :member_function_types []
                :is_cstruct false
                :is_unlimited_polymorphic false
              )
              :type_declaration (SymbolRef 3 "point")
              :abi :Source
              :access :Public
              :presence :Required
              :value_attr false
              :target_attr false
              :contiguous_attr false
              :bindc_name nil
              :is_volatile false
              :is_protected false
              :pass_attr :NotMethod
              :self_argument nil
              :codims []
            )
            "point" (ExternalSymbol
              :parent_symtab 3
              :name "point"
              :external (SymbolRef 1 "point")
              :module_name "m"
              :scope_names []
              :original_name "point"
              :access :Public
            )
          }
        )
        :name "main"
        :dependencies [
          "m"
        ]
        :body [
          (Assignment
            :target (Var
              :v (SymbolRef 3 "p")
            )
            :value (StructConstructor
              :dt_sym (SymbolRef 3 "point")
              :args [
                (call_arg
                  :value (IntegerConstant
                    :n 1
                    :type (Integer
                      :kind 4
                    )
                    :intboz_type :Decimal
                  )
                )
                (call_arg
                  :value (RealConstant
                    :r 2.0
                    :type (Real
                      :kind 4
                    )
                  )
                )
              ]
              :type (StructType
                :data_member_types [
                  (Integer
                    :kind 4
                  )
                  (Real
                    :kind 4
                  )
                ]
                :member_function_types []
                :is_cstruct false
                :is_unlimited_polymorphic false
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 3 "i")
            )
            :value (StructInstanceMember
              :v (Var
                :v (SymbolRef 3 "p")
              )
              :m (SymbolRef 2 "x")
              :type (Integer
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
        ]
      )
    }
  )
  :items []
)

See Also

Struct, StructInstanceMember, StructConstructor, UnionType, SelectType