- GCC fixes for real this time

SVN r1266 (trunk)
This commit is contained in:
Christoph Oelckers 2008-10-18 21:45:51 +00:00
parent 2aac1bf053
commit 8d5b595adc
2 changed files with 95 additions and 131 deletions

View file

@ -244,7 +244,6 @@ static FxExpression *ParseExpressionD (FScanner &sc, const PClass *cls);
static FxExpression *ParseExpressionC (FScanner &sc, const PClass *cls); static FxExpression *ParseExpressionC (FScanner &sc, const PClass *cls);
static FxExpression *ParseExpressionB (FScanner &sc, const PClass *cls); static FxExpression *ParseExpressionB (FScanner &sc, const PClass *cls);
static FxExpression *ParseExpressionA (FScanner &sc, const PClass *cls); static FxExpression *ParseExpressionA (FScanner &sc, const PClass *cls);
static FxExpression *ParseExpression0 (FScanner &sc, const PClass *cls);
FxExpression *ParseExpression (FScanner &sc, PClass *cls) FxExpression *ParseExpression (FScanner &sc, PClass *cls)
{ {
@ -441,61 +440,8 @@ static FxExpression *ParseExpressionB (FScanner &sc, const PClass *cls)
} }
} }
//==========================================================================
//
// ParseExpressionB
//
//==========================================================================
static FxExpression *ParseExpressionA (FScanner &sc, const PClass *cls) static FxExpression *ParseExpressionA (FScanner &sc, const PClass *cls)
{
FxExpression *base_expr = ParseExpression0 (sc, cls);
while(1)
{
FScriptPosition pos(sc);
if (sc.CheckToken('.'))
{
if (sc.CheckToken(TK_Default))
{
sc.MustGetToken('.');
base_expr = new FxClassDefaults(base_expr, pos);
}
sc.MustGetToken(TK_Identifier);
FName FieldName = sc.String;
pos = sc;
/* later!
if (SC_CheckToken('('))
{
if (base_expr->IsDefaultObject())
{
SC_ScriptError("Cannot call methods for default.");
}
base_expr = ParseFunctionCall(base_expr, FieldName, false, false, pos);
}
else
*/
{
base_expr = new FxDotIdentifier(base_expr, FieldName, pos);
}
}
else if (sc.CheckToken('['))
{
FxExpression *index = ParseExpressionM(sc, cls);
sc.MustGetToken(']');
base_expr = new FxArrayElement(base_expr, index, pos);
}
else break;
}
return base_expr;
}
static FxExpression *ParseExpression0 (FScanner &sc, const PClass *cls)
{ {
FScriptPosition scpos(sc); FScriptPosition scpos(sc);
if (sc.CheckToken('(')) if (sc.CheckToken('('))
@ -520,6 +466,34 @@ static FxExpression *ParseExpression0 (FScanner &sc, const PClass *cls)
{ {
return new FxConstant(sc.Float, scpos); return new FxConstant(sc.Float, scpos);
} }
/*
else if (sc.CheckToken(TK_Class))
{
// Accept class'SomeClassName'.SomeConstant
sc.MustGetToken(TK_NameConst);
cls = PClass::FindClass (sc.Name);
if (cls == NULL)
{
sc.ScriptError ("Unknown class '%s'", sc.String);
}
sc.MustGetToken('.');
sc.MustGetToken(TK_Identifier);
PSymbol *sym = cls->Symbols.FindSymbol (sc.String, true);
if (sym != NULL && sym->SymbolType == SYM_Const)
{
FxExpression *data = new FxExpression;
data->Type = EX_Const;
data->Value.Type = VAL_Int;
data->Value.Int = static_cast<PSymbolConst *>(sym)->Value;
return data;
}
else
{
sc.ScriptError ("'%s' is not a constant value in class '%s'", sc.String, cls->TypeName.GetChars());
return NULL;
}
}
*/
else if (sc.CheckToken(TK_Identifier)) else if (sc.CheckToken(TK_Identifier))
{ {
FName identifier = FName(sc.String); FName identifier = FName(sc.String);
@ -586,10 +560,7 @@ static FxExpression *ParseExpression0 (FScanner &sc, const PClass *cls)
return new FxAbs(x); return new FxAbs(x);
} }
default: case NAME_Sin:
if (sc.CheckToken('('))
{
if (identifier == NAME_Sin)
{ {
sc.MustGetToken('('); sc.MustGetToken('(');
@ -602,7 +573,9 @@ static FxExpression *ParseExpression0 (FScanner &sc, const PClass *cls)
sc.MustGetToken(')'); sc.MustGetToken(')');
return data; return data;
} }
else if (identifier == NAME_Cos) break;
case NAME_Cos:
{ {
sc.MustGetToken('('); sc.MustGetToken('(');
@ -615,7 +588,9 @@ static FxExpression *ParseExpression0 (FScanner &sc, const PClass *cls)
sc.MustGetToken(')'); sc.MustGetToken(')');
return data; return data;
} }
else break;
default:
{ {
int specnum, min_args, max_args; int specnum, min_args, max_args;
@ -652,19 +627,7 @@ static FxExpression *ParseExpression0 (FScanner &sc, const PClass *cls)
return data; return data;
} }
else
{
sc.ScriptError("Unknown function '%s'", identifier.GetChars());
}
}
}
else
{
return new FxIdentifier(identifier, sc);
}
/*
// Check if this is a constant // Check if this is a constant
if (cls != NULL) if (cls != NULL)
{ {
@ -704,15 +667,16 @@ static FxExpression *ParseExpression0 (FScanner &sc, const PClass *cls)
sc.MustGetToken(']'); sc.MustGetToken(']');
} }
return data; return data;
*/ }
break;
} }
} }
else else
{ {
FString tokname = sc.TokenName(sc.TokenType, sc.String); FString tokname = sc.TokenName(sc.TokenType, sc.String);
sc.ScriptError ("Unexpected token %s", tokname.GetChars()); sc.ScriptError ("Unexpected token %s", tokname.GetChars());
}
return NULL; return NULL;
}
} }
// //

