Merge DMD r304: refactor invariant => immutable

---
 dmd/cast.c        |    2 +-
 dmd/declaration.c |    2 +-
 dmd/declaration.h |    3 +--
 dmd/doc.c         |    2 +-
 dmd/expression.c  |    6 +++---
 dmd/interpret.c   |    4 ++--
 dmd/mtype.c       |    2 +-
 dmd/mtype.h       |    2 +-
 dmd/parse.c       |    4 ++--
 dmd/struct.c      |    2 +-
 10 files changed, 14 insertions(+), 15 deletions(-)
This commit is contained in:
Leandro Lucarella
2010-01-06 15:18:22 -03:00
parent 6e61ecee6b
commit 4d74a325fc
10 changed files with 14 additions and 15 deletions

View File

@@ -375,7 +375,7 @@ MATCH StructLiteralExp::implicitConvTo(Type *t)
if (t->mod == 0)
te = te->mutableOf();
else
{ assert(t->mod == MODinvariant);
{ assert(t->mod == MODimmutable);
te = te->invariantOf();
}
MATCH m2 = e->implicitConvTo(te);

View File

@@ -140,7 +140,7 @@ void Declaration::checkModify(Loc loc, Scope *sc, Type *t)
const char *p = NULL;
if (isConst())
p = "const";
else if (isInvariant())
else if (isImmutable())
p = "immutable";
else if (storage_class & STCmanifest)
p = "enum";

View File

@@ -67,7 +67,6 @@ enum STC
STCctorinit = 0x20000, // can only be set inside constructor
STCtemplateparameter = 0x40000, // template parameter
STCscope = 0x80000, // template parameter
STCinvariant = 0x100000,
STCimmutable = 0x100000,
STCref = 0x200000,
STCinit = 0x400000, // has explicit initializer
@@ -131,7 +130,7 @@ struct Declaration : Dsymbol
int isFinal() { return storage_class & STCfinal; }
int isAbstract() { return storage_class & STCabstract; }
int isConst() { return storage_class & STCconst; }
int isInvariant() { return storage_class & STCinvariant; }
int isImmutable() { return storage_class & STCimmutable; }
int isAuto() { return storage_class & STCauto; }
int isScope() { return storage_class & STCscope; }
int isSynchronized() { return storage_class & STCsynchronized; }

View File

@@ -678,7 +678,7 @@ void prefix(OutBuffer *buf, Dsymbol *s)
if (d->isConst())
buf->writestring("const ");
#if DMDV2
if (d->isInvariant())
if (d->isImmutable())
buf->writestring("immutable ");
#endif
if (d->isFinal())

View File

@@ -4083,7 +4083,7 @@ Expression *VarExp::semantic(Scope *sc)
#if DMDV2
if (sc->func && sc->func->isPure() && !sc->intypeof)
{
if (v->isDataseg() && !v->isInvariant())
if (v->isDataseg() && !v->isImmutable())
error("pure function '%s' cannot access mutable static data '%s'", sc->func->toChars(), v->toChars());
}
#endif
@@ -4763,7 +4763,7 @@ Expression *IsExp::semantic(Scope *sc)
case TOKinvariant:
case TOKimmutable:
if (!targ->isInvariant())
if (!targ->isImmutable())
goto Lno;
tded = targ;
break;
@@ -7426,7 +7426,7 @@ void CastExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
case MODconst:
buf->writestring(Token::tochars[TOKconst]);
break;
case MODinvariant:
case MODimmutable:
buf->writestring(Token::tochars[TOKimmutable]);
break;
case MODshared:

View File

@@ -993,7 +993,7 @@ Expression *getVarExp(Loc loc, InterState *istate, Declaration *d)
if (v)
{
#if DMDV2
if ((v->isConst() || v->isInvariant() || v->storage_class & STCmanifest) && v->init && !v->value)
if ((v->isConst() || v->isImmutable() || v->storage_class & STCmanifest) && v->init && !v->value)
#else
if (v->isConst() && v->init)
#endif
@@ -1051,7 +1051,7 @@ Expression *DeclarationExp::interpret(InterState *istate)
e = NULL;
}
#if DMDV2
else if (s == v && (v->isConst() || v->isInvariant()) && v->init)
else if (s == v && (v->isConst() || v->isImmutable()) && v->init)
#else
else if (s == v && v->isConst() && v->init)
#endif

View File

@@ -421,7 +421,7 @@ void Type::toCBuffer3(OutBuffer *buf, HdrGenState *hgs, int mod)
case MODconst:
p = "const(";
goto L1;
case MODinvariant:
case MODimmutable:
p = "invariant(";
L1: buf->writestring(p);
toCBuffer2(buf, hgs, this->mod);

View File

@@ -122,7 +122,7 @@ struct Type : Object
/* pick this order of numbers so switch statements work better
*/
#define MODconst 1 // type is const
#define MODinvariant 4 // type is invariant
#define MODimmutable 4 // type is invariant
#define MODshared 2 // type is shared
char *deco;
Type *pto; // merged pointer to this type

View File

@@ -222,7 +222,7 @@ Array *Parser::parseDeclDefs(int once)
s = parseInvariant();
else
{
stc = STCinvariant;
stc = STCimmutable;
goto Lstc;
}
#endif
@@ -303,7 +303,7 @@ Array *Parser::parseDeclDefs(int once)
case TOKabstract: stc |= STCabstract; goto Lstc;
case TOKsynchronized: stc |= STCsynchronized; goto Lstc;
case TOKdeprecated: stc |= STCdeprecated; goto Lstc;
//case TOKinvariant: stc |= STCinvariant; goto Lstc;
//case TOKinvariant: stc |= STCimmutable; goto Lstc;
default:
break;
}

View File

@@ -281,7 +281,7 @@ void StructDeclaration::semantic(Scope *sc)
if (sc->stc & STCabstract)
error("structs, unions cannot be abstract");
#if DMDV2
if (storage_class & STCinvariant)
if (storage_class & STCimmutable)
type = type->invariantOf();
else if (storage_class & STCconst)
type = type->constOf();