TypeInquiry

A question about a type rather than about a value.

Declaration

Syntax

TypeInquiry(int inquiry_id, ttype arg_type, expr? arg, ttype type,
    expr value)

Arguments

Argument

Description

inquiry_id

which inquiry this is, as the integer id of the inquiry registry.

arg_type

the type being asked about.

arg

the expression the type was taken from, when there was one; it is not evaluated.

type

the type of the result.

value

the answer. It is always known at compile time, so unlike most expressions this member is required.

Return values

The value of the expression.

Description

kind(x), huge(x), epsilon(x) and the rest ask about the type of their argument, not about its value. The argument is kept in arg for diagnostics and unparsing, but it is not evaluated, and the answer is already in value.

Examples

(TypeInquiry
  :inquiry_id 1
  :arg_type (Real
    :kind 4
  )
  :arg (Var
    :v (SymbolRef 1 "x")
  )
  :type (Integer
    :kind 4
  )
  :value (IntegerConstant
    :n 4
    :type (Integer
      :kind 4
    )
    :intboz_type :Decimal
  )
)

It comes from this complete ASR text document:

(TranslationUnit
  :symtab (SymbolTable
    :id 0
    :symbols {
      "main" (Program
        :symtab (SymbolTable
          :id 1
          :symbols {
            "a" (Variable
              :parent_symtab 1
              :name "a"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Array
                :type (Integer
                  :kind 4
                )
                :dims [
                  (dimension
                    :start (IntegerConstant
                      :n 1
                      :type (Integer
                        :kind 4
                      )
                      :intboz_type :Decimal
                    )
                    :length (IntegerConstant
                      :n 3
                      :type (Integer
                        :kind 4
                      )
                      :intboz_type :Decimal
                    )
                  )
                ]
                :physical_type :FixedSizeArray
                :memory_space :Global
              )
              :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 []
            )
            "b" (Variable
              :parent_symtab 1
              :name "b"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Logical
                :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 []
            )
            "c" (Variable
              :parent_symtab 1
              :name "c"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Allocatable
                :type (Array
                  :type (Integer
                    :kind 4
                  )
                  :dims [
                    (dimension
                      :start nil
                      :length nil
                    )
                  ]
                  :physical_type :DescriptorArray
                  :memory_space :Global
                )
              )
              :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 []
            )
            "i" (Variable
              :parent_symtab 1
              :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 []
            )
            "x" (Variable
              :parent_symtab 1
              :name "x"
              :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 []
            )
            "y" (Variable
              :parent_symtab 1
              :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 "main"
        :dependencies []
        :body [
          (Assignment
            :target (Var
              :v (SymbolRef 1 "y")
            )
            :value (IntrinsicElementalFunction
              :intrinsic_id 3
              :args [
                (Var
                  :v (SymbolRef 1 "x")
                )
              ]
              :overload_id 0
              :type (Real
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "i")
            )
            :value (IntrinsicArrayFunction
              :arr_intrinsic_id 14
              :args [
                (ArrayPhysicalCast
                  :arg (Var
                    :v (SymbolRef 1 "a")
                  )
                  :old :FixedSizeArray
                  :new :DescriptorArray
                  :type (Array
                    :type (Integer
                      :kind 4
                    )
                    :dims [
                      (dimension
                        :start (IntegerConstant
                          :n 1
                          :type (Integer
                            :kind 4
                          )
                          :intboz_type :Decimal
                        )
                        :length (IntegerConstant
                          :n 3
                          :type (Integer
                            :kind 4
                          )
                          :intboz_type :Decimal
                        )
                      )
                    ]
                    :physical_type :DescriptorArray
                    :memory_space :Global
                  )
                  :value nil
                )
              ]
              :overload_id 0
              :type (Integer
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "b")
            )
            :value (IntrinsicImpureFunction
              :impure_intrinsic_id 2
              :args [
                (Var
                  :v (SymbolRef 1 "c")
                )
              ]
              :overload_id 0
              :type (Logical
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "i")
            )
            :value (TypeInquiry
              :inquiry_id 1
              :arg_type (Real
                :kind 4
              )
              :arg (Var
                :v (SymbolRef 1 "x")
              )
              :type (Integer
                :kind 4
              )
              :value (IntegerConstant
                :n 4
                :type (Integer
                  :kind 4
                )
                :intboz_type :Decimal
              )
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
        ]
      )
    }
  )
  :items []
)

See Also

IntrinsicElementalFunction, SizeOfType, kinds