View file

@ -912,7 +912,7 @@ FxExpression *FxBinaryInt::Resolve(FCompileContext& ctx)
FxExpression *e = new FxConstant( FxExpression *e = new FxConstant(
Operator == TK_LShift? v1 << v2 : Operator == TK_LShift? v1 << v2 :
Operator == TK_RShift? v1 >> v2 : Operator == TK_RShift? v1 >> v2 :
Operator == TK_URShift? int(unsigned int(v1) >> v2) : Operator == TK_URShift? int((unsigned int)(v1) >> v2) :
Operator == '&'? v1 & v2 : Operator == '&'? v1 & v2 :
Operator == '|'? v1 | v2 : Operator == '|'? v1 | v2 :
Operator == '^'? v1 ^ v2 : 0, ScriptPosition); Operator == '^'? v1 ^ v2 : 0, ScriptPosition);
@ -940,7 +940,7 @@ ExpVal FxBinaryInt::EvalExpression (AActor *self, const PClass *cls)
ret.Int = ret.Int =
Operator == TK_LShift? v1 << v2 : Operator == TK_LShift? v1 << v2 :
Operator == TK_RShift? v1 >> v2 : Operator == TK_RShift? v1 >> v2 :
Operator == TK_URShift? int(unsigned int(v1) >> v2) : Operator == TK_URShift? int((unsigned int)(v1) >> v2) :
Operator == '&'? v1 & v2 : Operator == '&'? v1 & v2 :
Operator == '|'? v1 | v2 : Operator == '|'? v1 | v2 :
Operator == '^'? v1 ^ v2 : 0; Operator == '^'? v1 ^ v2 : 0;