1.1 --- a/generator.py Sun Mar 26 17:41:56 2017 +0200
1.2 +++ b/generator.py Sun Mar 26 18:03:40 2017 +0200
1.3 @@ -25,8 +25,7 @@
1.4 encode_instantiator_pointer, \
1.5 encode_literal_constant, encode_literal_constant_member, \
1.6 encode_literal_constant_size, encode_literal_constant_value, \
1.7 - encode_literal_data_initialiser, \
1.8 - encode_literal_instantiator, encode_literal_reference, \
1.9 + encode_literal_reference, \
1.10 encode_path, encode_pcode, encode_pos, encode_ppos, \
1.11 encode_predefined_reference, encode_size, \
1.12 encode_symbol, encode_tablename, \
1.13 @@ -1237,19 +1236,6 @@
1.14
1.15 print >>f_signatures, "#define __HAVE_%s" % encode_path(path)
1.16
1.17 - # Write additional literal instantiators. These do not call the
1.18 - # initialisers but instead populate the structures directly.
1.19 -
1.20 - # Signature: __newliteral_sequence(ARGS, NUM)
1.21 -
1.22 - if path in self.literal_instantiator_types:
1.23 - style = path.rsplit(".", 1)[-1]
1.24 -
1.25 - print >>f_signatures, "#define %s(ARGS, NUM) (%s(ARGS, NUM))" % (
1.26 - encode_literal_instantiator(path),
1.27 - encode_literal_data_initialiser(style),
1.28 - )
1.29 -
1.30 def write_main_program(self, f_code, f_signatures):
1.31
1.32 """
2.1 --- a/templates/progops.c Sun Mar 26 17:41:56 2017 +0200
2.2 +++ b/templates/progops.c Sun Mar 26 18:03:40 2017 +0200
2.3 @@ -62,9 +62,8 @@
2.4 return data;
2.5 }
2.6
2.7 -void __newdata_sequence(__attr self, __attr args[], unsigned int number, __fragment *data)
2.8 +void __newdata_sequence(unsigned int number, __fragment *data, __attr args[])
2.9 {
2.10 - __attr attr = {.seqvalue=data};
2.11 unsigned int i;
2.12
2.13 /* Copy the given number of values. */
2.14 @@ -73,36 +72,38 @@
2.15 data->attrs[i] = args[i];
2.16
2.17 data->size = number;
2.18 +}
2.19 +
2.20 +__attr __newdata_list(unsigned int number, __attr args[])
2.21 +{
2.22 + __attr self = __NEWINSTANCE(__builtins___list_list);
2.23 + __fragment *data = __new_fragment(number);
2.24
2.25 /* Store a reference to the data in the object's __data__ attribute. */
2.26
2.27 - __store_via_object(__VALUE(self), __data__, attr);
2.28 -}
2.29 -
2.30 -__attr __newdata_list(__attr args[], unsigned int number)
2.31 -{
2.32 - __attr self = __NEWINSTANCE(__builtins___list_list);
2.33 - __fragment *data = __new_fragment(number);
2.34 - __newdata_sequence(self, args, number, data);
2.35 + __store_via_object(__VALUE(self), __data__, (__attr) {.seqvalue=data});
2.36 + __newdata_sequence(number, data, args);
2.37 return self;
2.38 }
2.39
2.40 -__attr __newdata_tuple(__attr args[], unsigned int number)
2.41 +__attr __newdata_tuple(unsigned int number, __attr args[])
2.42 {
2.43 /* Allocate the tuple and fragment together. */
2.44
2.45 __attr self = __new(&__INSTANCETABLE(__builtins___tuple_tuple),
2.46 - &__builtins___tuple_tuple,
2.47 - __INSTANCESIZE(__builtins___tuple_tuple) + __FRAGMENT_SIZE(number), 0);
2.48 + &__builtins___tuple_tuple,
2.49 + __INSTANCESIZE(__builtins___tuple_tuple) + __FRAGMENT_SIZE(number), 0);
2.50 + __fragment *data = (__fragment *) ((void *) __VALUE(self) + __INSTANCESIZE(__builtins___tuple_tuple));
2.51
2.52 - /* Initialise the fragment. */
2.53 + /* Store a reference to the data in the object's __data__ attribute. */
2.54
2.55 - __newdata_sequence(self, args, number, (__fragment *) ((void *) __VALUE(self) + __INSTANCESIZE(__builtins___tuple_tuple)));
2.56 + __store_via_object(__VALUE(self), __data__, (__attr) {.seqvalue=data});
2.57 + __newdata_sequence(number, data, args);
2.58 return self;
2.59 }
2.60
2.61 #ifdef __HAVE___builtins___dict_dict
2.62 -__attr __newdata_dict(__attr args[], unsigned int number)
2.63 +__attr __newdata_dict(unsigned int number, __attr args[])
2.64 {
2.65 __attr self = __NEWINSTANCE(__builtins___dict_dict);
2.66
3.1 --- a/templates/progops.h Sun Mar 26 17:41:56 2017 +0200
3.2 +++ b/templates/progops.h Sun Mar 26 18:03:40 2017 +0200
3.3 @@ -32,11 +32,15 @@
3.4
3.5 __fragment *__new_fragment(unsigned int n);
3.6
3.7 -__attr __newdata_list(__attr args[], unsigned int number);
3.8 -__attr __newdata_tuple(__attr args[], unsigned int number);
3.9 +__attr __newdata_list(unsigned int number, __attr args[]);
3.10 +__attr __newdata_tuple(unsigned int number, __attr args[]);
3.11 +
3.12 +#define __newliteral___builtins___list_list(NUM, ...) __newdata_list(NUM, __ARGS(__VA_ARGS__))
3.13 +#define __newliteral___builtins___tuple_tuple(NUM, ...) __newdata_tuple(NUM, __ARGS(__VA_ARGS__))
3.14
3.15 #ifdef __HAVE___builtins___dict_dict
3.16 -__attr __newdata_dict(__attr args[], unsigned int number);
3.17 +__attr __newdata_dict(unsigned int number, __attr args[]);
3.18 +#define __newliteral___builtins___dict_dict(NUM, ...) __newdata_dict(NUM, __ARGS(__VA_ARGS__))
3.19 #endif /* __HAVE___builtins___dict_dict */
3.20
3.21 /* Helpers for raising errors within common operations. */
4.1 --- a/translator.py Sun Mar 26 17:41:56 2017 +0200
4.2 +++ b/translator.py Sun Mar 26 18:03:40 2017 +0200
4.3 @@ -1318,7 +1318,7 @@
4.4 # the number of values. The context is excluded.
4.5
4.6 if literal_instantiation:
4.7 - argstr = "__ARGS(%s), %d" % (", ".join(args[1:]), len(args) - 1)
4.8 + argstr = "%d, %s" % (len(args) - 1, ", ".join(args[1:]))
4.9 else:
4.10 argstr = ", ".join(args)
4.11