TypeInquiry

An expr node, which is used to represent the Inquiry intrinsic function whose value is computed based on the argument type.

声明

语法

TypeInquiry(int inquiry_id, ttype arg_type, expr? arg, ttype type, expr value)

参数

Argument Name

Argument Description

inquiry_id

Function unique ID

arg_type

argument type

arg

argument passed

type

output type

value

compile time value

返回值

The return value is the expression that the TypeInquiry represents.

描述

TypeInquiry is used to represent the Inquiry function. This node accepts exactly one ttype as it’s only argument (arg_type), and it returns a value depending on inquiry_id of ttype type. Since the type arg_type is known at compile time, also the compile time value is always present in value. There is an optional argument arg that specifies the variable used in the frontend language (used in LFortran, but not present in LPython/NumPy).

Here a list of inquiry_id that we support so far

Inquiry function

Output

Output type

Epsilon

smallest number E

arg_type

Huge

largest number

arg_type

Precision

decimal precision

int32

Radix

base of a numeric model

int32

Range

decimal exponent range

int32

Rank

rank of a data object

int32

Tiny

smallest positive number

arg_type

Note: All the functions output are computed based on the arg_type

类型

The arg_type and type vary for each inquiry_id signature. The output is either the default integer or the same as the argument type.

示例

The following example code creates TypeInquiry ASR node:

print *, tiny(5.0)

ASR:

(Print
    [(TypeInquiry
        Tiny
        (Real 4)
        (RealConstant
            5.000000
            (Real 4)
        )
        (Real 4)
        (RealConstant
            0.000000
            (Real 4)
        )
    )]
    ()
    ()
)

也可以看看

IntrinsicFunction