From 7845f408c5ab3e8cfde623c6fb9193ed8761ef0d Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Wed, 12 May 2010 14:24:34 +0430 Subject: [PATCH] add shift operators --- cc.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/cc.c b/cc.c index 817f2f7..2e8d9f9 100644 --- a/cc.c +++ b/cc.c @@ -370,9 +370,32 @@ static void readadd(void) } } -static void cmp(void (*op)(void)) +static void shift(void (*op)(void)) +{ + struct type t; + readadd(); + ts_pop(NULL); + ts_pop(&t); + op(); + ts_push_bt(TYPE_BT(&t)); +} + +static void readshift(void) { readadd(); + if (!tok_jmp(TOK2("<<"))) { + shift(o_shl); + return; + } + if (!tok_jmp(TOK2(">>"))) { + shift(o_shr); + return; + } +} + +static void cmp(void (*op)(void)) +{ + readshift(); ts_pop(NULL); ts_pop(NULL); op(); @@ -381,7 +404,7 @@ static void cmp(void (*op)(void)) static void readcmp(void) { - readadd(); + readshift(); if (!tok_jmp('<')) { cmp(o_lt); return; -- 2.11.4.GIT