1.1 --- a/deducer.py Sun Mar 19 00:56:43 2017 +0100 1.2 +++ b/deducer.py Fri Mar 24 22:39:37 2017 +0100 1.3 @@ -1730,51 +1730,17 @@ 1.4 1.5 attrs = self.get_references_for_access(access_location) 1.6 1.7 - # Where no specific attributes are defined, do not attempt 1.8 - # to refine the alias's types. 1.9 - 1.10 - if not attrs: 1.11 - return False 1.12 - 1.13 - # Invocations converting class accessors to instances do not 1.14 - # change the nature of class providers. 1.15 - 1.16 - provider_attrs = self.convert_invocation_providers(attrs, invocation) 1.17 - 1.18 - (class_types, instance_types, module_types, function_types, 1.19 - var_types) = separate_types(provider_attrs) 1.20 - 1.21 - # Where non-accessor types are found, do not attempt to refine 1.22 - # the defined accessor types. 1.23 - 1.24 - if function_types or var_types: 1.25 - return False 1.26 - 1.27 - class_types = set(provider_class_types).intersection(class_types) 1.28 - instance_types = set(provider_instance_types).intersection(instance_types) 1.29 - module_types = set(provider_module_types).intersection(module_types) 1.30 - 1.31 - new_provider_class_types.update(class_types) 1.32 - new_provider_instance_types.update(instance_types) 1.33 - new_provider_module_types.update(module_types) 1.34 - 1.35 - # Accessors are updated separately, employing invocation 1.36 - # result details. 1.37 - 1.38 - accessor_attrs = self.convert_invocations(attrs, invocation) 1.39 - 1.40 - (class_types, instance_types, module_types, function_types, 1.41 - var_types) = separate_types(accessor_attrs) 1.42 - 1.43 - class_types = set(accessor_class_types).intersection(class_types) 1.44 - instance_types = set(accessor_instance_types).intersection(instance_types) 1.45 - module_types = set(accessor_module_types).intersection(module_types) 1.46 - 1.47 - new_accessor_class_types.update(class_types) 1.48 - new_accessor_instance_types.update(instance_types) 1.49 - new_accessor_module_types.update(module_types) 1.50 - 1.51 - refs.update(accessor_attrs) 1.52 + if attrs: 1.53 + 1.54 + # Invocations converting class accessors to instances do 1.55 + # not change the nature of class providers. 1.56 + 1.57 + provider_attrs = self.convert_invocation_providers(attrs, invocation) 1.58 + 1.59 + # Accessors are updated separately, employing invocation 1.60 + # result details. 1.61 + 1.62 + accessor_attrs = self.convert_invocations(attrs, invocation) 1.63 1.64 # Alias references a name, not an access. 1.65 1.66 @@ -1791,35 +1757,41 @@ 1.67 provider_attrs = self.get_provider_references(access_location) 1.68 attrs = accessor_attrs = self.get_accessor_references(access_location) 1.69 1.70 - # Where no further information is found, do not attempt to 1.71 - # refine the defined accessor types. 1.72 - 1.73 - if not attrs: 1.74 - return False 1.75 - 1.76 - (class_types, instance_types, module_types, function_types, 1.77 - var_types) = separate_types(provider_attrs) 1.78 - 1.79 - class_types = set(provider_class_types).intersection(class_types) 1.80 - instance_types = set(provider_instance_types).intersection(instance_types) 1.81 - module_types = set(provider_module_types).intersection(module_types) 1.82 - 1.83 - new_provider_class_types.update(class_types) 1.84 - new_provider_instance_types.update(instance_types) 1.85 - new_provider_module_types.update(module_types) 1.86 - 1.87 - (class_types, instance_types, module_types, function_types, 1.88 - var_types) = separate_types(accessor_attrs) 1.89 - 1.90 - class_types = set(accessor_class_types).intersection(class_types) 1.91 - instance_types = set(accessor_instance_types).intersection(instance_types) 1.92 - module_types = set(accessor_module_types).intersection(module_types) 1.93 - 1.94 - new_accessor_class_types.update(class_types) 1.95 - new_accessor_instance_types.update(instance_types) 1.96 - new_accessor_module_types.update(module_types) 1.97 - 1.98 - refs.update(accessor_attrs) 1.99 + # Where no specific attributes are defined, do not attempt 1.100 + # to refine the alias's types. 1.101 + 1.102 + if not attrs: 1.103 + return False 1.104 + 1.105 + (class_types, instance_types, module_types, function_types, 1.106 + var_types) = separate_types(provider_attrs) 1.107 + 1.108 + # Where non-accessor types are found, do not attempt to refine 1.109 + # the defined accessor types. 1.110 + 1.111 + if function_types or var_types: 1.112 + return False 1.113 + 1.114 + class_types = set(provider_class_types).intersection(class_types) 1.115 + instance_types = set(provider_instance_types).intersection(instance_types) 1.116 + module_types = set(provider_module_types).intersection(module_types) 1.117 + 1.118 + new_provider_class_types.update(class_types) 1.119 + new_provider_instance_types.update(instance_types) 1.120 + new_provider_module_types.update(module_types) 1.121 + 1.122 + (class_types, instance_types, module_types, function_types, 1.123 + var_types) = separate_types(accessor_attrs) 1.124 + 1.125 + class_types = set(accessor_class_types).intersection(class_types) 1.126 + instance_types = set(accessor_instance_types).intersection(instance_types) 1.127 + module_types = set(accessor_module_types).intersection(module_types) 1.128 + 1.129 + new_accessor_class_types.update(class_types) 1.130 + new_accessor_instance_types.update(instance_types) 1.131 + new_accessor_module_types.update(module_types) 1.132 + 1.133 + refs.update(accessor_attrs) 1.134 1.135 # Update the alias relationships for invocations. 1.136 1.137 @@ -1868,14 +1840,6 @@ 1.138 1.139 attrs = self.get_references_for_access(access_location) 1.140 1.141 - # Where no further information is found, do not attempt to 1.142 - # refine the defined accessor types. 1.143 - 1.144 - if not attrs: 1.145 - return False 1.146 - 1.147 - refs.update(self.convert_invocations(attrs, invocation)) 1.148 - 1.149 # Alias references a name, not an access. 1.150 1.151 else: 1.152 @@ -1891,13 +1855,13 @@ 1.153 provider_attrs = self.get_provider_references(access_location) 1.154 attrs = accessor_attrs = self.get_accessor_references(access_location) 1.155 1.156 - # Where no further information is found, do not attempt to 1.157 - # refine the defined accessor types. 1.158 - 1.159 - if not attrs: 1.160 - return False 1.161 - 1.162 - refs.update(self.convert_invocations(attrs, invocation)) 1.163 + # Where no further information is found, do not attempt to 1.164 + # refine the defined accessor types. 1.165 + 1.166 + if not attrs: 1.167 + return False 1.168 + 1.169 + refs.update(self.convert_invocations(attrs, invocation)) 1.170 1.171 # Update the alias relationships for invocations. 1.172 1.173 @@ -2946,6 +2910,11 @@ 1.174 if context_var: 1.175 emit(("<context_identity>", context_var)) 1.176 1.177 + # Produce an advisory instruction regarding the final attribute. 1.178 + 1.179 + if origin: 1.180 + emit(("<final_identity>", origin)) 1.181 + 1.182 self.access_instructions[access_location] = instructions 1.183 self.accessor_kinds[access_location] = accessor_kinds 1.184
2.1 --- a/encoders.py Sun Mar 19 00:56:43 2017 +0100 2.2 +++ b/encoders.py Fri Mar 24 22:39:37 2017 +0100 2.3 @@ -237,9 +237,13 @@ 2.4 "<test_context_revert>", "<test_context_static>", 2.5 ) 2.6 2.7 -reference_acting_ops = attribute_ops + checked_ops + typename_ops 2.8 +reference_acting_ops = attribute_ops + checked_ops + type_ops + typename_ops 2.9 attribute_producing_ops = attribute_loading_ops + checked_loading_ops 2.10 2.11 +attribute_producing_variables = ( 2.12 + "<accessor>", "<context>", "<name>", "<private_context>", "<target_accessor>" 2.13 + ) 2.14 + 2.15 def encode_access_instruction(instruction, subs, context_index): 2.16 2.17 """ 2.18 @@ -340,13 +344,7 @@ 2.19 2.20 if isinstance(arg, tuple): 2.21 encoded, substituted = encode_access_instruction(arg, subs, context_index) 2.22 - 2.23 - # Convert attribute results to references where required. 2.24 - 2.25 - if op and op in reference_acting_ops and arg[0] in attribute_producing_ops: 2.26 - return "%s.value" % encoded, substituted 2.27 - else: 2.28 - return encoded, substituted 2.29 + return attribute_to_reference(op, arg[0], encoded, substituted) 2.30 2.31 # Special values only need replacing, not encoding. 2.32 2.33 @@ -355,13 +353,18 @@ 2.34 # Handle values modified by storage details. 2.35 2.36 if arg in context_values: 2.37 - return "%s(%s)" % (subs.get(arg), context_index), set([arg]) 2.38 + encoded = "%s(%s)" % (subs.get(arg), context_index) 2.39 else: 2.40 - return subs.get(arg), set([arg]) 2.41 + encoded = subs.get(arg) 2.42 + 2.43 + substituted = set([arg]) 2.44 + return attribute_to_reference(op, arg, encoded, substituted) 2.45 2.46 # Convert static references to the appropriate type. 2.47 2.48 - elif op and op in reference_acting_ops and arg != "<accessor>": 2.49 + elif op and op in reference_acting_ops and \ 2.50 + arg not in attribute_producing_variables: 2.51 + 2.52 return "&%s" % encode_path(arg), set() 2.53 2.54 # Other values may need encoding. 2.55 @@ -369,6 +372,18 @@ 2.56 else: 2.57 return encode_path(arg), set() 2.58 2.59 +def attribute_to_reference(op, arg, encoded, substituted): 2.60 + 2.61 + # Convert attribute results to references where required. 2.62 + 2.63 + if op and op in reference_acting_ops and ( 2.64 + arg in attribute_producing_ops or 2.65 + arg in attribute_producing_variables): 2.66 + 2.67 + return "__VALUE(%s)" % encoded, substituted 2.68 + else: 2.69 + return encoded, substituted 2.70 + 2.71 def encode_function_pointer(path): 2.72 2.73 "Encode 'path' as a reference to an output program function."
3.1 --- a/generator.py Sun Mar 19 00:56:43 2017 +0100 3.2 +++ b/generator.py Fri Mar 24 22:39:37 2017 +0100 3.3 @@ -43,6 +43,7 @@ 3.4 # NOTE: These must be synchronised with the library. 3.5 3.6 function_type = "__builtins__.core.function" 3.7 + int_type = "__builtins__.int.int" 3.8 none_type = "__builtins__.none.NoneType" 3.9 string_type = "__builtins__.str.string" 3.10 type_type = "__builtins__.core.type" 3.11 @@ -373,6 +374,11 @@ 3.12 for constant, n in self.optimiser.constants.items(): 3.13 self.make_literal_constant(f_decls, f_defs, n, constant) 3.14 3.15 + # Generate a common integer instance object, referenced when integer 3.16 + # attributes are accessed. 3.17 + 3.18 + self.make_common_integer(f_decls, f_defs) 3.19 + 3.20 # Finish the main source file. 3.21 3.22 self.write_main_program(f_code, f_signatures) 3.23 @@ -560,6 +566,11 @@ 3.24 3.25 value, value_type, encoding = constant 3.26 3.27 + # Do not generate individual integer constants. 3.28 + 3.29 + if value_type == self.int_type: 3.30 + return 3.31 + 3.32 const_path = encode_literal_constant(n) 3.33 structure_name = encode_literal_reference(n) 3.34 3.35 @@ -582,13 +593,23 @@ 3.36 3.37 self.make_constant(f_decls, f_defs, ref, attr_path, structure_name) 3.38 3.39 + def make_common_integer(self, f_decls, f_defs): 3.40 + 3.41 + """ 3.42 + Write common integer instance details to 'f_decls' (to declare a 3.43 + structure) and to 'f_defs' (to define the contents). 3.44 + """ 3.45 + 3.46 + ref = Reference("<instance>", self.int_type) 3.47 + self.make_constant(f_decls, f_defs, ref, "__common_integer", "__common_integer_obj") 3.48 + 3.49 def make_constant(self, f_decls, f_defs, ref, const_path, structure_name, data=None, encoding=None): 3.50 3.51 """ 3.52 Write constant details to 'f_decls' (to declare a structure) and to 3.53 'f_defs' (to define the contents) for the constant described by 'ref' 3.54 - having the given 'path' and 'structure_name' (for the constant structure 3.55 - itself). 3.56 + having the given 'const_path' (providing an attribute for the constant) 3.57 + and 'structure_name' (for the constant structure itself). 3.58 3.59 The additional 'data' and 'encoding' are used to describe specific 3.60 values. 3.61 @@ -1030,7 +1051,7 @@ 3.62 # Special internal size member. 3.63 3.64 elif attrname == "__size__": 3.65 - structure.append("{.intvalue=%d}" % attr) 3.66 + structure.append("__INTVALUE(%d)" % attr) 3.67 continue 3.68 3.69 # Special internal key member. 3.70 @@ -1137,6 +1158,13 @@ 3.71 # Obtain a constant value directly assigned to the attribute. 3.72 3.73 if self.optimiser.constant_numbers.has_key(alias): 3.74 + 3.75 + # Encode integer constants differently. 3.76 + 3.77 + value, value_type, encoding = self.importer.all_constant_values[alias] 3.78 + if value_type == self.int_type: 3.79 + return "__INTVALUE(%s) /* %s */" % (value, name) 3.80 + 3.81 constant_number = self.optimiser.constant_numbers[alias] 3.82 constant_value = encode_literal_constant(constant_number) 3.83 return "%s /* %s */" % (constant_value, name) 3.84 @@ -1264,13 +1292,11 @@ 3.85 __Catch(__tmp_exc) 3.86 { 3.87 if (__ISINSTANCE(__tmp_exc.arg, __ATTRVALUE(&__builtins___exception_system_SystemExit))) 3.88 - return __load_via_object( 3.89 - __load_via_object(__tmp_exc.arg.value, __data__).value, 3.90 - value).intvalue; 3.91 + return __TOINT(__load_via_object(__VALUE(__tmp_exc.arg), value)); 3.92 3.93 fprintf(stderr, "Program terminated due to exception: %%s.\\n", 3.94 __load_via_object( 3.95 - %s(__NULL, __tmp_exc.arg).value, 3.96 + __VALUE(%s(__NULL, __tmp_exc.arg)), 3.97 __data__).strvalue); 3.98 return 1; 3.99 }
4.1 --- a/lib/__builtins__/character.py Sun Mar 19 00:56:43 2017 +0100 4.2 +++ b/lib/__builtins__/character.py Fri Mar 24 22:39:37 2017 +0100 4.3 @@ -29,7 +29,7 @@ 4.4 check_int(i) 4.5 4.6 if 0 <= i <= 255: 4.7 - return str_chr(i.__data__) 4.8 + return str_chr(i) 4.9 else: 4.10 raise ValueError, i 4.11 4.12 @@ -94,7 +94,7 @@ 4.13 check_int(i) 4.14 4.15 if 0 <= i <= 2097151: 4.16 - return utf8string(unicode_unichr(i.__data__)) 4.17 + return utf8string(unicode_unichr(i)) 4.18 else: 4.19 raise ValueError, i 4.20
5.1 --- a/lib/__builtins__/int.py Sun Mar 19 00:56:43 2017 +0100 5.2 +++ b/lib/__builtins__/int.py Fri Mar 24 22:39:37 2017 +0100 5.3 @@ -3,7 +3,7 @@ 5.4 """ 5.5 Integer objects. 5.6 5.7 -Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk> 5.8 +Copyright (C) 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk> 5.9 5.10 This program is free software; you can redistribute it and/or modify it under 5.11 the terms of the GNU General Public License as published by the Free Software 5.12 @@ -34,11 +34,9 @@ 5.13 5.14 "Initialise the integer with the given 'number_or_string'." 5.15 5.16 - if _isinstance(number_or_string, int): 5.17 - self.__data__ = number_or_string.__data__ 5.18 - else: 5.19 - # NOTE: To be implemented. 5.20 - self.__data__ = None 5.21 + # NOTE: To be implemented. 5.22 + 5.23 + pass 5.24 5.25 def __hash__(self): 5.26 5.27 @@ -51,7 +49,7 @@ 5.28 "Perform 'op' on this int and 'other' if appropriate." 5.29 5.30 if _isinstance(other, int): 5.31 - return op(self.__data__, other.__data__) 5.32 + return op(self, other) 5.33 else: 5.34 return NotImplemented 5.35 5.36 @@ -60,7 +58,7 @@ 5.37 "Perform 'op' on 'other' and this int if appropriate." 5.38 5.39 if _isinstance(other, int): 5.40 - return op(other.__data__, self.__data__) 5.41 + return op(other, self) 5.42 else: 5.43 return NotImplemented 5.44 5.45 @@ -122,7 +120,7 @@ 5.46 5.47 "Return the inversion of this int." 5.48 5.49 - return int_not(self.__data__) 5.50 + return int_not(self) 5.51 5.52 __add__ = __radd__ = __iadd__ 5.53 __sub__ = __isub__ 5.54 @@ -206,7 +204,7 @@ 5.55 5.56 "Apply the unary negation operator." 5.57 5.58 - return int_neg(self.__data__) 5.59 + return int_neg(self) 5.60 5.61 def __pos__(self): 5.62 5.63 @@ -218,7 +216,7 @@ 5.64 5.65 "Return a string representation." 5.66 5.67 - return utf8string(int_str(self.__data__)) 5.68 + return utf8string(int_str(self)) 5.69 5.70 __repr__ = __str__ 5.71 5.72 @@ -233,8 +231,7 @@ 5.73 5.74 "Return whether this int is non-zero." 5.75 5.76 - zero = 0 5.77 - return int_ne(self.__data__, zero.__data__) 5.78 + return int_ne(self, 0) 5.79 5.80 # Limits. 5.81
6.1 --- a/lib/__builtins__/str.py Sun Mar 19 00:56:43 2017 +0100 6.2 +++ b/lib/__builtins__/str.py Fri Mar 24 22:39:37 2017 +0100 6.3 @@ -22,7 +22,7 @@ 6.4 from __builtins__.operator import _negate 6.5 from __builtins__.sequence import hashable, itemaccess 6.6 from __builtins__.types import check_int 6.7 -from native import int_new, str_add, str_lt, str_gt, str_eq, str_ord, \ 6.8 +from native import str_add, str_lt, str_gt, str_eq, str_ord, \ 6.9 str_substr 6.10 6.11 WHITESPACE = (" ", "\f", "\n", "\r", "\t") 6.12 @@ -53,7 +53,7 @@ 6.13 else: 6.14 self.__data__ = None 6.15 self.__key__ = None 6.16 - self.__size__ = None 6.17 + self.__size__ = 0 6.18 6.19 # Internal methods. 6.20 6.21 @@ -157,7 +157,7 @@ 6.22 6.23 "Return the number of bytes in this string." 6.24 6.25 - return int_new(self.__size__) 6.26 + return self.__size__ 6.27 6.28 # General type methods. 6.29 6.30 @@ -165,7 +165,7 @@ 6.31 6.32 "Return whether the string provides any data." 6.33 6.34 - return int_new(self.__size__).__bool__() 6.35 + return self.__size__.__bool__() 6.36 6.37 def __contains__(self, value): 6.38
7.1 --- a/lib/native/__init__.py Sun Mar 19 00:56:43 2017 +0100 7.2 +++ b/lib/native/__init__.py Fri Mar 24 22:39:37 2017 +0100 7.3 @@ -23,8 +23,7 @@ 7.4 7.5 from native.identity import is_, is_not 7.6 7.7 -from native.int import int_new, \ 7.8 - int_add, int_div, int_mod, int_mul, int_neg, int_pow, \ 7.9 +from native.int import int_add, int_div, int_mod, int_mul, int_neg, int_pow, \ 7.10 int_sub, int_and, int_not, int_or, int_xor, int_lt, \ 7.11 int_gt, int_eq, int_ne, int_str 7.12
8.1 --- a/lib/native/int.py Sun Mar 19 00:56:43 2017 +0100 8.2 +++ b/lib/native/int.py Fri Mar 24 22:39:37 2017 +0100 8.3 @@ -24,8 +24,6 @@ 8.4 this program. If not, see <http://www.gnu.org/licenses/>. 8.5 """ 8.6 8.7 -def int_new(data): pass 8.8 - 8.9 def int_add(self, other): pass 8.10 def int_div(self, other): pass 8.11 def int_mod(self, other): pass
9.1 --- a/templates/native/buffer.c Sun Mar 19 00:56:43 2017 +0100 9.2 +++ b/templates/native/buffer.c Fri Mar 24 22:39:37 2017 +0100 9.3 @@ -36,7 +36,7 @@ 9.4 9.5 /* Calculate the size of the string. */ 9.6 for (i = 0; i < data->size; i++) 9.7 - size += __load_via_object(data->attrs[i].value, __size__).intvalue; 9.8 + size += __TOINT(__load_via_object(__VALUE(data->attrs[i]), __size__)); 9.9 9.10 /* Reserve space for a new string. */ 9.11 s = (char *) __ALLOCATE(size + 1, sizeof(char)); 9.12 @@ -44,8 +44,8 @@ 9.13 /* Build a single string from the buffer contents. */ 9.14 for (i = 0, j = 0; i < data->size; i++) 9.15 { 9.16 - o = __load_via_object(data->attrs[i].value, __data__); 9.17 - n = __load_via_object(data->attrs[i].value, __size__).intvalue; 9.18 + o = __load_via_object(__VALUE(data->attrs[i]), __data__); 9.19 + n = __TOINT(__load_via_object(__VALUE(data->attrs[i]), __size__)); 9.20 memcpy(s + j, o.strvalue, n); /* does not null terminate but final byte should be zero */ 9.21 j += n; 9.22 }
10.1 --- a/templates/native/common.c Sun Mar 19 00:56:43 2017 +0100 10.2 +++ b/templates/native/common.c Fri Mar 24 22:39:37 2017 +0100 10.3 @@ -26,20 +26,12 @@ 10.4 10.5 /* Utility functions. */ 10.6 10.7 -__attr __new_int(int i) 10.8 -{ 10.9 - /* Create a new integer and mutate the __data__ attribute. */ 10.10 - __attr attr = __NEWINSTANCE(__builtins___int_int); 10.11 - attr.value->attrs[__ATTRPOS(__data__)].intvalue = i; 10.12 - return attr; 10.13 -} 10.14 - 10.15 __attr __new_str(char *s, int size) 10.16 { 10.17 /* Create a new string and mutate the __data__, __size__ and __key__ attributes. */ 10.18 __attr attr = __NEWINSTANCE(__builtins___str_string); 10.19 attr.value->attrs[__ATTRPOS(__data__)].strvalue = s; 10.20 - attr.value->attrs[__ATTRPOS(__size__)].intvalue = size; 10.21 + attr.value->attrs[__ATTRPOS(__size__)] = __INTVALUE(size); 10.22 attr.value->attrs[__ATTRPOS(__key__)] = __NULL; 10.23 return attr; 10.24 }
11.1 --- a/templates/native/common.h Sun Mar 19 00:56:43 2017 +0100 11.2 +++ b/templates/native/common.h Fri Mar 24 22:39:37 2017 +0100 11.3 @@ -23,7 +23,7 @@ 11.4 11.5 /* Utility functions. */ 11.6 11.7 -__attr __new_int(int i); 11.8 +#define __new_int(VALUE) __INTVALUE(VALUE) 11.9 __attr __new_str(char *s, int size); 11.10 __attr __new_list(__fragment *f); 11.11 __fragment *__fragment_append(__fragment *data, __attr value);
12.1 --- a/templates/native/iconv.c Sun Mar 19 00:56:43 2017 +0100 12.2 +++ b/templates/native/iconv.c Fri Mar 24 22:39:37 2017 +0100 12.3 @@ -51,13 +51,13 @@ 12.4 /* cd interpreted as iconv_t */ 12.5 iconv_t c = (iconv_t) cd.datavalue; 12.6 /* state.__data__ interpreted as list */ 12.7 - __fragment *f = __load_via_object(state.value, __data__).seqvalue; 12.8 + __fragment *f = __load_via_object(__VALUE(state), __data__).seqvalue; 12.9 12.10 /* Obtain the string, start position, and remaining bytes from the state. */ 12.11 12.12 - char *inbuf = __load_via_object(f->attrs[0].value, __data__).strvalue; 12.13 - int start = __load_via_object(f->attrs[1].value, __data__).intvalue; 12.14 - int remaining = __load_via_object(f->attrs[2].value, __data__).intvalue; 12.15 + char *inbuf = __load_via_object(__VALUE(f->attrs[0]), __data__).strvalue; 12.16 + int start = __TOINT(f->attrs[1]); 12.17 + int remaining = __TOINT(f->attrs[2]); 12.18 12.19 /* Allocate a string for the output buffer using the remaining input size 12.20 as a guide. */ 12.21 @@ -133,9 +133,9 @@ 12.22 __attr __fn_native_iconv_iconv_open(__attr __self, __attr tocode, __attr fromcode) 12.23 { 12.24 /* tocode.__data__ interpreted as string */ 12.25 - char *t = __load_via_object(tocode.value, __data__).strvalue; 12.26 + char *t = __load_via_object(__VALUE(tocode), __data__).strvalue; 12.27 /* fromcode.__data__ interpreted as string */ 12.28 - char *f = __load_via_object(fromcode.value, __data__).strvalue; 12.29 + char *f = __load_via_object(__VALUE(fromcode), __data__).strvalue; 12.30 iconv_t result; 12.31 __attr attr; 12.32
13.1 --- a/templates/native/identity.c Sun Mar 19 00:56:43 2017 +0100 13.2 +++ b/templates/native/identity.c Fri Mar 24 22:39:37 2017 +0100 13.3 @@ -28,11 +28,15 @@ 13.4 13.5 __attr __fn_native_identity_is_(__attr __self, __attr x, __attr y) 13.6 { 13.7 + /* NOTE: value member assumed equivalent to intvalue for comparison. */ 13.8 + 13.9 return x.value == y.value ? __builtins___boolean_True : __builtins___boolean_False; 13.10 } 13.11 13.12 __attr __fn_native_identity_is_not(__attr __self, __attr x, __attr y) 13.13 { 13.14 + /* NOTE: value member assumed equivalent to intvalue for comparison. */ 13.15 + 13.16 return x.value != y.value ? __builtins___boolean_True : __builtins___boolean_False; 13.17 } 13.18
14.1 --- a/templates/native/int.c Sun Mar 19 00:56:43 2017 +0100 14.2 +++ b/templates/native/int.c Fri Mar 24 22:39:37 2017 +0100 14.3 @@ -16,7 +16,6 @@ 14.4 this program. If not, see <http://www.gnu.org/licenses/>. 14.5 */ 14.6 14.7 -#include <limits.h> /* INT_MAX, INT_MIN */ 14.8 #include <math.h> /* ceil, log10, pow */ 14.9 #include <stdio.h> /* fdopen, snprintf */ 14.10 #include <errno.h> /* errno */ 14.11 @@ -32,20 +31,15 @@ 14.12 14.13 /* Integer operations. */ 14.14 14.15 -__attr __fn_native_int_int_new(__attr __self, __attr _data) 14.16 +__attr __fn_native_int_int_add(__attr __self, __attr self, __attr other) 14.17 { 14.18 - return __new_int(_data.intvalue); 14.19 -} 14.20 - 14.21 -__attr __fn_native_int_int_add(__attr __self, __attr _data, __attr other) 14.22 -{ 14.23 - /* _data and other interpreted as int.__data__ */ 14.24 - int i = _data.intvalue; 14.25 - int j = other.intvalue; 14.26 + /* self and other interpreted as int */ 14.27 + int i = __TOINT(self); 14.28 + int j = __TOINT(other); 14.29 14.30 /* Test for overflow. */ 14.31 - if (((i > 0) && (j > 0) && (i > INT_MAX - j)) || 14.32 - ((i < 0) && (j < 0) && (i < INT_MIN - j))) 14.33 + if (((i > 0) && (j > 0) && (i > __MAXINT - j)) || 14.34 + ((i < 0) && (j < 0) && (i < __MININT - j))) 14.35 14.36 __raise_overflow_error(); 14.37 14.38 @@ -53,15 +47,15 @@ 14.39 return __new_int(i + j); 14.40 } 14.41 14.42 -__attr __fn_native_int_int_sub(__attr __self, __attr _data, __attr other) 14.43 +__attr __fn_native_int_int_sub(__attr __self, __attr self, __attr other) 14.44 { 14.45 - /* _data and other interpreted as int.__data__ */ 14.46 - int i = _data.intvalue; 14.47 - int j = other.intvalue; 14.48 + /* self and other interpreted as int */ 14.49 + int i = __TOINT(self); 14.50 + int j = __TOINT(other); 14.51 14.52 /* Test for overflow. */ 14.53 - if (((i < 0) && (j > 0) && (i < INT_MIN + j)) || 14.54 - ((i > 0) && (j < 0) && (i > INT_MAX + j))) 14.55 + if (((i < 0) && (j > 0) && (i < __MININT + j)) || 14.56 + ((i > 0) && (j < 0) && (i > __MAXINT + j))) 14.57 14.58 __raise_overflow_error(); 14.59 14.60 @@ -69,17 +63,17 @@ 14.61 return __new_int(i - j); 14.62 } 14.63 14.64 -__attr __fn_native_int_int_mul(__attr __self, __attr _data, __attr other) 14.65 +__attr __fn_native_int_int_mul(__attr __self, __attr self, __attr other) 14.66 { 14.67 - /* _data and other interpreted as int.__data__ */ 14.68 - int i = _data.intvalue; 14.69 - int j = other.intvalue; 14.70 + /* self and other interpreted as int */ 14.71 + int i = __TOINT(self); 14.72 + int j = __TOINT(other); 14.73 14.74 /* Test for overflow. */ 14.75 - if (((i > 0) && (j > 0) && (i > INT_MAX / j)) || 14.76 - ((i < 0) && (j < 0) && (i > INT_MAX / j)) || 14.77 - ((i < 0) && (j > 0) && (i < INT_MIN / j)) || 14.78 - ((i > 0) && (j < 0) && (j < INT_MIN / i))) 14.79 + if (((i > 0) && (j > 0) && (i > __MAXINT / j)) || 14.80 + ((i < 0) && (j < 0) && (i > __MAXINT / j)) || 14.81 + ((i < 0) && (j > 0) && (i < __MININT / j)) || 14.82 + ((i > 0) && (j < 0) && (j < __MININT / i))) 14.83 14.84 __raise_overflow_error(); 14.85 14.86 @@ -87,56 +81,56 @@ 14.87 return __new_int(i * j); 14.88 } 14.89 14.90 -__attr __fn_native_int_int_div(__attr __self, __attr _data, __attr other) 14.91 +__attr __fn_native_int_int_div(__attr __self, __attr self, __attr other) 14.92 { 14.93 - /* _data and other interpreted as int.__data__ */ 14.94 - int i = _data.intvalue; 14.95 - int j = other.intvalue; 14.96 + /* self and other interpreted as int */ 14.97 + int i = __TOINT(self); 14.98 + int j = __TOINT(other); 14.99 14.100 /* Test for division by zero or overflow. */ 14.101 if (j == 0) 14.102 __raise_zero_division_error(); 14.103 - else if ((j == -1) && (i == INT_MIN)) 14.104 + else if ((j == -1) && (i == __MININT)) 14.105 __raise_overflow_error(); 14.106 14.107 /* Return the new integer. */ 14.108 return __new_int(i / j); 14.109 } 14.110 14.111 -__attr __fn_native_int_int_mod(__attr __self, __attr _data, __attr other) 14.112 +__attr __fn_native_int_int_mod(__attr __self, __attr self, __attr other) 14.113 { 14.114 - /* _data and other interpreted as int.__data_ */ 14.115 - int i = _data.intvalue; 14.116 - int j = other.intvalue; 14.117 + /* self and other interpreted as int */ 14.118 + int i = __TOINT(self); 14.119 + int j = __TOINT(other); 14.120 14.121 /* Test for division by zero or overflow. */ 14.122 if (j == 0) 14.123 __raise_zero_division_error(); 14.124 - else if ((j == -1) && (i == INT_MIN)) 14.125 + else if ((j == -1) && (i == __MININT)) 14.126 __raise_overflow_error(); 14.127 14.128 /* Return the new integer. */ 14.129 return __new_int(i % j); 14.130 } 14.131 14.132 -__attr __fn_native_int_int_neg(__attr __self, __attr _data) 14.133 +__attr __fn_native_int_int_neg(__attr __self, __attr self) 14.134 { 14.135 - /* _data interpreted as int.__data_ */ 14.136 - int i = _data.intvalue; 14.137 + /* self interpreted as int */ 14.138 + int i = __TOINT(self); 14.139 14.140 /* Test for overflow. */ 14.141 - if (i == INT_MIN) 14.142 + if (i == __MININT) 14.143 __raise_overflow_error(); 14.144 14.145 /* Return the new integer. */ 14.146 return __new_int(-i); 14.147 } 14.148 14.149 -__attr __fn_native_int_int_pow(__attr __self, __attr _data, __attr other) 14.150 +__attr __fn_native_int_int_pow(__attr __self, __attr self, __attr other) 14.151 { 14.152 - /* _data and other interpreted as int.__data_ */ 14.153 - int i = _data.intvalue; 14.154 - int j = other.intvalue; 14.155 + /* self and other interpreted as int */ 14.156 + int i = __TOINT(self); 14.157 + int j = __TOINT(other); 14.158 int k; 14.159 14.160 errno = 0; 14.161 @@ -151,95 +145,96 @@ 14.162 return __new_int(k); 14.163 } 14.164 14.165 -__attr __fn_native_int_int_and(__attr __self, __attr _data, __attr other) 14.166 +__attr __fn_native_int_int_and(__attr __self, __attr self, __attr other) 14.167 { 14.168 - /* _data and other interpreted as int.__data_ */ 14.169 - int i = _data.intvalue; 14.170 - int j = other.intvalue; 14.171 + /* self and other interpreted as int */ 14.172 + int i = __TOINT(self); 14.173 + int j = __TOINT(other); 14.174 14.175 /* Return the new integer. */ 14.176 /* NOTE: No overflow test applied. */ 14.177 return __new_int(i & j); 14.178 } 14.179 14.180 -__attr __fn_native_int_int_not(__attr __self, __attr _data) 14.181 +__attr __fn_native_int_int_not(__attr __self, __attr self) 14.182 { 14.183 - /* _data interpreted as int.__data_ */ 14.184 - int i = _data.intvalue; 14.185 + /* self interpreted as int */ 14.186 + int i = __TOINT(self); 14.187 14.188 /* Return the new integer. */ 14.189 return __new_int(~i); 14.190 } 14.191 14.192 -__attr __fn_native_int_int_or(__attr __self, __attr _data, __attr other) 14.193 +__attr __fn_native_int_int_or(__attr __self, __attr self, __attr other) 14.194 { 14.195 - /* _data and other interpreted as int.__data_ */ 14.196 - int i = _data.intvalue; 14.197 - int j = other.intvalue; 14.198 + /* self and other interpreted as int */ 14.199 + int i = __TOINT(self); 14.200 + int j = __TOINT(other); 14.201 14.202 /* Return the new integer. */ 14.203 /* NOTE: No overflow test applied. */ 14.204 return __new_int(i | j); 14.205 } 14.206 14.207 -__attr __fn_native_int_int_xor(__attr __self, __attr _data, __attr other) 14.208 +__attr __fn_native_int_int_xor(__attr __self, __attr self, __attr other) 14.209 { 14.210 - /* _data and other interpreted as int.__data_ */ 14.211 - int i = _data.intvalue; 14.212 - int j = other.intvalue; 14.213 + /* self and other interpreted as int */ 14.214 + int i = __TOINT(self); 14.215 + int j = __TOINT(other); 14.216 14.217 /* Return the new integer. */ 14.218 /* NOTE: No overflow test applied. */ 14.219 return __new_int(i ^ j); 14.220 } 14.221 14.222 -__attr __fn_native_int_int_lt(__attr __self, __attr _data, __attr other) 14.223 +__attr __fn_native_int_int_lt(__attr __self, __attr self, __attr other) 14.224 { 14.225 - /* _data and other interpreted as int.__data_ */ 14.226 - int i = _data.intvalue; 14.227 - int j = other.intvalue; 14.228 + /* self and other interpreted as int */ 14.229 + int i = __TOINT(self); 14.230 + int j = __TOINT(other); 14.231 14.232 /* Return a boolean result. */ 14.233 return i < j ? __builtins___boolean_True : __builtins___boolean_False; 14.234 } 14.235 14.236 -__attr __fn_native_int_int_gt(__attr __self, __attr _data, __attr other) 14.237 +__attr __fn_native_int_int_gt(__attr __self, __attr self, __attr other) 14.238 { 14.239 - /* _data and other interpreted as int.__data_ */ 14.240 - int i = _data.intvalue; 14.241 - int j = other.intvalue; 14.242 + /* self and other interpreted as int */ 14.243 + int i = __TOINT(self); 14.244 + int j = __TOINT(other); 14.245 14.246 /* Return a boolean result. */ 14.247 return i > j ? __builtins___boolean_True : __builtins___boolean_False; 14.248 } 14.249 14.250 -__attr __fn_native_int_int_eq(__attr __self, __attr _data, __attr other) 14.251 +__attr __fn_native_int_int_eq(__attr __self, __attr self, __attr other) 14.252 { 14.253 - /* _data and other interpreted as int.__data_ */ 14.254 - int i = _data.intvalue; 14.255 - int j = other.intvalue; 14.256 + /* self and other interpreted as int */ 14.257 + int i = __TOINT(self); 14.258 + int j = __TOINT(other); 14.259 14.260 /* Return a boolean result. */ 14.261 return i == j ? __builtins___boolean_True : __builtins___boolean_False; 14.262 } 14.263 14.264 -__attr __fn_native_int_int_ne(__attr __self, __attr _data, __attr other) 14.265 +__attr __fn_native_int_int_ne(__attr __self, __attr self, __attr other) 14.266 { 14.267 - /* _data and other interpreted as int.__data_ */ 14.268 - int i = _data.intvalue; 14.269 - int j = other.intvalue; 14.270 + /* self and other interpreted as int */ 14.271 + int i = __TOINT(self); 14.272 + int j = __TOINT(other); 14.273 14.274 /* Return a boolean result. */ 14.275 return i != j ? __builtins___boolean_True : __builtins___boolean_False; 14.276 } 14.277 14.278 -__attr __fn_native_int_int_str(__attr __self, __attr _data) 14.279 +__attr __fn_native_int_int_str(__attr __self, __attr self) 14.280 { 14.281 - /* _data interpreted as int.__data_ */ 14.282 - int i = _data.intvalue; 14.283 + /* self interpreted as int */ 14.284 + int i = __TOINT(self); 14.285 + 14.286 /* Employ a buffer big enough to fit the largest integer plus an extra 14.287 character, a minus sign, and the null terminator. */ 14.288 - unsigned int n = (int) log10(INT_MAX) + 3; 14.289 + unsigned int n = (int) log10(__MAXINT) + 3; 14.290 char *s = (char *) __ALLOCATE(n, sizeof(char)); 14.291 14.292 snprintf(s, n, "%d", i);
15.1 --- a/templates/native/int.h Sun Mar 19 00:56:43 2017 +0100 15.2 +++ b/templates/native/int.h Fri Mar 24 22:39:37 2017 +0100 15.3 @@ -23,8 +23,6 @@ 15.4 15.5 /* Integer operations. */ 15.6 15.7 -__attr __fn_native_int_int_new(__attr __self, __attr _data); 15.8 - 15.9 __attr __fn_native_int_int_add(__attr __self, __attr _data, __attr other); 15.10 __attr __fn_native_int_int_sub(__attr __self, __attr _data, __attr other); 15.11 __attr __fn_native_int_int_mul(__attr __self, __attr _data, __attr other);
16.1 --- a/templates/native/introspection.c Sun Mar 19 00:56:43 2017 +0100 16.2 +++ b/templates/native/introspection.c Fri Mar 24 22:39:37 2017 +0100 16.3 @@ -29,7 +29,7 @@ 16.4 __attr __fn_native_introspection_object_getattr(__attr __self, __attr obj, __attr name, __attr _default) 16.5 { 16.6 /* name interpreted as string */ 16.7 - __attr key = __load_via_object(name.value, __key__); 16.8 + __attr key = __load_via_object(__VALUE(name), __key__); 16.9 __attr out; 16.10 16.11 if ((key.code == 0) && (key.pos == 0)) 16.12 @@ -37,18 +37,18 @@ 16.13 16.14 /* Attempt to get the attribute from the object. */ 16.15 16.16 - out = __check_and_load_via_object_null(obj.value, key.pos, key.code); 16.17 - if (out.value == 0) 16.18 + out = __check_and_load_via_object_null(__VALUE(obj), key.pos, key.code); 16.19 + if (__ISNULL(out)) 16.20 { 16.21 /* Inspect the object's class if this failed. */ 16.22 16.23 - out = __check_and_load_via_class__(obj.value, key.pos, key.code); 16.24 - if (out.value == 0) 16.25 + out = __check_and_load_via_class__(__VALUE(obj), key.pos, key.code); 16.26 + if (__ISNULL(out)) 16.27 return _default; 16.28 16.29 /* Update the context to the object if it is a method. */ 16.30 16.31 - return __update_context(obj.value, out); 16.32 + return __update_context(obj, out); 16.33 } 16.34 16.35 return out; 16.36 @@ -57,7 +57,7 @@ 16.37 __attr __fn_native_introspection_isinstance(__attr __self, __attr obj, __attr cls) 16.38 { 16.39 /* cls must be a class. */ 16.40 - if (__is_instance_subclass(obj.value, cls)) 16.41 + if (__is_instance_subclass(__VALUE(obj), cls)) 16.42 return __builtins___boolean_True; 16.43 else 16.44 return __builtins___boolean_False; 16.45 @@ -66,7 +66,7 @@ 16.46 __attr __fn_native_introspection_issubclass(__attr __self, __attr obj, __attr cls) 16.47 { 16.48 /* obj and cls must be classes. */ 16.49 - if (__is_subclass(obj.value, cls)) 16.50 + if (__is_subclass(__VALUE(obj), cls)) 16.51 return __builtins___boolean_True; 16.52 else 16.53 return __builtins___boolean_False;
17.1 --- a/templates/native/io.c Sun Mar 19 00:56:43 2017 +0100 17.2 +++ b/templates/native/io.c Fri Mar 24 22:39:37 2017 +0100 17.3 @@ -57,10 +57,10 @@ 17.4 17.5 __attr __fn_native_io_fopen(__attr __self, __attr filename, __attr mode) 17.6 { 17.7 - /* filename interpreted as string */ 17.8 - char *fn = __load_via_object(filename.value, __data__).strvalue; 17.9 - /* mode interpreted as string */ 17.10 - char *s = __load_via_object(mode.value, __data__).strvalue; 17.11 + /* filename.__data__ interpreted as string */ 17.12 + char *fn = __load_via_object(__VALUE(filename), __data__).strvalue; 17.13 + /* mode.__data__ interpreted as string */ 17.14 + char *s = __load_via_object(__VALUE(mode), __data__).strvalue; 17.15 FILE *f; 17.16 __attr attr; 17.17 17.18 @@ -88,9 +88,9 @@ 17.19 __attr __fn_native_io_fdopen(__attr __self, __attr fd, __attr mode) 17.20 { 17.21 /* fd interpreted as int */ 17.22 - int i = __load_via_object(fd.value, __data__).intvalue; 17.23 - /* mode interpreted as string */ 17.24 - char *s = __load_via_object(mode.value, __data__).strvalue; 17.25 + int i = __TOINT(fd); 17.26 + /* mode.__data__ interpreted as string */ 17.27 + char *s = __load_via_object(__VALUE(mode), __data__).strvalue; 17.28 FILE *f; 17.29 __attr attr; 17.30 17.31 @@ -120,7 +120,7 @@ 17.32 /* fp interpreted as FILE reference */ 17.33 FILE *f = (FILE *) fp.datavalue; 17.34 /* size interpreted as int */ 17.35 - int to_read = __load_via_object(size.value, __data__).intvalue; 17.36 + int to_read = __TOINT(size); 17.37 char buf[to_read]; 17.38 size_t have_read; 17.39 int error; 17.40 @@ -147,9 +147,10 @@ 17.41 { 17.42 /* fp interpreted as FILE reference */ 17.43 FILE *f = (FILE *) fp.datavalue; 17.44 - /* str interpreted as string */ 17.45 - char *s = __load_via_object(str.value, __data__).strvalue; 17.46 - int to_write = __load_via_object(str.value, __size__).intvalue; 17.47 + /* str.__data__ interpreted as string */ 17.48 + char *s = __load_via_object(__VALUE(str), __data__).strvalue; 17.49 + /* str.__size__ interpreted as int */ 17.50 + int to_write = __TOINT(__load_via_object(__VALUE(str), __size__)); 17.51 size_t have_written = fwrite(s, sizeof(char), to_write, f); 17.52 int error; 17.53 17.54 @@ -167,7 +168,7 @@ 17.55 __attr __fn_native_io_close(__attr __self, __attr fd) 17.56 { 17.57 /* fd interpreted as int */ 17.58 - int i = __load_via_object(fd.value, __data__).intvalue; 17.59 + int i = __TOINT(fd); 17.60 17.61 errno = 0; 17.62 if (close(i) == -1) 17.63 @@ -179,9 +180,9 @@ 17.64 __attr __fn_native_io_read(__attr __self, __attr fd, __attr n) 17.65 { 17.66 /* fd interpreted as int */ 17.67 - int i = __load_via_object(fd.value, __data__).intvalue; 17.68 + int i = __TOINT(fd); 17.69 /* n interpreted as int */ 17.70 - int to_read = __load_via_object(n.value, __data__).intvalue; 17.71 + int to_read = __TOINT(n); 17.72 char buf[to_read]; 17.73 ssize_t have_read; 17.74 char *s; 17.75 @@ -202,10 +203,11 @@ 17.76 __attr __fn_native_io_write(__attr __self, __attr fd, __attr str) 17.77 { 17.78 /* fd interpreted as int */ 17.79 - int i = __load_via_object(fd.value, __data__).intvalue; 17.80 - /* str interpreted as string */ 17.81 - char *s = __load_via_object(str.value, __data__).strvalue; 17.82 - int size = __load_via_object(str.value, __size__).intvalue; 17.83 + int i = __TOINT(fd); 17.84 + /* str.__data__ interpreted as string */ 17.85 + char *s = __load_via_object(__VALUE(str), __data__).strvalue; 17.86 + /* str.__size__ interpreted as int */ 17.87 + int size = __TOINT(__load_via_object(__VALUE(str), __size__)); 17.88 ssize_t have_written; 17.89 17.90 errno = 0;
18.1 --- a/templates/native/limits.c Sun Mar 19 00:56:43 2017 +0100 18.2 +++ b/templates/native/limits.c Fri Mar 24 22:39:37 2017 +0100 18.3 @@ -16,7 +16,6 @@ 18.4 this program. If not, see <http://www.gnu.org/licenses/>. 18.5 */ 18.6 18.7 -#include <limits.h> /* INT_MAX, INT_MIN */ 18.8 #include "native/common.h" 18.9 #include "types.h" 18.10 #include "exceptions.h" 18.11 @@ -30,12 +29,12 @@ 18.12 18.13 __attr __fn_native_limits_get_maxint(__attr __self) 18.14 { 18.15 - return __new_int(INT_MAX); 18.16 + return __new_int(__MAXINT); 18.17 } 18.18 18.19 __attr __fn_native_limits_get_minint(__attr __self) 18.20 { 18.21 - return __new_int(INT_MIN); 18.22 + return __new_int(__MININT); 18.23 } 18.24 18.25 /* Module initialisation. */
19.1 --- a/templates/native/list.c Sun Mar 19 00:56:43 2017 +0100 19.2 +++ b/templates/native/list.c Fri Mar 24 22:39:37 2017 +0100 19.3 @@ -30,7 +30,7 @@ 19.4 __attr __fn_native_list_list_init(__attr __self, __attr size) 19.5 { 19.6 /* size interpreted as int */ 19.7 - unsigned int n = __load_via_object(size.value, __data__).intvalue; 19.8 + unsigned int n = __TOINT(size); 19.9 __attr attr = {.seqvalue=__new_fragment(n)}; 19.10 19.11 /* Return the __data__ attribute. */ 19.12 @@ -42,7 +42,7 @@ 19.13 /* _data interpreted as list.__data__ */ 19.14 __fragment *data = _data.seqvalue; 19.15 /* size interpreted as int */ 19.16 - unsigned int n = __load_via_object(size.value, __data__).intvalue; 19.17 + unsigned int n = __TOINT(size); 19.18 19.19 data->size = n; 19.20 return __builtins___none_None; 19.21 @@ -50,20 +50,20 @@ 19.22 19.23 __attr __fn_native_list_list_append(__attr __self, __attr self, __attr value) 19.24 { 19.25 - /* self interpreted as list */ 19.26 - __fragment *data = __load_via_object(self.value, __data__).seqvalue; 19.27 + /* self.__data__ interpreted as list */ 19.28 + __fragment *data = __load_via_object(__VALUE(self), __data__).seqvalue; 19.29 __fragment *newdata = __fragment_append(data, value); 19.30 19.31 /* Replace the __data__ attribute if appropriate. */ 19.32 if (newdata != data) 19.33 - __store_via_object(self.value, __data__, ((__attr) {.seqvalue=newdata})); 19.34 + __store_via_object(__VALUE(self), __data__, ((__attr) {.seqvalue=newdata})); 19.35 return __builtins___none_None; 19.36 } 19.37 19.38 __attr __fn_native_list_list_concat(__attr __self, __attr self, __attr other) 19.39 { 19.40 /* self, interpreted as list, other interpreted as list.__data__ */ 19.41 - __fragment *data = __load_via_object(self.value, __data__).seqvalue; 19.42 + __fragment *data = __load_via_object(__VALUE(self), __data__).seqvalue; 19.43 __fragment *other_data = other.seqvalue; 19.44 __fragment *newdata = data; 19.45 unsigned int size = data->size, capacity = data->capacity; 19.46 @@ -84,7 +84,7 @@ 19.47 19.48 /* Replace the __data__ attribute if appropriate. */ 19.49 if (newdata != data) 19.50 - __store_via_object(self.value, __data__, ((__attr) {.seqvalue=newdata})); 19.51 + __store_via_object(__VALUE(self), __data__, ((__attr) {.seqvalue=newdata})); 19.52 return __builtins___none_None; 19.53 } 19.54 19.55 @@ -107,7 +107,7 @@ 19.56 /* _data interpreted as list.__data__ */ 19.57 __attr *elements = _data.seqvalue->attrs; 19.58 /* index interpreted as int */ 19.59 - int i = __load_via_object(index.value, __data__).intvalue; 19.60 + int i = __TOINT(index); 19.61 19.62 return elements[i]; 19.63 } 19.64 @@ -117,7 +117,7 @@ 19.65 /* _data interpreted as list.__data__ */ 19.66 __attr *elements = _data.seqvalue->attrs; 19.67 /* index interpreted as int */ 19.68 - int i = __load_via_object(index.value, __data__).intvalue; 19.69 + int i = __TOINT(index); 19.70 19.71 /* Set the element. */ 19.72 elements[i] = value;
20.1 --- a/templates/native/locale.c Sun Mar 19 00:56:43 2017 +0100 20.2 +++ b/templates/native/locale.c Fri Mar 24 22:39:37 2017 +0100 20.3 @@ -32,7 +32,7 @@ 20.4 __attr __fn_native_locale_getlocale(__attr __self, __attr category) 20.5 { 20.6 /* category interpreted as int */ 20.7 - int cat = __load_via_object(category.value, __data__).intvalue; 20.8 + int cat = __TOINT(category); 20.9 char *result, *out; 20.10 size_t length; 20.11 20.12 @@ -51,9 +51,9 @@ 20.13 __attr __fn_native_locale_setlocale(__attr __self, __attr category, __attr value) 20.14 { 20.15 /* category interpreted as int */ 20.16 - int cat = __load_via_object(category.value, __data__).intvalue; 20.17 + int cat = __TOINT(category); 20.18 /* value interpreted as string */ 20.19 - char *s = __load_via_object(value.value, __data__).strvalue; 20.20 + char *s = __load_via_object(__VALUE(value), __data__).strvalue; 20.21 char *result, *out; 20.22 size_t length; 20.23
21.1 --- a/templates/native/program.c Sun Mar 19 00:56:43 2017 +0100 21.2 +++ b/templates/native/program.c Fri Mar 24 22:39:37 2017 +0100 21.3 @@ -28,7 +28,7 @@ 21.4 21.5 __attr __fn_native_program_get_using(__attr __self, __attr callable, __attr instance) 21.6 { 21.7 - return __test_context(instance.value, callable); 21.8 + return __test_context(instance, callable); 21.9 } 21.10 21.11 /* Module initialisation. */
22.1 --- a/templates/native/str.c Sun Mar 19 00:56:43 2017 +0100 22.2 +++ b/templates/native/str.c Fri Mar 24 22:39:37 2017 +0100 22.3 @@ -33,8 +33,8 @@ 22.4 /* _data, other interpreted as string.__data__ */ 22.5 char *s = _data.strvalue; 22.6 char *o = other.strvalue; 22.7 - /* _size, othersize interpreted as int.__data__ */ 22.8 - int ss = _size.intvalue, os = othersize.intvalue; 22.9 + /* _size, othersize interpreted as int */ 22.10 + int ss = __TOINT(_size), os = __TOINT(othersize); 22.11 int n = ss + os; 22.12 char *r = (char *) __ALLOCATE(n + 1, sizeof(char)); 22.13 22.14 @@ -47,8 +47,8 @@ 22.15 22.16 __attr __fn_native_str_str_chr(__attr __self, __attr _data) 22.17 { 22.18 - /* _data interpreted as int.__data__ */ 22.19 - int n = _data.intvalue; 22.20 + /* data interpreted as int */ 22.21 + int n = __TOINT(_data); 22.22 char *s = (char *) __ALLOCATE(2, sizeof(char)); 22.23 22.24 s[0] = (char) n; 22.25 @@ -98,11 +98,11 @@ 22.26 /* _data interpreted as string.__data__ */ 22.27 char *s = _data.strvalue, *sub; 22.28 /* start interpreted as int */ 22.29 - int istart = __load_via_object(start.value, __data__).intvalue; 22.30 + int istart = __TOINT(start); 22.31 /* end interpreted as int */ 22.32 - int iend = __load_via_object(end.value, __data__).intvalue; 22.33 + int iend = __TOINT(end); 22.34 /* step interpreted as int */ 22.35 - int istep = __load_via_object(step.value, __data__).intvalue; 22.36 + int istep = __TOINT(step); 22.37 22.38 /* Calculate the size of the substring. */ 22.39 size_t resultsize = ((iend - istart - (istep > 0 ? 1 : -1)) / istep) + 1;
23.1 --- a/templates/native/system.c Sun Mar 19 00:56:43 2017 +0100 23.2 +++ b/templates/native/system.c Fri Mar 24 22:39:37 2017 +0100 23.3 @@ -29,7 +29,7 @@ 23.4 23.5 __attr __fn_native_system_exit(__attr __self, __attr status) 23.6 { 23.7 - exit(__load_via_object(status.value, __data__).intvalue); 23.8 + exit(__VALUE(status)); 23.9 return __builtins___none_None; 23.10 } 23.11
24.1 --- a/templates/native/unicode.c Sun Mar 19 00:56:43 2017 +0100 24.2 +++ b/templates/native/unicode.c Fri Mar 24 22:39:37 2017 +0100 24.3 @@ -73,8 +73,8 @@ 24.4 { 24.5 /* _data interpreted as string.__data__ */ 24.6 char *s = _data.strvalue; 24.7 - /* _size interpreted as int.__data__ */ 24.8 - int size = _size.intvalue; 24.9 + /* _size interpreted as int */ 24.10 + int size = __TOINT(_size); 24.11 unsigned int i, c = 0; 24.12 24.13 for (i = 0; i < size; i++) 24.14 @@ -89,8 +89,8 @@ 24.15 { 24.16 /* _data interpreted as string.__data__ */ 24.17 char *s = _data.strvalue; 24.18 - /* _size interpreted as int.__data__ */ 24.19 - int size = _size.intvalue; 24.20 + /* _size interpreted as int */ 24.21 + int size = __TOINT(_size); 24.22 unsigned int i, c = 0, v; 24.23 24.24 for (i = 0; i < size; i++) 24.25 @@ -123,14 +123,14 @@ 24.26 { 24.27 /* _data interpreted as string.__data__ */ 24.28 char *s = _data.strvalue, *sub; 24.29 - /* _size interpreted as int.__data__ */ 24.30 - int ss = _size.intvalue; 24.31 + /* _size interpreted as int */ 24.32 + int ss = __TOINT(_size); 24.33 /* start interpreted as int */ 24.34 - int istart = __load_via_object(start.value, __data__).intvalue; 24.35 + int istart = __TOINT(start); 24.36 /* end interpreted as int */ 24.37 - int iend = __load_via_object(end.value, __data__).intvalue; 24.38 + int iend = __TOINT(end); 24.39 /* step interpreted as int */ 24.40 - int istep = __load_via_object(step.value, __data__).intvalue; 24.41 + int istep = __TOINT(step); 24.42 24.43 /* Calculate the number of characters. */ 24.44 size_t nchar = ((iend - istart - (istep > 0 ? 1 : -1)) / istep) + 1; 24.45 @@ -195,8 +195,8 @@ 24.46 24.47 __attr __fn_native_unicode_unicode_unichr(__attr __self, __attr value) 24.48 { 24.49 - /* value interpreted as int.__data__ */ 24.50 - int i = value.intvalue; 24.51 + /* value interpreted as int */ 24.52 + int i = __TOINT(value); 24.53 unsigned int resultsize; 24.54 char *s; 24.55
25.1 --- a/templates/ops.c Sun Mar 19 00:56:43 2017 +0100 25.2 +++ b/templates/ops.c Fri Mar 24 22:39:37 2017 +0100 25.3 @@ -23,6 +23,16 @@ 25.4 #include "progconsts.h" 25.5 #include "progtypes.h" 25.6 25.7 +/* Get object reference from attribute. */ 25.8 + 25.9 +__ref __VALUE(__attr attr) 25.10 +{ 25.11 + if (!__INTEGER(attr)) 25.12 + return attr.value; 25.13 + else 25.14 + return &__common_integer_obj; 25.15 +} 25.16 + 25.17 /* Basic structure tests. */ 25.18 25.19 static inline int __HASATTR(__ref obj, int pos, int code) 25.20 @@ -37,12 +47,12 @@ 25.21 return __ATTRVALUE(obj); 25.22 } 25.23 25.24 -__attr __load_static_replace(__ref context, __ref obj) 25.25 +__attr __load_static_replace(__attr context, __ref obj) 25.26 { 25.27 return __update_context(context, __ATTRVALUE(obj)); 25.28 } 25.29 25.30 -__attr __load_static_test(__ref context, __ref obj) 25.31 +__attr __load_static_test(__attr context, __ref obj) 25.32 { 25.33 return __test_context(context, __ATTRVALUE(obj)); 25.34 } 25.35 @@ -92,12 +102,12 @@ 25.36 25.37 int __is_subclass(__ref obj, __attr cls) 25.38 { 25.39 - return __HASATTR(obj, __TYPEPOS(cls.value), __TYPECODE(cls.value)); 25.40 + return __HASATTR(obj, __TYPEPOS(__VALUE(cls)), __TYPECODE(__VALUE(cls))); 25.41 } 25.42 25.43 int __is_instance_subclass(__ref obj, __attr cls) 25.44 { 25.45 - return __is_instance(obj) && __HASATTR(__get_class(obj), __TYPEPOS(cls.value), __TYPECODE(cls.value)); 25.46 + return __is_instance(obj) && __HASATTR(__get_class(obj), __TYPEPOS(__VALUE(cls)), __TYPECODE(__VALUE(cls))); 25.47 } 25.48 25.49 int __is_type_instance(__ref obj) 25.50 @@ -107,7 +117,7 @@ 25.51 25.52 __ref __get_class(__ref obj) 25.53 { 25.54 - return __load_via_object(obj, __class__).value; 25.55 + return __VALUE(__load_via_object(obj, __class__)); 25.56 } 25.57 25.58 __attr __get_class_attr(__ref obj) 25.59 @@ -174,7 +184,7 @@ 25.60 __attr __check_and_load_via_any__(__ref obj, int pos, int code) 25.61 { 25.62 __attr out = __check_and_load_via_object_null(obj, pos, code); 25.63 - if (out.value == 0) 25.64 + if (__ISNULL(out)) 25.65 out = __check_and_load_via_class__(obj, pos, code); 25.66 return out; 25.67 } 25.68 @@ -216,27 +226,28 @@ 25.69 25.70 /* Context-related operations. */ 25.71 25.72 -int __test_context_update(__ref context, __attr attr) 25.73 +int __test_context_update(__attr context, __attr attr) 25.74 { 25.75 /* Return whether the context should be updated for the attribute. */ 25.76 25.77 - __ref attrcontext = __CONTEXT_AS_VALUE(attr).value; 25.78 + __attr attrcontext = __CONTEXT_AS_VALUE(attr); 25.79 + __ref attrcontextvalue = __VALUE(attrcontext); 25.80 25.81 /* Preserve any existing null or instance context. */ 25.82 25.83 - if ((attrcontext == 0) || __is_instance(attrcontext)) 25.84 + if (__ISNULL(attrcontext) || __is_instance(attrcontextvalue)) 25.85 return 0; 25.86 25.87 /* Test any instance context against the context employed by the 25.88 attribute. */ 25.89 25.90 - if (__is_instance(context)) 25.91 + if (__is_instance(__VALUE(context))) 25.92 { 25.93 /* Obtain the special class attribute position and code identifying the 25.94 attribute context's class, inspecting the context instance for 25.95 compatibility. */ 25.96 25.97 - if (__test_common_instance__(context, __TYPEPOS(attrcontext), __TYPECODE(attrcontext))) 25.98 + if (__test_common_instance__(__VALUE(context), __TYPEPOS(attrcontextvalue), __TYPECODE(attrcontextvalue))) 25.99 return 1; 25.100 else 25.101 __raise_type_error(); 25.102 @@ -244,7 +255,7 @@ 25.103 25.104 /* Test for access to a type class attribute using a type instance. */ 25.105 25.106 - if (__test_specific_type(attrcontext, &__TYPE_CLASS_TYPE) && __is_type_instance(context)) 25.107 + if (__test_specific_type(attrcontextvalue, &__TYPE_CLASS_TYPE) && __is_type_instance(__VALUE(context))) 25.108 return 1; 25.109 25.110 /* Otherwise, preserve the attribute as retrieved. */ 25.111 @@ -252,7 +263,7 @@ 25.112 return 0; 25.113 } 25.114 25.115 -__attr __test_context(__ref context, __attr attr) 25.116 +__attr __test_context(__attr context, __attr attr) 25.117 { 25.118 /* Update the context or return the unchanged attribute. */ 25.119 25.120 @@ -262,22 +273,22 @@ 25.121 return attr; 25.122 } 25.123 25.124 -__attr __update_context(__ref context, __attr attr) 25.125 +__attr __update_context(__attr context, __attr attr) 25.126 { 25.127 return __new_wrapper(context, attr); 25.128 } 25.129 25.130 -__attr __test_context_revert(int target, __ref context, __attr attr, __ref contexts[]) 25.131 +__attr __test_context_revert(int target, __attr context, __attr attr, __attr contexts[]) 25.132 { 25.133 /* Revert the local context to that employed by the attribute if the 25.134 supplied context is not appropriate. */ 25.135 25.136 if (!__test_context_update(context, attr)) 25.137 - contexts[target] = __CONTEXT_AS_VALUE(attr).value; 25.138 + contexts[target] = __CONTEXT_AS_VALUE(attr); 25.139 return attr; 25.140 } 25.141 25.142 -__attr __test_context_static(int target, __ref context, __ref value, __ref contexts[]) 25.143 +__attr __test_context_static(int target, __attr context, __ref value, __attr contexts[]) 25.144 { 25.145 /* Set the local context to the specified context if appropriate. */ 25.146 25.147 @@ -288,48 +299,53 @@ 25.148 25.149 /* Context testing for invocations. */ 25.150 25.151 -int __type_method_invocation(__ref context, __attr target) 25.152 +int __type_method_invocation(__attr context, __attr target) 25.153 { 25.154 - __ref targetcontext = __CONTEXT_AS_VALUE(target).value; 25.155 + __attr targetcontext = __CONTEXT_AS_VALUE(target); 25.156 25.157 /* Require instances, not classes, where methods are function instances. */ 25.158 25.159 - if (!__is_instance(target.value)) 25.160 + if (!__is_instance(__VALUE(target))) 25.161 return 0; 25.162 25.163 /* Access the context of the callable and test if it is the type object. */ 25.164 25.165 - return ((targetcontext != 0) && __test_specific_type(targetcontext, &__TYPE_CLASS_TYPE) && __is_type_instance(context)); 25.166 + return (!__ISNULL(targetcontext) && __test_specific_type(__VALUE(targetcontext), &__TYPE_CLASS_TYPE) && __is_type_instance(__VALUE(context))); 25.167 } 25.168 25.169 __attr __unwrap_callable(__attr callable) 25.170 { 25.171 - __attr value = __check_and_load_via_object_null(callable.value, __ATTRPOS(__value__), __ATTRCODE(__value__)); 25.172 - return value.value ? value : callable; 25.173 + __attr value = __check_and_load_via_object_null(__VALUE(callable), __ATTRPOS(__value__), __ATTRCODE(__value__)); 25.174 + return __VALUE(value) ? value : callable; 25.175 } 25.176 25.177 -__attr (*__get_function(__ref context, __attr target))() 25.178 +__attr (*__get_function_unchecked(__attr target))() 25.179 +{ 25.180 + return __load_via_object(__VALUE(__unwrap_callable(target)), __fn__).fn; 25.181 +} 25.182 + 25.183 +__attr (*__get_function(__attr context, __attr target))() 25.184 { 25.185 target = __unwrap_callable(target); 25.186 25.187 /* Require null or instance contexts for functions and methods respectively, 25.188 or type instance contexts for type methods. */ 25.189 25.190 - if ((context == 0) || __is_instance(context) || __type_method_invocation(context, target)) 25.191 - return __load_via_object(target.value, __fn__).fn; 25.192 + if (__ISNULL(context) || __is_instance(__VALUE(context)) || __type_method_invocation(context, target)) 25.193 + return __load_via_object(__VALUE(target), __fn__).fn; 25.194 else 25.195 return __unbound_method; 25.196 } 25.197 25.198 -__attr (*__check_and_get_function(__ref context, __attr target))() 25.199 +__attr (*__check_and_get_function(__attr context, __attr target))() 25.200 { 25.201 target = __unwrap_callable(target); 25.202 25.203 /* Require null or instance contexts for functions and methods respectively, 25.204 or type instance contexts for type methods. */ 25.205 25.206 - if ((context == 0) || __is_instance(context) || __type_method_invocation(context, target)) 25.207 - return __check_and_load_via_object__(target.value, __ATTRPOS(__fn__), __ATTRCODE(__fn__)).fn; 25.208 + if (__ISNULL(context) || __is_instance(__VALUE(context)) || __type_method_invocation(context, target)) 25.209 + return __check_and_load_via_object__(__VALUE(target), __ATTRPOS(__fn__), __ATTRCODE(__fn__)).fn; 25.210 else 25.211 return __unbound_method; 25.212 } 25.213 @@ -354,7 +370,7 @@ 25.214 25.215 __attr __CONTEXT_AS_VALUE(__attr attr) 25.216 { 25.217 - return __check_and_load_via_object_null(attr.value, __ATTRPOS(__context__), __ATTRCODE(__context__)); 25.218 + return __check_and_load_via_object_null(__VALUE(attr), __ATTRPOS(__context__), __ATTRCODE(__context__)); 25.219 } 25.220 25.221 /* Type testing. */ 25.222 @@ -391,6 +407,14 @@ 25.223 return ptr; 25.224 } 25.225 25.226 +void *__ALLOCATEIM(size_t nmemb, size_t size) 25.227 +{ 25.228 + void *ptr = GC_MALLOC_ATOMIC(nmemb * size); /* sets memory to zero */ 25.229 + if (ptr == NULL) 25.230 + __raise_memory_error(); 25.231 + return ptr; 25.232 +} 25.233 + 25.234 void *__REALLOCATE(void *ptr, size_t size) 25.235 { 25.236 void *nptr = GC_REALLOC(ptr, size);
26.1 --- a/templates/ops.h Sun Mar 19 00:56:43 2017 +0100 26.2 +++ b/templates/ops.h Fri Mar 24 22:39:37 2017 +0100 26.3 @@ -22,11 +22,15 @@ 26.4 #include "types.h" 26.5 #include <string.h> /* for __COPY */ 26.6 26.7 +/* Get object reference from attribute. */ 26.8 + 26.9 +__ref __VALUE(__attr attr); 26.10 + 26.11 /* Direct access and manipulation of static objects. */ 26.12 26.13 __attr __load_static_ignore(__ref obj); 26.14 -__attr __load_static_replace(__ref context, __ref obj); 26.15 -__attr __load_static_test(__ref context, __ref obj); 26.16 +__attr __load_static_replace(__attr context, __ref obj); 26.17 +__attr __load_static_test(__attr context, __ref obj); 26.18 26.19 /* Direct retrieval operations, returning attributes. */ 26.20 26.21 @@ -93,23 +97,24 @@ 26.22 26.23 /* Context-related operations. */ 26.24 26.25 -int __test_context_update(__ref context, __attr attr); 26.26 -__attr __test_context(__ref context, __attr attr); 26.27 -__attr __update_context(__ref context, __attr attr); 26.28 -__attr __test_context_revert(int target, __ref context, __attr attr, __ref contexts[]); 26.29 -__attr __test_context_static(int target, __ref context, __ref value, __ref contexts[]); 26.30 +int __test_context_update(__attr context, __attr attr); 26.31 +__attr __test_context(__attr context, __attr attr); 26.32 +__attr __update_context(__attr context, __attr attr); 26.33 +__attr __test_context_revert(int target, __attr context, __attr attr, __attr contexts[]); 26.34 +__attr __test_context_static(int target, __attr context, __ref value, __attr contexts[]); 26.35 26.36 #define __get_context(__TARGET) (__tmp_contexts[__TARGET]) 26.37 -#define __set_context(__TARGET, __ATTR) (__tmp_contexts[__TARGET] = (__ATTR).value) 26.38 -#define __set_private_context(__ATTR) (__tmp_private_context = (__ATTR).value) 26.39 -#define __set_accessor(__ATTR) (__tmp_value = (__ATTR).value) 26.40 -#define __set_target_accessor(__ATTR) (__tmp_target_value = (__ATTR).value) 26.41 +#define __set_context(__TARGET, __ATTR) (__tmp_contexts[__TARGET] = (__ATTR)) 26.42 +#define __set_private_context(__ATTR) (__tmp_private_context = (__ATTR)) 26.43 +#define __set_accessor(__ATTR) (__tmp_value = (__ATTR)) 26.44 +#define __set_target_accessor(__ATTR) (__tmp_target_value = (__ATTR)) 26.45 26.46 /* Context testing for invocations. */ 26.47 26.48 __attr __unwrap_callable(__attr callable); 26.49 -__attr (*__get_function(__ref context, __attr target))(); 26.50 -__attr (*__check_and_get_function(__ref context, __attr target))(); 26.51 +__attr (*__get_function_unchecked(__attr target))(); 26.52 +__attr (*__get_function(__attr context, __attr target))(); 26.53 +__attr (*__check_and_get_function(__attr context, __attr target))(); 26.54 26.55 /* Parameter position operations. */ 26.56 26.57 @@ -132,6 +137,7 @@ 26.58 /* Memory allocation. */ 26.59 26.60 void *__ALLOCATE(size_t nmemb, size_t size); 26.61 +void *__ALLOCATEIM(size_t nmemb, size_t size); 26.62 void *__REALLOCATE(void *ptr, size_t size); 26.63 26.64 /* Copying of structures. */
27.1 --- a/templates/progops.c Sun Mar 19 00:56:43 2017 +0100 27.2 +++ b/templates/progops.c Fri Mar 24 22:39:37 2017 +0100 27.3 @@ -28,18 +28,18 @@ 27.4 27.5 /* Generic instantiation operations, defining common members. */ 27.6 27.7 -__attr __new(const __table * table, __ref cls, size_t size) 27.8 +__attr __new(const __table * table, __ref cls, size_t size, int immutable) 27.9 { 27.10 - __ref obj = (__ref) __ALLOCATE(1, size); 27.11 + __ref obj = (__ref) (immutable ? __ALLOCATEIM : __ALLOCATE)(1, size); 27.12 obj->table = table; 27.13 obj->pos = __INSTANCEPOS; 27.14 __store_via_object(obj, __class__, __ATTRVALUE(cls)); 27.15 - return (__attr) {.value=obj}; 27.16 + return __ATTRVALUE(obj); 27.17 } 27.18 27.19 -__attr __new_wrapper(__ref context, __attr attr) 27.20 +__attr __new_wrapper(__attr context, __attr attr) 27.21 { 27.22 - return __new___builtins___core_wrapper(__NULL, __ATTRVALUE(context), attr); 27.23 + return __new___builtins___core_wrapper(__NULL, context, attr); 27.24 } 27.25 27.26 /* Generic internal data allocation. */ 27.27 @@ -74,7 +74,7 @@ 27.28 27.29 /* Store a reference to the data in the object's __data__ attribute. */ 27.30 27.31 - __store_via_object(self.value, __data__, attr); 27.32 + __store_via_object(__VALUE(self), __data__, attr); 27.33 return self; 27.34 } 27.35 27.36 @@ -145,7 +145,7 @@ 27.37 27.38 /* Return instances as provided. */ 27.39 27.40 - if (__is_instance(arg.value)) 27.41 + if (__is_instance(__VALUE(arg))) 27.42 return arg; 27.43 27.44 /* Invoke non-instances to produce instances. */ 27.45 @@ -174,7 +174,7 @@ 27.46 /* Obtain the __args__ special member, referencing the parameter table. */ 27.47 /* Refer to the table and minimum/maximum. */ 27.48 27.49 - const __ptable *ptable = __check_and_load_via_object(target.value, __args__).ptable; 27.50 + const __ptable *ptable = __check_and_load_via_object(__VALUE(target), __args__).ptable; 27.51 const unsigned int min = ptable->min, max = ptable->max; 27.52 27.53 /* Reserve enough space for the arguments. */ 27.54 @@ -203,7 +203,7 @@ 27.55 /* Erase the remaining arguments. */ 27.56 27.57 for (pos = nargs; pos < max; pos++) 27.58 - allargs[pos].value = 0; 27.59 + __SETNULL(allargs[pos]); 27.60 27.61 /* Fill keyword arguments. */ 27.62 27.63 @@ -228,8 +228,8 @@ 27.64 27.65 for (pos = nargs; pos < max; pos++) 27.66 { 27.67 - if (allargs[pos].value == 0) 27.68 - allargs[pos] = __GETDEFAULT(target.value, pos - min); 27.69 + if (__ISNULL(allargs[pos])) 27.70 + allargs[pos] = __GETDEFAULT(__VALUE(target), pos - min); 27.71 } 27.72 } 27.73 27.74 @@ -238,8 +238,8 @@ 27.75 27.76 return __call_with_args( 27.77 always_callable ? 27.78 - __get_function(allargs[0].value, target) : 27.79 - __check_and_get_function(allargs[0].value, target), 27.80 + __get_function(allargs[0], target) : 27.81 + __check_and_get_function(allargs[0], target), 27.82 allargs, max); 27.83 } 27.84 27.85 @@ -265,8 +265,10 @@ 27.86 27.87 int __BOOL(__attr attr) 27.88 { 27.89 + __ref truevalue = __VALUE(__builtins___boolean_True); 27.90 + 27.91 /* Invoke the bool function with the object and test against True. */ 27.92 27.93 - return (attr.value == __builtins___boolean_True.value) || 27.94 - (__fn___builtins___boolean_bool(__NULL, attr).value == __builtins___boolean_True.value); 27.95 + return (__VALUE(attr) == truevalue) || 27.96 + (__VALUE(__fn___builtins___boolean_bool(__NULL, attr)) == truevalue); 27.97 }
28.1 --- a/templates/progops.h Sun Mar 19 00:56:43 2017 +0100 28.2 +++ b/templates/progops.h Fri Mar 24 22:39:37 2017 +0100 28.3 @@ -25,8 +25,8 @@ 28.4 28.5 /* Generic instantiation operations, defining common members. */ 28.6 28.7 -__attr __new(const __table *table, __ref cls, size_t size); 28.8 -__attr __new_wrapper(__ref context, __attr attr); 28.9 +__attr __new(const __table *table, __ref cls, size_t size, int immutable); 28.10 +__attr __new_wrapper(__attr context, __attr attr); 28.11 28.12 /* Generic internal data allocation. */ 28.13 28.14 @@ -78,7 +78,8 @@ 28.15 28.16 /* Convenience definitions. */ 28.17 28.18 -#define __NEWINSTANCE(__CLS) __new(&__InstanceTable_##__CLS, &__CLS, sizeof(__obj_##__CLS)) 28.19 +#define __NEWINSTANCE(__CLS) __new(&__InstanceTable_##__CLS, &__CLS, sizeof(__obj_##__CLS), 0) 28.20 +#define __NEWINSTANCEIM(__CLS) __new(&__InstanceTable_##__CLS, &__CLS, sizeof(__obj_##__CLS), 1) 28.21 #define __ISINSTANCE(__ATTR, __TYPE) __BOOL(__fn_native_introspection_isinstance(__NULL, __ATTR, __TYPE)) 28.22 28.23 #endif /* __PROGOPS_H__ */
29.1 --- a/templates/types.h Sun Mar 19 00:56:43 2017 +0100 29.2 +++ b/templates/types.h Fri Mar 24 22:39:37 2017 +0100 29.3 @@ -72,14 +72,19 @@ 29.4 29.5 typedef union __attr 29.6 { 29.7 + /* General attribute members. */ 29.8 + 29.9 __ref value; /* attribute value */ 29.10 + int intvalue; /* integer value data ((integer << 1) | 1) */ 29.11 + 29.12 + /* Special case attribute members. */ 29.13 + 29.14 const __ptable * ptable; /* parameter table */ 29.15 struct { 29.16 __pcode code; /* parameter table code for key */ 29.17 __ppos pos; /* parameter table position for key */ 29.18 }; 29.19 __attr (*fn)(); /* callable details */ 29.20 - int intvalue; /* integer value */ 29.21 float floatvalue; /* floating point value */ 29.22 char * strvalue; /* string value */ 29.23 __fragment * seqvalue; /* sequence data */ 29.24 @@ -106,10 +111,22 @@ 29.25 29.26 #define __FRAGMENT_SIZE(NUMBER) ((NUMBER) * sizeof(__attr) + 2 * sizeof(unsigned int)) 29.27 29.28 +/* Attribute interpretation. */ 29.29 + 29.30 +#define __INTEGER(ATTR) ((ATTR).intvalue % 2) 29.31 + 29.32 /* Attribute value setting. */ 29.33 29.34 #define __ATTRVALUE(VALUE) ((__attr) {.value=VALUE}) 29.35 #define __NULL __ATTRVALUE(0) 29.36 +#define __SETNULL(ATTR) ((ATTR).value = 0) 29.37 + 29.38 +/* Attribute as instance setting. */ 29.39 + 29.40 +#define __INTVALUE(VALUE) ((__attr) {.intvalue=((VALUE) << 1) | 1}) 29.41 +#define __TOINT(ATTR) ((ATTR).intvalue >> 1) 29.42 +#define __MAXINT ((1 << ((sizeof(__attr) * 8) - 2)) - 1) 29.43 +#define __MININT (-(1 << ((sizeof(__attr) * 8) - 2))) 29.44 29.45 /* Argument lists. */ 29.46
30.1 --- a/tests/get_using.py Sun Mar 19 00:56:43 2017 +0100 30.2 +++ b/tests/get_using.py Fri Mar 24 22:39:37 2017 +0100 30.3 @@ -21,6 +21,11 @@ 30.4 except UnboundMethodInvocation: 30.5 print "fn(): method is unbound" 30.6 30.7 +try: 30.8 + print f() # fails 30.9 +except UnboundMethodInvocation: 30.10 + print "f(): method is unbound" 30.11 + 30.12 d = D() 30.13 try: 30.14 fn = get_using(C.f, d)
31.1 --- a/tests/numbers.py Sun Mar 19 00:56:43 2017 +0100 31.2 +++ b/tests/numbers.py Fri Mar 24 22:39:37 2017 +0100 31.3 @@ -10,15 +10,15 @@ 31.4 print "# sys.maxint + sys.minint:", 31.5 print sys.maxint + sys.minint 31.6 31.7 -i = 2 ** 30 31.8 -print i # 1073741824 31.9 -print hex(i) # 0x40000000 31.10 -print oct(i) # 010000000000 31.11 +i = 2 ** 29 31.12 +print i # 536870912 31.13 +print hex(i) # 0x20000000 31.14 +print oct(i) # 04000000000 31.15 31.16 -j = -2 ** 30 31.17 -print j # -1073741824 31.18 -print hex(j) # -0x40000000 31.19 -print oct(j) # -010000000000 31.20 +j = -2 ** 29 31.21 +print j # -536870912 31.22 +print hex(j) # -0x20000000 31.23 +print oct(j) # -05000000000 31.24 31.25 print i + j # 0 31.26 31.27 @@ -39,9 +39,9 @@ 31.28 31.29 print i - i # 0 31.30 print j - j # 0 31.31 -print ~j # 1073741823 31.32 +print ~j # 536870911 31.33 print i & ~j # 0 31.34 -print i - 1 & ~j # 1073741823 31.35 +print i - 1 & ~j # 536870911 31.36 31.37 print hex(31) # 0x1f 31.38 print oct(31) # 037
32.1 --- a/translator.py Sun Mar 19 00:56:43 2017 +0100 32.2 +++ b/translator.py Fri Mar 24 22:39:37 2017 +0100 32.3 @@ -29,7 +29,7 @@ 32.4 from errors import InspectError, TranslateError 32.5 from os.path import exists, join 32.6 from os import makedirs 32.7 -from referencing import Reference 32.8 +from referencing import Reference, combine_types 32.9 from results import Result 32.10 from transresults import TrConstantValueRef, TrInstanceRef, \ 32.11 TrLiteralSequenceRef, TrResolvedNameRef, \ 32.12 @@ -542,7 +542,7 @@ 32.13 32.14 subs = { 32.15 "<expr>" : attr_expr, 32.16 - "<name>" : "%s.value" % attr_expr, 32.17 + "<name>" : attr_expr, 32.18 "<assexpr>" : self.in_assignment, 32.19 } 32.20 32.21 @@ -557,6 +557,7 @@ 32.22 32.23 context_index = self.function_target - 1 32.24 context_identity = None 32.25 + final_identity = None 32.26 32.27 # Obtain encoded versions of each instruction, accumulating temporary 32.28 # variables. 32.29 @@ -569,6 +570,13 @@ 32.30 context_identity, _substituted = encode_access_instruction_arg(instruction[1], subs, instruction[0], context_index) 32.31 continue 32.32 32.33 + # Intercept a special instruction identifying the target. The value 32.34 + # is not encoded since it is used internally. 32.35 + 32.36 + if instruction[0] == "<final_identity>": 32.37 + final_identity = instruction[1] 32.38 + continue 32.39 + 32.40 # Collect the encoded instruction, noting any temporary variables 32.41 # required by it. 32.42 32.43 @@ -582,6 +590,12 @@ 32.44 if self.temp_subs.has_key(sub): 32.45 self.record_temp(self.temp_subs[sub]) 32.46 32.47 + # Get full final identity details. 32.48 + 32.49 + if final_identity and not refs: 32.50 + ref = self.importer.identify(final_identity) 32.51 + refs = [ref] 32.52 + 32.53 del self.attrs[0] 32.54 return AttrResult(output, refs, location, context_identity) 32.55 32.56 @@ -629,7 +643,18 @@ 32.57 identified attributes. 32.58 """ 32.59 32.60 + # Determine whether any deduced references refer to the accessed 32.61 + # attribute. 32.62 + 32.63 + path, accessor_name, attrnames, access_number = location 32.64 + attrnames = attrnames and attrnames.split(".") 32.65 + remaining = attrnames and len(attrnames) > 1 32.66 + 32.67 access_location = self.deducer.const_accesses.get(location) 32.68 + 32.69 + if remaining and not access_location: 32.70 + return [] 32.71 + 32.72 refs = [] 32.73 l = self.deducer.referenced_attrs.get(access_location or location) 32.74 if l: 32.75 @@ -862,14 +887,10 @@ 32.76 else: 32.77 return 32.78 32.79 - # Produce an appropriate access to an attribute's value. 32.80 - 32.81 - name_to_value = "%s.value" % encode_path(name) 32.82 - 32.83 # Write a test that raises a TypeError upon failure. 32.84 32.85 - self.writestmt("if (!__test_%s_%s(%s, %s)) __raise_type_error();" % ( 32.86 - guard, guard_type, name_to_value, argstr)) 32.87 + self.writestmt("if (!__test_%s_%s(__VALUE(%s), %s)) __raise_type_error();" % ( 32.88 + guard, guard_type, encode_path(name), argstr)) 32.89 32.90 def process_function_node(self, n): 32.91 32.92 @@ -939,6 +960,8 @@ 32.93 32.94 if not instance_name: 32.95 instance_name = "&%s" % encode_path(objpath) 32.96 + else: 32.97 + instance_name = "__VALUE(%s)" % instance_name 32.98 32.99 # Where defaults are involved but cannot be identified, obtain a new 32.100 # instance of the lambda and populate the defaults. 32.101 @@ -1021,6 +1044,7 @@ 32.102 32.103 objpath = expr.get_origin() 32.104 location = expr.access_location() 32.105 + refs = expr.references() 32.106 32.107 # Identified target details. 32.108 32.109 @@ -1042,6 +1066,8 @@ 32.110 have_access_context = isinstance(expr, AttrResult) 32.111 context_identity = have_access_context and expr.context() 32.112 parameters = None 32.113 + num_parameters = None 32.114 + num_defaults = None 32.115 32.116 # Obtain details of the callable and of its parameters. 32.117 32.118 @@ -1056,6 +1082,9 @@ 32.119 32.120 elif objpath: 32.121 parameters = self.importer.function_parameters.get(objpath) 32.122 + function_defaults = self.importer.function_defaults.get(objpath) 32.123 + num_parameters = parameters and len(parameters) or 0 32.124 + num_defaults = function_defaults and len(function_defaults) or 0 32.125 32.126 # Class invocation involves instantiators. 32.127 32.128 @@ -1091,22 +1120,71 @@ 32.129 32.130 target_structure = "&%s" % encode_path(objpath) 32.131 32.132 - # Other targets are retrieved at run-time. Some information about them 32.133 - # may be available and be used to provide warnings about argument 32.134 - # compatibility. 32.135 - 32.136 - elif self.importer.give_warning("args"): 32.137 - unsuitable = self.get_referenced_attribute_invocations(location) 32.138 - 32.139 - if unsuitable: 32.140 - for ref in unsuitable: 32.141 - _objpath = ref.get_origin() 32.142 - num_parameters = len(self.importer.function_parameters[_objpath]) 32.143 - print >>sys.stderr, \ 32.144 - "In %s, at line %d, inappropriate number of " \ 32.145 - "arguments given. Need %d arguments to call %s." % ( 32.146 - self.get_namespace_path(), n.lineno, num_parameters, 32.147 - _objpath) 32.148 + # Other targets are retrieved at run-time. 32.149 + 32.150 + else: 32.151 + if location: 32.152 + path, name, attrnames, access_number = location 32.153 + attrname = attrnames and attrnames.rsplit(".", 1)[-1] 32.154 + 32.155 + # Determine any common aspects of any attribute. 32.156 + 32.157 + if attrname: 32.158 + all_params = set() 32.159 + all_defaults = set() 32.160 + min_params = set() 32.161 + max_params = set() 32.162 + refs = set() 32.163 + 32.164 + # Obtain parameters and defaults for each possible target. 32.165 + 32.166 + for ref in self.get_attributes_for_attrname(attrname): 32.167 + origin = ref.get_origin() 32.168 + params = self.importer.function_parameters.get(origin) 32.169 + 32.170 + defaults = self.importer.function_defaults.get(origin) 32.171 + if defaults is not None: 32.172 + all_defaults.add(tuple(defaults)) 32.173 + 32.174 + if params is not None: 32.175 + all_params.add(tuple(params)) 32.176 + min_params.add(len(params) - (defaults and len(defaults) or 0)) 32.177 + max_params.add(len(params)) 32.178 + refs.add(ref) 32.179 + else: 32.180 + refs = set() 32.181 + break 32.182 + 32.183 + # Where the parameters and defaults are always the same, 32.184 + # permit populating them in advance. 32.185 + 32.186 + if refs: 32.187 + if self.uses_keyword_arguments(n): 32.188 + if len(all_params) == 1 and (not all_defaults or len(all_defaults) == 1): 32.189 + parameters = first(all_params) 32.190 + function_defaults = all_defaults and first(all_defaults) or [] 32.191 + num_parameters = parameters and len(parameters) or 0 32.192 + num_defaults = function_defaults and len(function_defaults) or 0 32.193 + else: 32.194 + if len(min_params) == 1 and len(max_params) == 1: 32.195 + num_parameters = first(max_params) 32.196 + num_defaults = first(max_params) - first(min_params) 32.197 + 32.198 + # Some information about the target may be available and be used to 32.199 + # provide warnings about argument compatibility. 32.200 + 32.201 + if self.importer.give_warning("args"): 32.202 + unsuitable = self.get_referenced_attribute_invocations(location) 32.203 + 32.204 + if unsuitable: 32.205 + for ref in unsuitable: 32.206 + _objpath = ref.get_origin() 32.207 + print >>sys.stderr, \ 32.208 + "In %s, at line %d, inappropriate number of " \ 32.209 + "arguments given. Need %d arguments to call %s." % ( 32.210 + self.get_namespace_path(), n.lineno, 32.211 + len(self.importer.function_parameters[_objpath]), 32.212 + _objpath) 32.213 32.214 # Determine any readily-accessible target identity. 32.215 32.216 @@ -1120,16 +1198,19 @@ 32.217 if not target_identity: 32.218 self.record_temp("__tmp_targets") 32.219 32.220 - if context_identity and context_identity.startswith("__tmp_contexts"): 32.221 - self.record_temp("__tmp_contexts") 32.222 + if context_identity: 32.223 + if context_identity.startswith("__tmp_contexts"): 32.224 + self.record_temp("__tmp_contexts") 32.225 32.226 # Arguments are presented in a temporary frame array with any context 32.227 # always being the first argument. Where it would be unused, it may be 32.228 # set to null. 32.229 32.230 + known_parameters = num_parameters is not None 32.231 + 32.232 if context_required: 32.233 if have_access_context: 32.234 - args = ["__ATTRVALUE(%s)" % context_identity] 32.235 + args = [context_identity] 32.236 else: 32.237 args = ["__CONTEXT_AS_VALUE(%s)" % context_var] 32.238 else: 32.239 @@ -1138,7 +1219,7 @@ 32.240 # Complete the array with null values, permitting tests for a complete 32.241 # set of arguments. 32.242 32.243 - args += [None] * (parameters is None and len(n.args) or parameters is not None and len(parameters) or 0) 32.244 + args += [None] * (num_parameters is None and len(n.args) or num_parameters is not None and num_parameters or 0) 32.245 kwcodes = [] 32.246 kwargs = [] 32.247 32.248 @@ -1198,18 +1279,29 @@ 32.249 32.250 # Defaults are added to the frame where arguments are missing. 32.251 32.252 - if parameters: 32.253 - function_defaults = self.importer.function_defaults.get(objpath) 32.254 - if function_defaults: 32.255 - 32.256 - # Visit each default and set any missing arguments. 32.257 - # Use the target structure to obtain defaults, as opposed to the 32.258 - # actual function involved. 32.259 - 32.260 - for i, (argname, default) in enumerate(function_defaults): 32.261 - argnum = parameters.index(argname) 32.262 - if not args[argnum+1]: 32.263 - args[argnum+1] = "__GETDEFAULT(%s, %d)" % (target_structure, i) 32.264 + if parameters and function_defaults: 32.265 + 32.266 + # Visit each default and set any missing arguments. Where keyword 32.267 + # arguments have been used, the defaults must be inspected and, if 32.268 + # necessary, inserted into gaps in the argument list. 32.269 + 32.270 + for i, (argname, default) in enumerate(function_defaults): 32.271 + argnum = parameters.index(argname) 32.272 + if not args[argnum+1]: 32.273 + args[argnum+1] = "__GETDEFAULT(%s, %d)" % (target_structure, i) 32.274 + 32.275 + elif known_parameters: 32.276 + 32.277 + # No specific parameter details are provided, but no keyword 32.278 + # arguments are used. Thus, defaults can be supplied using position 32.279 + # information only. 32.280 + 32.281 + i = len(n.args) 32.282 + pos = i - (num_parameters - num_defaults) 32.283 + while i < num_parameters: 32.284 + args[i+1] = "__GETDEFAULT(%s.value, %d)" % (target_var, pos) 32.285 + i += 1 32.286 + pos += 1 32.287 32.288 # Test for missing arguments. 32.289 32.290 @@ -1264,10 +1356,19 @@ 32.291 stages.append("__get_function(%s, %s)" % ( 32.292 context_identity, target_var)) 32.293 else: 32.294 - stages.append("__get_function(__CONTEXT_AS_VALUE(%s).value, %s)" % ( 32.295 + stages.append("__get_function(__CONTEXT_AS_VALUE(%s), %s)" % ( 32.296 context_var, target_var)) 32.297 else: 32.298 - stages.append("__load_via_object(%s.value, __fn__).fn" % target_var) 32.299 + stages.append("__load_via_object(__VALUE(%s), __fn__).fn" % target_var) 32.300 + 32.301 + # With known parameters, the target can be tested. 32.302 + 32.303 + elif known_parameters: 32.304 + context_arg = context_required and args[0] or "__NULL" 32.305 + if self.always_callable(refs): 32.306 + stages.append("__get_function(%s, %s)" % (context_arg, target_var)) 32.307 + else: 32.308 + stages.append("__check_and_get_function(%s, %s)" % (context_arg, target_var)) 32.309 32.310 # With a known target, the function is obtained directly and called. 32.311 # By putting the invocation at the end of the final element in the 32.312 @@ -1275,7 +1376,7 @@ 32.313 # the sequence. Moreover, the parameters become part of the sequence 32.314 # and thereby participate in a guaranteed evaluation order. 32.315 32.316 - if target or function: 32.317 + if target or function or known_parameters: 32.318 stages[-1] += "(%s)" % argstr 32.319 if instantiation: 32.320 return InstantiationResult(instantiation, stages) 32.321 @@ -1288,7 +1389,7 @@ 32.322 else: 32.323 stages.append("__invoke(\n%s,\n%d, %d, %s, %s,\n%d, %s\n)" % ( 32.324 target_var, 32.325 - self.always_callable and 1 or 0, 32.326 + self.always_callable(refs) and 1 or 0, 32.327 len(kwargs), kwcodestr, kwargstr, 32.328 len(args), "__ARGS(%s)" % argstr)) 32.329 return InvocationResult(stages) 32.330 @@ -1304,13 +1405,13 @@ 32.331 32.332 "Determine whether all 'refs' are callable." 32.333 32.334 + if not refs: 32.335 + return False 32.336 + 32.337 for ref in refs: 32.338 - if not ref.static(): 32.339 + if not ref.has_kind("<function>") and not self.importer.get_attributes(ref, "__fn__"): 32.340 return False 32.341 - else: 32.342 - origin = ref.final() 32.343 - if not self.importer.get_attribute(origin, "__fn__"): 32.344 - return False 32.345 + 32.346 return True 32.347 32.348 def need_default_arguments(self, objpath, nargs): 32.349 @@ -1323,6 +1424,31 @@ 32.350 parameters = self.importer.function_parameters.get(objpath) 32.351 return nargs < len(parameters) 32.352 32.353 + def uses_keyword_arguments(self, n): 32.354 + 32.355 + "Return whether invocation node 'n' uses keyword arguments." 32.356 + 32.357 + for arg in enumerate(n.args): 32.358 + if isinstance(arg, compiler.ast.Keyword): 32.359 + return True 32.360 + 32.361 + return False 32.362 + 32.363 + def get_attributes_for_attrname(self, attrname): 32.364 + 32.365 + "Return a set of all attributes exposed by 'attrname'." 32.366 + 32.367 + usage = [(attrname, True, False)] 32.368 + class_types = self.deducer.get_class_types_for_usage(usage) 32.369 + instance_types = self.deducer.get_instance_types_for_usage(usage) 32.370 + module_types = self.deducer.get_module_types_for_usage(usage) 32.371 + attrs = set() 32.372 + 32.373 + for ref in combine_types(class_types, instance_types, module_types): 32.374 + attrs.update(self.importer.get_attributes(ref, attrname)) 32.375 + 32.376 + return attrs 32.377 + 32.378 def process_lambda_node(self, n): 32.379 32.380 "Process the given lambda node 'n'." 32.381 @@ -1342,7 +1468,7 @@ 32.382 32.383 else: 32.384 self.record_temp("__tmp_value") 32.385 - return make_expression("(__tmp_value = __COPY(&%s, sizeof(%s)), %s, __ATTRVALUE(__tmp_value))" % ( 32.386 + return make_expression("(__tmp_value = __ATTRVALUE(__COPY(&%s, sizeof(%s))), %s, __tmp_value)" % ( 32.387 encode_path(function_name), 32.388 encode_symbol("obj", function_name), 32.389 ", ".join(defaults))) 32.390 @@ -1923,16 +2049,16 @@ 32.391 if self.uses_temp(name, "__tmp_targets"): 32.392 self.writeline("__attr __tmp_targets[%d];" % targets) 32.393 if self.uses_temp(name, "__tmp_contexts"): 32.394 - self.writeline("__ref __tmp_contexts[%d];" % targets) 32.395 + self.writeline("__attr __tmp_contexts[%d];" % targets) 32.396 32.397 # Add temporary variable usage details. 32.398 32.399 if self.uses_temp(name, "__tmp_private_context"): 32.400 - self.writeline("__ref __tmp_private_context;") 32.401 + self.writeline("__attr __tmp_private_context;") 32.402 if self.uses_temp(name, "__tmp_value"): 32.403 - self.writeline("__ref __tmp_value;") 32.404 + self.writeline("__attr __tmp_value;") 32.405 if self.uses_temp(name, "__tmp_target_value"): 32.406 - self.writeline("__ref __tmp_target_value;") 32.407 + self.writeline("__attr __tmp_target_value;") 32.408 if self.uses_temp(name, "__tmp_result"): 32.409 self.writeline("__attr __tmp_result;") 32.410
33.1 --- a/transresults.py Sun Mar 19 00:56:43 2017 +0100 33.2 +++ b/transresults.py Fri Mar 24 22:39:37 2017 +0100 33.3 @@ -139,7 +139,13 @@ 33.4 "A constant value reference in the translation." 33.5 33.6 def __str__(self): 33.7 - return encode_literal_constant(self.number) 33.8 + 33.9 + # NOTE: Should reference a common variable for the type name. 33.10 + 33.11 + if self.ref.get_origin() == "__builtins__.int.int": 33.12 + return "__INTVALUE(%s)" % self.value 33.13 + else: 33.14 + return encode_literal_constant(self.number) 33.15 33.16 class TrLiteralSequenceRef(LiteralSequenceRef): 33.17 33.18 @@ -205,7 +211,7 @@ 33.19 return encode_instructions(self.instructions) 33.20 33.21 def __repr__(self): 33.22 - return "AttrResult(%r, %r, %r)" % (self.instructions, self.refs, self.location) 33.23 + return "AttrResult(%r, %r, %r, %r)" % (self.instructions, self.refs, self.location, self.context_identity) 33.24 33.25 class AliasResult(NameRef, Result): 33.26