enum to string

Lionello Lunesu lio at lunesu.remove.com
Thu Mar 12 17:11:36 PDT 2009


//src\dmd\mtype.c, line 5025 (in TypeEnum::dotExp, after the #endif):

/* If e.tupleof
  */
if (ident == Id::tupleof)
{
	/* Create a TupleExp out of the fields of the struct e:
	 * (e.field0, e.field1, e.field2, ...)
	 */
	e = e->semantic(sc);	// do this before turning on noaccesscheck
	Expressions *exps = new Expressions;
	exps->reserve(sym->members->dim);
	for (size_t i = 0; i < sym->members->dim; i++)
	{
		EnumMember *em = ((Dsymbol *)sym->members->data[i])->isEnumMember();
		char* s = em->ident->toChars();
		Expression *fe = new StringExp(e->loc, s, strlen(s), 'c');
		exps->push(fe);
	}
	e = new TupleExp(e->loc, exps);
	Scope sss;
	e = e->semantic(&sss);
	return e;
}


More information about the Digitalmars-d-learn mailing list