1.1 --- a/encoders.py Sun Nov 14 00:50:17 2021 +0100
1.2 +++ b/encoders.py Sun Nov 28 02:03:21 2021 +0100
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Encoder functions, producing representations of program objects.
1.6
1.7 -Copyright (C) 2016, 2017, 2018 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2016, 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -286,6 +286,16 @@
1.13 "<accessor>", "<context>", "<name>", "<private_context>", "<target_accessor>"
1.14 )
1.15
1.16 +# Instructions that need to be customised for certain attributes.
1.17 +
1.18 +via_object_ops = (
1.19 + "__store_via_object", "__check_and_store_via_object",
1.20 + )
1.21 +
1.22 +# NOTE: This duplicates a definition in transresults.
1.23 +
1.24 +special_attributes = ("__args__", "__data__", "__key__", "__size__")
1.25 +
1.26 def encode_access_instruction(instruction, subs, accessor_index, context_index):
1.27
1.28 """
1.29 @@ -379,6 +389,11 @@
1.30 elif not args:
1.31 op = "&%s" % encode_path(op)
1.32
1.33 + # Substitute the operation for certain attributes.
1.34 +
1.35 + if op in via_object_ops and args[1] in special_attributes:
1.36 + op = "%s_internal" % op
1.37 +
1.38 return "%s%s" % (op, argstr), substituted
1.39
1.40 def encode_access_instruction_arg(arg, subs, op, accessor_index, context_index):