mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-15 23:54:07 +00:00
Remove dead code; Fix issue regarding order of evaluation of function parameters (in C++) depending on the compiler (clang vs gcc vs msvc)
This commit is contained in:
@@ -127,7 +127,6 @@ GB_ALLOCATOR_PROC(heap_allocator_proc) {
|
||||
#include "unicode.cpp"
|
||||
#include "string.cpp"
|
||||
#include "array.cpp"
|
||||
// #include "integer128.cpp"
|
||||
#include "murmurhash3.cpp"
|
||||
|
||||
#define for_array(index_, array_) for (isize index_ = 0; index_ < (array_).count; index_++)
|
||||
|
||||
12
src/main.cpp
12
src/main.cpp
@@ -17,9 +17,9 @@
|
||||
#include "ir_opt.cpp"
|
||||
#include "ir_print.cpp"
|
||||
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
// NOTE(bill): 'name' is used in debugging and profiling modes
|
||||
i32 system_exec_command_line_app(char *name, bool is_silent, char *fmt, ...) {
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
STARTUPINFOW start_info = {gb_size_of(STARTUPINFOW)};
|
||||
PROCESS_INFORMATION pi = {0};
|
||||
char cmd_line[4096] = {0};
|
||||
@@ -61,9 +61,8 @@ i32 system_exec_command_line_app(char *name, bool is_silent, char *fmt, ...) {
|
||||
}
|
||||
|
||||
return exit_code;
|
||||
}
|
||||
|
||||
#elif defined(GB_SYSTEM_OSX) || defined(GB_SYSTEM_UNIX)
|
||||
i32 system_exec_command_line_app(char *name, bool is_silent, char *fmt, ...) {
|
||||
|
||||
char cmd_line[4096] = {0};
|
||||
isize cmd_len;
|
||||
@@ -107,8 +106,8 @@ i32 system_exec_command_line_app(char *name, bool is_silent, char *fmt, ...) {
|
||||
// exit_code = status;
|
||||
|
||||
return exit_code;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -393,11 +392,11 @@ bool parse_build_flags(Array<String> args) {
|
||||
case BuildFlag_CrossCompile: {
|
||||
GB_ASSERT(value.kind == ExactValue_String);
|
||||
cross_compile_target = value.value_string;
|
||||
#if defined(GB_SYSTEM_UNIX) && defined(GB_ARCH_64_BIT)
|
||||
#if defined(GB_SYSTEM_UNIX) && defined(GB_ARCH_64_BIT)
|
||||
if (str_eq_ignore_case(cross_compile_target, str_lit("Essence"))) {
|
||||
|
||||
} else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
gb_printf_err("Unsupported cross compilation target '%.*s'\n", LIT(cross_compile_target));
|
||||
gb_printf_err("Currently supported targets: Essence (from 64-bit Unixes only)\n");
|
||||
@@ -529,7 +528,6 @@ bool parse_build_flags(Array<String> args) {
|
||||
return !bad_flags;
|
||||
}
|
||||
|
||||
|
||||
void show_timings(Checker *c, Timings *t) {
|
||||
Parser *p = c->parser;
|
||||
isize lines = p->total_line_count;
|
||||
|
||||
@@ -53,7 +53,6 @@ Token ast_node_token(AstNode *node) {
|
||||
case AstNode_BranchStmt: return node->BranchStmt.token;
|
||||
case AstNode_UsingStmt: return node->UsingStmt.token;
|
||||
case AstNode_UsingInStmt: return node->UsingInStmt.using_token;
|
||||
case AstNode_AsmStmt: return node->AsmStmt.token;
|
||||
case AstNode_PushContext: return node->PushContext.token;
|
||||
|
||||
case AstNode_BadDecl: return node->BadDecl.begin;
|
||||
@@ -279,14 +278,6 @@ AstNode *clone_ast_node(gbAllocator a, AstNode *node) {
|
||||
n->UsingInStmt.list = clone_ast_node_array(a, n->UsingInStmt.list);
|
||||
n->UsingInStmt.expr = clone_ast_node(a, n->UsingInStmt.expr);
|
||||
break;
|
||||
case AstNode_AsmOperand:
|
||||
n->AsmOperand.operand = clone_ast_node(a, n->AsmOperand.operand);
|
||||
break;
|
||||
case AstNode_AsmStmt:
|
||||
n->AsmStmt.output_list = clone_ast_node(a, n->AsmStmt.output_list);
|
||||
n->AsmStmt.input_list = clone_ast_node(a, n->AsmStmt.input_list);
|
||||
n->AsmStmt.clobber_list = clone_ast_node(a, n->AsmStmt.clobber_list);
|
||||
break;
|
||||
case AstNode_PushContext:
|
||||
n->PushContext.expr = clone_ast_node(a, n->PushContext.expr);
|
||||
n->PushContext.body = clone_ast_node(a, n->PushContext.body);
|
||||
@@ -787,32 +778,6 @@ AstNode *ast_using_in_stmt(AstFile *f, Token using_token, Array<AstNode *> list,
|
||||
}
|
||||
|
||||
|
||||
AstNode *ast_asm_operand(AstFile *f, Token string, AstNode *operand) {
|
||||
AstNode *result = make_ast_node(f, AstNode_AsmOperand);
|
||||
result->AsmOperand.string = string;
|
||||
result->AsmOperand.operand = operand;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
AstNode *ast_asm_stmt(AstFile *f, Token token, bool is_volatile, Token open, Token close, Token code_string,
|
||||
AstNode *output_list, AstNode *input_list, AstNode *clobber_list,
|
||||
isize output_count, isize input_count, isize clobber_count) {
|
||||
AstNode *result = make_ast_node(f, AstNode_AsmStmt);
|
||||
result->AsmStmt.token = token;
|
||||
result->AsmStmt.is_volatile = is_volatile;
|
||||
result->AsmStmt.open = open;
|
||||
result->AsmStmt.close = close;
|
||||
result->AsmStmt.code_string = code_string;
|
||||
result->AsmStmt.output_list = output_list;
|
||||
result->AsmStmt.input_list = input_list;
|
||||
result->AsmStmt.clobber_list = clobber_list;
|
||||
result->AsmStmt.output_count = output_count;
|
||||
result->AsmStmt.input_count = input_count;
|
||||
result->AsmStmt.clobber_count = clobber_count;
|
||||
return result;
|
||||
}
|
||||
|
||||
AstNode *ast_push_context(AstFile *f, Token token, AstNode *expr, AstNode *body) {
|
||||
AstNode *result = make_ast_node(f, AstNode_PushContext);
|
||||
result->PushContext.token = token;
|
||||
@@ -2213,14 +2178,18 @@ AstNode *parse_unary_expr(AstFile *f, bool lhs) {
|
||||
expect_token(f, Token_OpenParen);
|
||||
AstNode *type = parse_type(f);
|
||||
expect_token(f, Token_CloseParen);
|
||||
return ast_type_cast(f, token, type, parse_unary_expr(f, lhs));
|
||||
AstNode *expr = parse_unary_expr(f, lhs);
|
||||
return ast_type_cast(f, token, type, expr);
|
||||
}
|
||||
case Token_Add:
|
||||
case Token_Sub:
|
||||
case Token_Not:
|
||||
case Token_Xor:
|
||||
case Token_And:
|
||||
return ast_unary_expr(f, advance_token(f), parse_unary_expr(f, lhs));
|
||||
case Token_And: {
|
||||
Token token = advance_token(f);
|
||||
AstNode *expr = parse_unary_expr(f, lhs);
|
||||
return ast_unary_expr(f, token, expr);
|
||||
}
|
||||
}
|
||||
|
||||
return parse_atom_expr(f, parse_operand(f, lhs), lhs);
|
||||
@@ -3427,32 +3396,6 @@ AstNode *parse_defer_stmt(AstFile *f) {
|
||||
return ast_defer_stmt(f, token, stmt);
|
||||
}
|
||||
|
||||
AstNode *parse_asm_stmt(AstFile *f) {
|
||||
Token token = expect_token(f, Token_asm);
|
||||
bool is_volatile = false;
|
||||
Token open, close, code_string;
|
||||
open = expect_token(f, Token_OpenBrace);
|
||||
code_string = expect_token(f, Token_String);
|
||||
AstNode *output_list = nullptr;
|
||||
AstNode *input_list = nullptr;
|
||||
AstNode *clobber_list = nullptr;
|
||||
isize output_count = 0;
|
||||
isize input_count = 0;
|
||||
isize clobber_count = 0;
|
||||
|
||||
// TODO(bill): Finish asm statement and determine syntax
|
||||
|
||||
// if (f->curr_token.kind != Token_CloseBrace) {
|
||||
// expect_token(f, Token_Colon);
|
||||
// }
|
||||
|
||||
close = expect_token(f, Token_CloseBrace);
|
||||
|
||||
return ast_asm_stmt(f, token, is_volatile, open, close, code_string,
|
||||
output_list, input_list, clobber_list,
|
||||
output_count, input_count, clobber_count);
|
||||
}
|
||||
|
||||
|
||||
enum ImportDeclKind {
|
||||
ImportDecl_Standard,
|
||||
@@ -3612,7 +3555,6 @@ AstNode *parse_stmt(AstFile *f) {
|
||||
case Token_switch: return parse_switch_stmt(f);
|
||||
case Token_defer: return parse_defer_stmt(f);
|
||||
case Token_return: return parse_return_stmt(f);
|
||||
case Token_asm: return parse_asm_stmt(f);
|
||||
|
||||
case Token_break:
|
||||
case Token_continue:
|
||||
@@ -3833,17 +3775,17 @@ ParseFileError init_ast_file(AstFile *f, String fullpath, TokenPos *err_pos) {
|
||||
|
||||
if (err == TokenizerInit_Empty) {
|
||||
Token token = {Token_EOF};
|
||||
token.pos.file = fullpath;
|
||||
token.pos.line = 1;
|
||||
token.pos.file = fullpath;
|
||||
token.pos.line = 1;
|
||||
token.pos.column = 1;
|
||||
array_add(&f->tokens, token);
|
||||
return ParseFile_None;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
while (f->curr_token.kind != Token_EOF) {
|
||||
Token token = tokenizer_get_token(&f->tokenizer);
|
||||
if (token.kind == Token_Invalid) {
|
||||
err_pos->line = token.pos.line;
|
||||
err_pos->line = token.pos.line;
|
||||
err_pos->column = token.pos.column;
|
||||
return ParseFile_InvalidToken;
|
||||
}
|
||||
|
||||
@@ -169,23 +169,23 @@ Array<AstNode *> make_ast_node_array(AstFile *f, isize init_capacity = 8) {
|
||||
Token token; \
|
||||
}) \
|
||||
AST_NODE_KIND(BasicDirective, "basic directive", struct { \
|
||||
Token token; \
|
||||
Token token; \
|
||||
String name; \
|
||||
}) \
|
||||
AST_NODE_KIND(Ellipsis, "ellipsis", struct { \
|
||||
Token token; \
|
||||
Token token; \
|
||||
AstNode *expr; \
|
||||
}) \
|
||||
AST_NODE_KIND(ProcGroup, "procedure group", struct { \
|
||||
Token token; \
|
||||
Token open; \
|
||||
Token close; \
|
||||
Token token; \
|
||||
Token open; \
|
||||
Token close; \
|
||||
Array<AstNode *> args; \
|
||||
}) \
|
||||
AST_NODE_KIND(ProcLit, "procedure literal", struct { \
|
||||
AstNode *type; \
|
||||
AstNode *body; \
|
||||
u64 tags; \
|
||||
AstNode * type; \
|
||||
AstNode * body; \
|
||||
u64 tags; \
|
||||
ProcInlining inlining; \
|
||||
}) \
|
||||
AST_NODE_KIND(CompoundLit, "compound literal", struct { \
|
||||
@@ -193,7 +193,7 @@ Array<AstNode *> make_ast_node_array(AstFile *f, isize init_capacity = 8) {
|
||||
Array<AstNode *> elems; \
|
||||
Token open, close; \
|
||||
}) \
|
||||
AST_NODE_KIND(_ExprBegin, "", i32) \
|
||||
AST_NODE_KIND(_ExprBegin, "", struct {}) \
|
||||
AST_NODE_KIND(BadExpr, "bad expression", struct { Token begin, end; }) \
|
||||
AST_NODE_KIND(TagExpr, "tag expression", struct { Token token, name; AstNode *expr; }) \
|
||||
AST_NODE_KIND(RunExpr, "run expression", struct { Token token, name; AstNode *expr; }) \
|
||||
@@ -220,8 +220,8 @@ AST_NODE_KIND(_ExprBegin, "", i32) \
|
||||
AST_NODE_KIND(TernaryExpr, "ternary expression", struct { AstNode *cond, *x, *y; }) \
|
||||
AST_NODE_KIND(TypeAssertion, "type assertion", struct { AstNode *expr; Token dot; AstNode *type; }) \
|
||||
AST_NODE_KIND(TypeCast, "type cast", struct { Token token; AstNode *type, *expr; }) \
|
||||
AST_NODE_KIND(_ExprEnd, "", i32) \
|
||||
AST_NODE_KIND(_StmtBegin, "", i32) \
|
||||
AST_NODE_KIND(_ExprEnd, "", struct {}) \
|
||||
AST_NODE_KIND(_StmtBegin, "", struct {}) \
|
||||
AST_NODE_KIND(BadStmt, "bad statement", struct { Token begin, end; }) \
|
||||
AST_NODE_KIND(EmptyStmt, "empty statement", struct { Token token; }) \
|
||||
AST_NODE_KIND(ExprStmt, "expression statement", struct { AstNode *expr; } ) \
|
||||
@@ -238,7 +238,7 @@ AST_NODE_KIND(_StmtBegin, "", i32) \
|
||||
Token op; \
|
||||
AstNode *expr; \
|
||||
}) \
|
||||
AST_NODE_KIND(_ComplexStmtBegin, "", i32) \
|
||||
AST_NODE_KIND(_ComplexStmtBegin, "", struct {}) \
|
||||
AST_NODE_KIND(BlockStmt, "block statement", struct { \
|
||||
Array<AstNode *> stmts; \
|
||||
Token open, close; \
|
||||
@@ -310,28 +310,14 @@ AST_NODE_KIND(_ComplexStmtBegin, "", i32) \
|
||||
Token in_token; \
|
||||
AstNode *expr; \
|
||||
}) \
|
||||
AST_NODE_KIND(AsmOperand, "assembly operand", struct { \
|
||||
Token string; \
|
||||
AstNode *operand; \
|
||||
}) \
|
||||
AST_NODE_KIND(AsmStmt, "assembly statement", struct { \
|
||||
Token token; \
|
||||
bool is_volatile; \
|
||||
Token open, close; \
|
||||
Token code_string; \
|
||||
AstNode *output_list; \
|
||||
AstNode *input_list; \
|
||||
AstNode *clobber_list; \
|
||||
isize output_count, input_count, clobber_count; \
|
||||
}) \
|
||||
AST_NODE_KIND(PushContext, "context <- statement", struct { \
|
||||
Token token; \
|
||||
AstNode *expr; \
|
||||
AstNode *body; \
|
||||
}) \
|
||||
AST_NODE_KIND(_ComplexStmtEnd, "", i32) \
|
||||
AST_NODE_KIND(_StmtEnd, "", i32) \
|
||||
AST_NODE_KIND(_DeclBegin, "", i32) \
|
||||
AST_NODE_KIND(_ComplexStmtEnd, "", struct {}) \
|
||||
AST_NODE_KIND(_StmtEnd, "", struct {}) \
|
||||
AST_NODE_KIND(_DeclBegin, "", struct {}) \
|
||||
AST_NODE_KIND(BadDecl, "bad declaration", struct { Token begin, end; }) \
|
||||
AST_NODE_KIND(ForeignBlockDecl, "foreign block declaration", struct { \
|
||||
Token token; \
|
||||
@@ -339,8 +325,8 @@ AST_NODE_KIND(_DeclBegin, "", i32) \
|
||||
Token open, close; \
|
||||
Array<AstNode *> decls; \
|
||||
Array<AstNode *> attributes; \
|
||||
bool been_handled; \
|
||||
CommentGroup docs; \
|
||||
bool been_handled; \
|
||||
}) \
|
||||
AST_NODE_KIND(Label, "label", struct { \
|
||||
Token token; \
|
||||
@@ -350,12 +336,12 @@ AST_NODE_KIND(_DeclBegin, "", i32) \
|
||||
Array<AstNode *> names; \
|
||||
AstNode * type; \
|
||||
Array<AstNode *> values; \
|
||||
bool is_using; \
|
||||
bool is_mutable; \
|
||||
bool been_handled; \
|
||||
Array<AstNode *> attributes; \
|
||||
CommentGroup docs; \
|
||||
CommentGroup comment; \
|
||||
bool is_using; \
|
||||
bool is_mutable; \
|
||||
bool been_handled; \
|
||||
}) \
|
||||
AST_NODE_KIND(ImportDecl, "import declaration", struct { \
|
||||
AstFile *file; \
|
||||
@@ -363,21 +349,21 @@ AST_NODE_KIND(_DeclBegin, "", i32) \
|
||||
Token relpath; \
|
||||
String fullpath; \
|
||||
Token import_name; \
|
||||
bool is_using; \
|
||||
bool been_handled; \
|
||||
Array<AstNode *> using_in_list; \
|
||||
CommentGroup docs; \
|
||||
CommentGroup comment; \
|
||||
bool is_using; \
|
||||
bool been_handled; \
|
||||
}) \
|
||||
AST_NODE_KIND(ExportDecl, "export declaration", struct { \
|
||||
AstFile *file; \
|
||||
Token token; \
|
||||
Token relpath; \
|
||||
String fullpath; \
|
||||
bool been_handled; \
|
||||
Array<AstNode *> using_in_list; \
|
||||
CommentGroup docs; \
|
||||
CommentGroup comment; \
|
||||
bool been_handled; \
|
||||
}) \
|
||||
AST_NODE_KIND(ForeignImportDecl, "foreign import declaration", struct { \
|
||||
Token token; \
|
||||
@@ -386,11 +372,11 @@ AST_NODE_KIND(_DeclBegin, "", i32) \
|
||||
String base_dir; \
|
||||
String collection_name; \
|
||||
String fullpath; \
|
||||
bool been_handled; \
|
||||
CommentGroup docs; \
|
||||
CommentGroup comment; \
|
||||
bool been_handled; \
|
||||
}) \
|
||||
AST_NODE_KIND(_DeclEnd, "", i32) \
|
||||
AST_NODE_KIND(_DeclEnd, "", struct {}) \
|
||||
AST_NODE_KIND(Attribute, "attribute", struct { \
|
||||
Token token; \
|
||||
AstNode *type; \
|
||||
@@ -413,7 +399,7 @@ AST_NODE_KIND(_DeclEnd, "", i32) \
|
||||
AstNode *name; \
|
||||
AstNode *list; \
|
||||
}) \
|
||||
AST_NODE_KIND(_TypeBegin, "", i32) \
|
||||
AST_NODE_KIND(_TypeBegin, "", struct {}) \
|
||||
AST_NODE_KIND(TypeType, "type", struct { \
|
||||
Token token; \
|
||||
AstNode *specialization; \
|
||||
@@ -457,9 +443,9 @@ AST_NODE_KIND(_TypeBegin, "", i32) \
|
||||
Array<AstNode *> fields; \
|
||||
isize field_count; \
|
||||
AstNode * polymorphic_params; \
|
||||
AstNode * align; \
|
||||
bool is_packed; \
|
||||
bool is_raw_union; \
|
||||
AstNode * align; \
|
||||
}) \
|
||||
AST_NODE_KIND(UnionType, "union type", struct { \
|
||||
Token token; \
|
||||
@@ -469,8 +455,8 @@ AST_NODE_KIND(_TypeBegin, "", i32) \
|
||||
AST_NODE_KIND(EnumType, "enum type", struct { \
|
||||
Token token; \
|
||||
AstNode * base_type; \
|
||||
bool is_export; \
|
||||
Array<AstNode *> fields; /* FieldValue */ \
|
||||
bool is_export; \
|
||||
}) \
|
||||
AST_NODE_KIND(BitFieldType, "bit field type", struct { \
|
||||
Token token; \
|
||||
@@ -483,7 +469,7 @@ AST_NODE_KIND(_TypeBegin, "", i32) \
|
||||
AstNode *key; \
|
||||
AstNode *value; \
|
||||
}) \
|
||||
AST_NODE_KIND(_TypeEnd, "", i32)
|
||||
AST_NODE_KIND(_TypeEnd, "", struct {})
|
||||
|
||||
enum AstNodeKind {
|
||||
AstNode_Invalid,
|
||||
|
||||
@@ -169,8 +169,8 @@ bool operator>=(TokenPos const &a, TokenPos const &b) { return token_pos_cmp(a,
|
||||
|
||||
struct Token {
|
||||
TokenKind kind;
|
||||
String string;
|
||||
TokenPos pos;
|
||||
String string;
|
||||
TokenPos pos;
|
||||
};
|
||||
|
||||
Token empty_token = {Token_Invalid};
|
||||
|
||||
Reference in New Issue
Block a user