StringConcat

Concatenation of two strings.

Declaration

Sintaxe

StringConcat(expr left, expr right, ttype type, expr? value)

Argumentos

Argument

Descrição

left

the left operand.

right

the right operand.

type

the type of the result. Its length is the sum of the operand lengths when both are known.

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

a // b. The result is a new value; neither operand is modified.

Exemplos

(StringConcat
  :left (Var
    :v (SymbolRef 1 "s")
  )
  :right (StringConstant
    :s "!"
    :type (String
      :kind 1
      :len (IntegerConstant
        :n 1
        :type (Integer
          :kind 4
        )
        :intboz_type :Decimal
      )
      :len_kind :ExpressionLength
      :physical_type :DescriptorString
    )
  )
  :type (String
    :kind 1
    :len nil
    :len_kind :DeferredLength
    :physical_type :DescriptorString
  )
  :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 []
            )
            "c" (Variable
              :parent_symtab 1
              :name "c"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (String
                :kind 1
                :len (IntegerConstant
                  :n 1
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
                :len_kind :ExpressionLength
                :physical_type :DescriptorString
              )
              :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 []
            )
            "n" (Variable
              :parent_symtab 1
              :name "n"
              :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 []
            )
            "s" (Variable
              :parent_symtab 1
              :name "s"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (String
                :kind 1
                :len (IntegerConstant
                  :n 5
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
                :len_kind :ExpressionLength
                :physical_type :DescriptorString
              )
              :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 []
            )
            "t" (Variable
              :parent_symtab 1
              :name "t"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Allocatable
                :type (String
                  :kind 1
                  :len nil
                  :len_kind :DeferredLength
                  :physical_type :DescriptorString
                )
              )
              :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 "s")
            )
            :value (StringConstant
              :s "hello"
              :type (String
                :kind 1
                :len (IntegerConstant
                  :n 5
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
                :len_kind :ExpressionLength
                :physical_type :DescriptorString
              )
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "t")
            )
            :value (StringConcat
              :left (Var
                :v (SymbolRef 1 "s")
              )
              :right (StringConstant
                :s "!"
                :type (String
                  :kind 1
                  :len (IntegerConstant
                    :n 1
                    :type (Integer
                      :kind 4
                    )
                    :intboz_type :Decimal
                  )
                  :len_kind :ExpressionLength
                  :physical_type :DescriptorString
                )
              )
              :type (String
                :kind 1
                :len nil
                :len_kind :DeferredLength
                :physical_type :DescriptorString
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "t")
            )
            :value (StringRepeat
              :left (Var
                :v (SymbolRef 1 "s")
              )
              :right (IntegerConstant
                :n 3
                :type (Integer
                  :kind 4
                )
                :intboz_type :Decimal
              )
              :type (String
                :kind 1
                :len nil
                :len_kind :DeferredLength
                :physical_type :DescriptorString
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "n")
            )
            :value (StringLen
              :arg (Var
                :v (SymbolRef 1 "s")
              )
              :type (Integer
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "c")
            )
            :value (StringItem
              :arg (Var
                :v (SymbolRef 1 "s")
              )
              :idx (IntegerConstant
                :n 1
                :type (Integer
                  :kind 4
                )
                :intboz_type :Decimal
              )
              :type (String
                :kind 1
                :len (IntegerConstant
                  :n 1
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
                :len_kind :ExpressionLength
                :physical_type :DescriptorString
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "t")
            )
            :value (StringSection
              :arg (Var
                :v (SymbolRef 1 "s")
              )
              :start (IntegerConstant
                :n 2
                :type (Integer
                  :kind 4
                )
                :intboz_type :Decimal
              )
              :end (IntegerConstant
                :n 4
                :type (Integer
                  :kind 4
                )
                :intboz_type :Decimal
              )
              :step (IntegerConstant
                :n 1
                :type (Integer
                  :kind 4
                )
                :intboz_type :Decimal
              )
              :type (String
                :kind 1
                :len (IntegerConstant
                  :n 3
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
                :len_kind :ExpressionLength
                :physical_type :DescriptorString
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "b")
            )
            :value (StringCompare
              :left (Var
                :v (SymbolRef 1 "s")
              )
              :op :Eq
              :right (StringConstant
                :s "world"
                :type (String
                  :kind 1
                  :len (IntegerConstant
                    :n 5
                    :type (Integer
                      :kind 4
                    )
                    :intboz_type :Decimal
                  )
                  :len_kind :ExpressionLength
                  :physical_type :DescriptorString
                )
              )
              :type (Logical
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "b")
            )
            :value (StringContains
              :substr (StringConstant
                :s "ell"
                :type (String
                  :kind 1
                  :len (IntegerConstant
                    :n 3
                    :type (Integer
                      :kind 4
                    )
                    :intboz_type :Decimal
                  )
                  :len_kind :ExpressionLength
                  :physical_type :DescriptorString
                )
              )
              :str (Var
                :v (SymbolRef 1 "s")
              )
              :type (Logical
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "n")
            )
            :value (StringOrd
              :arg (Var
                :v (SymbolRef 1 "c")
              )
              :type (Integer
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "c")
            )
            :value (StringChr
              :arg (IntegerConstant
                :n 65
                :type (Integer
                  :kind 4
                )
                :intboz_type :Decimal
              )
              :type (String
                :kind 1
                :len (IntegerConstant
                  :n 1
                  :type (Integer
                    :kind 4
                  )
                  :intboz_type :Decimal
                )
                :len_kind :ExpressionLength
                :physical_type :DescriptorString
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "n")
            )
            :value (Ichar
              :arg (Var
                :v (SymbolRef 1 "c")
              )
              :type (Integer
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
          (Assignment
            :target (Var
              :v (SymbolRef 1 "n")
            )
            :value (Iachar
              :arg (Var
                :v (SymbolRef 1 "c")
              )
              :type (Integer
                :kind 4
              )
              :value nil
            )
            :overloaded nil
            :realloc_lhs false
            :move_allocation false
          )
        ]
      )
    }
  )
  :items []
)

Veja Também

StringRepeat, StringSection, OverloadedStringConcat