Merge branch 'master' into floatcvt

# Conflicts:
#	src/dobjtype.cpp
#	src/dobjtype.h
#	src/version.h
This commit is contained in:
Christoph Oelckers 2016-04-04 01:21:24 +02:00
commit fd27c8db9e
13 changed files with 1220 additions and 101 deletions

View file

@ -525,12 +525,17 @@ static void ParseUserVariable (FScanner &sc, PSymbolTable *symt, PClassActor *cl
// Read the type and make sure it's acceptable.
sc.MustGetAnyToken();
if (sc.TokenType != TK_Int && sc.TokenType != TK_Float)
switch (sc.TokenType)
{
sc.ScriptMessage("User variables must be of type 'int' or 'float'");
case TK_Int: type = TypeSInt32; break;
case TK_Float: type = TypeFloat64; break;
case TK_String: type = TypeString; break;
default:
type = TypeError;
sc.ScriptMessage("User variables must be of type 'int' or 'float' or 'string'");
FScriptPosition::ErrorCounter++;
break;
}
type = sc.TokenType == TK_Int ? (PType *)TypeSInt32 : (PType *)TypeFloat64;
sc.MustGetToken(TK_Identifier);
// For now, restrict user variables to those that begin with "user_" to guarantee
@ -576,11 +581,9 @@ static void ParseUserVariable (FScanner &sc, PSymbolTable *symt, PClassActor *cl
}
sc.MustGetToken(';');
PField *sym = new PField(symname, type, 0);
sym->Offset = cls->Extend(type);
if (symt->AddSymbol(sym) == NULL)
PField *sym = cls->AddField(symname, type, 0);
if (cls == NULL)
{
delete sym;
sc.ScriptMessage ("'%s' is already defined in '%s'.",
symname.GetChars(), cls ? cls->TypeName.GetChars() : "Global");
FScriptPosition::ErrorCounter++;