concepts.dsl.dsl_functions.Function#

class Function[source]#

Bases: object

A function object holds a function type and an optional overridden __call__.

The function object holds an additional field called overridden_call, which isa callable function. This field is used to override the __call__ method of the function object.

By default, the __call__ function returns a FunctionApplication object, which contains the name of the function and a list of arguments. However, when overridden_call is set, the __call__ method will return the result of calling overridden_call with the arguments.

Methods

from_function(function[, implementation, sig])

Create a function object from an actual Python function.

get_overridden_call([ftype_index])

Get the overridden call function.

get_sub_function(ftype_index)

partial(*args[, execute_fully_bound_functions])

remap_arguments(remapping)

Generate a new Function object with a different argument order.

set_function_body(function_body)

Set the function body.

set_function_name(function_name)

Set the function name.

Attributes

__call__(*args, **kwargs)[source]#

Call self as a function.

__init__(name, ftype, derived_expression=None, overridden_call=None, resolved_from=None, function_body=None)[source]#
Parameters:
__new__(**kwargs)#
classmethod from_function(function, implementation=True, sig=None)[source]#

Create a function object from an actual Python function.

Parameters:
  • function (Callable) – The function.

  • implementation (bool) – Whether the function is an implementation. Defaults to True.

  • sig (Signature | None) – The signature of the function. Defaults to None.

get_overridden_call(ftype_index=None)[source]#

Get the overridden call function.

Parameters:

ftype_index (int | None)

Return type:

Callable | None

get_sub_function(ftype_index)[source]#
Parameters:

ftype_index (int)

Return type:

Function

partial(*args, execute_fully_bound_functions=False, **kwargs)[source]#
Return type:

Function | FunctionApplicationExpression

remap_arguments(remapping)[source]#

Generate a new Function object with a different argument order. Specifically, remapping is a permutation. The i-th argument to the new function will be the remapping[i]-th argument in the old function.

Parameters:

remapping (List[int]) – The remapping.

Returns:

The new function.

Return type:

Function

set_function_body(function_body)[source]#

Set the function body.

Parameters:

function_body (Callable)

set_function_name(function_name)[source]#

Set the function name.

Parameters:

function_name (str)

property all_sub_functions#
property arguments: Tuple[Variable]#
property is_generator_function: bool#
property is_overloaded: bool#

Return True if the function is overloaded.

property nr_arguments: int#
property return_type: ObjectType | ValueType | FunctionType | SequenceType#