IntrinsicImpureSubroutine

A call to an intrinsic subroutine.

Declaration

Syntax

IntrinsicImpureSubroutine(int sub_intrinsic_id, expr* args,
    int overload_id)

Arguments

Argument

Description

sub_intrinsic_id

which intrinsic subroutine this is, as the integer id of the intrinsic registry.

args

the actual arguments.

overload_id

which signature of the intrinsic was selected, when it has several.

Return values

None.

Description

Intrinsic subroutines such as random_number and date_and_time are not symbols: there is no Function to point at, so the call names the intrinsic by id instead.

A later pass either lowers the call into ASR of its own or leaves it for the backend, which is why the id, and not a name, is what is stored: the registry in src/libasr/pass/intrinsic_function_registry.h owns the mapping.

Examples

(IntrinsicImpureSubroutine
  :sub_intrinsic_id 0
  :args [
    (Var
      :v (SymbolRef 1 "x")
    )
  ]
  :overload_id 0
)

It comes from this complete ASR text document:

(TranslationUnit
  :symtab (SymbolTable
    :id 0
    :symbols {
      "main" (Program
        :symtab (SymbolTable
          :id 1
          :symbols {
            "x" (Variable
              :parent_symtab 1
              :name "x"
              :dependencies []
              :intent :Local
              :symbolic_value nil
              :value nil
              :storage :Default
              :type (Real
                :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 [
          (IntrinsicImpureSubroutine
            :sub_intrinsic_id 0
            :args [
              (Var
                :v (SymbolRef 1 "x")
              )
            ]
            :overload_id 0
          )
        ]
      )
    }
  )
  :items []
)

See Also

IntrinsicElementalFunction, IntrinsicImpureFunction, SubroutineCall