unique_name sheningans
This commit is contained in:
@@ -728,11 +728,11 @@ gen_ast(Ast *ast) {
|
||||
}
|
||||
|
||||
CASE(ENUM, Decl) {
|
||||
gen("/*enum %Q{", node->name);
|
||||
gen("/*enum %Q{", node->unique_name);
|
||||
// @todo add typespec
|
||||
global_indent++;
|
||||
For(node->scope->decls) {
|
||||
genln("%Q", it->name);
|
||||
genln("%Q", it->unique_name);
|
||||
gen(" = ");
|
||||
gen_value(it->pos, it->value);
|
||||
gen(",");
|
||||
|
||||
@@ -1011,6 +1011,7 @@ parse_decl(B32 is_global) {
|
||||
if (result) {
|
||||
set_flag(result->flags, flags);
|
||||
result->name = tname->intern_val;
|
||||
result->unique_name = tname->intern_val;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -53,14 +53,14 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope, Array<Ast_Decl *> *replace, Arr
|
||||
Ast_Atom *src = (Ast_Atom *)ast;
|
||||
Ast_Atom *dst = ast_create_copy(parent_scope, Ast_Atom, ast);
|
||||
|
||||
if (replace && with && (dst->flags & AST_TYPESPEC)) {
|
||||
if (replace && with) {
|
||||
// @todo: IF ITS STRUCT we only want to replace TYPESPECS
|
||||
For(*replace) {
|
||||
assert(it->type == pctx->type_type);
|
||||
if (it->name == dst->intern_val) {
|
||||
int it_index = replace->get_index(&it);
|
||||
Ast_Call_Item *replacement = with[0][it_index];
|
||||
Ast *replacement_v = replacement->item;
|
||||
// assert(replacement_v->resolved_type == pctx->type_type);
|
||||
dst = (Ast_Atom *)ast_copy(replacement_v, parent_scope, 0, 0);
|
||||
}
|
||||
}
|
||||
@@ -316,8 +316,7 @@ Ast_Decl *get_or_instantiate_polymorph_type(Token *pos, Ast_Decl *poly, Array<As
|
||||
result->polymorph_hash = hash;
|
||||
|
||||
assert(result->di != poly->di);
|
||||
result->name = get_unique_name_for_decl(result);
|
||||
result->unique_name = result->name;
|
||||
result->unique_name = get_unique_name_for_decl(result);
|
||||
|
||||
poly->polymorphs.allocator = pctx->heap;
|
||||
poly->polymorphs.add(result);
|
||||
@@ -366,8 +365,7 @@ Ast_Decl *get_or_instantiate_polymorph_lambda(Token *pos, Ast_Decl *poly, Array<
|
||||
result->polymorph_hash = hash;
|
||||
|
||||
assert(result->di != poly->di);
|
||||
result->name = get_unique_name_for_decl(result);
|
||||
result->unique_name = result->name;
|
||||
result->unique_name = get_unique_name_for_decl(result);
|
||||
|
||||
poly->polymorphs.allocator = pctx->heap;
|
||||
poly->polymorphs.add(result);
|
||||
|
||||
@@ -1699,6 +1699,7 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_and_const_str
|
||||
For(matches) {
|
||||
if (it.lambda_arg->flags & AST_POLYMORPH) {
|
||||
replacements.add(it.call_arg);
|
||||
matches.ordered_remove(it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1706,6 +1707,11 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_and_const_str
|
||||
Ast_Decl *instance = get_or_instantiate_polymorph_lambda(node->pos, poly, replacements, field_access_scope);
|
||||
node->resolved_decl = instance;
|
||||
lambda = instance->lambda;
|
||||
|
||||
// We know need to fix the matches list CAUSE ITS FUCKED
|
||||
// Thanks polymorphism
|
||||
For(matches) {
|
||||
}
|
||||
}
|
||||
|
||||
// Typecheck the arguments and produce properly ordered list of arguments for codegeneration
|
||||
|
||||
@@ -261,7 +261,6 @@ type_struct_complete(Ast_Type *type, Ast_Decl *node) {
|
||||
type->padding = type->size - members_size;
|
||||
type->agg.members = members.tight_copy(pctx->perm);
|
||||
type->kind = TYPE_STRUCT;
|
||||
node->unique_name = pctx->internf("%Q%Q", pctx->symbol_prefix, node->name);
|
||||
}
|
||||
else {
|
||||
assert(node->kind == AST_UNION);
|
||||
@@ -289,7 +288,6 @@ type_struct_complete(Ast_Type *type, Ast_Decl *node) {
|
||||
type->size = align_up(type->size, type->align);
|
||||
type->agg.members = members.tight_copy(pctx->perm);
|
||||
type->kind = TYPE_UNION;
|
||||
node->unique_name = pctx->internf("%Q%Q", pctx->symbol_prefix, node->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ MultipleArgs :: (): Tuple(int, F32)
|
||||
PolyLambda :: ($T: Type): T
|
||||
return 32
|
||||
|
||||
|
||||
GetCount :: (a: int): int
|
||||
return a
|
||||
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
MA :: #import "Arena.core"
|
||||
|
||||
/*
|
||||
PushStruct :: (a: *MA.Arena, $T: Type): *$T
|
||||
size := size_of(Type)
|
||||
result := PushSize(a, size)
|
||||
return result
|
||||
*/
|
||||
|
||||
PushStruct :: (a: *MA.Arena, type: Type): *void
|
||||
ti := GetTypeInfo(type)
|
||||
result := MA.PushSize(a, ti.size->U64)
|
||||
return result
|
||||
PushStruct :: (a: *MA.Arena, $T: Type): *T
|
||||
v: T
|
||||
size := SizeOf(v)
|
||||
result := MA.PushSize(a, size->U64)
|
||||
return result->*T
|
||||
|
||||
main :: (argc: int, argv: **char): int
|
||||
arena: MA.Arena
|
||||
|
||||
Reference in New Issue
Block a user