From: Brendan Hansen Date: Mon, 10 Aug 2020 20:43:29 +0000 (-0500) Subject: added binary op reduction to comparison and boolean operators X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=9a2dc98aefe03869c3f9a5e61dde60456763830a;p=onyx.git added binary op reduction to comparison and boolean operators --- diff --git a/onyx b/onyx index 0481c589..1234b025 100755 Binary files a/onyx and b/onyx differ diff --git a/src/onyxchecker.c b/src/onyxchecker.c index 8354c391..7a468ef9 100644 --- a/src/onyxchecker.c +++ b/src/onyxchecker.c @@ -473,6 +473,11 @@ CHECK(binaryop_compare, AstBinaryOp** pbinop) { } binop->type = &basic_types[Basic_Kind_Bool]; + if (binop->flags & Ast_Flag_Comptime) { + // NOTE: Not a binary op + *pbinop = (AstBinaryOp *) ast_reduce(semstate.node_allocator, (AstTyped *) binop); + } + return 0; } @@ -501,6 +506,11 @@ CHECK(binaryop_bool, AstBinaryOp** pbinop) { } binop->type = &basic_types[Basic_Kind_Bool]; + + if (binop->flags & Ast_Flag_Comptime) { + // NOTE: Not a binary op + *pbinop = (AstBinaryOp *) ast_reduce(semstate.node_allocator, (AstTyped *) binop); + } return 0; } @@ -621,7 +631,6 @@ CHECK(binaryop, AstBinaryOp** pbinop, b32 assignment_is_ok) { // NOTE: Not a binary op *pbinop = (AstBinaryOp *) ast_reduce(semstate.node_allocator, (AstTyped *) binop); } - return 0; } diff --git a/src/onyxutils.c b/src/onyxutils.c index 72dde5fd..9bb20b38 100644 --- a/src/onyxutils.c +++ b/src/onyxutils.c @@ -206,9 +206,6 @@ AstNode* symbol_resolve(Scope* start_scope, OnyxToken* tkn) { } \ break; - -AstTyped* ast_reduce(bh_allocator a, AstTyped* node); - AstNumLit* ast_reduce_binop(bh_allocator a, AstBinaryOp* node) { AstNumLit* left = (AstNumLit *) ast_reduce(a, node->left); AstNumLit* right = (AstNumLit *) ast_reduce(a, node->right);