summary refs log tree commit diff
path: root/minic
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-02-11 20:14:08 -0500
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-02-11 20:21:01 -0500
commitc0db8eafdfe5b49191451104d207f8cf61e1c52a (patch)
tree35339ba5665e4142f2ac0e44e9b7ed2916237d0d /minic
parent66a8044fcc4c6863570170b04e91947af7311044 (diff)
downloadroux-c0db8eafdfe5b49191451104d207f8cf61e1c52a.tar.gz
patch minic for new comparisons
This solved one pending bug: comparisons of long
variables are now compiled properly.  A bug for
comparisons < and <= of pointers remain, it is
related to signedness, not width.  This can be
easily fixed by the reader!
Diffstat (limited to 'minic')
-rw-r--r--minic/minic.y10
1 files changed, 7 insertions, 3 deletions
diff --git a/minic/minic.y b/minic/minic.y
index 0abef05..06ef2d6 100644
--- a/minic/minic.y
+++ b/minic/minic.y
@@ -312,13 +312,14 @@ expr(Node *n)
 		['/'] = "div",
 		['%'] = "rem",
 		['&'] = "and",
-		['<'] = "cslt",  /* meeeeh, careful with pointers/long */
+		['<'] = "cslt",  /* meeeeh, wrong for pointers! */
 		['l'] = "csle",
 		['e'] = "ceq",
 		['n'] = "cne",
 	};
 	Symb sr, s0, s1, sl;
 	int o, l;
+	char ty[2];
 
 	sr.t = Tmp;
 	sr.u.n = tmp++;
@@ -411,12 +412,15 @@ expr(Node *n)
 		o = n->op;
 	Binop:
 		sr.ctyp = prom(o, &s0, &s1);
-		if (strchr("ne<l", n->op))
+		if (strchr("ne<l", n->op)) {
+			sprintf(ty, "%c", irtyp(sr.ctyp));
 			sr.ctyp = INT;
+		} else
+			strcpy(ty, "");
 		fprintf(of, "\t");
 		psymb(sr);
 		fprintf(of, " =%c", irtyp(sr.ctyp));
-		fprintf(of, " %s ", otoa[o]);
+		fprintf(of, " %s%s ", otoa[o], ty);
 	Args:
 		psymb(s0);
 		fprintf(of, ", ");