mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-03 00:18:20 +00:00
Fix Python gotcha with module globals, and missing 'cond' in lslextrafuncs.
The previous commit didn't work as expected. "from module import var" freezes the value at load time; changing it later has no effect. A reference to the module needs to be used. Fix that and the similar problem with LSO. Also revert some "from lslcommon import *" introduced earlier. That also revealed another bug about missing 'cond' in the import list of lslextrafuncs. This should fix all functions that return values on null key input.
This commit is contained in:
parent
7c2c09188d
commit
991e811f2d
4 changed files with 12 additions and 10 deletions
|
@ -475,7 +475,7 @@ def InternalUTF8toString(s):
|
||||||
# NOTE: Without the above line, the following one hits a bug in
|
# NOTE: Without the above line, the following one hits a bug in
|
||||||
# python-coverage. It IS executed but not detected.
|
# python-coverage. It IS executed but not detected.
|
||||||
continue
|
continue
|
||||||
if LSO:
|
if lslcommon.LSO:
|
||||||
raise ELSONotSupported(u"Byte strings not supported")
|
raise ELSONotSupported(u"Byte strings not supported")
|
||||||
ret += u'?' * len(partialchar)
|
ret += u'?' * len(partialchar)
|
||||||
partialchar = b''
|
partialchar = b''
|
||||||
|
@ -484,14 +484,14 @@ def InternalUTF8toString(s):
|
||||||
partialchar = c
|
partialchar = c
|
||||||
pending = 1 if o < 0xE0 else 2 if o < 0xF0 else 3
|
pending = 1 if o < 0xE0 else 2 if o < 0xF0 else 3
|
||||||
elif o >= 0x80:
|
elif o >= 0x80:
|
||||||
if LSO:
|
if lslcommon.LSO:
|
||||||
raise ELSONotSupported(u"Byte strings not supported")
|
raise ELSONotSupported(u"Byte strings not supported")
|
||||||
ret += u'?'
|
ret += u'?'
|
||||||
else:
|
else:
|
||||||
ret += c.decode('utf8')
|
ret += c.decode('utf8')
|
||||||
|
|
||||||
if partialchar:
|
if partialchar:
|
||||||
if LSO:
|
if lslcommon.LSO:
|
||||||
raise ELSONotSupported(u"Byte strings not supported")
|
raise ELSONotSupported(u"Byte strings not supported")
|
||||||
ret += u'?' * len(partialchar)
|
ret += u'?' * len(partialchar)
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,10 @@
|
||||||
|
|
||||||
# Extra functions that have predictable return values for certain arguments.
|
# Extra functions that have predictable return values for certain arguments.
|
||||||
|
|
||||||
from lslcommon import *
|
import lslcommon
|
||||||
|
from lslcommon import Key #, Vector, Quaternion
|
||||||
from lslbasefuncs import ELSLCantCompute, isinteger, iskey, islist, \
|
from lslbasefuncs import ELSLCantCompute, isinteger, iskey, islist, \
|
||||||
isvector, isstring, NULL_KEY, ZERO_VECTOR, ZERO_ROTATION
|
isvector, isstring, NULL_KEY, ZERO_VECTOR, ZERO_ROTATION, cond
|
||||||
#isfloat, isrotation
|
#isfloat, isrotation
|
||||||
|
|
||||||
TouchEvents = ('touch', 'touch_start', 'touch_end')
|
TouchEvents = ('touch', 'touch_start', 'touch_end')
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
# Convert an abstract syntax tree + symbol table back to a script as text.
|
# Convert an abstract syntax tree + symbol table back to a script as text.
|
||||||
|
|
||||||
import lslfuncs
|
import lslfuncs
|
||||||
from lslcommon import *
|
import lslcommon
|
||||||
|
from lslcommon import Key, Vector, Quaternion
|
||||||
from lslparse import warning
|
from lslparse import warning
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
@ -426,7 +427,7 @@ class outscript(object):
|
||||||
|
|
||||||
if nt == 'EXPR':
|
if nt == 'EXPR':
|
||||||
return self.dent() + self.OutExpr(child[0]) + (
|
return self.dent() + self.OutExpr(child[0]) + (
|
||||||
';\n' if not IsCalc else '')
|
';\n' if not lslcommon.IsCalc else '')
|
||||||
|
|
||||||
if nt == 'LAMBDA':
|
if nt == 'LAMBDA':
|
||||||
return ''
|
return ''
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
# TODO: Add info to be able to propagate error position to the source.
|
# TODO: Add info to be able to propagate error position to the source.
|
||||||
|
|
||||||
from lslcommon import *
|
from lslcommon import Key, Vector, Quaternion
|
||||||
import lslcommon
|
import lslcommon
|
||||||
import lslfuncs
|
import lslfuncs
|
||||||
import sys, re
|
import sys, re
|
||||||
|
@ -2621,7 +2621,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
self.linestart = True
|
self.linestart = True
|
||||||
self.tok = self.GetToken()
|
self.tok = self.GetToken()
|
||||||
|
|
||||||
self.globals = self.BuildTempGlobalsTable() if not IsCalc \
|
self.globals = self.BuildTempGlobalsTable() if not lslcommon.IsCalc \
|
||||||
else self.funclibrary.copy()
|
else self.funclibrary.copy()
|
||||||
|
|
||||||
# Restart
|
# Restart
|
||||||
|
@ -2636,7 +2636,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
self.usedspots = 0
|
self.usedspots = 0
|
||||||
|
|
||||||
# Start the parsing proper
|
# Start the parsing proper
|
||||||
if IsCalc:
|
if lslcommon.IsCalc:
|
||||||
self.Parse_single_expression()
|
self.Parse_single_expression()
|
||||||
else:
|
else:
|
||||||
self.Parse_script()
|
self.Parse_script()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue