Delete more old code
This commit is contained in:
173
ccodegen.cpp
173
ccodegen.cpp
@@ -367,40 +367,7 @@ gen_ast(Ast *ast){
|
|||||||
gen("// const Bool %s = ", node->name.str);
|
gen("// const Bool %s = ", node->name.str);
|
||||||
gen_value(node->value);
|
gen_value(node->value);
|
||||||
}break;
|
}break;
|
||||||
|
invalid_default_case;
|
||||||
// if(sym->type_val->kind == TYPE_STRUCT){
|
|
||||||
// Ast_Struct *agg = (Ast_Struct *)sym->type_val->ast;
|
|
||||||
// if(node->value->kind == AST_STRUCT){
|
|
||||||
// gen("typedef struct %s{", node->name.str);
|
|
||||||
// global_indent++;
|
|
||||||
// is_inside_struct++;
|
|
||||||
// For(agg->members){
|
|
||||||
// genln("");
|
|
||||||
// gen_ast(it);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// For(agg->const_members){
|
|
||||||
// genln("");
|
|
||||||
// gen_ast(it);
|
|
||||||
// }
|
|
||||||
// is_inside_struct--;
|
|
||||||
// global_indent--;
|
|
||||||
// genln("}%s;", node->name.str);
|
|
||||||
// }
|
|
||||||
// else{
|
|
||||||
// // Type alias
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else if(sym->type_val->kind == TYPE_ENUM){
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// else{
|
|
||||||
// gen("// typedef ");
|
|
||||||
// gen_simple_decl(sym->type_val, node->name);
|
|
||||||
// gen(";");
|
|
||||||
// }
|
|
||||||
// }break;
|
|
||||||
default: compiler_error(node->pos, "C_Codegen: Unhandled type %s of constant expression", docname(node->type));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BREAK();
|
BREAK();
|
||||||
@@ -414,102 +381,6 @@ gen_ast(Ast *ast){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
function String
|
|
||||||
compile_string(String filecontent, String filename = "default_name"_s){
|
|
||||||
F64 total_time = os_time();
|
|
||||||
Scratch scratch(thread_ctx.scratch);
|
|
||||||
OS_Heap heap = win32_os_heap_create(false, mib(4), 0);
|
|
||||||
|
|
||||||
Parse_Ctx ctx = {};
|
|
||||||
parse_init(&ctx, scratch, &heap);
|
|
||||||
|
|
||||||
F64 tokenize_begin = os_time();
|
|
||||||
lex_restream(&ctx, filecontent, filename);
|
|
||||||
F64 tokenize_end = os_time();
|
|
||||||
|
|
||||||
F64 parse_begin = os_time();
|
|
||||||
Ast_Package *result = parse_file();
|
|
||||||
sym_insert_builtins();
|
|
||||||
pctx->resolving_package = result;
|
|
||||||
F64 parse_end = os_time();
|
|
||||||
|
|
||||||
gen(R"==(
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <math.h>
|
|
||||||
typedef int8_t S8;
|
|
||||||
typedef int16_t S16;
|
|
||||||
typedef int32_t S32;
|
|
||||||
typedef int64_t S64;
|
|
||||||
typedef uint8_t U8;
|
|
||||||
typedef uint16_t U16;
|
|
||||||
typedef uint32_t U32;
|
|
||||||
typedef uint64_t U64;
|
|
||||||
typedef S8 B8;
|
|
||||||
typedef S16 B16;
|
|
||||||
typedef S32 B32;
|
|
||||||
typedef S64 B64;
|
|
||||||
typedef U64 SizeU;
|
|
||||||
typedef S64 SizeS;
|
|
||||||
typedef float F32;
|
|
||||||
typedef double F64;
|
|
||||||
typedef S32 Bool;
|
|
||||||
|
|
||||||
typedef struct Slice{
|
|
||||||
S64 len;
|
|
||||||
void *data;
|
|
||||||
}Slice;
|
|
||||||
|
|
||||||
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();
|
|
||||||
resolve_package(result);
|
|
||||||
F64 resolve_end = os_time();
|
|
||||||
|
|
||||||
F64 codegen_begin = os_time();
|
|
||||||
gen_ast(result);
|
|
||||||
F64 codegen_end = os_time();
|
|
||||||
|
|
||||||
exp_destroy(&heap);
|
|
||||||
|
|
||||||
F64 flattening_begin = os_time();
|
|
||||||
String string_result = string_flatten(scratch, &pctx->gen);
|
|
||||||
F64 flattening_end = os_time();
|
|
||||||
|
|
||||||
printf("\n//-------------------------------");
|
|
||||||
printf("\n// Tokenization: %f", tokenize_end - tokenize_begin);
|
|
||||||
printf("\n// Parsing : %f", parse_end - parse_begin);
|
|
||||||
printf("\n// Resolving : %f", resolve_end - resolve_begin);
|
|
||||||
printf("\n// Codegen : %f", codegen_end - codegen_begin);
|
|
||||||
printf("\n// Flattening : %f", flattening_end - flattening_begin);
|
|
||||||
printf("\n// Total : %f", flattening_end - total_time);
|
|
||||||
printf("\n//-------------------------------");
|
|
||||||
|
|
||||||
return string_result;
|
|
||||||
}
|
|
||||||
|
|
||||||
function String
|
|
||||||
compile_file(String filename){
|
|
||||||
Scratch scratch;
|
|
||||||
String filecontent = os_read_file(scratch, filename);
|
|
||||||
assert(filecontent.len);
|
|
||||||
String result = compile_string(filecontent, filename);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
function String
|
function String
|
||||||
compile_files(Array<String> filename){
|
compile_files(Array<String> filename){
|
||||||
Scratch scratch(thread_ctx.scratch);
|
Scratch scratch(thread_ctx.scratch);
|
||||||
@@ -553,7 +424,6 @@ compile_files(Array<String> filename){
|
|||||||
package = ast_package(token, &heap, it.name);
|
package = ast_package(token, &heap, it.name);
|
||||||
insert_builtin_types_into_package(package);
|
insert_builtin_types_into_package(package);
|
||||||
pctx->packages.add(package);
|
pctx->packages.add(package);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pctx->currently_parsed_scope = package;
|
pctx->currently_parsed_scope = package;
|
||||||
@@ -579,6 +449,47 @@ compile_files(Array<String> filename){
|
|||||||
resolve_package(it);
|
resolve_package(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
gen(R"==(
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <math.h>
|
||||||
|
typedef int8_t S8;
|
||||||
|
typedef int16_t S16;
|
||||||
|
typedef int32_t S32;
|
||||||
|
typedef int64_t S64;
|
||||||
|
typedef uint8_t U8;
|
||||||
|
typedef uint16_t U16;
|
||||||
|
typedef uint32_t U32;
|
||||||
|
typedef uint64_t U64;
|
||||||
|
typedef S8 B8;
|
||||||
|
typedef S16 B16;
|
||||||
|
typedef S32 B32;
|
||||||
|
typedef S64 B64;
|
||||||
|
typedef U64 SizeU;
|
||||||
|
typedef S64 SizeS;
|
||||||
|
typedef float F32;
|
||||||
|
typedef double F64;
|
||||||
|
typedef S32 Bool;
|
||||||
|
|
||||||
|
typedef struct Slice{
|
||||||
|
S64 len;
|
||||||
|
void *data;
|
||||||
|
}Slice;
|
||||||
|
|
||||||
|
typedef struct String{
|
||||||
|
U8 *str;
|
||||||
|
S64 len;
|
||||||
|
}String;
|
||||||
|
#define LIT(x) (String){.str=(U8 *)x, .len=sizeof(x)-1}
|
||||||
|
|
||||||
|
void entry();
|
||||||
|
int main(){
|
||||||
|
entry();
|
||||||
|
}
|
||||||
|
)==");
|
||||||
|
#endif
|
||||||
|
|
||||||
For(pctx->ordered_decls){
|
For(pctx->ordered_decls){
|
||||||
genln("");
|
genln("");
|
||||||
gen_ast(it);
|
gen_ast(it);
|
||||||
|
|||||||
Reference in New Issue
Block a user