diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-11-03 16:06:26 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-11-03 16:06:26 -0500 |
| commit | 39a58bc129fd9461d54b837bc1650c4c650aa333 (patch) | |
| tree | d3a7e9b3be33856cc8343f6cb273f9a14c28effd /compile.c | |
| parent | 3743913ce2c5bc37f899d437c09b60cbb3bc6dea (diff) | |
Clean up behavior and syntax for unsigned bit shifts (<<<, >>>)
Diffstat (limited to 'compile.c')
| -rw-r--r-- | compile.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -725,6 +725,14 @@ CORD compile_statement(env_t *env, ast_t *ast) if (lhs_t->tag != IntType && lhs_t->tag != ByteType) code_err(ast, "I can't do a shift assignment with this operator between %T and %T", lhs_t, rhs_t); return CORD_all(lhs, " >>= ", rhs, ";"); + case BINOP_ULSHIFT: + if (lhs_t->tag != IntType && lhs_t->tag != ByteType) + code_err(ast, "I can't do a shift assignment with this operator between %T and %T", lhs_t, rhs_t); + return CORD_all("{ ", compile_unsigned_type(lhs_t), " *dest = (void*)&(", lhs, "); *dest <<= ", rhs, "; }"); + case BINOP_URSHIFT: + if (lhs_t->tag != IntType && lhs_t->tag != ByteType) + code_err(ast, "I can't do a shift assignment with this operator between %T and %T", lhs_t, rhs_t); + return CORD_all("{ ", compile_unsigned_type(lhs_t), " *dest = (void*)&(", lhs, "); *dest >>= ", rhs, "; }"); case BINOP_AND: { if (lhs_t->tag == BoolType) return CORD_all("if (", lhs, ") ", lhs, " = ", rhs, ";"); |
