]> Cypherpunks repositories - gostls13.git/commitdiff
static initialization of strings
authorKen Thompson <ken@golang.org>
Tue, 19 May 2009 20:37:36 +0000 (13:37 -0700)
committerKen Thompson <ken@golang.org>
Tue, 19 May 2009 20:37:36 +0000 (13:37 -0700)
R=r
OCL=29036
CL=29036

src/cmd/6g/gen.c
src/cmd/6g/gg.h

index 55eb43a618d9e2ddabcfb19689d1eec09c07214a..61d25184e852b031ac0da2543c68d478d2974244 100644 (file)
@@ -830,6 +830,25 @@ lit:
                p = gins(ADATA, &nam, nr);
                p->from.scale = nr->type->width;
                break;
+
+       case TSTRING:
+               p = gins(ADATA, &nam, N);
+               datastring(nr->val.u.sval->s, nr->val.u.sval->len, &p->to);
+               p->from.scale = types[tptr]->width;
+               p->to.index = p->to.type;
+               p->to.type = D_ADDR;
+//print("%P\n", p);
+
+               nodconst(&nod1, types[TINT32], nr->val.u.sval->len);
+               p = gins(ADATA, &nam, &nod1);
+               p->from.scale = types[TINT32]->width;
+               p->from.offset += types[tptr]->width;
+//print("%P\n", p);
+
+               p = gins(ADATA, &nam, &nod1);
+               p->from.scale = types[TINT32]->width;
+               p->from.offset += types[tptr]->width+types[TINT32]->width;
+               break;
        }
 
 yes:
index 266a11ddc635c30d6b8ed90c60153af68ddce4dc..0d83506aeee7c33b328c27001dbc2224865d1497 100644 (file)
@@ -125,6 +125,11 @@ int        sudoaddable(int, Node*, Addr*);
 void   afunclit(Addr*);
 void   datagostring(Strlit*, Addr*);
 
+/*
+ * obj.c
+ */
+void   datastring(char*, int, Addr*);
+
 /*
  * list.c
  */