- 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,85 +560,74 @@ static FxExpression *ParseExpression0 (FScanner &sc, const PClass *cls)
return new FxAbs(x); return new FxAbs(x);
} }
case NAME_Sin:
{
sc.MustGetToken('(');
FxExpression *data = new FxExpression;
data->Type = EX_Sin;
data->ValueType = VAL_Float;
data->Children[0] = ParseExpressionM (sc, cls);
sc.MustGetToken(')');
return data;
}
break;
case NAME_Cos:
{
sc.MustGetToken('(');
FxExpression *data = new FxExpression;
data->Type = EX_Cos;
data->ValueType = VAL_Float;
data->Children[0] = ParseExpressionM (sc, cls);
sc.MustGetToken(')');
return data;
}
break;
default: default:
if (sc.CheckToken('(')) {
int specnum, min_args, max_args;
// Check if this is an action special
specnum = P_FindLineSpecial (sc.String, &min_args, &max_args);
if (specnum != 0 && min_args >= 0)
{ {
if (identifier == NAME_Sin) int i;
sc.MustGetToken('(');
FxExpression *data = new FxExpression, **left;
data->Type = EX_ActionSpecial;
data->Value.Int = specnum;
data->ValueType = VAL_Int;
data->Children[0] = ParseExpressionM (sc, cls);
left = &data->Children[1];
for (i = 1; i < 5 && sc.CheckToken(','); ++i)
{ {
sc.MustGetToken('('); FxExpression *right = new FxExpression;
right->Type = EX_Right;
FxExpression *data = new FxExpression; right->Children[0] = ParseExpressionM (sc, cls);
data->Type = EX_Sin; *left = right;
data->ValueType = VAL_Float; left = &right->Children[1];
data->Children[0] = ParseExpressionM (sc, cls);
sc.MustGetToken(')');
return data;
} }
else if (identifier == NAME_Cos) *left = NULL;
{ sc.MustGetToken(')');
sc.MustGetToken('('); if (i < min_args)
sc.ScriptError ("Not enough arguments to action special");
if (i > max_args)
sc.ScriptError ("Too many arguments to action special");
FxExpression *data = new FxExpression; return data;
data->Type = EX_Cos;
data->ValueType = VAL_Float;
data->Children[0] = ParseExpressionM (sc, cls);
sc.MustGetToken(')');
return data;
}
else
{
int specnum, min_args, max_args;
// Check if this is an action special
specnum = P_FindLineSpecial (sc.String, &min_args, &max_args);
if (specnum != 0 && min_args >= 0)
{
int i;
sc.MustGetToken('(');
FxExpression *data = new FxExpression, **left;
data->Type = EX_ActionSpecial;
data->Value.Int = specnum;
data->ValueType = VAL_Int;
data->Children[0] = ParseExpressionM (sc, cls);
left = &data->Children[1];
for (i = 1; i < 5 && sc.CheckToken(','); ++i)
{
FxExpression *right = new FxExpression;
right->Type = EX_Right;
right->Children[0] = ParseExpressionM (sc, cls);
*left = right;
left = &right->Children[1];
}
*left = NULL;
sc.MustGetToken(')');
if (i < min_args)
sc.ScriptError ("Not enough arguments to action special");
if (i > max_args)
sc.ScriptError ("Too many arguments to action special");
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;
} }
// //
@ -938,4 +902,4 @@ static FxExpression *ParseExpressionA (FScanner &sc, const PClass *cls)
} }
} }
*/ */

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;