comparison dmd/expression.c @ 19:788401029ecf trunk

[svn r23] * Updated to DMD 1.021
author lindquist
date Thu, 04 Oct 2007 03:42:56 +0200
parents c53b6e3fe49a
children 3cfcb944304e
comparison
equal deleted inserted replaced
18:c05ef76f1c20 19:788401029ecf
617 if (arguments) 617 if (arguments)
618 { 618 {
619 for (size_t i = 0; i < arguments->dim; i++) 619 for (size_t i = 0; i < arguments->dim; i++)
620 { Expression *arg = (Expression *)arguments->data[i]; 620 { Expression *arg = (Expression *)arguments->data[i];
621 621
622 if (i) 622 if (arg)
623 buf->writeByte(','); 623 { if (i)
624 expToCBuffer(buf, hgs, arg, PREC_assign); 624 buf->writeByte(',');
625 expToCBuffer(buf, hgs, arg, PREC_assign);
626 }
625 } 627 }
626 } 628 }
627 } 629 }
628 630
629 /************************************************** 631 /**************************************************
3977 buf->writestring("halt"); 3979 buf->writestring("halt");
3978 } 3980 }
3979 3981
3980 /************************************************************/ 3982 /************************************************************/
3981 3983
3982 IftypeExp::IftypeExp(Loc loc, Type *targ, Identifier *id, enum TOK tok, 3984 IsExp::IsExp(Loc loc, Type *targ, Identifier *id, enum TOK tok,
3983 Type *tspec, enum TOK tok2) 3985 Type *tspec, enum TOK tok2)
3984 : Expression(loc, TOKis, sizeof(IftypeExp)) 3986 : Expression(loc, TOKis, sizeof(IsExp))
3985 { 3987 {
3986 this->targ = targ; 3988 this->targ = targ;
3987 this->id = id; 3989 this->id = id;
3988 this->tok = tok; 3990 this->tok = tok;
3989 this->tspec = tspec; 3991 this->tspec = tspec;
3990 this->tok2 = tok2; 3992 this->tok2 = tok2;
3991 } 3993 }
3992 3994
3993 Expression *IftypeExp::syntaxCopy() 3995 Expression *IsExp::syntaxCopy()
3994 { 3996 {
3995 return new IftypeExp(loc, 3997 return new IsExp(loc,
3996 targ->syntaxCopy(), 3998 targ->syntaxCopy(),
3997 id, 3999 id,
3998 tok, 4000 tok,
3999 tspec ? tspec->syntaxCopy() : NULL, 4001 tspec ? tspec->syntaxCopy() : NULL,
4000 tok2); 4002 tok2);
4001 } 4003 }
4002 4004
4003 Expression *IftypeExp::semantic(Scope *sc) 4005 Expression *IsExp::semantic(Scope *sc)
4004 { Type *tded; 4006 { Type *tded;
4005 4007
4006 //printf("IftypeExp::semantic()\n"); 4008 //printf("IsExp::semantic()\n");
4007 if (id && !(sc->flags & SCOPEstaticif)) 4009 if (id && !(sc->flags & SCOPEstaticif))
4008 error("can only declare type aliases within static if conditionals"); 4010 error("can only declare type aliases within static if conditionals");
4009 4011
4010 unsigned errors_save = global.errors; 4012 unsigned errors_save = global.errors;
4011 global.errors = 0; 4013 global.errors = 0;
4199 4201
4200 Lno: 4202 Lno:
4201 return new IntegerExp(0); 4203 return new IntegerExp(0);
4202 } 4204 }
4203 4205
4204 void IftypeExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) 4206 void IsExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
4205 { 4207 {
4206 buf->writestring("is("); 4208 buf->writestring("is(");
4207 targ->toCBuffer(buf, id, hgs); 4209 targ->toCBuffer(buf, id, hgs);
4208 if (tspec) 4210 if (tok2 != TOKreserved)
4211 {
4212 buf->printf(" %s %s", Token::toChars(tok), Token::toChars(tok2));
4213 }
4214 else if (tspec)
4209 { 4215 {
4210 if (tok == TOKcolon) 4216 if (tok == TOKcolon)
4211 buf->writestring(" : "); 4217 buf->writestring(" : ");
4212 else 4218 else
4213 buf->writestring(" == "); 4219 buf->writestring(" == ");
4214 tspec->toCBuffer(buf, NULL, hgs); 4220 tspec->toCBuffer(buf, NULL, hgs);
4215 } 4221 }
4222 #if V2
4223 if (parameters)
4224 { // First parameter is already output, so start with second
4225 for (int i = 1; i < parameters->dim; i++)
4226 {
4227 buf->writeByte(',');
4228 TemplateParameter *tp = (TemplateParameter *)parameters->data[i];
4229 tp->toCBuffer(buf, hgs);
4230 }
4231 }
4232 #endif
4216 buf->writeByte(')'); 4233 buf->writeByte(')');
4217 } 4234 }
4218 4235
4219 4236
4220 /************************************************************/ 4237 /************************************************************/
5306 int i; 5323 int i;
5307 Type *t1; 5324 Type *t1;
5308 int istemp; 5325 int istemp;
5309 5326
5310 #if LOGSEMANTIC 5327 #if LOGSEMANTIC
5311 printf("CallExp::semantic('%s')\n", toChars()); 5328 printf("CallExp::semantic() %s\n", toChars());
5312 #endif 5329 #endif
5313 if (type) 5330 if (type)
5314 return this; // semantic() already run 5331 return this; // semantic() already run
5315 #if 0 5332 #if 0
5316 if (arguments && arguments->dim) 5333 if (arguments && arguments->dim)
5441 if (t1->ty == Tstruct) 5458 if (t1->ty == Tstruct)
5442 { 5459 {
5443 ad = ((TypeStruct *)t1)->sym; 5460 ad = ((TypeStruct *)t1)->sym;
5444 if (search_function(ad, Id::call)) 5461 if (search_function(ad, Id::call))
5445 goto L1; // overload of opCall, therefore it's a call 5462 goto L1; // overload of opCall, therefore it's a call
5463
5464 if (e1->op != TOKtype)
5465 error("%s %s does not overload ()", ad->kind(), ad->toChars());
5446 /* It's a struct literal 5466 /* It's a struct literal
5447 */ 5467 */
5448 Expression *e = new StructLiteralExp(loc, (StructDeclaration *)ad, arguments); 5468 Expression *e = new StructLiteralExp(loc, (StructDeclaration *)ad, arguments);
5449 e = e->semantic(sc); 5469 e = e->semantic(sc);
5450 return e; 5470 return e;