Fix type conversion on calling LSL functions.

We had a big chaos with type conversion. That caused a bug where passing a key to a function that required a string, or vice versa, crashed the script.

Diminish the chaos by modifying the parameters just prior to invocation (in lslfoldconst). We also remove the, now unnecessary, calls to force floats, either alone or within vectors or quaternions.
This commit is contained in:
Sei Lisa 2016-12-21 06:01:03 +01:00
parent 27eeec06cf
commit 6879037735
4 changed files with 80 additions and 47 deletions

View file

@ -482,6 +482,28 @@ class Test03_Optimizer(UnitTestCase):
self.assertRaises(EParseAlreadyDefined, self.parser.parse,
'default { timer() {} timer() {} }')
p = self.parser.parse('default{timer(){\n'
'llLog(3);llLog(3.0);\n'
'llStringToBase64((key)"");llGetAgentInfo("");\n'
'llStringToBase64("");llGetAgentInfo((key)"");\n'
'}}\n'
)
self.opt.optimize(p, ('optimize','constfold'))
out = self.outscript.output(p)
self.assertEqual(out, 'default\n'
'{\n'
' timer()\n'
' {\n'
' 1.0986123;\n'
' 1.0986123;\n'
' "";\n'
' 0;\n'
' "";\n'
' 0;\n'
' }\n'
'}\n'
)
try:
self.parser.parse('default { timer() { return } }')
# should raise EParseSyntax, so it should never get here