LogicalConstant

A logical literal.

Declaration

Sintaxe

LogicalConstant(bool value, ttype type)

Argumentos

Argument

Descrição

value

true or false.

type

the logical type, which fixes the kind and therefore the storage size.

Valores de retorno

The value of the expression.

Descrição

The default logical kind is 4, matching the default integer kind, so a logical occupies the same storage as an integer unless another kind is asked for.

Exemplos

(LogicalConstant
  :value true
  :type (Logical
    :kind 4
  )
)

It comes from this complete ASR text document:

(TranslationUnit
  :symtab (SymbolTable
    :id 0
    :symbols {
      "main" (Program
        :symtab (SymbolTable
          :id 1
          :symbols {
            "p" (Variable
              :parent_symtab 1
              :name "p"
              :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 []
            )
            "q" (Variable
              :parent_symtab 1
              :name "q"
              :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 []
            )
          }
        )
        :name "main"
        :dependencies []
        :body [
          (Assignment
            :target (Var
              :v (SymbolRef 1 "p")
            )
            :value (LogicalConstant
              :value true
              :type (Logical
                :kind 4
              )
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "q")
            )
            :value (LogicalNot
              :arg (Var
                :v (SymbolRef 1 "p")
              )
              :type (Logical
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "q")
            )
            :value (LogicalBinOp
              :left (Var
                :v (SymbolRef 1 "p")
              )
              :op :Or
              :right (LogicalConstant
                :value false
                :type (Logical
                  :kind 4
                )
              )
              :type (Logical
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "q")
            )
            :value (LogicalCompare
              :left (Var
                :v (SymbolRef 1 "p")
              )
              :op :Eq
              :right (Var
                :v (SymbolRef 1 "q")
              )
              :type (Logical
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
        ]
      )
    }
  )
  :items []
)

Veja Também

IntegerConstant, Logical, LogicalBinOp