feat: add prepared error/null ok returns from gen_* functions
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#include <common/fzl_opcodes.h>
|
||||
#include <common/fzl_types.h>
|
||||
#include <compiler/fzl_parser.h>
|
||||
#include <compiler/internals/gen.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Currently, only NOT operator
|
||||
gen_res_t gen_unary_logical(fzl_gen_t *gen, fzl_node_t *node)
|
||||
{
|
||||
if (!gen || !node)
|
||||
return gen_error;
|
||||
|
||||
gen_res_t operand_res = gen_common(gen, node->unary_op.operand);
|
||||
if (operand_res.error)
|
||||
return gen_error;
|
||||
|
||||
if (node->type == FZL_NODETYPE_NOT)
|
||||
gen_op(gen, FZL_OPCODE_NOT);
|
||||
else
|
||||
return gen_error;
|
||||
|
||||
return (gen_res_t){.error = false, .type = FZL_TYPE_BOOL, .classname = NULL};
|
||||
}
|
||||
Reference in New Issue
Block a user