1.1 --- a/translator.py Sun Feb 12 23:24:42 2017 +0100
1.2 +++ b/translator.py Mon Feb 13 15:35:36 2017 +0100
1.3 @@ -142,7 +142,7 @@
1.4 elif static_name:
1.5 parent = ref.parent()
1.6 context = ref.has_kind("<function>") and encode_path(parent) or None
1.7 - return "((__attr) {{.context=%s, .value=&%s}})" % (context and "&%s" % context or "0", static_name)
1.8 + return "((__attr) {.value=&%s})" % static_name
1.9
1.10 # Qualified names must be converted into parent-relative accesses.
1.11
1.12 @@ -875,7 +875,7 @@
1.13
1.14 if not ref.static():
1.15 self.process_assignment_for_object(
1.16 - n.name, make_expression("((__attr) {{.context=0, .value=&%s}})" %
1.17 + n.name, make_expression("((__attr) {.value=&%s})" %
1.18 encode_path(class_name)))
1.19
1.20 self.enter_namespace(n.name)
1.21 @@ -1054,9 +1054,7 @@
1.22 context = self.is_method(objpath)
1.23
1.24 self.process_assignment_for_object(original_name,
1.25 - make_expression("((__attr) {{.context=%s, .value=&%s}})" % (
1.26 - context and "&%s" % encode_path(context) or "0",
1.27 - encode_path(objpath))))
1.28 + make_expression("((__attr) {.value=&%s})" % encode_path(objpath)))
1.29
1.30 def process_function_defaults(self, n, name, objpath, instance_name=None):
1.31
1.32 @@ -1349,7 +1347,8 @@
1.33 self.record_temp("__tmp_targets")
1.34
1.35 if context_required:
1.36 - stages.append("__get_function(__tmp_targets[%d])" % self.function_target)
1.37 + stages.append("__get_function(__CONTEXT_AS_VALUE(__tmp_targets[%d]).value, __tmp_targets[%d])" % (
1.38 + self.function_target, self.function_target))
1.39 else:
1.40 stages.append("__load_via_object(__tmp_targets[%d].value, %s).fn" % (
1.41 self.function_target, encode_symbol("pos", "__fn__")))
1.42 @@ -1414,14 +1413,14 @@
1.43 # Without defaults, produce an attribute referring to the function.
1.44
1.45 if not defaults:
1.46 - return make_expression("((__attr) {{.context=0, .value=&%s}})" % encode_path(function_name))
1.47 + return make_expression("((__attr) {.value=&%s})" % encode_path(function_name))
1.48
1.49 # With defaults, copy the function structure and set the defaults on the
1.50 # copy.
1.51
1.52 else:
1.53 self.record_temp("__tmp_value")
1.54 - return make_expression("(__tmp_value = __COPY(&%s, sizeof(%s)), %s, (__attr) {{.context=0, .value=__tmp_value}})" % (
1.55 + return make_expression("(__tmp_value = __COPY(&%s, sizeof(%s)), %s, (__attr) {.value=__tmp_value})" % (
1.56 encode_path(function_name),
1.57 encode_symbol("obj", function_name),
1.58 ", ".join(defaults)))