Yengine: more on constants operations reduction
parent
bf0697d5f4
commit
730a35eedc
|
@ -66,7 +66,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||
{
|
||||
public static readonly string OBJECT_CODE_MAGIC = "YObjectCode";
|
||||
// reserve positive version values for original xmr
|
||||
public static int COMPILED_VERSION_VALUE = -3; // decremented when compiler or object file changes
|
||||
public static int COMPILED_VERSION_VALUE = -4; // decremented when compiler or object file changes
|
||||
|
||||
public static readonly int CALL_FRAME_MEMUSE = 64;
|
||||
public static readonly int STRING_LEN_TO_MEMUSE = 2;
|
||||
|
|
|
@ -1339,13 +1339,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||
{
|
||||
public TokenKwAndAndAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn)
|
||||
{
|
||||
binOpConst = TokenRValConstOps.Null;
|
||||
binOpConst = TokenRValConstOps.binConstsLogicAndAnd;
|
||||
unOpConst = TokenRValConstOps.Null;
|
||||
sdtClassOp = false;
|
||||
}
|
||||
public TokenKwAndAndAnd(Token original) : base(original)
|
||||
{
|
||||
binOpConst = TokenRValConstOps.Null;
|
||||
binOpConst = TokenRValConstOps.binConstsLogicAndAnd;
|
||||
unOpConst = TokenRValConstOps.Null;
|
||||
sdtClassOp = false;
|
||||
}
|
||||
|
@ -1358,13 +1358,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||
{
|
||||
public TokenKwOrOrOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn)
|
||||
{
|
||||
binOpConst = TokenRValConstOps.Null;
|
||||
binOpConst = TokenRValConstOps.binConstsLoginOrOr;
|
||||
unOpConst = TokenRValConstOps.Null;
|
||||
sdtClassOp = false;
|
||||
}
|
||||
public TokenKwOrOrOr(Token original) : base(original)
|
||||
{
|
||||
binOpConst = TokenRValConstOps.Null;
|
||||
binOpConst = TokenRValConstOps.binConstsLoginOrOr;
|
||||
unOpConst = TokenRValConstOps.Null;
|
||||
sdtClassOp = false;
|
||||
}
|
||||
|
@ -1457,8 +1457,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||
}
|
||||
public class TokenKwAndAnd: TokenKw
|
||||
{
|
||||
public TokenKwAndAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
|
||||
public TokenKwAndAnd(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
|
||||
public TokenKwAndAnd(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.binConstsLogicAndAnd; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
|
||||
public TokenKwAndAnd(Token original) : base(original) { binOpConst = TokenRValConstOps.binConstsLogicAndAnd; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
|
||||
public override string ToString()
|
||||
{
|
||||
return "&&";
|
||||
|
@ -1466,8 +1466,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||
}
|
||||
public class TokenKwOrOr: TokenKw
|
||||
{
|
||||
public TokenKwOrOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
|
||||
public TokenKwOrOr(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
|
||||
public TokenKwOrOr(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.binConstsLoginOrOr; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
|
||||
public TokenKwOrOr(Token original) : base(original) { binOpConst = TokenRValConstOps.binConstsLoginOrOr; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
|
||||
public override string ToString()
|
||||
{
|
||||
return "||";
|
||||
|
@ -1574,8 +1574,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||
}
|
||||
public class TokenKwExclam: TokenKw
|
||||
{
|
||||
public TokenKwExclam(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
|
||||
public TokenKwExclam(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; }
|
||||
public TokenKwExclam(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.unOpExclam; sdtClassOp = true; }
|
||||
public TokenKwExclam(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.unOpExclam; sdtClassOp = true; }
|
||||
public override string ToString()
|
||||
{
|
||||
return "!";
|
||||
|
@ -2201,8 +2201,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||
double r;
|
||||
try
|
||||
{
|
||||
if ((left is int) && (right is int))
|
||||
if ((left is int li) && (right is int ri))
|
||||
{
|
||||
if(li == -2147483648 && ri == -1)
|
||||
return -2147483648;
|
||||
return (int)left / (int)right;
|
||||
}
|
||||
if ((left is double) && (right is int))
|
||||
|
@ -2238,9 +2240,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||
double r;
|
||||
try
|
||||
{
|
||||
if ((left is int) && (right is int))
|
||||
if ((left is int li) && (right is int ri))
|
||||
{
|
||||
return (int)left % (int)right;
|
||||
if (li == -2147483648 && ri == -1)
|
||||
return 0;
|
||||
return li % ri;
|
||||
}
|
||||
if ((left is double) && (right is int))
|
||||
{
|
||||
|
@ -2297,98 +2301,30 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||
{
|
||||
return (int)left & (int)right;
|
||||
}
|
||||
if((left is int) && (right is double))
|
||||
{
|
||||
return (int)left & (int)(double)right;
|
||||
}
|
||||
if((left is double) && (right is int))
|
||||
{
|
||||
return (int)(double)left & (int)right;
|
||||
}
|
||||
if((left is double) && (right is double))
|
||||
{
|
||||
return (int)(double)left & (int)(double)right;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static object LSh(object left, object right)
|
||||
{
|
||||
if((left is int) && (right is int))
|
||||
{
|
||||
return (int)left << (int)right;
|
||||
}
|
||||
if((left is int) && (right is double))
|
||||
{
|
||||
return (int)left << (int)(double)right;
|
||||
}
|
||||
if((left is double) && (right is int))
|
||||
{
|
||||
return (int)(double)left << (int)right;
|
||||
}
|
||||
if((left is double) && (right is double))
|
||||
{
|
||||
return (int)(double)left << (int)(double)right;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static object Or(object left, object right)
|
||||
{
|
||||
if((left is int) && (right is int))
|
||||
{
|
||||
return (int)left | (int)right;
|
||||
}
|
||||
if((left is int) && (right is double))
|
||||
{
|
||||
return (int)left | (int)(double)right;
|
||||
}
|
||||
if((left is double) && (right is int))
|
||||
{
|
||||
return (int)(double)left | (int)right;
|
||||
}
|
||||
if((left is double) && (right is double))
|
||||
{
|
||||
return (int)(double)left | (int)(double)right;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static object RSh(object left, object right)
|
||||
{
|
||||
if((left is int) && (right is int))
|
||||
{
|
||||
return (int)left >> (int)right;
|
||||
}
|
||||
if((left is int) && (right is double))
|
||||
{
|
||||
return (int)left >> (int)(double)right;
|
||||
}
|
||||
if((left is double) && (right is int))
|
||||
{
|
||||
return (int)(double)left >> (int)right;
|
||||
}
|
||||
if((left is double) && (right is double))
|
||||
{
|
||||
return (int)(double)left >> (int)(double)right;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static object Xor(object left, object right)
|
||||
{
|
||||
if((left is int) && (right is int))
|
||||
{
|
||||
return (int)left ^ (int)right;
|
||||
}
|
||||
if((left is int) && (right is double))
|
||||
{
|
||||
return (int)left ^ (int)(double)right;
|
||||
}
|
||||
if((left is double) && (right is int))
|
||||
{
|
||||
return (int)(double)left ^ (int)right;
|
||||
}
|
||||
if((left is double) && (right is double))
|
||||
{
|
||||
return (int)(double)left ^ (int)(double)right;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static object Add(object left, object right)
|
||||
|
@ -2570,12 +2506,49 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||
return null;
|
||||
return (res != 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
public static object binConstsLogicAndAnd(object left, object right)
|
||||
{
|
||||
if ((left is int li) && (right is int ri))
|
||||
{
|
||||
if (li == 0)
|
||||
return 0;
|
||||
if (ri == 0)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
public static object binConstsLoginOrOr(object left, object right)
|
||||
{
|
||||
if ((left is int li) && (right is int ri))
|
||||
{
|
||||
if (li != 0)
|
||||
return 1;
|
||||
if (ri != 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static object unOpExclam(object left)
|
||||
{
|
||||
if ((left is int li))
|
||||
{
|
||||
if (li == 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Various datatypes.
|
||||
*/
|
||||
public abstract class TokenType: Token
|
||||
public abstract class TokenType: Token
|
||||
{
|
||||
|
||||
public TokenType(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { }
|
||||
|
|
|
@ -86,6 +86,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||
m_StackSize = stackSize;
|
||||
m_StackLeft = stackSize;
|
||||
m_HeapSize = heapSize;
|
||||
m_heapUsed = 0;
|
||||
m_CompilerErrors = errors;
|
||||
m_StateFileName = GetStateFileName(scriptBasePath, m_ItemID);
|
||||
|
||||
|
|
Loading…
Reference in New Issue