Skip to content

Commit f71eeb2

Browse files
committed
Fix repl to not analyze preproc_decls in presemantic and other build fixes
1 parent eaf03b6 commit f71eeb2

File tree

6 files changed

+16
-54
lines changed

6 files changed

+16
-54
lines changed

codegen/metac_codegen.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ extern metac_compiler_t compiler;
539539

540540
static void InitCompilerInterface(metac_bytecode_ctx_t* ctx)
541541
{
542-
// #ifdef METAC_COMPILER_INTERFACE
542+
#ifdef METAC_COMPILER_INTERFACE
543543
void* c = ctx->c;
544544
const BackendInterface gen = *ctx->gen;
545545

@@ -555,7 +555,7 @@ static void InitCompilerInterface(metac_bytecode_ctx_t* ctx)
555555
ctx->Externals[0].ExtValue = ctx->CompilerInterfaceValue;
556556
ctx->ExternalsCount += 1;
557557
}
558-
// #endif
558+
#endif
559559
}
560560

561561
bool IsExternal(metac_sema_expr_t* expr)

find_parsefunctions/findParseFunctions.c

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#define ACCEL ACCEL_TABLE
2-
#define NO_FIBERS
3-
#define PRINT_CODE
1+
#define NO_FIBERS 1
2+
#define OLD_PARSER 1
3+
#define PRINT_CODE 1
44

55
#include "../os/compat.h"
66
#include "../driver/metac_driver.c"
@@ -14,49 +14,6 @@
1414
# include <unistd.h>
1515
#endif
1616

17-
metac_decl_t* FindDecl(decl_array_t decls,
18-
metac_parser_t* parser, const char* name)
19-
{
20-
const uint32_t len = cast(uint32_t) strlen(name);
21-
const uint32_t hash = crc32c_nozero(~0, name, len);
22-
const uint32_t key = IDENTIFIER_KEY(hash, len);
23-
24-
metac_identifier_ptr_t NameId =
25-
IsIdentifierInTable(&parser->IdentifierTable, key, name);
26-
27-
if (NameId.v == 0)
28-
return 0;
29-
30-
for(uint32_t idx = 0;
31-
idx < decls.Length;
32-
idx++)
33-
{
34-
metac_decl_t* decl = decls.Ptr[idx];
35-
// printf("decl: %s\n",
36-
// MetaCPrinter_PrintDecl(&parser->DebugPrinter, decl));
37-
metac_identifier_ptr_t idPtr = {0};
38-
if (decl->Kind == decl_type_enum)
39-
{
40-
idPtr = (cast(decl_type_enum_t*) decl)->Identifier;
41-
}
42-
else if (decl->Kind == decl_function)
43-
{
44-
idPtr = (cast(decl_function_t*) decl)->Identifier;
45-
}
46-
else if (decl->Kind == decl_type_typedef)
47-
{
48-
decl_type_typedef_t* typdef = cast(decl_type_typedef_t*) decl;
49-
idPtr = typdef->Identifier;
50-
decl = cast(metac_decl_t*) typdef->Type;
51-
}
52-
53-
if (idPtr.v == NameId.v)
54-
return decl;
55-
}
56-
57-
return 0;
58-
}
59-
6017
metac_identifier_ptr_t IdentifierFromDecl(metac_decl_t* decl)
6118
{
6219
metac_identifier_ptr_t result = {0};

parser/metac_parsetree.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ int MetaCNode_TreeWalk_Real(metac_node_t node, walker_function_t walker_fn, void
3838
// decl_type_tuple doesn't really exist
3939
assert(0);
4040

41+
case node_decl_preproc:
42+
{
43+
//TODO do something here.
44+
} break;
45+
4146
case node_decl_variable:
4247
{
4348
decl_variable_t* decl_variable = cast(decl_variable_t*) node;

repl/repl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ static inline int Presemantic(metac_node_t node, void* ctx)
233233

234234
return 1;
235235
}
236+
else if (node->Kind == node_decl_preproc)
237+
{
238+
// ignore preproc decls in presemantic
239+
return 1;
240+
}
236241
else if (MetaCNode_IsDecl(node))
237242
{
238243
MetaCSemantic_doDeclSemantic(context->Sema, node);

semantic/metac_lvn.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ typedef struct metac_lvn_table_t
4040
#define SLOT_FROM_HASH(HASH, COLLIDER, MASK) \
4141
(((HASH) ^ (COLLIDER)) & (MASK))
4242

43-
#if !defined(ALIGN16)
44-
#define ALIGN16(N) \
45-
((N + 15) & (~15))
46-
#endif
47-
4843
metac_lvn_table_t* MetaCLVNTable_Init(metac_alloc_t* alloc)
4944
{
5045
#define INITIAL_LVN_SLOT_LOG2 7

semantic/metac_type_table.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static inline const bool TupleSlotsEqual(const metac_type_table_slot_t* a,
188188
static inline const bool MetaCExpr_Equal(const metac_expr_t* a,
189189
const metac_expr_t* b)
190190
{
191-
assert(0);
191+
// assert(0);
192192
return false;
193193
}
194194

0 commit comments

Comments
 (0)