aboutsummaryrefslogtreecommitdiff
path: root/src/compile
diff options
context:
space:
mode:
Diffstat (limited to 'src/compile')
-rw-r--r--src/compile/assertions.c35
-rw-r--r--src/compile/assignments.c7
-rw-r--r--src/compile/conditionals.c2
-rw-r--r--src/compile/doctests.c17
-rw-r--r--src/compile/enums.c20
-rw-r--r--src/compile/files.c4
-rw-r--r--src/compile/functions.c24
-rw-r--r--src/compile/indexing.c4
-rw-r--r--src/compile/lists.c2
-rw-r--r--src/compile/loops.c4
-rw-r--r--src/compile/optionals.c11
-rw-r--r--src/compile/promotions.c12
-rw-r--r--src/compile/sets.c2
-rw-r--r--src/compile/statements.c4
-rw-r--r--src/compile/structs.c9
-rw-r--r--src/compile/tables.c2
-rw-r--r--src/compile/types.c4
17 files changed, 78 insertions, 85 deletions
diff --git a/src/compile/assertions.c b/src/compile/assertions.c
index ce9abcbc..0f1d27b6 100644
--- a/src/compile/assertions.c
+++ b/src/compile/assertions.c
@@ -53,27 +53,26 @@ Text_t compile_assertion(env_t *env, ast_t *ast) {
ast_t *var_comparison = new (ast_t, .file = expr->file, .start = expr->start, .end = expr->end,
.tag = expr->tag, .__data.Equals = {.lhs = lhs_var, .rhs = rhs_var});
int64_t line = get_line_number(ast->file, ast->start);
- return Texts("{ // assertion\n", compile_declaration(operand_t, Text("_lhs")), " = ",
- compile_to_type(env, cmp.lhs, operand_t), ";\n", "\n#line ", String(line), "\n",
- compile_declaration(operand_t, Text("_rhs")), " = ", compile_to_type(env, cmp.rhs, operand_t),
- ";\n", "\n#line ", String(line), "\n", "if (!(", compile_condition(env, var_comparison), "))\n",
- "#line ", String(line), "\n",
- Texts("fail_source(", quoted_str(ast->file->filename), ", ",
- String((int64_t)(expr->start - expr->file->text)), ", ",
- String((int64_t)(expr->end - expr->file->text)), ", ",
- message ? Texts("Text$as_c_string(", compile_to_type(env, message, Type(TextType)), ")")
- : Text("\"This assertion failed!\""),
- ", ", "\" (\", ", expr_as_text(Text("_lhs"), operand_t, Text("no")),
- ", "
- "\" ",
- failure, " \", ", expr_as_text(Text("_rhs"), operand_t, Text("no")), ", \")\");\n"),
- "}\n");
+ return Texts(
+ "{ // assertion\n", compile_declaration(operand_t, Text("_lhs")), " = ",
+ compile_to_type(env, cmp.lhs, operand_t), ";\n", "\n#line ", line, "\n",
+ compile_declaration(operand_t, Text("_rhs")), " = ", compile_to_type(env, cmp.rhs, operand_t), ";\n",
+ "\n#line ", line, "\n", "if (!(", compile_condition(env, var_comparison), "))\n", "#line ", line, "\n",
+ Texts("fail_source(", quoted_str(ast->file->filename), ", ", (int64_t)(expr->start - expr->file->text),
+ ", ", (int64_t)(expr->end - expr->file->text), ", ",
+ message ? Texts("Text$as_c_string(", compile_to_type(env, message, Type(TextType)), ")")
+ : Text("\"This assertion failed!\""),
+ ", ", "\" (\", ", expr_as_text(Text("_lhs"), operand_t, Text("no")),
+ ", "
+ "\" ",
+ failure, " \", ", expr_as_text(Text("_rhs"), operand_t, Text("no")), ", \")\");\n"),
+ "}\n");
}
default: {
int64_t line = get_line_number(ast->file, ast->start);
- return Texts("if (!(", compile_condition(env, expr), "))\n", "#line ", String(line), "\n", "fail_source(",
- quoted_str(ast->file->filename), ", ", String((int64_t)(expr->start - expr->file->text)), ", ",
- String((int64_t)(expr->end - expr->file->text)), ", ",
+ return Texts("if (!(", compile_condition(env, expr), "))\n", "#line ", line, "\n", "fail_source(",
+ quoted_str(ast->file->filename), ", ", (int64_t)(expr->start - expr->file->text), ", ",
+ (int64_t)(expr->end - expr->file->text), ", ",
message ? Texts("Text$as_c_string(", compile_to_type(env, message, Type(TextType)), ")")
: Text("\"This assertion failed!\""),
");\n");
diff --git a/src/compile/assignments.c b/src/compile/assignments.c
index ab28b972..3cb60fd5 100644
--- a/src/compile/assignments.c
+++ b/src/compile/assignments.c
@@ -119,12 +119,12 @@ Text_t compile_assignment_statement(env_t *env, ast_t *ast) {
"stack memory.");
env_t *val_env = with_enum_scope(env, lhs_t);
Text_t val = compile_to_type(val_env, value->ast, lhs_t);
- code = Texts(code, compile_type(lhs_t), " $", String(i), " = ", val, ";\n");
+ code = Texts(code, compile_type(lhs_t), " $", i, " = ", val, ";\n");
i += 1;
}
i = 1;
for (ast_list_t *target = assign->targets; target; target = target->next) {
- code = Texts(code, compile_assignment(env, target->ast, Texts("$", String(i))), ";\n");
+ code = Texts(code, compile_assignment(env, target->ast, Texts("$", i)), ";\n");
i += 1;
}
return Texts(code, "\n}");
@@ -171,8 +171,7 @@ Text_t compile_lvalue(env_t *env, ast_t *ast) {
")");
} else {
return Texts("List_lvalue(", compile_type(item_type), ", ", target_code, ", ", index_code, ", ",
- String((int)(ast->start - ast->file->text)), ", ",
- String((int)(ast->end - ast->file->text)), ")");
+ (int64_t)(ast->start - ast->file->text), ", ", (int64_t)(ast->end - ast->file->text), ")");
}
} else if (container_t->tag == TableType) {
DeclareMatch(table_type, container_t, TableType);
diff --git a/src/compile/conditionals.c b/src/compile/conditionals.c
index 23d2a177..f9dfa751 100644
--- a/src/compile/conditionals.c
+++ b/src/compile/conditionals.c
@@ -59,7 +59,7 @@ Text_t compile_if_statement(env_t *env, ast_t *ast) {
code = Texts(code, compile_block(nonnull_scope, if_->body));
if (if_->else_body) {
- Text_t label = Texts("_falsey_", String((int64_t)(ast->start - ast->file->text)));
+ Text_t label = Texts("_falsey_", (int64_t)(ast->start - ast->file->text));
code = Texts(code, "else goto ", label,
";\n"
"} else {\n",
diff --git a/src/compile/doctests.c b/src/compile/doctests.c
index 872684ed..20081ae7 100644
--- a/src/compile/doctests.c
+++ b/src/compile/doctests.c
@@ -4,7 +4,6 @@
#include "../config.h"
#include "../environment.h"
#include "../stdlib/datatypes.h"
-#include "../stdlib/print.h"
#include "../stdlib/text.h"
#include "../stdlib/util.h"
#include "../typecheck.h"
@@ -69,12 +68,12 @@ Text_t compile_doctest(env_t *env, ast_t *ast) {
if (target == assign->targets) expr_t = lhs_t;
env_t *val_scope = with_enum_scope(env, lhs_t);
Text_t val_code = compile_to_type(val_scope, value->ast, lhs_t);
- test_code = Texts(test_code, compile_type(lhs_t), " $", String(i), " = ", val_code, ";\n");
+ test_code = Texts(test_code, compile_type(lhs_t), " $", i, " = ", val_code, ";\n");
i += 1;
}
i = 1;
for (ast_list_t *target = assign->targets; target; target = target->next) {
- test_code = Texts(test_code, compile_assignment(env, target->ast, Texts("$", String(i))), ";\n");
+ test_code = Texts(test_code, compile_assignment(env, target->ast, Texts("$", i)), ";\n");
i += 1;
}
@@ -104,16 +103,16 @@ Text_t compile_doctest(env_t *env, ast_t *ast) {
if (test->expected) {
return Texts(setup, "test(", compile_type(expr_t), ", ", test_code, ", ",
compile_to_type(env, test->expected, expr_t), ", ", compile_type_info(expr_t), ", ",
- String((int64_t)(test->expr->start - test->expr->file->text)), ", ",
- String((int64_t)(test->expr->end - test->expr->file->text)), ");");
+ (int64_t)(test->expr->start - test->expr->file->text), ", ",
+ (int64_t)(test->expr->end - test->expr->file->text), ");");
} else {
if (expr_t->tag == VoidType || expr_t->tag == AbortType) {
return Texts(setup, "inspect_void(", test_code, ", ", compile_type_info(expr_t), ", ",
- String((int64_t)(test->expr->start - test->expr->file->text)), ", ",
- String((int64_t)(test->expr->end - test->expr->file->text)), ");");
+ (int64_t)(test->expr->start - test->expr->file->text), ", ",
+ (int64_t)(test->expr->end - test->expr->file->text), ");");
}
return Texts(setup, "inspect(", compile_type(expr_t), ", ", test_code, ", ", compile_type_info(expr_t), ", ",
- String((int64_t)(test->expr->start - test->expr->file->text)), ", ",
- String((int64_t)(test->expr->end - test->expr->file->text)), ");");
+ (int64_t)(test->expr->start - test->expr->file->text), ", ",
+ (int64_t)(test->expr->end - test->expr->file->text), ");");
}
}
diff --git a/src/compile/enums.c b/src/compile/enums.c
index d9c29f26..f5500831 100644
--- a/src/compile/enums.c
+++ b/src/compile/enums.c
@@ -30,12 +30,12 @@ Text_t compile_enum_typeinfo(env_t *env, ast_t *ast) {
type_t *t = Table$str_get(*env->types, def->name);
const char *metamethods = is_packed_data(t) ? "PackedDataEnum$metamethods" : "Enum$metamethods";
Text_t info = namespace_name(env, env->namespace, Texts(def->name, "$$info"));
- Text_t typeinfo = Texts("public const TypeInfo_t ", info, " = {", String((int64_t)type_size(t)), "u, ",
- String((int64_t)type_align(t)), "u, .metamethods=", metamethods,
- ", {.tag=EnumInfo, .EnumInfo={.name=\"", def->name,
- "\", "
- ".num_tags=",
- String((int64_t)num_tags), ", .tags=(NamedType_t[]){");
+ Text_t typeinfo =
+ Texts("public const TypeInfo_t ", info, " = {", (int64_t)type_size(t), "u, ", (int64_t)type_align(t),
+ "u, .metamethods=", metamethods, ", {.tag=EnumInfo, .EnumInfo={.name=\"", def->name,
+ "\", "
+ ".num_tags=",
+ (int64_t)num_tags, ", .tags=(NamedType_t[]){");
for (tag_ast_t *tag = def->tags; tag; tag = tag->next) {
const char *tag_type_name = String(def->name, "$", tag->name);
@@ -144,10 +144,10 @@ Text_t compile_empty_enum(type_t *t) {
assert(tag);
assert(tag->type);
if (Match(tag->type, StructType)->fields)
- return Texts("((", compile_type(t), "){.$tag=", String(tag->tag_value), ", .", tag->name, "=",
- compile_empty(tag->type), "})");
- else if (enum_has_fields(t)) return Texts("((", compile_type(t), "){.$tag=", String(tag->tag_value), "})");
- else return Texts("((", compile_type(t), ")", String(tag->tag_value), ")");
+ return Texts("((", compile_type(t), "){.$tag=", tag->tag_value, ", .", tag->name, "=", compile_empty(tag->type),
+ "})");
+ else if (enum_has_fields(t)) return Texts("((", compile_type(t), "){.$tag=", tag->tag_value, "})");
+ else return Texts("((", compile_type(t), ")", tag->tag_value, ")");
}
public
diff --git a/src/compile/files.c b/src/compile/files.c
index 2b0ac4bf..a6af2300 100644
--- a/src/compile/files.c
+++ b/src/compile/files.c
@@ -103,7 +103,7 @@ static Text_t compile_top_level_code(env_t *env, ast_t *ast) {
"types, not ",
type_to_str(Match(type, FunctionType)->ret));
Text_t name_code =
- namespace_name(env, env->namespace, Texts(name, "$", String(get_line_number(ast->file, ast->start))));
+ namespace_name(env, env->namespace, Texts(name, "$", get_line_number(ast->file, ast->start)));
return compile_function(env, name_code, ast, &env->code->staticdefs);
}
case StructDef: {
@@ -125,7 +125,7 @@ static Text_t compile_top_level_code(env_t *env, ast_t *ast) {
DeclareMatch(def, ast, LangDef);
Text_t code =
Texts("public const TypeInfo_t ", namespace_name(env, env->namespace, Texts(def->name, "$$info")), " = {",
- String((int64_t)sizeof(Text_t)), ", ", String((int64_t)__alignof__(Text_t)),
+ (int64_t)sizeof(Text_t), ", ", (int64_t)__alignof__(Text_t),
", .metamethods=Text$metamethods, .tag=TextInfo, .TextInfo={", quoted_str(def->name), "}};\n");
env_t *ns_env = namespace_env(env, def->name);
return Texts(code, def->namespace ? compile_top_level_code(ns_env, def->namespace) : EMPTY_TEXT);
diff --git a/src/compile/functions.c b/src/compile/functions.c
index 01de26e3..6caefa8b 100644
--- a/src/compile/functions.c
+++ b/src/compile/functions.c
@@ -32,7 +32,7 @@ Text_t compile_function_declaration(env_t *env, ast_t *ast) {
if (ret_t->tag == AbortType) ret_type_code = Texts("__attribute__((noreturn)) _Noreturn ", ret_type_code);
Text_t name = namespace_name(env, env->namespace, Text$from_str(decl_name));
if (env->namespace && env->namespace->parent && env->namespace->name && streq(decl_name, env->namespace->name))
- name = namespace_name(env, env->namespace, Text$from_str(String(get_line_number(ast->file, ast->start))));
+ name = namespace_name(env, env->namespace, Texts(get_line_number(ast->file, ast->start)));
return Texts(ret_type_code, " ", name, arg_signature, ";\n");
}
@@ -56,8 +56,7 @@ Text_t compile_convert_declaration(env_t *env, ast_t *ast) {
"Conversions are only supported for text, struct, and enum "
"types, not ",
type_to_str(ret_t));
- Text_t name_code =
- namespace_name(env, env->namespace, Texts(name, "$", String(get_line_number(ast->file, ast->start))));
+ Text_t name_code = namespace_name(env, env->namespace, Texts(name, "$", get_line_number(ast->file, ast->start)));
return Texts(ret_type_code, " ", name_code, arg_signature, ";\n");
}
@@ -248,7 +247,7 @@ Text_t compile_function_call(env_t *env, ast_t *ast) {
public
Text_t compile_lambda(env_t *env, ast_t *ast) {
DeclareMatch(lambda, ast, Lambda);
- Text_t name = namespace_name(env, env->namespace, Texts("lambda$", String(lambda->id)));
+ Text_t name = namespace_name(env, env->namespace, Texts("lambda$", lambda->id));
env_t *body_scope = fresh_scope(env);
body_scope->deferred = NULL;
@@ -736,7 +735,7 @@ Text_t compile_function(env_t *env, Text_t name_code, ast_t *ast, Text_t *static
// FIXME: this currently just deletes the first entry, but this
// should be more like a least-recently-used cache eviction policy
// or least-frequently-used
- pop_code = Texts("if (cache.entries.length > ", String(cache_size.value),
+ pop_code = Texts("if (cache.entries.length > ", cache_size.value,
") Table$remove(&cache, cache.entries.data + "
"cache.entries.stride*0, table_type);\n");
}
@@ -772,14 +771,13 @@ Text_t compile_function(env_t *env, Text_t name_code, ast_t *ast, Text_t *static
int64_t num_fields = used_names.entries.length;
const char *metamethods = is_packed_data(t) ? "PackedData$metamethods" : "Struct$metamethods";
- Text_t args_typeinfo =
- Texts("((TypeInfo_t[1]){{.size=sizeof(args), "
- ".align=__alignof__(args), .metamethods=",
- metamethods,
- ", .tag=StructInfo, "
- ".StructInfo.name=\"FunctionArguments\", "
- ".StructInfo.num_fields=",
- String(num_fields), ", .StructInfo.fields=(NamedType_t[", String(num_fields), "]){");
+ Text_t args_typeinfo = Texts("((TypeInfo_t[1]){{.size=sizeof(args), "
+ ".align=__alignof__(args), .metamethods=",
+ metamethods,
+ ", .tag=StructInfo, "
+ ".StructInfo.name=\"FunctionArguments\", "
+ ".StructInfo.num_fields=",
+ num_fields, ", .StructInfo.fields=(NamedType_t[", num_fields, "]){");
Text_t args_type = Text("struct { ");
for (arg_t *f = fields; f; f = f->next) {
args_typeinfo = Texts(args_typeinfo, "{\"", f->name, "\", ", compile_type_info(f->type), "}");
diff --git a/src/compile/indexing.c b/src/compile/indexing.c
index e99feeb2..39af1160 100644
--- a/src/compile/indexing.c
+++ b/src/compile/indexing.c
@@ -44,8 +44,8 @@ Text_t compile_indexing(env_t *env, ast_t *ast) {
return Texts("List_get_unchecked(", compile_type(item_type), ", ", list, ", ", index_code, ")");
else
return Texts("List_get(", compile_type(item_type), ", ", list, ", ", index_code, ", ",
- String((int64_t)(indexing->index->start - f->text)), ", ",
- String((int64_t)(indexing->index->end - f->text)), ")");
+ (int64_t)(indexing->index->start - f->text), ", ", (int64_t)(indexing->index->end - f->text),
+ ")");
} else if (container_t->tag == TableType) {
DeclareMatch(table_type, container_t, TableType);
if (indexing->unchecked) code_err(ast, "Table indexes cannot be unchecked");
diff --git a/src/compile/lists.c b/src/compile/lists.c
index 5df39863..d9d71278 100644
--- a/src/compile/lists.c
+++ b/src/compile/lists.c
@@ -33,7 +33,7 @@ Text_t compile_typed_list(env_t *env, ast_t *ast, type_t *list_type) {
{
env_t *scope = item_type->tag == EnumType ? with_enum_scope(env, item_type) : env;
if (is_incomplete_type(item_type)) code_err(ast, "This list's type can't be inferred!");
- Text_t code = Texts("TypedListN(", compile_type(item_type), ", ", String(n));
+ Text_t code = Texts("TypedListN(", compile_type(item_type), ", ", n);
for (ast_list_t *item = list->items; item; item = item->next) {
code = Texts(code, ", ", compile_to_type(scope, item->ast, item_type));
}
diff --git a/src/compile/loops.c b/src/compile/loops.c
index c742589a..332024f4 100644
--- a/src/compile/loops.c
+++ b/src/compile/loops.c
@@ -405,7 +405,7 @@ Text_t compile_skip(env_t *env, ast_t *ast) {
if (matched) {
if (ctx->skip_label.length == 0) {
static int64_t skip_label_count = 1;
- ctx->skip_label = Texts("skip_", String(skip_label_count));
+ ctx->skip_label = Texts("skip_", skip_label_count);
++skip_label_count;
}
Text_t code = EMPTY_TEXT;
@@ -431,7 +431,7 @@ Text_t compile_stop(env_t *env, ast_t *ast) {
if (matched) {
if (ctx->stop_label.length == 0) {
static int64_t stop_label_count = 1;
- ctx->stop_label = Texts("stop_", String(stop_label_count));
+ ctx->stop_label = Texts("stop_", stop_label_count);
++stop_label_count;
}
Text_t code = EMPTY_TEXT;
diff --git a/src/compile/optionals.c b/src/compile/optionals.c
index b3d94005..cd50b1bf 100644
--- a/src/compile/optionals.c
+++ b/src/compile/optionals.c
@@ -125,10 +125,9 @@ Text_t compile_non_optional(env_t *env, ast_t *ast) {
type_t *t = get_type(env, value);
Text_t value_code = compile(env, value);
int64_t line = get_line_number(ast->file, ast->start);
- return Texts("({ ", compile_declaration(t, Text("opt")), " = ", value_code, "; ", "if unlikely (",
- check_none(t, Text("opt")), ")\n", "#line ", String(line), "\n", "fail_source(",
- quoted_str(ast->file->filename), ", ", String((int64_t)(value->start - value->file->text)), ", ",
- String((int64_t)(value->end - value->file->text)), ", ",
- "\"This was expected to be a value, but it's none\");\n", optional_into_nonnone(t, Text("opt")),
- "; })");
+ return Texts(
+ "({ ", compile_declaration(t, Text("opt")), " = ", value_code, "; ", "if unlikely (",
+ check_none(t, Text("opt")), ")\n", "#line ", line, "\n", "fail_source(", quoted_str(ast->file->filename), ", ",
+ (int64_t)(value->start - value->file->text), ", ", (int64_t)(value->end - value->file->text), ", ",
+ "\"This was expected to be a value, but it's none\");\n", optional_into_nonnone(t, Text("opt")), "; })");
}
diff --git a/src/compile/promotions.c b/src/compile/promotions.c
index fcedce3f..6595e5aa 100644
--- a/src/compile/promotions.c
+++ b/src/compile/promotions.c
@@ -43,12 +43,12 @@ bool promote(env_t *env, ast_t *ast, Text_t *code, type_t *actual, type_t *neede
// Automatic optional checking for nums:
if (needed->tag == NumType && actual->tag == OptionalType && Match(actual, OptionalType)->type->tag == NumType) {
int64_t line = get_line_number(ast->file, ast->start);
- *code = Texts("({ ", compile_declaration(actual, Text("opt")), " = ", *code, "; ", "if unlikely (",
- check_none(actual, Text("opt")), ")\n", "#line ", String(line), "\n", "fail_source(",
- quoted_str(ast->file->filename), ", ", String((int64_t)(ast->start - ast->file->text)), ", ",
- String((int64_t)(ast->end - ast->file->text)), ", ",
- "\"This was expected to be a value, but it's none\");\n",
- optional_into_nonnone(actual, Text("opt")), "; })");
+ *code =
+ Texts("({ ", compile_declaration(actual, Text("opt")), " = ", *code, "; ", "if unlikely (",
+ check_none(actual, Text("opt")), ")\n", "#line ", line, "\n", "fail_source(",
+ quoted_str(ast->file->filename), ", ", (int64_t)(ast->start - ast->file->text), ", ",
+ (int64_t)(ast->end - ast->file->text), ", ", "\"This was expected to be a value, but it's none\");\n",
+ optional_into_nonnone(actual, Text("opt")), "; })");
return true;
}
diff --git a/src/compile/sets.c b/src/compile/sets.c
index d33677cc..3346a9aa 100644
--- a/src/compile/sets.c
+++ b/src/compile/sets.c
@@ -25,7 +25,7 @@ Text_t compile_typed_set(env_t *env, ast_t *ast, type_t *set_type) {
}
{ // No comprehension:
- Text_t code = Texts("Set(", compile_type(item_type), ", ", compile_type_info(item_type), ", ", String(n));
+ Text_t code = Texts("Set(", compile_type(item_type), ", ", compile_type_info(item_type), ", ", n);
env_t *scope = item_type->tag == EnumType ? with_enum_scope(env, item_type) : env;
for (ast_list_t *item = set->items; item; item = item->next) {
code = Texts(code, ", ", compile_to_type(scope, item->ast, item_type));
diff --git a/src/compile/statements.c b/src/compile/statements.c
index 7c58559d..e296795b 100644
--- a/src/compile/statements.c
+++ b/src/compile/statements.c
@@ -22,7 +22,7 @@ public
Text_t with_source_info(env_t *env, ast_t *ast, Text_t code) {
if (code.length == 0 || !ast || !ast->file || !env->do_source_mapping) return code;
int64_t line = get_line_number(ast->file, ast->start);
- return Texts("\n#line ", String(line), "\n", code);
+ return Texts("\n#line ", line, "\n", code);
}
static Text_t _compile_statement(env_t *env, ast_t *ast) {
@@ -121,7 +121,7 @@ static Text_t _compile_statement(env_t *env, ast_t *ast) {
if (Text$starts_with(entry->b->code, Text("userdata->"), NULL)) {
Table$str_set(defer_env->locals, entry->name, entry->b);
} else {
- Text_t defer_name = Texts("defer$", String(++defer_id), "$", entry->name);
+ Text_t defer_name = Texts("defer$", ++defer_id, "$", entry->name);
defer_id += 1;
code = Texts(code, compile_declaration(entry->b->type, defer_name), " = ", entry->b->code, ";\n");
set_binding(defer_env, entry->name, entry->b->type, defer_name);
diff --git a/src/compile/structs.c b/src/compile/structs.c
index 526c11c7..8560a790 100644
--- a/src/compile/structs.c
+++ b/src/compile/structs.c
@@ -18,7 +18,7 @@ Text_t compile_struct_typeinfo(env_t *env, type_t *t, const char *name, arg_ast_
? Text$from_str(name)
: Texts("struct ", namespace_name(env, env->namespace, Texts(name, "$$struct")));
- int num_fields = 0;
+ int64_t num_fields = 0;
for (arg_ast_t *f = fields; f; f = f->next)
num_fields += 1;
const char *short_name = name;
@@ -33,9 +33,9 @@ Text_t compile_struct_typeinfo(env_t *env, type_t *t, const char *name, arg_ast_
", "
".tag=StructInfo, .StructInfo.name=\"",
short_name, "\"", is_secret ? Text(", .StructInfo.is_secret=true") : EMPTY_TEXT,
- is_opaque ? Text(", .StructInfo.is_opaque=true") : EMPTY_TEXT, ", .StructInfo.num_fields=", String(num_fields));
+ is_opaque ? Text(", .StructInfo.is_opaque=true") : EMPTY_TEXT, ", .StructInfo.num_fields=", num_fields);
if (fields) {
- typeinfo = Texts(typeinfo, ", .StructInfo.fields=(NamedType_t[", String(num_fields), "]){");
+ typeinfo = Texts(typeinfo, ", .StructInfo.fields=(NamedType_t[", num_fields, "]){");
for (arg_ast_t *f = fields; f; f = f->next) {
type_t *field_type = get_arg_ast_type(env, f);
typeinfo = Texts(typeinfo, "{\"", f->name, "\", ", compile_type_info(field_type), "}");
@@ -70,8 +70,7 @@ Text_t compile_struct_header(env_t *env, ast_t *ast) {
Text_t struct_code = def->external ? EMPTY_TEXT : Texts(type_code, " {\n", fields, "};\n");
type_t *t = Table$str_get(*env->types, def->name);
- Text_t unpadded_size =
- def->opaque ? Texts("sizeof(", type_code, ")") : Text$from_str(String((int64_t)unpadded_struct_size(t)));
+ Text_t unpadded_size = def->opaque ? Texts("sizeof(", type_code, ")") : Texts((int64_t)unpadded_struct_size(t));
Text_t typeinfo_code = Texts("extern const TypeInfo_t ", typeinfo_name, ";\n");
Text_t optional_code = EMPTY_TEXT;
if (!def->opaque) {
diff --git a/src/compile/tables.c b/src/compile/tables.c
index b955178e..dde8669a 100644
--- a/src/compile/tables.c
+++ b/src/compile/tables.c
@@ -43,7 +43,7 @@ Text_t compile_typed_table(env_t *env, ast_t *ast, type_t *table_type) {
size_t n = 0;
for (ast_list_t *entry = table->entries; entry; entry = entry->next)
++n;
- code = Texts(code, ", ", String((int64_t)n));
+ code = Texts(code, ", ", (int64_t)n);
for (ast_list_t *entry = table->entries; entry; entry = entry->next) {
DeclareMatch(e, entry->ast, TableEntry);
diff --git a/src/compile/types.c b/src/compile/types.c
index aa06e2fd..f6f276a5 100644
--- a/src/compile/types.c
+++ b/src/compile/types.c
@@ -23,10 +23,10 @@ Text_t compile_type(type_t *t) {
case ByteType: return Text("Byte_t");
case CStringType: return Text("const char*");
case BigIntType: return Text("Int_t");
- case IntType: return Texts("Int", String(Match(t, IntType)->bits), "_t");
+ case IntType: return Texts("Int", (int32_t)Match(t, IntType)->bits, "_t");
case NumType:
return Match(t, NumType)->bits == TYPE_NBITS64 ? Text("Num_t")
- : Texts("Num", String(Match(t, NumType)->bits), "_t");
+ : Texts("Num", (int32_t)Match(t, NumType)->bits, "_t");
case TextType: {
DeclareMatch(text, t, TextType);
if (!text->lang || streq(text->lang, "Text")) return Text("Text_t");