IntegerCompare

A comparison of two integers.

Declaration

Sintaxe

IntegerCompare(expr left, cmpop op, expr right, ttype type,
    expr? value)

Argumentos

Argument

Descrição

left

the left operand.

op

the comparison; see cmpop.

right

the right operand.

type

the logical type of the result.

value

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

Valores de retorno

The value of the expression.

Descrição

The operands are of the same integer type and the result is logical, so the type of the node is a Logical, not an integer.

Exemplos

(IntegerCompare
  :left (Var
    :v (SymbolRef 1 "i")
  )
  :op :Lt
  :right (Var
    :v (SymbolRef 1 "j")
  )
  :type (Logical
    :kind 4
  )
  :value nil
)

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 []
            )
            "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 []
            )
            "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 []
            )
          }
        )
        :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
          )
          (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
          )
          (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
          )
          (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
          )
          (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
          )
          (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
          )
        ]
      )
    }
  )
  :items []
)

Veja Também

cmpop, RealCompare, IntegerBinOp