611
611
static void generate_delete(struct generator * g, struct node * p)
612
{ wp(g, "~Mslice_del(z);~C", p);
613
wp(g, "~{int ret;~N", p);
614
wp(g, "~Mret = slice_del(z);~C", p);
615
wp(g, "~Mif (ret < 0) return ret;~N"
642
646
static void generate_assignto(struct generator * g, struct node * p)
643
647
{ g->V[0] = p->name;
644
wp(g, "~M~V0 = assign_to(z, ~V0);~C", p);
648
wp(g, "~M~V0 = assign_to(z, ~V0);~C"
649
"~Mif (~V0 == 0) return -1;~C", p);
647
652
static void generate_sliceto(struct generator * g, struct node * p)
648
653
{ g->V[0] = p->name;
649
wp(g, "~M~V0 = slice_to(z, ~V0);~C", p);
654
wp(g, "~M~V0 = slice_to(z, ~V0);~C"
655
"~Mif (~V0 == 0) return -1;~C", p);
652
658
static void generate_data_address(struct generator * g, struct node * p)
664
670
int keep_c = style == c_attach;
665
671
if (p->mode == m_backward) keep_c = !keep_c;
672
wp(g, "~{int ret;~N", p);
666
673
if (keep_c) w(g, "~{int c = z->c;~N");
667
wp(g, "~Minsert_~$(z, z->c, z->c, ", p);
674
wp(g, "~Mret = insert_~$(z, z->c, z->c, ", p);
668
675
generate_data_address(g, p);
669
676
wp(g, ");~C", p);
670
677
if (keep_c) w(g, "~Mz->c = c;~N~}");
678
wp(g, "~Mif (ret < 0) return ret;~N"
673
682
static void generate_assignfrom(struct generator * g, struct node * p)
675
684
int keep_c = p->mode == m_forward; /* like 'attach' */
685
wp(g, "~{int ret;~N", p);
676
686
if (keep_c) wp(g, "~{int c = z->c;~N"
677
"~Minsert_~$(z, z->c, z->l, ", p);
678
else wp(g, "~Minsert_~$(z, z->lb, z->c, ", p);
687
"~Mret = insert_~$(z, z->c, z->l, ", p);
688
else wp(g, "~Mret = insert_~$(z, z->lb, z->c, ", p);
679
689
generate_data_address(g, p);
680
690
wp(g, ");~C", p);
681
691
if (keep_c) w(g, "~Mz->c = c;~N~}");
692
wp(g, "~Mif (ret < 0) return ret;~N"
684
696
/* bugs marked <======= fixed 22/7/02. Similar fixes required for Java */
686
698
static void generate_slicefrom(struct generator * g, struct node * p)
688
700
/* w(g, "~Mslice_from_s(z, "); <============= bug! should be: */
689
wp(g, "~Mslice_from_~$(z, ", p);
701
wp(g, "~{int ret;~N", p);
702
wp(g, "~Mret = slice_from_~$(z, ", p);
690
703
generate_data_address(g, p);
691
704
wp(g, ");~C", p);
705
wp(g, "~Mif (ret < 0) return ret;~N"
694
709
static void generate_setlimit(struct generator * g, struct node * p)
767
782
static void generate_call(struct generator * g, struct node * p)
769
784
g->V[0] = p->name;
770
wp(g, "~Mif (!~V0(z)) ~f~C", p);
785
wp(g, "~{int ret = ~V0(z);~N"
786
"~Mif (ret == 0) ~f~C"
787
"~Mif (ret < 0) return ret;~N~}", p);
773
790
static void generate_grouping(struct generator * g, struct node * p, int complement)