1.1 --- a/encoders.py Sat Oct 29 20:22:30 2016 +0200
1.2 +++ b/encoders.py Sat Oct 29 22:46:20 2016 +0200
1.3 @@ -343,12 +343,30 @@
1.4
1.5 return "__predefined_%s" % encode_path(path)
1.6
1.7 +def encode_size(kind, path=None):
1.8 +
1.9 + """
1.10 + Encode a structure size reference for the given 'kind' of structure, with
1.11 + 'path' indicating a specific structure name.
1.12 + """
1.13 +
1.14 + return "__%ssize%s" % (structure_size_prefixes.get(kind, kind), path and "_%s" % encode_path(path) or "")
1.15 +
1.16 def encode_symbol(symbol_type, path=None):
1.17
1.18 "Encode a symbol with the given 'symbol_type' and optional 'path'."
1.19
1.20 return "__%s%s" % (symbol_type, path and "_%s" % encode_path(path) or "")
1.21
1.22 +def encode_tablename(kind, path):
1.23 +
1.24 + """
1.25 + Encode a table reference for the given 'kind' of table structure, indicating
1.26 + a 'path' for the specific object concerned.
1.27 + """
1.28 +
1.29 + return "__%sTable_%s" % (table_name_prefixes[kind], encode_path(path))
1.30 +
1.31 def encode_type_attribute(path):
1.32
1.33 "Encode the special type attribute for 'path'."
1.34 @@ -357,6 +375,25 @@
1.35
1.36
1.37
1.38 +# A mapping from kinds to structure size reference prefixes.
1.39 +
1.40 +structure_size_prefixes = {
1.41 + "<class>" : "c",
1.42 + "<module>" : "m",
1.43 + "<instance>" : "i"
1.44 + }
1.45 +
1.46 +# A mapping from kinds to table name prefixes.
1.47 +
1.48 +table_name_prefixes = {
1.49 + "<class>" : "Class",
1.50 + "<function>" : "Function",
1.51 + "<module>" : "Module",
1.52 + "<instance>" : "Instance"
1.53 + }
1.54 +
1.55 +
1.56 +
1.57 # Output language reserved words.
1.58
1.59 reserved_words = [