home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 1B
/
DATAFILE_PDCD1B.iso
/
_pocketbk
/
pocketbook
/
004
/
aka220_zip
/
AKA2.DOC
< prev
next >
Wrap
Text File
|
1994-08-25
|
8KB
|
218 lines
AKA
AKA is a variable compactor for OPL programs developed for Psion
Series 3/3a machines. Variable compaction is the replacement of
long (meaningful) variable names with optimally short (obscure)
ones. Variables in this context includes data variables and
procedure and label names.
OPL is an interpreted language and the translator that generates
the intermediate code incorporates into that code the name of
each global variable on each occurrence within the source
program.
The use of AKA brings the following advantages:
- Distributed object files (*.OPA and *.OPO) are reduced in
size; This may be particularly important where the distribution
medium is an SSD;
- There is no penalty in the use of long mnemonic variable
names in the source code, and no advantage in using short and
obscure ones;
- Compacted modules require significantly less working memory
in the run-time interpreter;
- Compacted modules run slightly faster;
- The use of reverse-translation tools is confounded to a large
extent, since the code so produced is effectively 'obfuscated'.
The status of AKA
AKA may be distributed freely for personal, non-commercial use,
provided that:
a) no charge is made for the program or its supply, and
b) the original archive is supplied complete and unmodified.
Commercial users of AKA (those creating or distributing software
in expectation of reward) should register the program with Ferret
Information Systems Ltd - further details of registration can be
found in the accompanying file REGISTER.DOC.
This document and the programs referred to within it are supplied
in the belief that the contents are correct and they operate as
described, but Ferret Information Systems Ltd. (the company)
shall not be liable in any circumstances whatsoever for any
direct or indirect loss or damage suffered by any person as a
consequence of any fault or defect in any goods or services
supplied by the company and in no circumstances shall the company
be liable for consequential damage or loss arising from the use
or performance of such goods or services.
What AKA does
AKA makes two passes through the set of source files. The first
tabulates all the variables that are not reserved or built-in,
and assigns each its optimally small replacement name (or alias)
based on its category (global or local) and the number of
occurrences of the variable in the source files.
The second pass creates the output files - with extension .OPP -
substituting the aliases for the original names. This will
overwrite any existing .OPP files of the same name.
A list file tabulating the variable name substitutions and the
likely space saved by compaction is written to a file named
AKA.LIS in the current directory. The estimate of space saved is
a theoretical figure; Various other factors affect the actual
size and padding of translated files.
AKA will handle all legal constructs of OPL/mcwa in the source
files. The output files can be translated without prior manual
amendment, as normal OPL source files. See the 'Notes' section,
below, for further guidance.
Using AKA - preliminaries
AKA should be used when program testing is complete and modules
are ready to be built for distribution.
In order to be handled by AKA, OPL source files must be
pre-processed using the -p switch to HHTRAN or S3ATRAN. This
removes comments, resolves conditional translation, and performs
token replacement. In most cases this can be done simply by:
hhtran -p *.opl
for OPL/mcw, with a similar command for OPL/mcwa. It is
recommended that this step be performed always - even if the
sources make no use of the pre-processor. The resulting files
*.PRP are then transformed by AKA.
Invoking AKA
When AKA starts it expects to find the files AKA.MSG and AKA.DAT
in the same directory as the AKA executable; If these files are
not found it halts forthwith.
AKA expects one argument on the command line:
aka sources
where 'sources' is either an ambiguous filespec (possibly with
path) or a single filename preceded by an @ sign. The latter is
interpreted as the name of a file (possibly with path) containing
the names of the actual files to process, one per line. The files
named in the @ file may also be pathed.
Type just 'aka' for a reminder of the program syntax.
Examples:
aka *.prp
processes all .PRP files in the current directory and produces
compacted files of the same name but with extension .OPP.
aka @list.fil
processes all files named in the file LIST.FIL and creates the
output files with extension .OPP. If a filename in LIST.FIL has
no extension then .PRP is assumed.
An @ file containing the names of the files to process may have
blank lines in it - these are ignored. Also ignored is any text
following the pathname and separated by at least one space
character. This can be used to add comments to the @ file.
It is possible to invoke AKA with an additional switch (/i or -i)
as the second argument, e.g.
aka *.prp -i
in which case AKA stops after the first pass through the source
files and informs of the likely saving from variable compaction.
No output files *.OPP are produced, but the informational file
AKA.LIS is.
Notes
AKA must be presented with syntactically correct post-processed
source files. Furthermore, the set of files must be complete -
that is all variables used must be declared in one of the source
files seen by AKA. This is necessary because AKA performs
variable substitution on a global basis, and cannot track
entities external to the source files.
The pre-declared calculator variables M0 - M9 are never
substituted, and existing variables never renamed to one of them.
As a result, the calculator variable usage is not affected by
AKA.
In some circumstances it is necessary to prevent a variable, or
variables, from being compacted. This arises where a procedure is
called by its string name using the @(name$): syntax. If such
procedures are not identified, then AKA will change their lexical
name, but cannot change their string name (which is known only at
run-time) and so a 'missing procedure' error will result.
To circumvent this problem, create a file called AKA.EXT in the
same directory as the source files. In this file, name, one per
line, those procedures that are called indirectly. Include the
colon character as part of the procedure name. A sample AKA.EXT
file follows; A line with a semicolon in the first character
position is ignored.
; AKA.EXT for my project - procedures called indirectly
choicea:
choiceb:
choicec:
If AKA detects an AKA.EXT file in the current directory, it will
display a message confirming that it is processing that file.
Limits
The current implementation places the following limits on program
use:
- no more than 1024 distinct variable identifiers (excluding
built-ins) can be processed in a set of source files;
- no more than 90 variables identifiers can be specified in the
AKA.EXT file of user-defined reserved identifiers;
The program will abort if either of these limits is exceeded.
Messages from AKA
AKA produces messages of two kinds - informational and error.
Error messages cause AKA to abandon further processing.
Messages of the form:
! AKA: aborting - error is n Message text
indicate an internal error, or the traversal of an implementation
limit. Please inform the author if a message of this type appears
and the reason for it is not obvious.
--------------------------
David Palmer
Ferret Information Systems
March 1994
dpalmer@cix.compulink.co.uk