1.1 --- a/encoders.py Mon Feb 27 11:57:15 2017 +0100
1.2 +++ b/encoders.py Mon Feb 27 14:41:27 2017 +0100
1.3 @@ -273,25 +273,10 @@
1.4
1.5 # Modify certain arguments.
1.6
1.7 - # Convert attribute name arguments to position symbols.
1.8 -
1.9 - if op in attribute_ops:
1.10 - arg = a[1]
1.11 - a[1] = encode_pos(arg)
1.12 -
1.13 - # Convert attribute name arguments to position and code symbols.
1.14 + # Convert type name arguments.
1.15
1.16 - elif op in checked_ops:
1.17 - arg = a[1]
1.18 - a[1] = encode_pos(arg)
1.19 - a.insert(2, encode_code(arg))
1.20 -
1.21 - # Convert type name arguments to position and code symbols.
1.22 -
1.23 - elif op in typename_ops:
1.24 - arg = encode_type_attribute(args[1])
1.25 - a[1] = encode_pos(arg)
1.26 - a.insert(2, encode_code(arg))
1.27 + if op in typename_ops:
1.28 + a[1] = encode_path(encode_type_attribute(args[1]))
1.29
1.30 # Obtain addresses of type arguments.
1.31
2.1 --- a/generator.py Mon Feb 27 11:57:15 2017 +0100
2.2 +++ b/generator.py Mon Feb 27 14:41:27 2017 +0100
2.3 @@ -1182,23 +1182,18 @@
2.4 {
2.5 if (__ISINSTANCE(__tmp_exc.arg, ((__attr) {.value=&__builtins___exception_system_SystemExit})))
2.6 return __load_via_object(
2.7 - __load_via_object(__tmp_exc.arg.value, %s).value,
2.8 - %s).intvalue;
2.9 + __load_via_object(__tmp_exc.arg.value, __data__).value,
2.10 + value).intvalue;
2.11
2.12 fprintf(stderr, "Program terminated due to exception: %%s.\\n",
2.13 __load_via_object(
2.14 %s((__attr[]) {__NULL, __tmp_exc.arg}).value,
2.15 - %s).strvalue);
2.16 + __data__).strvalue);
2.17 return 1;
2.18 }
2.19
2.20 return 0;
2.21 }
2.22 -""" % (
2.23 - encode_pos("value"),
2.24 - encode_pos("__data__"),
2.25 - encode_function_pointer("__builtins__.str.str"),
2.26 - encode_pos("__data__")
2.27 - )
2.28 +""" % encode_function_pointer("__builtins__.str.str")
2.29
2.30 # vim: tabstop=4 expandtab shiftwidth=4
3.1 --- a/templates/native/buffer.c Mon Feb 27 11:57:15 2017 +0100
3.2 +++ b/templates/native/buffer.c Mon Feb 27 14:41:27 2017 +0100
3.3 @@ -37,7 +37,7 @@
3.4
3.5 /* Calculate the size of the string. */
3.6 for (i = 0; i < data->size; i++)
3.7 - size += __load_via_object(data->attrs[i].value, __ATTRPOS(__size__)).intvalue;
3.8 + size += __load_via_object(data->attrs[i].value, __size__).intvalue;
3.9
3.10 /* Reserve space for a new string. */
3.11 s = (char *) __ALLOCATE(size + 1, sizeof(char));
3.12 @@ -45,8 +45,8 @@
3.13 /* Build a single string from the buffer contents. */
3.14 for (i = 0, j = 0; i < data->size; i++)
3.15 {
3.16 - o = __load_via_object(data->attrs[i].value, __ATTRPOS(__data__));
3.17 - n = __load_via_object(data->attrs[i].value, __ATTRPOS(__size__)).intvalue;
3.18 + o = __load_via_object(data->attrs[i].value, __data__);
3.19 + n = __load_via_object(data->attrs[i].value, __size__).intvalue;
3.20 memcpy(s + j, o.strvalue, n); /* does not null terminate but final byte should be zero */
3.21 j += n;
3.22 }
4.1 --- a/templates/native/iconv.c Mon Feb 27 11:57:15 2017 +0100
4.2 +++ b/templates/native/iconv.c Mon Feb 27 14:41:27 2017 +0100
4.3 @@ -57,13 +57,13 @@
4.4 /* cd interpreted as iconv_t */
4.5 iconv_t c = (iconv_t) cd->datavalue;
4.6 /* state.__data__ interpreted as list */
4.7 - __fragment *f = __load_via_object(state->value, __ATTRPOS(__data__)).seqvalue;
4.8 + __fragment *f = __load_via_object(state->value, __data__).seqvalue;
4.9
4.10 /* Obtain the string, start position, and remaining bytes from the state. */
4.11
4.12 - char *inbuf = __load_via_object(f->attrs[0].value, __ATTRPOS(__data__)).strvalue;
4.13 - int start = __load_via_object(f->attrs[1].value, __ATTRPOS(__data__)).intvalue;
4.14 - int remaining = __load_via_object(f->attrs[2].value, __ATTRPOS(__data__)).intvalue;
4.15 + char *inbuf = __load_via_object(f->attrs[0].value, __data__).strvalue;
4.16 + int start = __load_via_object(f->attrs[1].value, __data__).intvalue;
4.17 + int remaining = __load_via_object(f->attrs[2].value, __data__).intvalue;
4.18
4.19 /* Allocate a string for the output buffer using the remaining input size
4.20 as a guide. */
4.21 @@ -142,9 +142,9 @@
4.22 __attr * const tocode = &__args[1];
4.23 __attr * const fromcode = &__args[2];
4.24 /* tocode.__data__ interpreted as string */
4.25 - char *t = __load_via_object(tocode->value, __ATTRPOS(__data__)).strvalue;
4.26 + char *t = __load_via_object(tocode->value, __data__).strvalue;
4.27 /* fromcode.__data__ interpreted as string */
4.28 - char *f = __load_via_object(fromcode->value, __ATTRPOS(__data__)).strvalue;
4.29 + char *f = __load_via_object(fromcode->value, __data__).strvalue;
4.30 iconv_t result;
4.31 __attr attr;
4.32
5.1 --- a/templates/native/introspection.c Mon Feb 27 11:57:15 2017 +0100
5.2 +++ b/templates/native/introspection.c Mon Feb 27 14:41:27 2017 +0100
5.3 @@ -32,7 +32,7 @@
5.4 __attr * const name = &__args[2];
5.5 __attr * const _default = &__args[3];
5.6 /* name.__data__ interpreted as string */
5.7 - __attr key = __load_via_object(name->value, __ATTRPOS(__key__));
5.8 + __attr key = __load_via_object(name->value, __key__);
5.9 __attr out;
5.10
5.11 if ((key.code == 0) && (key.pos == 0))
5.12 @@ -45,7 +45,7 @@
5.13 {
5.14 /* Inspect the object's class if this failed. */
5.15
5.16 - out = __check_and_load_via_class(obj->value, key.pos, key.code);
5.17 + out = __check_and_load_via_class__(obj->value, key.pos, key.code);
5.18 if (out.value == 0)
5.19 return *_default;
5.20
6.1 --- a/templates/native/io.c Mon Feb 27 11:57:15 2017 +0100
6.2 +++ b/templates/native/io.c Mon Feb 27 14:41:27 2017 +0100
6.3 @@ -62,9 +62,9 @@
6.4 __attr * const filename = &__args[1];
6.5 __attr * const mode = &__args[2];
6.6 /* filename.__data__ interpreted as string */
6.7 - char *fn = __load_via_object(filename->value, __ATTRPOS(__data__)).strvalue;
6.8 + char *fn = __load_via_object(filename->value, __data__).strvalue;
6.9 /* mode.__data__ interpreted as string */
6.10 - char *s = __load_via_object(mode->value, __ATTRPOS(__data__)).strvalue;
6.11 + char *s = __load_via_object(mode->value, __data__).strvalue;
6.12 FILE *f;
6.13 __attr attr;
6.14
6.15 @@ -94,9 +94,9 @@
6.16 __attr * const fd = &__args[1];
6.17 __attr * const mode = &__args[2];
6.18 /* fd.__data__ interpreted as int */
6.19 - int i = __load_via_object(fd->value, __ATTRPOS(__data__)).intvalue;
6.20 + int i = __load_via_object(fd->value, __data__).intvalue;
6.21 /* mode.__data__ interpreted as string */
6.22 - char *s = __load_via_object(mode->value, __ATTRPOS(__data__)).strvalue;
6.23 + char *s = __load_via_object(mode->value, __data__).strvalue;
6.24 FILE *f;
6.25 __attr attr;
6.26
6.27 @@ -128,7 +128,7 @@
6.28 /* fp interpreted as FILE reference */
6.29 FILE *f = (FILE *) fp->datavalue;
6.30 /* size.__data__ interpreted as int */
6.31 - int to_read = __load_via_object(size->value, __ATTRPOS(__data__)).intvalue;
6.32 + int to_read = __load_via_object(size->value, __data__).intvalue;
6.33 char buf[to_read];
6.34 size_t have_read;
6.35 int error;
6.36 @@ -158,9 +158,9 @@
6.37 /* fp interpreted as FILE reference */
6.38 FILE *f = (FILE *) fp->datavalue;
6.39 /* str.__data__ interpreted as string */
6.40 - char *s = __load_via_object(str->value, __ATTRPOS(__data__)).strvalue;
6.41 + char *s = __load_via_object(str->value, __data__).strvalue;
6.42 /* str.__size__ interpreted as int */
6.43 - int to_write = __load_via_object(str->value, __ATTRPOS(__size__)).intvalue;
6.44 + int to_write = __load_via_object(str->value, __size__).intvalue;
6.45 size_t have_written = fwrite(s, sizeof(char), to_write, f);
6.46 int error;
6.47
6.48 @@ -179,7 +179,7 @@
6.49 {
6.50 __attr * const fd = &__args[1];
6.51 /* fd.__data__ interpreted as int */
6.52 - int i = __load_via_object(fd->value, __ATTRPOS(__data__)).intvalue;
6.53 + int i = __load_via_object(fd->value, __data__).intvalue;
6.54
6.55 errno = 0;
6.56 if (close(i) == -1)
6.57 @@ -193,9 +193,9 @@
6.58 __attr * const fd = &__args[1];
6.59 __attr * const n = &__args[2];
6.60 /* fd.__data__ interpreted as int */
6.61 - int i = __load_via_object(fd->value, __ATTRPOS(__data__)).intvalue;
6.62 + int i = __load_via_object(fd->value, __data__).intvalue;
6.63 /* n.__data__ interpreted as int */
6.64 - int to_read = __load_via_object(n->value, __ATTRPOS(__data__)).intvalue;
6.65 + int to_read = __load_via_object(n->value, __data__).intvalue;
6.66 char buf[to_read];
6.67 ssize_t have_read;
6.68 char *s;
6.69 @@ -218,11 +218,11 @@
6.70 __attr * const fd = &__args[1];
6.71 __attr * const str = &__args[2];
6.72 /* fd.__data__ interpreted as int */
6.73 - int i = __load_via_object(fd->value, __ATTRPOS(__data__)).intvalue;
6.74 + int i = __load_via_object(fd->value, __data__).intvalue;
6.75 /* str.__data__ interpreted as string */
6.76 - char *s = __load_via_object(str->value, __ATTRPOS(__data__)).strvalue;
6.77 + char *s = __load_via_object(str->value, __data__).strvalue;
6.78 /* str.__size__ interpreted as int */
6.79 - int size = __load_via_object(str->value, __ATTRPOS(__size__)).intvalue;
6.80 + int size = __load_via_object(str->value, __size__).intvalue;
6.81 ssize_t have_written;
6.82
6.83 errno = 0;
7.1 --- a/templates/native/list.c Mon Feb 27 11:57:15 2017 +0100
7.2 +++ b/templates/native/list.c Mon Feb 27 14:41:27 2017 +0100
7.3 @@ -31,7 +31,7 @@
7.4 {
7.5 __attr * const size = &__args[1];
7.6 /* size.__data__ interpreted as int */
7.7 - unsigned int n = __load_via_object(size->value, __ATTRPOS(__data__)).intvalue;
7.8 + unsigned int n = __load_via_object(size->value, __data__).intvalue;
7.9 __attr attr = {.seqvalue=__new_fragment(n)};
7.10
7.11 /* Return the __data__ attribute. */
7.12 @@ -45,7 +45,7 @@
7.13 /* _data interpreted as list */
7.14 __fragment *data = _data->seqvalue;
7.15 /* size.__data__ interpreted as int */
7.16 - unsigned int n = __load_via_object(size->value, __ATTRPOS(__data__)).intvalue;
7.17 + unsigned int n = __load_via_object(size->value, __data__).intvalue;
7.18
7.19 data->size = n;
7.20 return __builtins___none_None;
7.21 @@ -56,12 +56,12 @@
7.22 __attr * const self = &__args[1];
7.23 __attr * const value = &__args[2];
7.24 /* self.__data__ interpreted as list */
7.25 - __fragment *data = __load_via_object(self->value, __ATTRPOS(__data__)).seqvalue;
7.26 + __fragment *data = __load_via_object(self->value, __data__).seqvalue;
7.27 __fragment *newdata = __fragment_append(data, value);
7.28
7.29 /* Replace the __data__ attribute if appropriate. */
7.30 if (newdata != data)
7.31 - __store_via_object(self->value, __ATTRPOS(__data__), ((__attr) {.seqvalue=newdata}));
7.32 + __store_via_object(self->value, __data__, ((__attr) {.seqvalue=newdata}));
7.33 return __builtins___none_None;
7.34 }
7.35
7.36 @@ -70,7 +70,7 @@
7.37 __attr * const self = &__args[1];
7.38 __attr * const other = &__args[2];
7.39 /* self.__data__, other interpreted as list */
7.40 - __fragment *data = __load_via_object(self->value, __ATTRPOS(__data__)).seqvalue;
7.41 + __fragment *data = __load_via_object(self->value, __data__).seqvalue;
7.42 __fragment *other_data = other->seqvalue;
7.43 __fragment *newdata = data;
7.44 unsigned int size = data->size, capacity = data->capacity;
7.45 @@ -92,7 +92,7 @@
7.46
7.47 /* Replace the __data__ attribute if appropriate. */
7.48 if (newdata != data)
7.49 - __store_via_object(self->value, __ATTRPOS(__data__), ((__attr) {.seqvalue=newdata}));
7.50 + __store_via_object(self->value, __data__, ((__attr) {.seqvalue=newdata}));
7.51 return __builtins___none_None;
7.52 }
7.53
7.54 @@ -120,7 +120,7 @@
7.55 /* _data interpreted as fragment */
7.56 __attr *elements = _data->seqvalue->attrs;
7.57 /* index.__data__ interpreted as int */
7.58 - int i = __load_via_object(index->value, __ATTRPOS(__data__)).intvalue;
7.59 + int i = __load_via_object(index->value, __data__).intvalue;
7.60
7.61 return elements[i];
7.62 }
7.63 @@ -133,7 +133,7 @@
7.64 /* _data interpreted as fragment */
7.65 __attr *elements = _data->seqvalue->attrs;
7.66 /* index.__data__ interpreted as int */
7.67 - int i = __load_via_object(index->value, __ATTRPOS(__data__)).intvalue;
7.68 + int i = __load_via_object(index->value, __data__).intvalue;
7.69
7.70 /* Set the element. */
7.71 elements[i] = *value;
8.1 --- a/templates/native/locale.c Mon Feb 27 11:57:15 2017 +0100
8.2 +++ b/templates/native/locale.c Mon Feb 27 14:41:27 2017 +0100
8.3 @@ -33,7 +33,7 @@
8.4 {
8.5 __attr * const category = &__args[1];
8.6 /* category.__data__ interpreted as int */
8.7 - int cat = __load_via_object(category->value, __ATTRPOS(__data__)).intvalue;
8.8 + int cat = __load_via_object(category->value, __data__).intvalue;
8.9 char *result, *out;
8.10 size_t length;
8.11
8.12 @@ -54,9 +54,9 @@
8.13 __attr * const category = &__args[1];
8.14 __attr * const value = &__args[2];
8.15 /* category.__data__ interpreted as int */
8.16 - int cat = __load_via_object(category->value, __ATTRPOS(__data__)).intvalue;
8.17 + int cat = __load_via_object(category->value, __data__).intvalue;
8.18 /* value.__data__ interpreted as string */
8.19 - char *s = __load_via_object(value->value, __ATTRPOS(__data__)).strvalue;
8.20 + char *s = __load_via_object(value->value, __data__).strvalue;
8.21 char *result, *out;
8.22 size_t length;
8.23
9.1 --- a/templates/native/str.c Mon Feb 27 11:57:15 2017 +0100
9.2 +++ b/templates/native/str.c Mon Feb 27 14:41:27 2017 +0100
9.3 @@ -113,11 +113,11 @@
9.4 /* _data interpreted as string */
9.5 char *s = _data->strvalue, *sub;
9.6 /* start.__data__ interpreted as int */
9.7 - int istart = __load_via_object(start->value, __ATTRPOS(__data__)).intvalue;
9.8 + int istart = __load_via_object(start->value, __data__).intvalue;
9.9 /* end.__data__ interpreted as int */
9.10 - int iend = __load_via_object(end->value, __ATTRPOS(__data__)).intvalue;
9.11 + int iend = __load_via_object(end->value, __data__).intvalue;
9.12 /* step.__data__ interpreted as int */
9.13 - int istep = __load_via_object(step->value, __ATTRPOS(__data__)).intvalue;
9.14 + int istep = __load_via_object(step->value, __data__).intvalue;
9.15
9.16 /* Calculate the size of the substring. */
9.17 size_t resultsize = ((iend - istart - (istep > 0 ? 1 : -1)) / istep) + 1;
10.1 --- a/templates/native/system.c Mon Feb 27 11:57:15 2017 +0100
10.2 +++ b/templates/native/system.c Mon Feb 27 14:41:27 2017 +0100
10.3 @@ -31,7 +31,7 @@
10.4 {
10.5 __attr * const status = &__args[1];
10.6
10.7 - exit(__load_via_object(status->value, __ATTRPOS(__data__)).intvalue);
10.8 + exit(__load_via_object(status->value, __data__).intvalue);
10.9 return __builtins___none_None;
10.10 }
10.11
11.1 --- a/templates/native/unicode.c Mon Feb 27 11:57:15 2017 +0100
11.2 +++ b/templates/native/unicode.c Mon Feb 27 14:41:27 2017 +0100
11.3 @@ -135,11 +135,11 @@
11.4 /* _size interpreted as int */
11.5 int ss = _size->intvalue;
11.6 /* start.__data__ interpreted as int */
11.7 - int istart = __load_via_object(start->value, __ATTRPOS(__data__)).intvalue;
11.8 + int istart = __load_via_object(start->value, __data__).intvalue;
11.9 /* end.__data__ interpreted as int */
11.10 - int iend = __load_via_object(end->value, __ATTRPOS(__data__)).intvalue;
11.11 + int iend = __load_via_object(end->value, __data__).intvalue;
11.12 /* step.__data__ interpreted as int */
11.13 - int istep = __load_via_object(step->value, __ATTRPOS(__data__)).intvalue;
11.14 + int istep = __load_via_object(step->value, __data__).intvalue;
11.15
11.16 /* Calculate the number of characters. */
11.17 size_t nchar = ((iend - istart - (istep > 0 ? 1 : -1)) / istep) + 1;
12.1 --- a/templates/ops.c Mon Feb 27 11:57:15 2017 +0100
12.2 +++ b/templates/ops.c Mon Feb 27 14:41:27 2017 +0100
12.3 @@ -41,33 +41,33 @@
12.4
12.5 /* Direct retrieval operations, returning and setting attributes. */
12.6
12.7 -__attr __load_via_object(__ref obj, int pos)
12.8 +__attr __load_via_object__(__ref obj, int pos)
12.9 {
12.10 return obj->attrs[pos];
12.11 }
12.12
12.13 -__attr __load_via_class(__ref obj, int pos)
12.14 +__attr __load_via_class__(__ref obj, int pos)
12.15 {
12.16 - return __load_via_object(__get_class(obj), pos);
12.17 + return __load_via_object__(__get_class(obj), pos);
12.18 }
12.19
12.20 -__attr __get_class_and_load(__ref obj, int pos)
12.21 +__attr __get_class_and_load__(__ref obj, int pos)
12.22 {
12.23 if (__is_instance(obj))
12.24 - return __load_via_class(obj, pos);
12.25 + return __load_via_class__(obj, pos);
12.26 else
12.27 - return __load_via_object(obj, pos);
12.28 + return __load_via_object__(obj, pos);
12.29 }
12.30
12.31 /* Direct storage operations. */
12.32
12.33 -int __store_via_object(__ref obj, int pos, __attr value)
12.34 +int __store_via_object__(__ref obj, int pos, __attr value)
12.35 {
12.36 obj->attrs[pos] = value;
12.37 return 1;
12.38 }
12.39
12.40 -int __get_class_and_store(__ref obj, int pos, __attr value)
12.41 +int __get_class_and_store__(__ref obj, int pos, __attr value)
12.42 {
12.43 /* Forbid class-relative assignments. */
12.44
12.45 @@ -89,12 +89,12 @@
12.46
12.47 __ref __get_class(__ref obj)
12.48 {
12.49 - return __load_via_object(obj, __pos___class__).value;
12.50 + return __load_via_object(obj, __class__).value;
12.51 }
12.52
12.53 __attr __get_class_attr(__ref obj)
12.54 {
12.55 - return __load_via_object(obj, __pos___class__);
12.56 + return __load_via_object(obj, __class__);
12.57 }
12.58
12.59 /* Attribute testing operations. */
12.60 @@ -114,17 +114,17 @@
12.61 return obj == type ? obj : 0;
12.62 }
12.63
12.64 -__ref __test_common_instance(__ref obj, int pos, int code)
12.65 +__ref __test_common_instance__(__ref obj, int pos, int code)
12.66 {
12.67 return __HASATTR(__get_class(obj), pos, code) ? obj : 0;
12.68 }
12.69
12.70 -__ref __test_common_object(__ref obj, int pos, int code)
12.71 +__ref __test_common_object__(__ref obj, int pos, int code)
12.72 {
12.73 - return __test_common_type(obj, pos, code) || __test_common_instance(obj, pos, code) ? obj : 0;
12.74 + return __test_common_type__(obj, pos, code) || __test_common_instance__(obj, pos, code) ? obj : 0;
12.75 }
12.76
12.77 -__ref __test_common_type(__ref obj, int pos, int code)
12.78 +__ref __test_common_type__(__ref obj, int pos, int code)
12.79 {
12.80 return __HASATTR(obj, pos, code) ? obj : 0;
12.81 }
12.82 @@ -134,36 +134,36 @@
12.83 __attr __check_and_load_via_object_null(__ref obj, int pos, int code)
12.84 {
12.85 if (__HASATTR(obj, pos, code))
12.86 - return __load_via_object(obj, pos);
12.87 + return __load_via_object__(obj, pos);
12.88 else
12.89 return __NULL;
12.90 }
12.91
12.92 -__attr __check_and_load_via_class(__ref obj, int pos, int code)
12.93 +__attr __check_and_load_via_class__(__ref obj, int pos, int code)
12.94 {
12.95 - return __check_and_load_via_object(__get_class(obj), pos, code);
12.96 + return __check_and_load_via_object__(__get_class(obj), pos, code);
12.97 }
12.98
12.99 -__attr __check_and_load_via_object(__ref obj, int pos, int code)
12.100 +__attr __check_and_load_via_object__(__ref obj, int pos, int code)
12.101 {
12.102 if (__HASATTR(obj, pos, code))
12.103 - return __load_via_object(obj, pos);
12.104 + return __load_via_object__(obj, pos);
12.105
12.106 __raise_type_error();
12.107 return __NULL;
12.108 }
12.109
12.110 -__attr __check_and_load_via_any(__ref obj, int pos, int code)
12.111 +__attr __check_and_load_via_any__(__ref obj, int pos, int code)
12.112 {
12.113 __attr out = __check_and_load_via_object_null(obj, pos, code);
12.114 if (out.value == 0)
12.115 - out = __check_and_load_via_class(obj, pos, code);
12.116 + out = __check_and_load_via_class__(obj, pos, code);
12.117 return out;
12.118 }
12.119
12.120 /* Attribute testing and storage operations. */
12.121
12.122 -int __check_and_store_via_class(__ref obj, int pos, int code, __attr value)
12.123 +int __check_and_store_via_class__(__ref obj, int pos, int code, __attr value)
12.124 {
12.125 /* Forbid class-relative assignments. */
12.126
12.127 @@ -171,11 +171,11 @@
12.128 return 0;
12.129 }
12.130
12.131 -int __check_and_store_via_object(__ref obj, int pos, int code, __attr value)
12.132 +int __check_and_store_via_object__(__ref obj, int pos, int code, __attr value)
12.133 {
12.134 if (__HASATTR(obj, pos, code))
12.135 {
12.136 - __store_via_object(obj, pos, value);
12.137 + __store_via_object__(obj, pos, value);
12.138 return 1;
12.139 }
12.140
12.141 @@ -185,9 +185,9 @@
12.142 return 0;
12.143 }
12.144
12.145 -int __check_and_store_via_any(__ref obj, int pos, int code, __attr value)
12.146 +int __check_and_store_via_any__(__ref obj, int pos, int code, __attr value)
12.147 {
12.148 - if (__check_and_store_via_object(obj, pos, code, value))
12.149 + if (__check_and_store_via_object__(obj, pos, code, value))
12.150 return 1;
12.151
12.152 /* Forbid class-relative assignments. */
12.153 @@ -218,7 +218,7 @@
12.154 attribute context's class, inspecting the context instance for
12.155 compatibility. */
12.156
12.157 - if (__test_common_instance(context, __TYPEPOS(attrcontext), __TYPECODE(attrcontext)))
12.158 + if (__test_common_instance__(context, __TYPEPOS(attrcontext), __TYPECODE(attrcontext)))
12.159 return 1;
12.160 else
12.161 __raise_type_error();
12.162 @@ -298,7 +298,7 @@
12.163 or type instance contexts for type methods. */
12.164
12.165 if ((context == 0) || __is_instance(context) || __type_method_invocation(context, target))
12.166 - return __load_via_object(target.value, __ATTRPOS(__fn__)).fn;
12.167 + return __load_via_object(target.value, __fn__).fn;
12.168 else
12.169 return __unbound_method;
12.170 }
12.171 @@ -311,7 +311,7 @@
12.172 or type instance contexts for type methods. */
12.173
12.174 if ((context == 0) || __is_instance(context) || __type_method_invocation(context, target))
12.175 - return __check_and_load_via_object(target.value, __ATTRPOS(__fn__), __ATTRCODE(__fn__)).fn;
12.176 + return __check_and_load_via_object__(target.value, __ATTRPOS(__fn__), __ATTRCODE(__fn__)).fn;
12.177 else
12.178 return __unbound_method;
12.179 }
13.1 --- a/templates/ops.h Mon Feb 27 11:57:15 2017 +0100
13.2 +++ b/templates/ops.h Mon Feb 27 14:41:27 2017 +0100
13.3 @@ -30,14 +30,21 @@
13.4
13.5 /* Direct retrieval operations, returning attributes. */
13.6
13.7 -__attr __load_via_class(__ref obj, int pos);
13.8 -__attr __load_via_object(__ref obj, int pos);
13.9 -__attr __get_class_and_load(__ref obj, int pos);
13.10 +__attr __load_via_class__(__ref obj, int pos);
13.11 +__attr __load_via_object__(__ref obj, int pos);
13.12 +__attr __get_class_and_load__(__ref obj, int pos);
13.13 +
13.14 +#define __load_via_class(OBJ, ATTRNAME) (__load_via_class__(OBJ, __ATTRPOS(ATTRNAME)))
13.15 +#define __load_via_object(OBJ, ATTRNAME) (__load_via_object__(OBJ, __ATTRPOS(ATTRNAME)))
13.16 +#define __get_class_and_load(OBJ, ATTRNAME) (__get_class_and_load__(OBJ, __ATTRPOS(ATTRNAME)))
13.17
13.18 /* Direct storage operations. */
13.19
13.20 -int __store_via_object(__ref obj, int pos, __attr value);
13.21 -int __get_class_and_store(__ref obj, int pos, __attr value);
13.22 +int __store_via_object__(__ref obj, int pos, __attr value);
13.23 +int __get_class_and_store__(__ref obj, int pos, __attr value);
13.24 +
13.25 +#define __store_via_object(OBJ, ATTRNAME, VALUE) (__store_via_object__(OBJ, __ATTRPOS(ATTRNAME), VALUE))
13.26 +#define __get_class_and_store(OBJ, ATTRNAME, VALUE) (__get_class_and_store__(OBJ, __ATTRPOS(ATTRNAME), VALUE))
13.27
13.28 /* Introspection. */
13.29
13.30 @@ -51,22 +58,36 @@
13.31 __ref __test_specific_instance(__ref obj, __ref type);
13.32 __ref __test_specific_object(__ref obj, __ref type);
13.33 __ref __test_specific_type(__ref obj, __ref type);
13.34 -__ref __test_common_instance(__ref obj, int pos, int code);
13.35 -__ref __test_common_object(__ref obj, int pos, int code);
13.36 -__ref __test_common_type(__ref obj, int pos, int code);
13.37 +
13.38 +__ref __test_common_instance__(__ref obj, int pos, int code);
13.39 +__ref __test_common_object__(__ref obj, int pos, int code);
13.40 +__ref __test_common_type__(__ref obj, int pos, int code);
13.41 +
13.42 +#define __test_common_instance(OBJ, TYPENAME) (__test_common_instance__(OBJ, __ATTRPOS(TYPENAME), __ATTRCODE(TYPENAME)))
13.43 +#define __test_common_object(OBJ, TYPENAME) (__test_common_object__(OBJ, __ATTRPOS(TYPENAME), __ATTRCODE(TYPENAME)))
13.44 +#define __test_common_type(OBJ, TYPENAME) (__test_common_type__(OBJ, __ATTRPOS(TYPENAME), __ATTRCODE(TYPENAME)))
13.45
13.46 /* Attribute testing and retrieval operations. */
13.47
13.48 -__attr __check_and_load_via_class(__ref obj, int pos, int code);
13.49 -__attr __check_and_load_via_object(__ref obj, int pos, int code);
13.50 __attr __check_and_load_via_object_null(__ref obj, int pos, int code);
13.51 -__attr __check_and_load_via_any(__ref obj, int pos, int code);
13.52 +
13.53 +__attr __check_and_load_via_class__(__ref obj, int pos, int code);
13.54 +__attr __check_and_load_via_object__(__ref obj, int pos, int code);
13.55 +__attr __check_and_load_via_any__(__ref obj, int pos, int code);
13.56 +
13.57 +#define __check_and_load_via_class(OBJ, ATTRNAME) (__check_and_load_via_class__(OBJ, __ATTRPOS(ATTRNAME), __ATTRCODE(ATTRNAME)))
13.58 +#define __check_and_load_via_object(OBJ, ATTRNAME) (__check_and_load_via_object__(OBJ, __ATTRPOS(ATTRNAME), __ATTRCODE(ATTRNAME)))
13.59 +#define __check_and_load_via_any(OBJ, ATTRNAME) (__check_and_load_via_any__(OBJ, __ATTRPOS(ATTRNAME), __ATTRCODE(ATTRNAME)))
13.60
13.61 /* Attribute testing and storage operations. */
13.62
13.63 -int __check_and_store_via_class(__ref obj, int pos, int code, __attr value);
13.64 -int __check_and_store_via_object(__ref obj, int pos, int code, __attr value);
13.65 -int __check_and_store_via_any(__ref obj, int pos, int code, __attr value);
13.66 +int __check_and_store_via_class__(__ref obj, int pos, int code, __attr value);
13.67 +int __check_and_store_via_object__(__ref obj, int pos, int code, __attr value);
13.68 +int __check_and_store_via_any__(__ref obj, int pos, int code, __attr value);
13.69 +
13.70 +#define __check_and_store_via_class(OBJ, ATTRNAME, VALUE) (__check_and_store_via_class__(OBJ, __ATTRPOS(ATTRNAME), __ATTRCODE(ATTRNAME), VALUE))
13.71 +#define __check_and_store_via_object(OBJ, ATTRNAME, VALUE) (__check_and_store_via_object__(OBJ, __ATTRPOS(ATTRNAME), __ATTRCODE(ATTRNAME), VALUE))
13.72 +#define __check_and_store_via_any(OBJ, ATTRNAME, VALUE) (__check_and_store_via_any__(OBJ, __ATTRPOS(ATTRNAME), __ATTRCODE(ATTRNAME), VALUE))
13.73
13.74 /* Context-related operations. */
13.75
14.1 --- a/templates/progops.c Mon Feb 27 11:57:15 2017 +0100
14.2 +++ b/templates/progops.c Mon Feb 27 14:41:27 2017 +0100
14.3 @@ -31,7 +31,7 @@
14.4 {
14.5 __ref obj = (__ref) __ALLOCATE(1, size);
14.6 obj->table = table;
14.7 - __store_via_object(obj, __ATTRPOS(__class__), (__attr) {.value=cls});
14.8 + __store_via_object(obj, __class__, (__attr) {.value=cls});
14.9 return (__attr) {.value=obj};
14.10 }
14.11
14.12 @@ -72,7 +72,7 @@
14.13
14.14 /* Store a reference to the data in the object's __data__ attribute. */
14.15
14.16 - __store_via_object(args[0].value, __ATTRPOS(__data__), attr);
14.17 + __store_via_object(args[0].value, __data__, attr);
14.18 }
14.19
14.20 #ifdef __HAVE___builtins___dict_dict
14.21 @@ -191,7 +191,7 @@
14.22 /* Obtain the __args__ special member, referencing the parameter table. */
14.23 /* Refer to the table and minimum/maximum. */
14.24
14.25 - const __ptable *ptable = __check_and_load_via_object(target.value, __ATTRPOS(__args__), __ATTRCODE(__args__)).ptable;
14.26 + const __ptable *ptable = __check_and_load_via_object(target.value, __args__).ptable;
14.27 const unsigned int min = ptable->min, max = ptable->max;
14.28
14.29 /* Reserve enough space for the arguments. */
14.30 @@ -266,12 +266,12 @@
14.31
14.32 void __SETDEFAULT(__ref obj, int pos, __attr value)
14.33 {
14.34 - __store_via_object(obj, __FUNCTION_INSTANCE_SIZE + pos, value);
14.35 + __store_via_object__(obj, __FUNCTION_INSTANCE_SIZE + pos, value);
14.36 }
14.37
14.38 __attr __GETDEFAULT(__ref obj, int pos)
14.39 {
14.40 - return __load_via_object(obj, __FUNCTION_INSTANCE_SIZE + pos);
14.41 + return __load_via_object__(obj, __FUNCTION_INSTANCE_SIZE + pos);
14.42 }
14.43
14.44 int __BOOL(__attr attr)
15.1 --- a/translator.py Mon Feb 27 11:57:15 2017 +0100
15.2 +++ b/translator.py Mon Feb 27 14:41:27 2017 +0100
15.3 @@ -23,9 +23,9 @@
15.4 first, get_builtin_class, init_item, is_newer, \
15.5 predefined_constants
15.6 from encoders import encode_access_instruction, encode_access_instruction_arg, \
15.7 - encode_code, encode_function_pointer, encode_literal_constant, \
15.8 + encode_function_pointer, encode_literal_constant, \
15.9 encode_literal_instantiator, encode_instantiator_pointer, \
15.10 - encode_instructions, encode_path, encode_pos, \
15.11 + encode_instructions, encode_path, \
15.12 encode_symbol, encode_type_attribute, \
15.13 is_type_attribute
15.14 from errors import InspectError, TranslateError
15.15 @@ -142,7 +142,7 @@
15.16
15.17 elif parent:
15.18 return "__store_via_object(&%s, %s, %s)" % (
15.19 - encode_path(parent), encode_pos(attrname), self.expr)
15.20 + encode_path(parent), attrname, self.expr)
15.21
15.22 # All other assignments involve the names as they were given.
15.23
15.24 @@ -160,7 +160,7 @@
15.25
15.26 elif parent:
15.27 return "__load_via_object(&%s, %s)" % (
15.28 - encode_path(parent), encode_pos(attrname))
15.29 + encode_path(parent), attrname)
15.30
15.31 # All other accesses involve the names as they were given.
15.32
15.33 @@ -979,8 +979,8 @@
15.34 parent, attrname = path.rsplit(".", 1)
15.35
15.36 self.writestmt("__store_via_object(&%s, %s, __load_via_object(&%s, %s));" % (
15.37 - encode_path(class_name), encode_pos(name),
15.38 - encode_path(parent), encode_pos(attrname)
15.39 + encode_path(class_name), name,
15.40 + encode_path(parent), attrname
15.41 ))
15.42
15.43 def process_from_node(self, n):
15.44 @@ -1063,8 +1063,7 @@
15.45 argstr = "&%s" % encode_path(ref.get_origin())
15.46 elif guard == "common":
15.47 ref = first(self.deducer.accessor_all_general_types[location])
15.48 - typeattr = encode_type_attribute(ref.get_origin())
15.49 - argstr = "%s, %s" % (encode_pos(typeattr), encode_code(typeattr))
15.50 + argstr = encode_path(encode_type_attribute(ref.get_origin()))
15.51 else:
15.52 return
15.53
15.54 @@ -1447,8 +1446,7 @@
15.55 stages.append("__get_function(__CONTEXT_AS_VALUE(%s).value, %s)" % (
15.56 target_var, target_var))
15.57 else:
15.58 - stages.append("__load_via_object(%s.value, %s).fn" % (
15.59 - target_var, encode_pos("__fn__")))
15.60 + stages.append("__load_via_object(%s.value, __fn__).fn" % target_var)
15.61
15.62 # With a known target, the function is obtained directly and called.
15.63 # By putting the invocation at the end of the final element in the