Foreign variables, exporting some of the info to the c program, compile errors though

This commit is contained in:
Krzosa Karol
2022-06-18 16:01:05 +02:00
parent 0ed4f62557
commit e63dc0322a
7 changed files with 47 additions and 11 deletions

View File

@@ -208,7 +208,9 @@ enum {
function void
gen_var(Ast_Decl *decl, B32 emit_value, B32 scope_names){
if(is_flag_set(decl->flags, AST_FOREIGN)) gen("extern ");
gen_simple_decl(decl->type, decl->name, decl->parent_scope, scope_names);
if(is_flag_set(decl->flags, AST_FOREIGN)) return;
if(emit_value == DONT_EMIT_VALUE){
return;
@@ -645,6 +647,7 @@ insert_builtin_into_scope(Ast_Scope *p, String name, Ast_Type *type){
decl->parent_scope = p;
decl->state = DECL_RESOLVED;
insert_into_scope(p, decl);
pctx->all_types.add(type);
}
function void
@@ -821,6 +824,27 @@ typedef struct String{
}
}
#if 1
gen("Type_Info type_infos[] = {");
global_indent++;
For(pctx->all_types){
genln("{.kind = %d, .size = %d, .align = %d, .is_unsigned = %s, .type_id = %d, ",
(S32)it->kind, (S32)it->size, (S32)it->align, it->is_unsigned ? "true" : "false", it->type_id);
switch(it->kind){
case TYPE_POINTER: {
gen(".base = %d", it->base->type_id);
} break;
case TYPE_ARRAY: {
gen(".base = %d, ", it->base->type_id);
gen(".array_size = %d", it->arr.size);
}break;
// invalid_default_case;
}
gen("},");
}
global_indent--;
gen("};");
#endif
For(pctx->ordered_decls){
genln("");