parent
a922d5d42a
commit
91d911007b
|
@ -1000,6 +1000,7 @@ struct CodeGen {
|
|||
bool error_during_imports;
|
||||
uint32_t next_node_index;
|
||||
uint32_t next_error_index;
|
||||
uint32_t error_value_count;
|
||||
TypeTableEntry *err_tag_type;
|
||||
};
|
||||
|
||||
|
|
|
@ -2984,7 +2984,7 @@ static TypeTableEntry *analyze_cast_expr(CodeGen *g, ImportTableEntry *import, B
|
|||
wanted_type->id == TypeTableEntryIdInt)
|
||||
{
|
||||
BigNum bn;
|
||||
bignum_init_unsigned(&bn, g->next_error_index);
|
||||
bignum_init_unsigned(&bn, g->error_value_count);
|
||||
if (bignum_fits_in_bits(&bn, wanted_type->size_in_bits, wanted_type->data.integral.is_signed)) {
|
||||
node->data.fn_call_expr.cast_op = CastOpErrToInt;
|
||||
eval_const_expr_implicit_cast(g, node, expr_node);
|
||||
|
@ -4355,10 +4355,15 @@ void semantic_analyze(CodeGen *g) {
|
|||
assert(target_import);
|
||||
|
||||
target_import->importers.append({import, child});
|
||||
} else if (child->type == NodeTypeErrorValueDecl) {
|
||||
g->error_value_count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g->err_tag_type = get_smallest_unsigned_int_type(g, g->error_value_count);
|
||||
|
||||
{
|
||||
auto it = g->import_table.entry_iterator();
|
||||
for (;;) {
|
||||
|
@ -4375,7 +4380,7 @@ void semantic_analyze(CodeGen *g) {
|
|||
}
|
||||
}
|
||||
|
||||
g->err_tag_type = get_smallest_unsigned_int_type(g, g->next_error_index);
|
||||
assert(g->error_value_count == g->next_error_index);
|
||||
|
||||
{
|
||||
auto it = g->import_table.entry_iterator();
|
||||
|
|
|
@ -27,6 +27,7 @@ CodeGen *codegen_create(Buf *root_source_dir) {
|
|||
g->build_type = CodeGenBuildTypeDebug;
|
||||
g->root_source_dir = root_source_dir;
|
||||
g->next_error_index = 1;
|
||||
g->error_value_count = 1;
|
||||
|
||||
return g;
|
||||
}
|
||||
|
@ -684,7 +685,7 @@ static LLVMValueRef gen_field_access_expr(CodeGen *g, AstNode *node, bool is_lva
|
|||
{
|
||||
TypeTableEntry *type_entry;
|
||||
LLVMValueRef ptr = gen_field_ptr(g, node, &type_entry);
|
||||
if (is_lvalue) {
|
||||
if (is_lvalue || handle_is_ptr(type_entry)) {
|
||||
return ptr;
|
||||
} else {
|
||||
add_debug_source_node(g, node);
|
||||
|
|
|
@ -97,7 +97,7 @@ pub struct OutStream {
|
|||
pub fn flush(os: &OutStream) %void => {
|
||||
const amt_to_write = os.index;
|
||||
os.index = 0;
|
||||
switch (write(fd, os.buffer.ptr, amt_to_write)) {
|
||||
switch (write(os.fd, os.buffer.ptr, amt_to_write)) {
|
||||
EINVAL => unreachable{},
|
||||
EDQUOT => %.DiskQuota,
|
||||
EFBIG => %.FileTooBig,
|
||||
|
|
Loading…
Reference in New Issue