Fixing bugs, pointer arithmetic checking, better for, working on first program

This commit is contained in:
Krzosa Karol
2022-06-06 23:50:38 +02:00
parent 729e7aee86
commit f852a23fcb
8 changed files with 127 additions and 50 deletions

View File

@@ -66,7 +66,7 @@ gen_simple_decl(Ast_Resolved_Type *ast, Intern_String name){
function void
gen_value(Value a){
gen("%s", docname(a.type));
// gen("%s", docname(a.type));
switch(a.type->kind){
CASE_INT: {
Scratch scratch;
@@ -94,10 +94,12 @@ gen_expr(Ast_Expr *ast){
}
CASE(INDEX, Index){
gen("(");
gen_expr(node->expr);
gen("[");
gen_expr(node->index);
gen("]");
gen(")");
BREAK();
}
@@ -335,7 +337,7 @@ gen_ast(Ast *ast){
if(sym->type_val->kind == TYPE_STRUCT){
Ast_Struct *agg = (Ast_Struct *)sym->type_val->ast;
if(node->value->kind == AST_STRUCT){
gen("struct %s{", node->name.str);
gen("typedef struct %s{", node->name.str);
global_indent++;
For(agg->members){
genln("");
@@ -347,7 +349,7 @@ gen_ast(Ast *ast){
gen_ast(it);
}
global_indent--;
genln("};");
genln("}%s;", node->name.str);
}
else{
// Type alias
@@ -428,12 +430,18 @@ typedef U64 SizeU;
typedef S64 SizeS;
typedef float F32;
typedef double F64;
typedef S32 Bool;
typedef struct String{
U8 *str;
S64 len;
}String;
#define LIT(x) (String){.str=(U8 *)x, .len=sizeof(x)-1}
void entry();
int main(){
entry();
}
)==");
F64 resolve_begin = os_time();