0
|
1 module dmd.StringExp;
|
|
2
|
|
3 import dmd.Expression;
|
|
4 import dmd.backend.elem;
|
|
5 import dmd.InterState;
|
|
6 import dmd.TypeSArray;
|
|
7 import dmd.CastExp;
|
|
8 import dmd.MATCH;
|
|
9 import dmd.TY;
|
|
10 import dmd.TypeDArray;
|
|
11 import dmd.Type;
|
|
12 import dmd.TOK;
|
|
13 import dmd.OutBuffer;
|
|
14 import dmd.Loc;
|
|
15 import dmd.Scope;
|
|
16 import dmd.IRState;
|
|
17 import dmd.StringExp;
|
|
18 import dmd.HdrGenState;
|
|
19 import dmd.Utf;
|
|
20 import dmd.backend.dt_t;
|
|
21 import dmd.backend.Symbol;
|
|
22 import dmd.backend.StringTab;
|
|
23 import dmd.backend.Util;
|
|
24 import dmd.backend.SC;
|
|
25 import dmd.backend.TYM;
|
|
26 import dmd.backend.FL;
|
|
27 import dmd.backend.TYPE;
|
|
28 import dmd.backend.OPER;
|
|
29
|
4
|
30 import core.memory;
|
2
|
31
|
0
|
32 import core.stdc.string;
|
|
33
|
|
34 class StringExp : Expression
|
|
35 {
|
|
36 void* string_; // char, wchar, or dchar data
|
|
37 size_t len; // number of chars, wchars, or dchars
|
|
38 ubyte sz; // 1: char, 2: wchar, 4: dchar
|
|
39 ubyte committed; // !=0 if type is committed
|
|
40 ubyte postfix; // 'c', 'w', 'd'
|
|
41
|
|
42 this(Loc loc, string s)
|
|
43 {
|
|
44 this(loc, s, 0);
|
|
45 }
|
|
46
|
|
47 this(Loc loc, string s, ubyte postfix)
|
|
48 {
|
|
49 super(loc, TOK.TOKstring, StringExp.sizeof);
|
|
50
|
|
51 this.string_ = cast(void*)s.ptr;
|
|
52 this.len = s.length;
|
|
53 this.sz = 1;
|
|
54 this.committed = 0;
|
|
55 this.postfix = postfix;
|
|
56 }
|
|
57
|
|
58 int equals(Object o)
|
|
59 {
|
|
60 assert(false);
|
|
61 }
|
|
62
|
|
63 string toChars()
|
|
64 {
|
|
65 assert(false);
|
|
66 }
|
|
67
|
|
68 Expression semantic(Scope sc)
|
|
69 {
|
|
70 version (LOGSEMANTIC) {
|
|
71 printf("StringExp.semantic() %s\n", toChars());
|
|
72 }
|
|
73 if (!type)
|
|
74 {
|
|
75 scope OutBuffer buffer = new OutBuffer();
|
|
76 size_t newlen = 0;
|
|
77 string p;
|
|
78 size_t u;
|
|
79 dchar c;
|
|
80
|
|
81 switch (postfix)
|
|
82 {
|
|
83 case 'd':
|
|
84 for (u = 0; u < len;)
|
|
85 {
|
|
86 p = utf_decodeChar(cast(string)string_[0..len], &u, &c);
|
|
87 if (p !is null)
|
|
88 {
|
|
89 error("%s", p);
|
|
90 break;
|
|
91 }
|
|
92 else
|
|
93 {
|
|
94 buffer.write4(c);
|
|
95 newlen++;
|
|
96 }
|
|
97 }
|
|
98 buffer.write4(0);
|
|
99 string_ = buffer.extractData();
|
|
100 len = newlen;
|
|
101 sz = 4;
|
|
102 //type = new TypeSArray(Type.tdchar, new IntegerExp(loc, len, Type.tindex));
|
|
103 type = new TypeDArray(Type.tdchar.invariantOf());
|
|
104 committed = 1;
|
|
105 break;
|
|
106
|
|
107 case 'w':
|
|
108 for (u = 0; u < len;)
|
|
109 {
|
|
110 p = utf_decodeChar(cast(string)string_[0..len], &u, &c);
|
|
111 if (p !is null)
|
|
112 {
|
|
113 error("%s", p);
|
|
114 break;
|
|
115 }
|
|
116 else
|
|
117 {
|
|
118 buffer.writeUTF16(c);
|
|
119 newlen++;
|
|
120 if (c >= 0x10000)
|
|
121 newlen++;
|
|
122 }
|
|
123 }
|
|
124 buffer.writeUTF16(0);
|
|
125 string_ = buffer.extractData();
|
|
126 len = newlen;
|
|
127 sz = 2;
|
|
128 //type = new TypeSArray(Type.twchar, new IntegerExp(loc, len, Type.tindex));
|
|
129 type = new TypeDArray(Type.twchar.invariantOf());
|
|
130 committed = 1;
|
|
131 break;
|
|
132
|
|
133 case 'c':
|
|
134 committed = 1;
|
|
135 default:
|
|
136 //type = new TypeSArray(Type.tchar, new IntegerExp(loc, len, Type.tindex));
|
|
137 type = new TypeDArray(Type.tchar.invariantOf());
|
|
138 break;
|
|
139 }
|
|
140 type = type.semantic(loc, sc);
|
|
141 //type = type.invariantOf();
|
|
142 //printf("type = %s\n", type.toChars());
|
|
143 }
|
|
144 return this;
|
|
145 }
|
|
146
|
|
147 Expression interpret(InterState* istate)
|
|
148 {
|
|
149 assert(false);
|
|
150 }
|
|
151
|
|
152 size_t length()
|
|
153 {
|
|
154 assert(false);
|
|
155 }
|
|
156
|
|
157 StringExp toUTF8(Scope sc)
|
|
158 {
|
|
159 assert(false);
|
|
160 }
|
|
161
|
|
162 Expression implicitCastTo(Scope sc, Type t)
|
|
163 {
|
|
164 //printf("StringExp.implicitCastTo(%s of type %s) => %s\n", toChars(), type.toChars(), t.toChars());
|
|
165 ubyte committed = this.committed;
|
|
166 Expression e = Expression.implicitCastTo(sc, t);
|
|
167 if (e.op == TOK.TOKstring)
|
|
168 {
|
|
169 // Retain polysemous nature if it started out that way
|
|
170 (cast(StringExp)e).committed = committed;
|
|
171 }
|
|
172 return e;
|
|
173 }
|
|
174
|
|
175 MATCH implicitConvTo(Type t)
|
|
176 {
|
|
177 MATCH m;
|
|
178
|
|
179 static if (false) {
|
|
180 printf("StringExp.implicitConvTo(this=%s, committed=%d, type=%s, t=%s)\n",
|
|
181 toChars(), committed, type.toChars(), t.toChars());
|
|
182 }
|
|
183 if (!committed)
|
|
184 {
|
|
185 if (!committed && t.ty == TY.Tpointer && t.nextOf().ty == TY.Tvoid)
|
|
186 {
|
|
187 return MATCH.MATCHnomatch;
|
|
188 }
|
|
189 if (type.ty == TY.Tsarray || type.ty == TY.Tarray || type.ty == TY.Tpointer)
|
|
190 {
|
|
191 TY tyn = type.nextOf().ty;
|
|
192 if (tyn == TY.Tchar || tyn == TY.Twchar || tyn == TY.Tdchar)
|
|
193 {
|
|
194 Type tn;
|
|
195 MATCH mm;
|
|
196
|
|
197 switch (t.ty)
|
|
198 {
|
|
199 case TY.Tsarray:
|
|
200 if (type.ty == TY.Tsarray)
|
|
201 {
|
|
202 if ((cast(TypeSArray)type).dim.toInteger() !=
|
|
203 (cast(TypeSArray)t).dim.toInteger())
|
|
204 return MATCH.MATCHnomatch;
|
|
205 TY tynto = t.nextOf().ty;
|
|
206 if (tynto == TY.Tchar || tynto == TY.Twchar || tynto == TY.Tdchar)
|
|
207 return MATCH.MATCHexact;
|
|
208 }
|
|
209 else if (type.ty == TY.Tarray)
|
|
210 {
|
|
211 if (length() > (cast(TypeSArray)t).dim.toInteger())
|
|
212 return MATCH.MATCHnomatch;
|
|
213 TY tynto = t.nextOf().ty;
|
|
214 if (tynto == TY.Tchar || tynto == TY.Twchar || tynto == TY.Tdchar)
|
|
215 return MATCH.MATCHexact;
|
|
216 }
|
|
217 case TY.Tarray:
|
|
218 case TY.Tpointer:
|
|
219 tn = t.nextOf();
|
|
220 mm = MATCH.MATCHexact;
|
|
221 if (type.nextOf().mod != tn.mod)
|
|
222 {
|
|
223 if (!tn.isConst())
|
|
224 return MATCH.MATCHnomatch;
|
|
225 mm = MATCH.MATCHconst;
|
|
226 }
|
|
227 switch (tn.ty)
|
|
228 {
|
|
229 case TY.Tchar:
|
|
230 case TY.Twchar:
|
|
231 case TY.Tdchar:
|
|
232 return mm;
|
|
233 }
|
|
234 break;
|
|
235 default:
|
|
236 break; ///
|
|
237 }
|
|
238 }
|
|
239 }
|
|
240 }
|
|
241 return Expression.implicitConvTo(t);
|
|
242 static if (false) {
|
|
243 m = cast(MATCH)type.implicitConvTo(t);
|
|
244 if (m)
|
|
245 {
|
|
246 return m;
|
|
247 }
|
|
248
|
|
249 return MATCH.MATCHnomatch;
|
|
250 }
|
|
251 }
|
|
252
|
|
253 static uint X(TY tf, TY tt) {
|
|
254 return ((tf) * 256 + (tt));
|
|
255 }
|
|
256
|
|
257 Expression castTo(Scope sc, Type t)
|
|
258 {
|
|
259 /* This follows copy-on-write; any changes to 'this'
|
|
260 * will result in a copy.
|
|
261 * The this.string member is considered immutable.
|
|
262 */
|
|
263 StringExp se;
|
|
264 Type tb;
|
|
265 int copied = 0;
|
|
266
|
|
267 //printf("StringExp.castTo(t = %s), '%s' committed = %d\n", t.toChars(), toChars(), committed);
|
|
268
|
|
269 if (!committed && t.ty == TY.Tpointer && t.nextOf().ty == TY.Tvoid)
|
|
270 {
|
|
271 error("cannot convert string literal to void*");
|
|
272 }
|
|
273
|
|
274 se = this;
|
|
275 if (!committed)
|
|
276 {
|
|
277 se = cast(StringExp)copy();
|
|
278 se.committed = 1;
|
|
279 copied = 1;
|
|
280 }
|
|
281
|
|
282 if (type == t)
|
|
283 {
|
|
284 return se;
|
|
285 }
|
|
286
|
|
287 tb = t.toBasetype();
|
|
288 //printf("\ttype = %s\n", type.toChars());
|
|
289 if (tb.ty == TY.Tdelegate && type.toBasetype().ty != TY.Tdelegate)
|
|
290 return Expression.castTo(sc, t);
|
|
291
|
|
292 Type typeb = type.toBasetype();
|
|
293 if (typeb == tb)
|
|
294 {
|
|
295 if (!copied)
|
|
296 {
|
|
297 se = cast(StringExp)copy();
|
|
298 copied = 1;
|
|
299 }
|
|
300 se.type = t;
|
|
301 return se;
|
|
302 }
|
|
303
|
|
304 if (committed && tb.ty == TY.Tsarray && typeb.ty == TY.Tarray)
|
|
305 {
|
|
306 se = cast(StringExp)copy();
|
|
307 se.sz = cast(ubyte)tb.nextOf().size();
|
|
308 se.len = (len * sz) / se.sz;
|
|
309 se.committed = 1;
|
|
310 se.type = t;
|
|
311 return se;
|
|
312 }
|
|
313
|
|
314 if (tb.ty != TY.Tsarray && tb.ty != TY.Tarray && tb.ty != TY.Tpointer)
|
|
315 {
|
|
316 if (!copied)
|
|
317 {
|
|
318 se = cast(StringExp)copy();
|
|
319 copied = 1;
|
|
320 }
|
|
321 goto Lcast;
|
|
322 }
|
|
323 if (typeb.ty != TY.Tsarray && typeb.ty != TY.Tarray && typeb.ty != TY.Tpointer)
|
|
324 {
|
|
325 if (!copied)
|
|
326 {
|
|
327 se = cast(StringExp)copy();
|
|
328 copied = 1;
|
|
329 }
|
|
330 goto Lcast;
|
|
331 }
|
|
332
|
|
333 if (typeb.nextOf().size() == tb.nextOf().size())
|
|
334 {
|
|
335 if (!copied)
|
|
336 {
|
|
337 se = cast(StringExp)copy();
|
|
338 copied = 1;
|
|
339 }
|
|
340
|
|
341 if (tb.ty == TY.Tsarray)
|
|
342 goto L2; // handle possible change in static array dimension
|
|
343 se.type = t;
|
|
344 return se;
|
|
345 }
|
|
346
|
|
347 if (committed)
|
|
348 goto Lcast;
|
|
349
|
|
350 {
|
|
351 scope OutBuffer buffer = new OutBuffer();
|
|
352 size_t newlen = 0;
|
|
353 TY tfty = typeb.nextOf().toBasetype().ty;
|
|
354 TY ttty = tb.nextOf().toBasetype().ty;
|
|
355 switch (X(tfty, ttty))
|
|
356 {
|
|
357 case X(TY.Tchar, TY.Tchar):
|
|
358 case X(TY.Twchar,TY.Twchar):
|
|
359 case X(TY.Tdchar,TY.Tdchar):
|
|
360 break;
|
|
361
|
|
362 case X(TY.Tchar, TY.Twchar):
|
|
363 for (size_t u = 0; u < len;)
|
|
364 {
|
|
365 dchar c;
|
|
366 string p = utf_decodeChar(cast(string)se.string_[0..len], &u, &c);
|
|
367 if (p !is null)
|
|
368 error("%s", p);
|
|
369 else
|
|
370 buffer.writeUTF16(c);
|
|
371 }
|
|
372 newlen = buffer.offset / 2;
|
|
373 buffer.writeUTF16(0);
|
|
374 goto L1;
|
|
375
|
|
376 case X(TY.Tchar, TY.Tdchar):
|
|
377 for (size_t u = 0; u < len;)
|
|
378 {
|
|
379 dchar c;
|
|
380 string p = utf_decodeChar(cast(string)se.string_[0..len], &u, &c);
|
|
381 if (p !is null)
|
|
382 error("%s", p);
|
|
383 buffer.write4(c);
|
|
384 newlen++;
|
|
385 }
|
|
386 buffer.write4(0);
|
|
387 goto L1;
|
|
388
|
|
389 case X(TY.Twchar,TY.Tchar):
|
|
390 for (size_t u = 0; u < len;)
|
|
391 {
|
|
392 dchar c;
|
|
393 string p = utf_decodeWchar(cast(wstring)se.string_[0..len], &u, &c);
|
|
394 if (p)
|
|
395 error("%s", p);
|
|
396 else
|
|
397 buffer.writeUTF8(c);
|
|
398 }
|
|
399 newlen = buffer.offset;
|
|
400 buffer.writeUTF8(0);
|
|
401 goto L1;
|
|
402
|
|
403 case X(TY.Twchar,TY.Tdchar):
|
|
404 for (size_t u = 0; u < len;)
|
|
405 {
|
|
406 dchar c;
|
|
407 string p = utf_decodeWchar(cast(wstring)se.string_[0..len], &u, &c);
|
|
408 if (p)
|
|
409 error("%s", p);
|
|
410 buffer.write4(c);
|
|
411 newlen++;
|
|
412 }
|
|
413 buffer.write4(0);
|
|
414 goto L1;
|
|
415
|
|
416 case X(TY.Tdchar,TY.Tchar):
|
|
417 for (size_t u = 0; u < len; u++)
|
|
418 {
|
|
419 dchar c = (cast(dchar*)se.string_)[u];
|
|
420 if (!utf_isValidDchar(c))
|
|
421 error("invalid UCS-32 char \\U%08x", c);
|
|
422 else
|
|
423 buffer.writeUTF8(c);
|
|
424 newlen++;
|
|
425 }
|
|
426 newlen = buffer.offset;
|
|
427 buffer.writeUTF8(0);
|
|
428 goto L1;
|
|
429
|
|
430 case X(TY.Tdchar,TY.Twchar):
|
|
431 for (size_t u = 0; u < len; u++)
|
|
432 {
|
|
433 dchar c = (cast(dchar*)se.string_)[u];
|
|
434 if (!utf_isValidDchar(c))
|
|
435 error("invalid UCS-32 char \\U%08x", c);
|
|
436 else
|
|
437 buffer.writeUTF16(c);
|
|
438 newlen++;
|
|
439 }
|
|
440 newlen = buffer.offset / 2;
|
|
441 buffer.writeUTF16(0);
|
|
442 goto L1;
|
|
443
|
|
444 L1:
|
|
445 if (!copied)
|
|
446 {
|
|
447 se = cast(StringExp)copy();
|
|
448 copied = 1;
|
|
449 }
|
|
450 se.string_ = buffer.extractData();
|
|
451 se.len = newlen;
|
|
452 se.sz = cast(ubyte)tb.nextOf().size();
|
|
453 break;
|
|
454
|
|
455 default:
|
|
456 assert(typeb.nextOf().size() != tb.nextOf().size());
|
|
457 goto Lcast;
|
|
458 }
|
|
459 }
|
|
460 L2:
|
|
461 assert(copied);
|
|
462
|
|
463 // See if need to truncate or extend the literal
|
|
464 if (tb.ty == TY.Tsarray)
|
|
465 {
|
|
466 int dim2 = cast(int)(cast(TypeSArray)tb).dim.toInteger();
|
|
467
|
|
468 //printf("dim from = %d, to = %d\n", se.len, dim2);
|
|
469
|
|
470 // Changing dimensions
|
|
471 if (dim2 != se.len)
|
|
472 {
|
|
473 // Copy when changing the string literal
|
|
474 uint newsz = se.sz;
|
|
475 void *s;
|
|
476 int d;
|
|
477
|
|
478 d = (dim2 < se.len) ? dim2 : se.len;
|
2
|
479 s = cast(ubyte*)GC.malloc((dim2 + 1) * newsz);
|
0
|
480 memcpy(s, se.string_, d * newsz);
|
|
481 // Extend with 0, add terminating 0
|
|
482 memset(cast(char*)s + d * newsz, 0, (dim2 + 1 - d) * newsz);
|
|
483 se.string_ = s;
|
|
484 se.len = dim2;
|
|
485 }
|
|
486 }
|
|
487 se.type = t;
|
|
488 return se;
|
|
489
|
|
490 Lcast:
|
|
491 Expression e = new CastExp(loc, se, t);
|
|
492 e.type = t; // so semantic() won't be run on e
|
|
493 return e;
|
|
494 }
|
|
495
|
|
496 int compare(Object obj)
|
|
497 {
|
|
498 assert(false);
|
|
499 }
|
|
500
|
|
501 bool isBool(bool result)
|
|
502 {
|
|
503 assert(false);
|
|
504 }
|
|
505
|
|
506 uint charAt(size_t i)
|
|
507 {
|
|
508 assert(false);
|
|
509 }
|
|
510
|
|
511 void toCBuffer(OutBuffer buf, HdrGenState* hgs)
|
|
512 {
|
|
513 assert(false);
|
|
514 }
|
|
515
|
|
516 void toMangleBuffer(OutBuffer buf)
|
|
517 {
|
|
518 assert(false);
|
|
519 }
|
|
520
|
|
521 elem* toElem(IRState* irs)
|
|
522 {
|
|
523 elem* e;
|
|
524 Type tb = type.toBasetype();
|
|
525
|
|
526 static if (false) {
|
|
527 printf("StringExp.toElem() %s, type = %s\n", toChars(), type.toChars());
|
|
528 }
|
|
529
|
|
530 if (tb.ty == TY.Tarray)
|
|
531 {
|
|
532 Symbol* si;
|
|
533 dt_t* dt;
|
|
534 StringTab* st;
|
|
535
|
|
536 static if (false) {
|
|
537 printf("irs.m = %p\n", irs.m);
|
|
538 printf(" m = %s\n", irs.m.toChars());
|
|
539 printf(" len = %d\n", len);
|
|
540 printf(" sz = %d\n", sz);
|
|
541 }
|
|
542 for (size_t i = 0; i < STSIZE; i++)
|
|
543 {
|
|
544 st = &stringTab[(stidx + i) % STSIZE];
|
|
545 //if (!st.m) continue;
|
|
546 //printf(" st.m = %s\n", st.m.toChars());
|
|
547 //printf(" st.len = %d\n", st.len);
|
|
548 //printf(" st.sz = %d\n", st.sz);
|
|
549 if (st.m is irs.m &&
|
|
550 st.si &&
|
|
551 st.len == len &&
|
|
552 st.sz == sz &&
|
|
553 memcmp(st.string_, string_, sz * len) == 0)
|
|
554 {
|
|
555 //printf("use cached value\n");
|
|
556 si = st.si; // use cached value
|
|
557 goto L1;
|
|
558 }
|
|
559 }
|
|
560
|
|
561 stidx = (stidx + 1) % STSIZE;
|
|
562 st = &stringTab[stidx];
|
|
563
|
|
564 dt = null;
|
|
565 toDt(&dt);
|
|
566
|
|
567 si = symbol_generate(SC.SCstatic, type_fake(TYM.TYdarray));
|
|
568 si.Sdt = dt;
|
|
569 si.Sfl = FL.FLdata;
|
|
570 version (ELFOBJ) {// Burton
|
|
571 si.Sseg = Segment.CDATA;
|
|
572 }
|
|
573 version (MACHOBJ) {
|
|
574 si.Sseg = Segment.DATA;
|
|
575 }
|
|
576 outdata(si);
|
|
577
|
|
578 st.m = irs.m;
|
|
579 st.si = si;
|
|
580 st.string_ = string_;
|
|
581 st.len = len;
|
|
582 st.sz = sz;
|
|
583 L1:
|
|
584 e = el_var(si);
|
|
585 }
|
|
586 else if (tb.ty == TY.Tsarray)
|
|
587 {
|
|
588 Symbol *si;
|
|
589 dt_t *dt = null;
|
|
590
|
|
591 toDt(&dt);
|
|
592 dtnzeros(&dt, sz); // leave terminating 0
|
|
593
|
|
594 si = symbol_generate(SC.SCstatic,type_allocn(TYM.TYarray, tschar));
|
|
595 si.Sdt = dt;
|
|
596 si.Sfl = FL.FLdata;
|
|
597
|
|
598 version (ELFOBJ_OR_MACHOBJ) { // Burton
|
|
599 si.Sseg = Segment.CDATA;
|
|
600 }
|
|
601 outdata(si);
|
|
602
|
|
603 e = el_var(si);
|
|
604 }
|
|
605 else if (tb.ty == TY.Tpointer)
|
|
606 {
|
|
607 e = el_calloc();
|
|
608 e.Eoper = OPER.OPstring;
|
|
609 static if (true) {
|
|
610 // Match MEM_PH_FREE for OPstring in ztc\el.c
|
2
|
611 e.EV.ss.Vstring = cast(char*)GC.malloc((len + 1) * sz);
|
0
|
612 memcpy(e.EV.ss.Vstring, string_, (len + 1) * sz);
|
|
613 } else {
|
|
614 e.EV.ss.Vstring = cast(char*)string_;
|
|
615 }
|
|
616 e.EV.ss.Vstrlen = (len + 1) * sz;
|
|
617 e.Ety = TYM.TYnptr;
|
|
618 }
|
|
619 else
|
|
620 {
|
|
621 writef("type is %s\n", type.toChars());
|
|
622 assert(0);
|
|
623 }
|
|
624 el_setLoc(e,loc);
|
|
625 return e;
|
|
626 }
|
|
627
|
|
628 dt_t** toDt(dt_t** pdt)
|
|
629 {
|
|
630 //printf("StringExp.toDt() '%s', type = %s\n", toChars(), type.toChars());
|
|
631 Type t = type.toBasetype();
|
|
632
|
|
633 // BUG: should implement some form of static string pooling
|
|
634 switch (t.ty)
|
|
635 {
|
|
636 case TY.Tarray:
|
|
637 dtdword(pdt, len);
|
|
638 pdt = dtabytes(pdt, TYM.TYnptr, 0, (len + 1) * sz, cast(char*)string_);
|
|
639 break;
|
|
640
|
|
641 case TY.Tsarray:
|
|
642 {
|
|
643 TypeSArray tsa = cast(TypeSArray)type;
|
|
644 long dim;
|
|
645
|
|
646 pdt = dtnbytes(pdt, len * sz, cast(const(char)*)string_);
|
|
647 if (tsa.dim)
|
|
648 {
|
|
649 dim = tsa.dim.toInteger();
|
|
650 if (len < dim)
|
|
651 {
|
|
652 // Pad remainder with 0
|
|
653 pdt = dtnzeros(pdt, cast(uint)((dim - len) * tsa.next.size()));
|
|
654 }
|
|
655 }
|
|
656 break;
|
|
657 }
|
|
658
|
|
659 case TY.Tpointer:
|
|
660 pdt = dtabytes(pdt, TYM.TYnptr, 0, (len + 1) * sz, cast(char*)string_);
|
|
661 break;
|
|
662
|
|
663 default:
|
|
664 writef("StringExp.toDt(type = %s)\n", type.toChars());
|
|
665 assert(0);
|
|
666 }
|
|
667
|
|
668 return pdt;
|
|
669 }
|
|
670 }
|
|
671
|