ref: e888ffdaf5a6a7aee73253cc982847e72be0bd94
parent: a100cd930fb84e4e0e1d3dc3c24d3bddd28eb4f0
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Aug 11 19:33:45 EDT 2014
Add unary operators '-' and '~'
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
@@ -86,6 +86,8 @@
#define ONE '!'
#define OOR 'o'
#define OAND 'y'
+#define ONEG '_'
+#define OCPL '~'
extern void error(unsigned nerror, ...);
extern void genaddable(Node *list[]);
--- a/cc2/cgen.c
+++ b/cc2/cgen.c
@@ -124,6 +124,7 @@
}
switch (np->op) {
+ case ONEG: case OCPL:
case OOR: case OAND:
case OPTR: case OADDR:
case OINC:
@@ -195,6 +196,7 @@
case CONST:
np->addable = 20;
break;
+ case ONEG: case OCPL:
case OPTR: case OADDR:
xaddable(lp);
break;
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -302,6 +302,8 @@
['!'] = operator,
['y'] = operator,
['o'] = operator,
+ ['_'] = unary,
+ ['~'] = unary,
['\177'] = NULL
};