mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
mantis 8933: disable some YEngine excessive implicit cast
This commit is contained in:
@@ -1020,35 +1020,36 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
TokenType stkTokType = tokenTypeObj; // stack has a type 'object' on it now
|
||||
Type argSysType = argTokType.ToSysType(); // this is the type the script expects
|
||||
if(argSysType == typeof(double))
|
||||
{ // LSL_Float/double -> double
|
||||
{ // LSL_Float/double -> double
|
||||
ilGen.Emit(declFunc, OpCodes.Call, ehArgUnwrapFloat);
|
||||
stkTokType = tokenTypeFlt; // stack has a type 'double' on it now
|
||||
}
|
||||
if(argSysType == typeof(int))
|
||||
{ // LSL_Integer/int -> int
|
||||
else if (argSysType == typeof(int))
|
||||
{ // LSL_Integer/int -> int
|
||||
ilGen.Emit(declFunc, OpCodes.Call, ehArgUnwrapInteger);
|
||||
stkTokType = tokenTypeInt; // stack has a type 'int' on it now
|
||||
}
|
||||
if(argSysType == typeof(LSL_List))
|
||||
{ // LSL_List -> LSL_List
|
||||
else if (argSysType == typeof(LSL_List))
|
||||
{ // LSL_List -> LSL_List
|
||||
TypeCast.CastTopOfStack(this, argVar.name, stkTokType, argTokType, true);
|
||||
stkTokType = argTokType; // stack has a type 'LSL_List' on it now
|
||||
}
|
||||
if(argSysType == typeof(LSL_Rotation))
|
||||
{ // OpenMetaverse.Quaternion/LSL_Rotation -> LSL_Rotation
|
||||
else if (argSysType == typeof(LSL_Rotation))
|
||||
{ // OpenMetaverse.Quaternion/LSL_Rotation -> LSL_Rotation
|
||||
ilGen.Emit(declFunc, OpCodes.Call, ehArgUnwrapRotation);
|
||||
stkTokType = tokenTypeRot; // stack has a type 'LSL_Rotation' on it now
|
||||
}
|
||||
if(argSysType == typeof(string))
|
||||
{ // LSL_Key/LSL_String/string -> string
|
||||
else if (argSysType == typeof(string))
|
||||
{ // LSL_Key/LSL_String/string -> string
|
||||
ilGen.Emit(declFunc, OpCodes.Call, ehArgUnwrapString);
|
||||
stkTokType = tokenTypeStr; // stack has a type 'string' on it now
|
||||
}
|
||||
if(argSysType == typeof(LSL_Vector))
|
||||
{ // OpenMetaverse.Vector3/LSL_Vector -> LSL_Vector
|
||||
else if (argSysType == typeof(LSL_Vector))
|
||||
{ // OpenMetaverse.Vector3/LSL_Vector -> LSL_Vector
|
||||
ilGen.Emit(declFunc, OpCodes.Call, ehArgUnwrapVector);
|
||||
stkTokType = tokenTypeVec; // stack has a type 'LSL_Vector' on it now
|
||||
}
|
||||
|
||||
local.PopPost(this, argVar.name, stkTokType); // pop stack type into argtype
|
||||
}
|
||||
|
||||
@@ -4001,39 +4002,39 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
CompValu cVal = null;
|
||||
if(rVal is TokenRValAsnPost)
|
||||
cVal = GenerateFromRValAsnPost((TokenRValAsnPost)rVal);
|
||||
if(rVal is TokenRValAsnPre)
|
||||
else if (rVal is TokenRValAsnPre)
|
||||
cVal = GenerateFromRValAsnPre((TokenRValAsnPre)rVal);
|
||||
if(rVal is TokenRValCall)
|
||||
else if (rVal is TokenRValCall)
|
||||
cVal = GenerateFromRValCall((TokenRValCall)rVal);
|
||||
if(rVal is TokenRValCast)
|
||||
else if (rVal is TokenRValCast)
|
||||
cVal = GenerateFromRValCast((TokenRValCast)rVal);
|
||||
if(rVal is TokenRValCondExpr)
|
||||
else if (rVal is TokenRValCondExpr)
|
||||
cVal = GenerateFromRValCondExpr((TokenRValCondExpr)rVal);
|
||||
if(rVal is TokenRValConst)
|
||||
else if (rVal is TokenRValConst)
|
||||
cVal = GenerateFromRValConst((TokenRValConst)rVal);
|
||||
if(rVal is TokenRValInitDef)
|
||||
else if (rVal is TokenRValInitDef)
|
||||
cVal = GenerateFromRValInitDef((TokenRValInitDef)rVal);
|
||||
if(rVal is TokenRValIsType)
|
||||
else if (rVal is TokenRValIsType)
|
||||
cVal = GenerateFromRValIsType((TokenRValIsType)rVal);
|
||||
if(rVal is TokenRValList)
|
||||
else if (rVal is TokenRValList)
|
||||
cVal = GenerateFromRValList((TokenRValList)rVal);
|
||||
if(rVal is TokenRValNewArIni)
|
||||
else if (rVal is TokenRValNewArIni)
|
||||
cVal = GenerateFromRValNewArIni((TokenRValNewArIni)rVal);
|
||||
if(rVal is TokenRValOpBin)
|
||||
else if (rVal is TokenRValOpBin)
|
||||
cVal = GenerateFromRValOpBin((TokenRValOpBin)rVal);
|
||||
if(rVal is TokenRValOpUn)
|
||||
else if (rVal is TokenRValOpUn)
|
||||
cVal = GenerateFromRValOpUn((TokenRValOpUn)rVal);
|
||||
if(rVal is TokenRValParen)
|
||||
else if (rVal is TokenRValParen)
|
||||
cVal = GenerateFromRValParen((TokenRValParen)rVal);
|
||||
if(rVal is TokenRValRot)
|
||||
else if (rVal is TokenRValRot)
|
||||
cVal = GenerateFromRValRot((TokenRValRot)rVal);
|
||||
if(rVal is TokenRValThis)
|
||||
else if (rVal is TokenRValThis)
|
||||
cVal = GenerateFromRValThis((TokenRValThis)rVal);
|
||||
if(rVal is TokenRValUndef)
|
||||
else if (rVal is TokenRValUndef)
|
||||
cVal = GenerateFromRValUndef((TokenRValUndef)rVal);
|
||||
if(rVal is TokenRValVec)
|
||||
else if (rVal is TokenRValVec)
|
||||
cVal = GenerateFromRValVec((TokenRValVec)rVal);
|
||||
if(rVal is TokenLVal)
|
||||
else if (rVal is TokenLVal)
|
||||
cVal = GenerateFromLVal((TokenLVal)rVal, argsig);
|
||||
|
||||
if(cVal == null)
|
||||
@@ -5616,7 +5617,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
outRVal.Pop(this, opcode); // pop into result
|
||||
return outRVal; // tell caller where we put it
|
||||
}
|
||||
if(inRVal.type is TokenTypeBool)
|
||||
if (inRVal.type is TokenTypeBool)
|
||||
{
|
||||
CompValuTemp outRVal = new CompValuTemp(new TokenTypeInt(opcode), this);
|
||||
inRVal.PushVal(this, opcode, outRVal.type); // push value to negate, make sure not LSL-boxed
|
||||
|
||||
@@ -6724,7 +6724,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
if(val is int)
|
||||
nval = (char)(int)val;
|
||||
}
|
||||
if(castTo is TokenTypeFloat)
|
||||
else if (castTo is TokenTypeFloat)
|
||||
{
|
||||
if(val is double)
|
||||
return rVal;
|
||||
@@ -6733,7 +6733,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
if(val is string)
|
||||
nval = new LSL_Float((string)val).value;
|
||||
}
|
||||
if(castTo is TokenTypeInt)
|
||||
else if (castTo is TokenTypeInt)
|
||||
{
|
||||
if(val is int)
|
||||
return rVal;
|
||||
@@ -6744,14 +6744,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
if(val is string)
|
||||
nval = new LSL_Integer((string)val).value;
|
||||
}
|
||||
if(castTo is TokenTypeRot)
|
||||
else if (castTo is TokenTypeRot)
|
||||
{
|
||||
if(val is LSL_Rotation)
|
||||
return rVal;
|
||||
if(val is string)
|
||||
nval = new LSL_Rotation((string)val);
|
||||
}
|
||||
if((castTo is TokenTypeKey) || (castTo is TokenTypeStr))
|
||||
else if ((castTo is TokenTypeKey) || (castTo is TokenTypeStr))
|
||||
{
|
||||
if(val is string)
|
||||
nval = val; // in case of key/string conversion
|
||||
@@ -6766,13 +6766,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
if(val is LSL_Vector)
|
||||
nval = TypeCast.VectorToString((LSL_Vector)val);
|
||||
}
|
||||
if(castTo is TokenTypeVec)
|
||||
else if (castTo is TokenTypeVec)
|
||||
{
|
||||
if(val is LSL_Vector)
|
||||
return rVal;
|
||||
if(val is string)
|
||||
nval = new LSL_Vector((string)val);
|
||||
}
|
||||
|
||||
if(nval != null)
|
||||
{
|
||||
TokenRVal rValConst = new TokenRValConst(castTo, nval);
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
// EXPLICIT type casts (an * is in middle of the key)
|
||||
// In general, only mark explicit if it might throw an exception
|
||||
ltc.Add("array object", TypeCastArray2Object);
|
||||
ltc.Add("bool float", TypeCastBool2Float);
|
||||
ltc.Add("bool*float", TypeCastBool2Float);
|
||||
ltc.Add("bool integer", TypeCastBool2Integer);
|
||||
ltc.Add("bool list", TypeCastBool2List);
|
||||
ltc.Add("bool object", TypeCastBool2Object);
|
||||
@@ -127,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
ltc.Add("exception object", TypeCastExc2Object);
|
||||
ltc.Add("exception string", TypeCastExc2String);
|
||||
ltc.Add("float bool", TypeCastFloat2Bool);
|
||||
ltc.Add("float integer", TypeCastFloat2Integer);
|
||||
ltc.Add("float*integer", TypeCastFloat2Integer);
|
||||
ltc.Add("float list", TypeCastFloat2List);
|
||||
ltc.Add("float object", TypeCastFloat2Object);
|
||||
ltc.Add("float string", TypeCastFloat2String);
|
||||
@@ -155,12 +155,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
ltc.Add("rotation object", TypeCastRotation2Object);
|
||||
ltc.Add("rotation string", TypeCastRotation2String);
|
||||
ltc.Add("string bool", TypeCastString2Bool);
|
||||
ltc.Add("string float", TypeCastString2Float);
|
||||
ltc.Add("string integer", TypeCastString2Integer);
|
||||
ltc.Add("string*float", TypeCastString2Float);
|
||||
ltc.Add("string*integer", TypeCastString2Integer);
|
||||
ltc.Add("string list", TypeCastString2List);
|
||||
ltc.Add("string object", TypeCastString2Object);
|
||||
ltc.Add("string rotation", TypeCastString2Rotation);
|
||||
ltc.Add("string vector", TypeCastString2Vector);
|
||||
ltc.Add("string*rotation", TypeCastString2Rotation);
|
||||
ltc.Add("string*vector", TypeCastString2Vector);
|
||||
ltc.Add("vector bool", TypeCastVector2Bool);
|
||||
ltc.Add("vector list", TypeCastVector2List);
|
||||
ltc.Add("vector object", TypeCastVector2Object);
|
||||
@@ -504,17 +504,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
*/
|
||||
public static void LSLUnwrap(IScriptCodeGen scg, Token errorAt, TokenType type)
|
||||
{
|
||||
if(type.ToLSLWrapType() == typeof(LSL_Float))
|
||||
Type t = type.ToLSLWrapType();
|
||||
if (t == typeof(LSL_String))
|
||||
{
|
||||
scg.ilGen.Emit(errorAt, OpCodes.Ldfld, lslFloatValueFieldInfo);
|
||||
scg.ilGen.Emit(errorAt, OpCodes.Ldfld, lslStringValueFieldInfo);
|
||||
}
|
||||
if(type.ToLSLWrapType() == typeof(LSL_Integer))
|
||||
else if(t == typeof(LSL_Integer))
|
||||
{
|
||||
scg.ilGen.Emit(errorAt, OpCodes.Ldfld, lslIntegerValueFieldInfo);
|
||||
}
|
||||
if(type.ToLSLWrapType() == typeof(LSL_String))
|
||||
else if (t == typeof(LSL_Float))
|
||||
{
|
||||
scg.ilGen.Emit(errorAt, OpCodes.Ldfld, lslStringValueFieldInfo);
|
||||
scg.ilGen.Emit(errorAt, OpCodes.Ldfld, lslFloatValueFieldInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,17 +524,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
||||
*/
|
||||
private static void LSLWrap(IScriptCodeGen scg, Token errorAt, TokenType type)
|
||||
{
|
||||
if(type.ToLSLWrapType() == typeof(LSL_Float))
|
||||
Type t = type.ToLSLWrapType();
|
||||
if (t == typeof(LSL_String))
|
||||
{
|
||||
scg.ilGen.Emit(errorAt, OpCodes.Newobj, lslFloatConstructorInfo);
|
||||
scg.ilGen.Emit(errorAt, OpCodes.Newobj, lslStringConstructorInfo);
|
||||
}
|
||||
if(type.ToLSLWrapType() == typeof(LSL_Integer))
|
||||
else if (t == typeof(LSL_Integer))
|
||||
{
|
||||
scg.ilGen.Emit(errorAt, OpCodes.Newobj, lslIntegerConstructorInfo);
|
||||
}
|
||||
if(type.ToLSLWrapType() == typeof(LSL_String))
|
||||
else if (t == typeof(LSL_Float))
|
||||
{
|
||||
scg.ilGen.Emit(errorAt, OpCodes.Newobj, lslStringConstructorInfo);
|
||||
scg.ilGen.Emit(errorAt, OpCodes.Newobj, lslFloatConstructorInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user