1.1 --- a/encoders.py Fri Sep 09 22:42:31 2016 +0200
1.2 +++ b/encoders.py Tue Sep 20 23:14:43 2016 +0200
1.3 @@ -19,6 +19,8 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 +from common import first
1.8 +
1.9 # Output encoding and decoding for the summary files.
1.10
1.11 def encode_attrnames(attrnames):
1.12 @@ -83,6 +85,46 @@
1.13
1.14 return s == "A"
1.15
1.16 +
1.17 +
1.18 +# Test generation functions.
1.19 +
1.20 +def get_kinds(all_types):
1.21 +
1.22 + """
1.23 + Return object kind details for 'all_types', being a collection of
1.24 + references for program types.
1.25 + """
1.26 +
1.27 + return map(lambda ref: ref.get_kind(), all_types)
1.28 +
1.29 +def test_for_kind(prefix, kind):
1.30 +
1.31 + "Return a test condition identifier featuring 'prefix' and 'kind'."
1.32 +
1.33 + return "%s-%s" % (prefix, kind == "<instance>" and "instance" or "type")
1.34 +
1.35 +def test_for_kinds(prefix, all_kinds):
1.36 +
1.37 + """
1.38 + Return identifiers describing test conditions incorporating the given
1.39 + 'prefix' and involving 'all_kinds', being a collection of object kinds.
1.40 + """
1.41 +
1.42 + return test_for_kind(prefix, first(all_kinds))
1.43 +
1.44 +def test_for_types(prefix, all_types):
1.45 +
1.46 + """
1.47 + Return identifiers describing test conditions incorporating the given
1.48 + 'prefix' and involving 'all_types', being a collection of references to
1.49 + program types.
1.50 + """
1.51 +
1.52 + return test_for_kind(prefix, first(all_types).get_kind())
1.53 +
1.54 +
1.55 +
1.56 # Output program encoding.
1.57
1.58 def encode_function_pointer(path):
1.59 @@ -112,6 +154,8 @@
1.60
1.61 return "__%s%s" % (symbol_type, path and "_%s" % encode_path(path) or "")
1.62
1.63 +
1.64 +
1.65 # Output language reserved words.
1.66
1.67 reserved_words = [