StructInstanceMember

A component of a derived type object.

Declaration

Syntax

StructInstanceMember(expr v, symbol m, ttype type, expr? value)

Arguments

Argument

Description

v

the object.

m

the component’s Variable symbol, owned by the type’s symbol table.

type

the type of the component.

value

the compile time value of the expression, when the frontend could fold it; nil otherwise.

Return values

The value of the expression.

Description

p%x. The component is named by its symbol rather than by a string, so a rename or a shadowed name cannot make the reference ambiguous.

Nested components are nested nodes: a%b%c is a StructInstanceMember of a StructInstanceMember.

Examples

(StructInstanceMember
  :v (Var
    :v (SymbolRef 3 "p")
  )
  :m (SymbolRef 2 "x")
  :type (Integer
    :kind 4
  )
  :value nil
)

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

StructStaticMember, Struct, Var, UnionInstanceMember