summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lisc/lisc.h1
-rw-r--r--lisc/util.c15
2 files changed, 16 insertions, 0 deletions
diff --git a/lisc/lisc.h b/lisc/lisc.h
index 4903961..efae900 100644
--- a/lisc/lisc.h
+++ b/lisc/lisc.h
@@ -326,6 +326,7 @@ void *vnew(ulong, size_t);
 void vgrow(void *, ulong);
 Ref newtmp(char *, Fn *);
 Ref getcon(int64_t, Fn *);
+void addcon(Con *, Con *);
 
 /* parse.c */
 extern OpDesc opdesc[NOp];
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;
+	}
+}