This is an attempt to fix the handling of constants in LSL.

It wraps constants in new LSLType(x), so that lists with
constant values are processed correctly. Contains changes to
the lsl.parser.cs that are not (yet) reflected in opensim-libs,
since this experimental patch affects XEngine only. Also contains
nuts.
0.6.0-stable
Melanie Thielker 2008-09-01 23:33:12 +00:00
parent bfeb3881f2
commit a5d2674a43
3 changed files with 34 additions and 31 deletions

View File

@ -726,16 +726,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
if ("LSL_Types.LSLFloat" == c.Type)
{
int dotIndex = c.Value.IndexOf('.') + 1;
// Skip first dot (in type name)
dotIndex = c.Value.IndexOf('.', dotIndex) + 1;
if (0 < dotIndex && (dotIndex == c.Value.Length || !Char.IsDigit(c.Value[dotIndex])))
c.Value = c.Value.Insert(dotIndex, "0");
}
// commencted because the parser does it now
// need to quote strings
if ("LSL_Types.LSLString" == c.Type)
retstr += Generate("\"");
// if ("LSL_Types.LSLString" == c.Type)
// retstr += Generate("\"");
retstr += Generate(c.Value, c);
if ("LSL_Types.LSLString" == c.Type)
retstr += Generate("\"");
// if ("LSL_Types.LSLString" == c.Type)
// retstr += Generate("\"");
return retstr;
}

View File

@ -1304,24 +1304,24 @@ public class ReturnStatement_2 : ReturnStatement {
public ReturnStatement_2(Parser yyq):base(yyq){}}
public class Constant_1 : Constant {
public Constant_1(Parser yyq):base(yyq,"integer",
public Constant_1(Parser yyq):base(yyq,"integer", "new LSL_Types.LSLInteger("+
((INTEGER_CONSTANT)(yyq.StackAt(0).m_value))
.yytext){}}
.yytext+")"){}}
public class Constant_2 : Constant {
public Constant_2(Parser yyq):base(yyq,"integer",
public Constant_2(Parser yyq):base(yyq,"integer", "new LSL_Types.LSLInteger("+
((HEX_INTEGER_CONSTANT)(yyq.StackAt(0).m_value))
.yytext){}}
.yytext+")"){}}
public class Constant_3 : Constant {
public Constant_3(Parser yyq):base(yyq,"float",
public Constant_3(Parser yyq):base(yyq,"float", "new LSL_Types.LSLFloat("+
((FLOAT_CONSTANT)(yyq.StackAt(0).m_value))
.yytext){}}
.yytext+")"){}}
public class Constant_4 : Constant {
public Constant_4(Parser yyq):base(yyq,"string",
public Constant_4(Parser yyq):base(yyq,"string", "new LSL_Types.LSLString(\""+
((STRING_CONSTANT)(yyq.StackAt(0).m_value))
.yytext){}}
.yytext+"\")"){}}
public class ListConstant_1 : ListConstant {
public ListConstant_1(Parser yyq):base(yyq,

View File

@ -1453,25 +1453,25 @@ namespace OpenSim.Region.ScriptEngine.Shared
return new LSLInteger(i1.value / i2);
}
static public LSLFloat operator +(LSLInteger i1, double f)
{
return new LSLFloat((double)i1.value + f);
}
static public LSLFloat operator -(LSLInteger i1, double f)
{
return new LSLFloat((double)i1.value - f);
}
static public LSLFloat operator *(LSLInteger i1, double f)
{
return new LSLFloat((double)i1.value * f);
}
static public LSLFloat operator /(LSLInteger i1, double f)
{
return new LSLFloat((double)i1.value / f);
}
// static public LSLFloat operator +(LSLInteger i1, double f)
// {
// return new LSLFloat((double)i1.value + f);
// }
//
// static public LSLFloat operator -(LSLInteger i1, double f)
// {
// return new LSLFloat((double)i1.value - f);
// }
//
// static public LSLFloat operator *(LSLInteger i1, double f)
// {
// return new LSLFloat((double)i1.value * f);
// }
//
// static public LSLFloat operator /(LSLInteger i1, double f)
// {
// return new LSLFloat((double)i1.value / f);
// }
static public LSLInteger operator -(LSLInteger i)
{