Version 1 (modified by manualwiki, 10 years ago) (diff) |
---|
Function parameter entity
Function parameter entities are almost identical to Expression entities. In fact they are represented and handled internally as expressions. The only difference is that the type selector has been introduced which can be used to get the assigned types of the parameter according to the "-spec" specification of the function.
Initial selector
Please note that there is no initial selector provided for this entity. An equivalent expression to get the function parameter indicated by the position would be the following: @expr.fundef.parameters[index in @expr.index]
Selectors
Although all selectors and properties of the expression entity are available, the following ones might be useful when handling parameters:
The type of returned entities are indicated in parentheses for each selector.
- type (type): return the assigned types of the parameter according to the "-spec" specification of the function having this parameter.
- fundef (function): returns the function entity which contains the parameter.
- vars (variable): returns every variable entity referred in the expression of the parameter.
- records (record): returns every record entity referred in the expression of the parameter.
- sub (expression): returns the set of expressions that are nested in the expression of the parameter in any depth.
- file (file): returns the file entity where the parameter is located.
- origin (expression): returns the origin of the parameter's value determined by data-flow analysis.
- reach (expression): returns the places where the parameter's value is copied, determined by data-flow analysis.
Properties
- value: returns the value of the parameter.
- class (atom): returns the class of the parameter: it can be either expr (stands for single expressions) or pattern.
- index (int): returns the index of the expression in the containing expression list.