Lichen

Changeset

838:00fd67211882
2018-07-03 Paul Boddie raw files shortlog changelog graph Take advantage of context testing when acquiring functions for invocation. Since a context whose nature has been determined will have been tested, either as a consequence of deduction or at run-time, use of __get_function (which tests the context again) is unnecessary.
translator.py (file)
     1.1 --- a/translator.py	Mon Jul 02 19:19:54 2018 +0200
     1.2 +++ b/translator.py	Tue Jul 03 17:02:45 2018 +0200
     1.3 @@ -1403,12 +1403,14 @@
     1.4  
     1.5          elif function:
     1.6              if context_required:
     1.7 +
     1.8 +                # With context_verified or context_identity...
     1.9 +
    1.10                  if have_access_context:
    1.11 -                    if context_verified:
    1.12 -                        emit("__get_function_member(%s)" % target_expr)
    1.13 -                    else:
    1.14 -                        emit("__get_function(%s, %s)" % (
    1.15 -                            context_identity, target_expr))
    1.16 +                    emit("__get_function_member(%s)" % target_expr)
    1.17 +
    1.18 +                # Otherwise, test the context for the function/method.
    1.19 +
    1.20                  else:
    1.21                      emit("__get_function(__CONTEXT_AS_VALUE(%s), %s)" % (
    1.22                          target_var, target_expr))
    1.23 @@ -1420,7 +1422,7 @@
    1.24          elif known_parameters:
    1.25              context_arg = context_required and args[0] or "__NULL"
    1.26              if self.always_callable(refs):
    1.27 -                if context_verified:
    1.28 +                if context_verified or context_identity:
    1.29                      emit("__get_function_member(%s)" % target_expr)
    1.30                  else:
    1.31                      emit("__get_function(%s, %s)" % (context_arg, target_expr))