IntegerConstant

An integer literal.

Declaración

Sintaxis

IntegerConstant(int n, ttype type, integerboz intboz_type)

Argumentos

Argument

Descripción

n

the value.

type

the integer type, which fixes the kind and therefore the range of the constant.

intboz_type

how the constant was written: Decimal, or Binary, Octal or Hex for a BOZ literal; see integerboz.

Valores devueltos

The value of the expression.

Descripción

The value is stored as a number, not as text, so a BOZ literal such as z'ff' is an IntegerConstant with n equal to 255. intboz_type records only how it was spelled, which matters for diagnostics and for unparsing but not for code generation.

An IntegerConstant has no value member because it is its own value.

Ejemplos

(IntegerConstant
  :n 255
  :type (Integer
    :kind 4
  )
  :intboz_type :Hex
)

It comes from this complete ASR text document:

(TranslationUnit
  :symtab (SymbolTable
    :id 0
    :symbols {
      "main" (Program
        :symtab (SymbolTable
          :id 1
          :symbols {
            "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 []
              :common_block nil
            )
            "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 []
              :common_block nil
            )
            "j" (Variable
              :parent_symtab 1
              :name "j"
              :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 []
              :common_block nil
            )
          }
        )
        :name "main"
        :dependencies []
        :body [
          (Assignment
            :target (Var
              :v (SymbolRef 1 "i")
            )
            :value (IntegerConstant
              :n 255
              :type (Integer
                :kind 4
              )
              :intboz_type :Hex
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
            :new_target false
            :new_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "j")
            )
            :value (IntegerBinOp
              :left (Var
                :v (SymbolRef 1 "i")
              )
              :op :Mul
              :right (IntegerConstant
                :n 2
                :type (Integer
                  :kind 4
                )
                :intboz_type :Decimal
              )
              :type (Integer
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
            :new_target false
            :new_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "j")
            )
            :value (IntegerUnaryMinus
              :arg (Var
                :v (SymbolRef 1 "i")
              )
              :type (Integer
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
            :new_target false
            :new_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "j")
            )
            :value (IntegerBitNot
              :arg (Var
                :v (SymbolRef 1 "i")
              )
              :type (Integer
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
            :new_target false
            :new_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "j")
            )
            :value (IntegerBitLen
              :a (Var
                :v (SymbolRef 1 "i")
              )
              :type (Integer
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
            :new_target false
            :new_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "b")
            )
            :value (IntegerCompare
              :left (Var
                :v (SymbolRef 1 "i")
              )
              :op :Lt
              :right (Var
                :v (SymbolRef 1 "j")
              )
              :type (Logical
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
            :new_target false
            :new_allocation false
          )
        ]
        :global_init nil
      )
    }
  )
  :items []
  :global_init nil
)

Ver también

RealConstant, LogicalConstant, integerboz, Integer