mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Move the print_node() subtree dump debug function to lslcommon.
This commit is contained in:
parent
ef6ed30536
commit
e4eaab9e84
2 changed files with 23 additions and 25 deletions
|
@ -70,3 +70,26 @@ LSLType2Python = {'integer':int, 'float':float,
|
|||
def warning(txt):
|
||||
assert type(txt) == unicode
|
||||
sys.stderr.write(u"WARNING: " + txt + u"\n")
|
||||
|
||||
# Debug function
|
||||
def print_node(node, indent = 0):
|
||||
nt = node['nt']
|
||||
write = sys.stdout.write
|
||||
spaces = ' ' * (indent*4+2)
|
||||
write('%s{ nt:%s\n' % (' '*(indent*4), nt))
|
||||
if 't' in node:
|
||||
write('%s,t:%s\n' % (spaces, node['t']))
|
||||
if 'name' in node:
|
||||
write('%s,name:%s\n' % (spaces, node['name']))
|
||||
if 'value' in node:
|
||||
write('%s,value:%s\n' % (spaces, repr(node['value'])))
|
||||
|
||||
for prop in node:
|
||||
if prop not in ('ch', 'nt', 't', 'name', 'value','X','SEF'):
|
||||
write('%s,%s:%s\n' % (spaces, prop, repr(node[prop])))
|
||||
if 'ch' in node:
|
||||
write(spaces + ',ch:[\n')
|
||||
for subnode in node['ch']:
|
||||
print_node(subnode, indent+1)
|
||||
write(spaces + ']\n')
|
||||
write(' '*(indent*4) + '}\n\n')
|
||||
|
|
|
@ -25,31 +25,6 @@ import math
|
|||
from lslfuncopt import OptimizeFunc, OptimizeArgs, FuncOptSetup
|
||||
|
||||
|
||||
# Debug
|
||||
import sys
|
||||
def print_node(node, indent):
|
||||
nt = node['nt']
|
||||
write = sys.stdout.write
|
||||
spaces = ' ' * (indent*4+2)
|
||||
write('%s{ nt:%s\n' % (' '*(indent*4), nt))
|
||||
if 't' in node:
|
||||
write('%s,t:%s\n' % (spaces, node['t']))
|
||||
if 'name' in node:
|
||||
write('%s,name:%s\n' % (spaces, node['name']))
|
||||
if 'value' in node:
|
||||
write('%s,value:%s\n' % (spaces, repr(node['value'])))
|
||||
|
||||
for prop in node:
|
||||
if prop not in ('ch', 'nt', 't', 'name', 'value','X','SEF'):
|
||||
write('%s,%s:%s\n' % (spaces, prop, repr(node[prop])))
|
||||
if 'ch' in node:
|
||||
write(spaces + ',ch:[\n')
|
||||
for subnode in node['ch']:
|
||||
print_node(subnode, indent+1)
|
||||
write(spaces + ']\n')
|
||||
write(' '*(indent*4) + '}\n\n')
|
||||
|
||||
|
||||
class foldconst(object):
|
||||
|
||||
def isLocalVar(self, node):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue