From 8d5b595adc194a7958f562698ae120f8afe0412b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 18 Oct 2008 21:45:51 +0000 Subject: [PATCH] - GCC fixes for real this time SVN r1266 (trunk) --- src/thingdef/thingdef_exp.cpp | 222 +++++++++++---------------- src/thingdef/thingdef_expression.cpp | 4 +- 2 files changed, 95 insertions(+), 131 deletions(-) diff --git a/src/thingdef/thingdef_exp.cpp b/src/thingdef/thingdef_exp.cpp index cdea60515..680ac39f3 100644 --- a/src/thingdef/thingdef_exp.cpp +++ b/src/thingdef/thingdef_exp.cpp @@ -244,7 +244,6 @@ static FxExpression *ParseExpressionD (FScanner &sc, const PClass *cls); static FxExpression *ParseExpressionC (FScanner &sc, const PClass *cls); static FxExpression *ParseExpressionB (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) { @@ -441,61 +440,8 @@ static FxExpression *ParseExpressionB (FScanner &sc, const PClass *cls) } } -//========================================================================== -// -// ParseExpressionB -// -//========================================================================== 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); if (sc.CheckToken('(')) @@ -520,6 +466,34 @@ static FxExpression *ParseExpression0 (FScanner &sc, const PClass *cls) { 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(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)) { FName identifier = FName(sc.String); @@ -586,85 +560,74 @@ static FxExpression *ParseExpression0 (FScanner &sc, const PClass *cls) 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: - 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 *data = new FxExpression; - data->Type = EX_Sin; - data->ValueType = VAL_Float; - - data->Children[0] = ParseExpressionM (sc, cls); - - sc.MustGetToken(')'); - return data; + FxExpression *right = new FxExpression; + right->Type = EX_Right; + right->Children[0] = ParseExpressionM (sc, cls); + *left = right; + left = &right->Children[1]; } - else if (identifier == NAME_Cos) - { - sc.MustGetToken('('); + *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"); - FxExpression *data = new FxExpression; - 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); + return data; } - /* // Check if this is a constant if (cls != NULL) { @@ -704,15 +667,16 @@ static FxExpression *ParseExpression0 (FScanner &sc, const PClass *cls) sc.MustGetToken(']'); } return data; - */ + } + break; } } else { FString tokname = sc.TokenName(sc.TokenType, sc.String); sc.ScriptError ("Unexpected token %s", tokname.GetChars()); + return NULL; } - return NULL; } // @@ -938,4 +902,4 @@ static FxExpression *ParseExpressionA (FScanner &sc, const PClass *cls) } } -*/ +*/ \ No newline at end of file diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index b5b9663cf..ebe10c467 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -912,7 +912,7 @@ FxExpression *FxBinaryInt::Resolve(FCompileContext& ctx) FxExpression *e = new FxConstant( Operator == TK_LShift? 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 : 0, ScriptPosition); @@ -940,7 +940,7 @@ ExpVal FxBinaryInt::EvalExpression (AActor *self, const PClass *cls) ret.Int = Operator == TK_LShift? 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 : 0;