summary refs log tree commit diff
path: root/lisc/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'lisc/util.c')
-rw-r--r--lisc/util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lisc/util.c b/lisc/util.c
index 53aad55..90fa1bb 100644
--- a/lisc/util.c
+++ b/lisc/util.c
@@ -192,3 +192,18 @@ getcon(int64_t val, Fn *fn)
 	fn->con[c] = (Con){.type = CNum, .val = val};
 	return CON(c);
 }
+
+void
+addcon(Con *c0, Con *c1)
+{
+	if (c0->type == CUndef)
+		*c0 = *c1;
+	else {
+		if (c1->type == CAddr) {
+			if (c0->type == CAddr)
+				diag("addcon: adding two addresses");
+			strcpy(c0->label, c1->label);
+		}
+		c0->val += c1->val;
+	}
+}