aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-11-03 16:06:26 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-11-03 16:06:26 -0500
commit39a58bc129fd9461d54b837bc1650c4c650aa333 (patch)
treed3a7e9b3be33856cc8343f6cb273f9a14c28effd /compile.c
parent3743913ce2c5bc37f899d437c09b60cbb3bc6dea (diff)
Clean up behavior and syntax for unsigned bit shifts (<<<, >>>)
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index 383a4e03..1f67156a 100644
--- a/compile.c
+++ b/compile.c
@@ -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, ";");