|
@@ -123,35 +123,29 @@ void gen_func_sig(FILE *stream, const char *ret_type, const char *name, const ch
|
|
|
fprintf(stream, ")");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-void gen_vector_ctor_sig(FILE *stream, size_t n, Type_Def type_def)
|
|
|
+void gen_vector_ctor(FILE *stream, Stmt stmt, size_t n, Type_Def type_def)
|
|
|
{
|
|
|
Short_String vector_type = make_vector_type(n, type_def);
|
|
|
Short_String vector_prefix = make_vector_prefix(n, type_def);
|
|
|
assert(n <= VECTOR_MAX_SIZE);
|
|
|
gen_func_sig(stream, vector_type.cstr, vector_prefix.cstr, type_def.name, vector_comps, n);
|
|
|
-}
|
|
|
|
|
|
-void gen_vector_ctor_decl(FILE *stream, size_t n, Type_Def type_def)
|
|
|
-{
|
|
|
- gen_vector_ctor_sig(stream, n, type_def);
|
|
|
- fprintf(stream, ";\n");
|
|
|
-}
|
|
|
-
|
|
|
-void gen_vector_ctor_impl(FILE *stream, size_t n, Type_Def type_def)
|
|
|
-{
|
|
|
- Short_String type = make_vector_type(n, type_def);
|
|
|
-
|
|
|
- gen_vector_ctor_sig(stream, n, type_def);
|
|
|
- fprintf(stream, "\n");
|
|
|
- fprintf(stream, "{\n");
|
|
|
- fprintf(stream, " %s v;\n", type.cstr);
|
|
|
- assert(n <= VECTOR_MAX_SIZE);
|
|
|
- for (size_t i = 0; i < n; ++i) {
|
|
|
- fprintf(stream, " v.%s = %s;\n", vector_comps[i], vector_comps[i]);
|
|
|
+ if (stmt == STMT_DECL) {
|
|
|
+ fprintf(stream, ";\n");
|
|
|
+ } else if (stmt == STMT_IMPL) {
|
|
|
+ fprintf(stream, "\n");
|
|
|
+ fprintf(stream, "{\n");
|
|
|
+ fprintf(stream, " %s v;\n", vector_type.cstr);
|
|
|
+ assert(n <= VECTOR_MAX_SIZE);
|
|
|
+ for (size_t i = 0; i < n; ++i) {
|
|
|
+ fprintf(stream, " v.%s = %s;\n", vector_comps[i], vector_comps[i]);
|
|
|
+ }
|
|
|
+ fprintf(stream, " return v;\n");
|
|
|
+ fprintf(stream, "}\n");
|
|
|
+ } else {
|
|
|
+ assert(0 && "unreachable");
|
|
|
+ exit(69);
|
|
|
}
|
|
|
- fprintf(stream, " return v;\n");
|
|
|
- fprintf(stream, "}\n");
|
|
|
}
|
|
|
|
|
|
void gen_vector_scalar_ctor(FILE *stream, Stmt stmt, size_t n, Type_Def type_def)
|
|
@@ -611,7 +605,7 @@ int main()
|
|
|
for (size_t n = VECTOR_MIN_SIZE; n <= VECTOR_MAX_SIZE; ++n) {
|
|
|
for (Type type = 0; type < COUNT_TYPES; ++type) {
|
|
|
gen_vector_printf_macros(stream, n, type_defs[type]);
|
|
|
- gen_vector_ctor_decl(stream, n, type_defs[type]);
|
|
|
+ gen_vector_ctor(stream, STMT_DECL, n, type_defs[type]);
|
|
|
gen_vector_scalar_ctor(stream, STMT_DECL, n, type_defs[type]);
|
|
|
for (size_t src_n = VECTOR_MIN_SIZE; src_n <= VECTOR_MAX_SIZE; ++src_n) {
|
|
|
for (Type src_type = 0; src_type < COUNT_TYPES; ++src_type) {
|
|
@@ -663,7 +657,7 @@ int main()
|
|
|
}
|
|
|
for (size_t n = VECTOR_MIN_SIZE; n <= VECTOR_MAX_SIZE; ++n) {
|
|
|
for (Type type = 0; type < COUNT_TYPES; ++type) {
|
|
|
- gen_vector_ctor_impl(stream, n, type_defs[type]);
|
|
|
+ gen_vector_ctor(stream, STMT_IMPL, n, type_defs[type]);
|
|
|
fputc('\n', stream);
|
|
|
gen_vector_scalar_ctor(stream, STMT_IMPL, n, type_defs[type]);
|
|
|
fputc('\n', stream);
|