stream_read_byte :: proc (use s: ^Stream) -> (Error, u8) {
if vtable == null do return Error.NoVtable, cast(u8) 0;
- if vtable.read_byte == null_proc do return Error.NotImplemented, cast(u8) 0;
+ if vtable.read_byte == null_proc do return Error.NotImplemented, 0;
return vtable.read_byte(s);
}
err : io.Error;
err, out = stream_read_byte(s);
- if err != Error.None do return err, cast(u8) 0;
+ if err != Error.None do return err, 0;
err = stream_unread_byte(s);
- if err != Error.None do return err, cast(u8) 0;
+ if err != Error.None do return err, 0;
return Error.None, out;
}
return Error.None, bytes_to_read;
},
- read_byte = proc (s: ^Stream) -> (Error, u8) #export "DEBUG ME" {
+ read_byte = proc (s: ^Stream) -> (Error, u8) {
ss : ^StringStream = ~~s;
use ss;
- if curr_pos >= data.count do return Error.EOF, cast(u8) 0;
+ if curr_pos >= data.count do return Error.EOF, 0;
defer curr_pos += 1;
return Error.None, data[curr_pos];
dss : ^DynamicStringStream = ~~s;
use dss;
- if curr_pos >= data.count do return Error.EOF, cast(u8) 0;
+ if curr_pos >= data.count do return Error.EOF, 0;
defer curr_pos += 1;
return Error.None, data[curr_pos];
else if (node->kind == Ast_Kind_NumLit) {
if (convert_numlit_to_type((AstNumLit *) node, type)) return 1;
}
+ else if (node->kind == Ast_Kind_Compound) {
+ if (type->kind != Type_Kind_Compound) return 0;
+
+ AstCompound* compound = (AstCompound *) node;
+
+ u32 expr_count = bh_arr_length(compound->exprs);
+ if (expr_count != type->Compound.count) return 0;
+
+ fori (i, 0, (i64) expr_count) {
+ if (!type_check_or_auto_cast(&compound->exprs[i], type->Compound.types[i])) return 0;
+ }
+
+ compound->type = type_build_compound_type(semstate.node_allocator, compound);
+
+ return 1;
+ }
return 0;
}
Type* resolve_expression_type(AstTyped* node) {
+ if (node->kind == Ast_Kind_Compound) {
+ bh_arr_each(AstTyped *, expr, ((AstCompound *) node)->exprs) {
+ resolve_expression_type(*expr);
+ }
+ }
+
if (node->type == NULL)
node->type = type_build_from_ast(semstate.allocator, node->type_node);
CheckStatus check_compound(AstCompound* compound) {
bh_arr_each(AstTyped *, expr, compound->exprs) {
CHECK(expression, expr);
- resolve_expression_type(*expr);
}
compound->type = type_build_compound_type(semstate.node_allocator, compound);