Change how LSLCalc is handled.

Instead of using an option in the command line, use a global in lslcommon, settable by the main program (only the main LSLCalc program, which differs from LSL-PyOptimizer's main, changes it).
This commit is contained in:
Sei Lisa 2016-12-20 21:25:33 +01:00
parent 1b6777e47b
commit 7c2c09188d
3 changed files with 9 additions and 7 deletions

View file

@ -46,4 +46,7 @@ Bugs = set([6495])
# of how LSO's behaviour differs from Mono's in the fine details.
LSO = False
# Set to True by lslcalc's main
IsCalc = False
DataPath = ''

View file

@ -18,7 +18,7 @@
# Convert an abstract syntax tree + symbol table back to a script as text.
import lslfuncs
from lslcommon import Key, Vector, Quaternion
from lslcommon import *
from lslparse import warning
import math
@ -426,7 +426,7 @@ class outscript(object):
if nt == 'EXPR':
return self.dent() + self.OutExpr(child[0]) + (
';\n' if not self.lslcalc else '')
';\n' if not IsCalc else '')
if nt == 'LAMBDA':
return ''
@ -444,7 +444,6 @@ class outscript(object):
self.optsigns = self.optimize and 'optsigns' in options
self.optfloats = self.optimize and 'optfloats' in options
self.foldconst = self.optimize and 'constfold' in options
self.lslcalc = 'lslcalc' in options
self.warntabs = 'warntabs' in options

View file

@ -20,7 +20,7 @@
# TODO: Add info to be able to propagate error position to the source.
from lslcommon import Key, Vector, Quaternion
from lslcommon import *
import lslcommon
import lslfuncs
import sys, re
@ -2621,8 +2621,8 @@ list lazy_list_set(list L, integer i, list v)
self.linestart = True
self.tok = self.GetToken()
self.globals = self.BuildTempGlobalsTable() if \
'lslcalc' not in options else self.funclibrary.copy()
self.globals = self.BuildTempGlobalsTable() if not IsCalc \
else self.funclibrary.copy()
# Restart
@ -2636,7 +2636,7 @@ list lazy_list_set(list L, integer i, list v)
self.usedspots = 0
# Start the parsing proper
if 'lslcalc' in options:
if IsCalc:
self.Parse_single_expression()
else:
self.Parse_script()