Foreign variables, exporting some of the info to the c program, compile errors though
This commit is contained in:
24
ccodegen.cpp
24
ccodegen.cpp
@@ -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("");
|
||||
|
||||
Reference in New Issue
Block a user