Block

The scope of a block construct.

Declaration

Sintaxe

Block(symbol_table symtab, identifier name, stmt* body)

Argumentos

Argument

Descrição

symtab

the symbol table of the construct, holding the variables it declares.

name

a generated name for the block, unique in its scope.

body

the statements of the construct.

Valores de retorno

Nenhum.

Descrição

A block construct declares variables of its own, so like AssociateBlock it is a symbol holding a scope rather than a statement holding a list. BlockCall marks where in the enclosing statement list the block runs.

The variables of the block are ordinary Variable symbols in symtab. They are allocated when the block is entered and are not visible outside it.

Exemplos

An ASR text document that uses it:

(TranslationUnit
  :symtab (SymbolTable
    :id 0
    :symbols {
      "main" (Program
        :symtab (SymbolTable
          :id 1
          :symbols {
            "block" (Block
              :symtab (SymbolTable
                :id 2
                :symbols {
                  "m" (Variable
                    :parent_symtab 2
                    :name "m"
                    :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 "block"
              :body [
                (Assignment
                  :target (Var
                    :v (SymbolRef 2 "m")
                  )
                  :value (IntegerConstant
                    :n 3
                    :type (Integer
                      :kind 4
                    )
                    :intboz_type :Decimal
                  )
                  :overloaded nil
                  :realloc_lhs false
                  :move_allocation false
                )
                (Assignment
                  :target (Var
                    :v (SymbolRef 1 "x")
                  )
                  :value (Var
                    :v (SymbolRef 2 "m")
                  )
                  :overloaded nil
                  :realloc_lhs false
                  :move_allocation false
                )
              ]
            )
            "x" (Variable
              :parent_symtab 1
              :name "x"
              :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 [
          (BlockCall
            :label -1
            :m (SymbolRef 1 "block")
          )
        ]
      )
    }
  )
  :items []
)

Veja Também

BlockCall, AssociateBlock, Variable