1.1 --- a/lplc Fri Mar 03 13:41:13 2017 +0100
1.2 +++ b/lplc Fri Mar 03 13:44:32 2017 +0100
1.3 @@ -82,6 +82,12 @@
1.4 else:
1.5 return l, needed
1.6
1.7 +def getvalue(l, i):
1.8 + if l and len(l) > i:
1.9 + return l[i]
1.10 + else:
1.11 + return None
1.12 +
1.13 def remove_all(dirname):
1.14
1.15 "Remove 'dirname' and its contents."
1.16 @@ -145,6 +151,15 @@
1.17 args Show invocations where a callable may be involved that cannot accept
1.18 the arguments provided
1.19
1.20 +Control over program organisation can be exercised using the following options
1.21 +with each requiring an input filename providing a particular form of
1.22 +information:
1.23 +
1.24 +--attr-codes Attribute codes identifying named object attributes
1.25 +--attr-locations Attribute locations in objects
1.26 +--param-codes Parameter codes identifying named parameters
1.27 +--param-locations Parameter locations in signatures
1.28 +
1.29 The following informational options can be specified to produce output instead
1.30 of compiling a program:
1.31
1.32 @@ -171,11 +186,16 @@
1.33
1.34 # Determine the options and arguments.
1.35
1.36 + attrnames = []
1.37 + attrlocations = []
1.38 debug = False
1.39 gc_sections = False
1.40 ignore_env = False
1.41 make = True
1.42 make_verbose = True
1.43 + outputs = []
1.44 + paramnames = []
1.45 + paramlocations = []
1.46 reset = False
1.47 reset_all = False
1.48 timings = True
1.49 @@ -185,7 +205,6 @@
1.50
1.51 unrecognised = []
1.52 filenames = []
1.53 - outputs = []
1.54
1.55 # Obtain program filenames by default.
1.56
1.57 @@ -193,10 +212,15 @@
1.58 needed = None
1.59
1.60 for arg in args:
1.61 - if arg in ("-c", "--compile"): make = False
1.62 + if arg == "--attr-codes": l = attrnames; needed = 1
1.63 + elif arg == "--attr-locations": l = attrlocations; needed = 1
1.64 + elif arg in ("-c", "--compile"): make = False
1.65 elif arg in ("-E", "--no-env"): ignore_env = True
1.66 elif arg in ("-g", "--debug"): debug = True
1.67 elif arg in ("-G", "--gc-sections"): gc_sections = True
1.68 + # "P" handled below.
1.69 + elif arg == "--param-codes": l = paramnames; needed = 1
1.70 + elif arg == "--param-locations": l = paramlocations; needed = 1
1.71 elif arg in ("-q", "--quiet"): make_verbose = False
1.72 elif arg in ("-r", "--reset"): reset = True
1.73 elif arg in ("-R", "--reset-all"): reset_all = True
1.74 @@ -290,18 +314,20 @@
1.75
1.76 if timings: now = stopwatch("Deduction", now)
1.77
1.78 - o = optimiser.Optimiser(i, d, output_dir)
1.79 + o = optimiser.Optimiser(i, d, output_dir,
1.80 + getvalue(attrnames, 0), getvalue(attrlocations, 0),
1.81 + getvalue(paramnames, 0), getvalue(paramlocations, 0))
1.82 o.to_output()
1.83
1.84 + if timings: now = stopwatch("Optimisation", now)
1.85 +
1.86 # Detect structure or signature changes demanding a reset of the
1.87 # generated sources.
1.88
1.89 reset = reset or o.need_reset()
1.90
1.91 - if timings: now = stopwatch("Optimisation", now)
1.92 -
1.93 g = generator.Generator(i, o, generated_dir)
1.94 - g.to_output(debug, gc_sections)
1.95 + g.to_output(reset, debug, gc_sections)
1.96
1.97 if timings: now = stopwatch("Generation", now)
1.98