diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-04-23 12:50:30 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-04-23 12:50:30 -0400 |
| commit | fbb25decf062349b0f28b3027d6be34a11f2a812 (patch) | |
| tree | ecbbf62e677833fcaff5e4033d92f43099fa6049 /ast.c | |
| parent | 803995aea2b1012355c929a7e148d500cd253997 (diff) | |
Support struct literals as constants
Diffstat (limited to 'ast.c')
| -rw-r--r-- | ast.c | 24 |
1 files changed, 0 insertions, 24 deletions
@@ -196,28 +196,4 @@ bool is_idempotent(ast_t *ast) } } -bool is_constant(ast_t *ast) -{ - switch (ast->tag) { - case Bool: case Int: case Num: case Nil: case TextLiteral: return true; - case TextJoin: { - auto text = Match(ast, TextJoin); - return !text->children || !text->children->next; - } - case Not: return is_constant(Match(ast, Not)->value); - case Negative: return is_constant(Match(ast, Negative)->value); - case BinaryOp: { - auto binop = Match(ast, BinaryOp); - switch (binop->op) { - case BINOP_UNKNOWN: case BINOP_POWER: case BINOP_CONCAT: case BINOP_MIN: case BINOP_MAX: case BINOP_CMP: - return false; - default: - return is_constant(binop->lhs) && is_constant(binop->rhs); - } - } - case Use: return true; - default: return false; - } -} - // vim: ts=4 sw=0 et cino=L2,l1,(0,W4,m1,\:0 |
