21 lines
507 B
C
21 lines
507 B
C
#include <common/fzl_opcodes.h>
|
|
#include <compiler/fzl_parser.h>
|
|
#include <compiler/internals/gen.h>
|
|
#include <stdio.h>
|
|
|
|
// Unary math operations
|
|
gen_res_t gen_unary_math(fzl_gen_t *gen, fzl_node_t *node)
|
|
{
|
|
if (!gen || !node)
|
|
return gen_error;
|
|
|
|
gen_res_t res = gen_common(gen, node->unary_op.operand);
|
|
if (res.error)
|
|
return gen_error;
|
|
|
|
if (node->type == FZL_NODETYPE_UNARY_MINUS)
|
|
gen_op(gen, FZL_OPCODE_NEG);
|
|
|
|
return (gen_res_t){.error = false, .type = res.type, .classname = NULL};
|
|
}
|