+constant_t node_plus_eval(node_t*n)
+{
+ EVAL_HEADER_LEFTRIGHT;
+ char left_int = left.type == CONSTANT_INT || left.type == CONSTANT_UINT;
+ if(left_int && (right.type == CONSTANT_INT || right.type == CONSTANT_UINT)) {
+ /* FIXME: what to do about signed/unsigned overflows? */
+ int i = constant_to_int(&left) + constant_to_int(&right);
+ r.type = CONSTANT_INT;
+ r.i = i;
+ } else if(left_int && right.type == CONSTANT_FLOAT) {
+ double f = constant_to_int(&left) + constant_to_float(&right);
+ r.type = CONSTANT_FLOAT;
+ r.f = f;
+ } else if(left.type == CONSTANT_STRING) {
+ char*add = constant_tostring(&right);
+ int l1 = left.s->len;
+ int l2 = strlen(add);
+ char*s = malloc(l1+l2+1);
+ memcpy(s, left.s->str, l1);
+ memcpy(s+l1, add, l2);
+ s[l1+l2]=0;
+ r.type = CONSTANT_STRING;
+ r.s = malloc(sizeof(string_t));
+ r.s->str = s;
+ r.s->len = l1+l2;
+ } else {
+ r.type = CONSTANT_UNKNOWN;
+ }
+ return r;
+}