File: //usr/local/share/man/man3/Imager::Expr::Assem.3pm
.\" Automatically generated by Pod::Man 4.11 (Pod::Simple 3.35)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Imager::Expr::Assem 3"
.TH Imager::Expr::Assem 3 "2020-06-13" "perl v5.26.3" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
.Vb 2
\& Imager::Expr::Assem \- an assembler for producing code for the Imager
\& register machine
.Ve
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 2
\& use Imager::Expr::Assem;
\& my $expr = Imager::Expr\->new(assem=>\*(Aq...\*(Aq, ...)
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This module is a simple Imager::Expr compiler that compiles a
low-level language that has a nearly 1\-to\-1 relationship to the
internal representation used for compiled register machine code.
.SS "Syntax"
.IX Subsection "Syntax"
Each line can contain multiple statements separated by semi-colons.
.PP
Anything after '#' in a line is ignored.
.PP
Types of statements:
.IP "variable definition" 4
.IX Item "variable definition"
.RS 4
.RS 4
\&\f(CW\*(C`var\*(C'\fR \fIname\fR:\fItype\fR
.RE
.RE
.RS 4
.Sp
defines variable \fIname\fR to have \fItype\fR, which can be any of \f(CW\*(C`n\*(C'\fR or
\&\f(CW\*(C`num\*(C'\fR for a numeric type or \f(CW\*(C`pixel\*(C'\fR, \f(CW\*(C`p\*(C'\fR or \f(CW\*(C`c\*(C'\fR for a pixel or
color type.
.Sp
Variable names cannot include white-space.
.RE
.IP "operators" 4
.IX Item "operators"
Operators can be split into 3 basic types, those that have a result
value, those that don't and the null operator, eg. jump has no value.
.Sp
The format for operators that return a value is typically:
.RS 4
.Sp
.RS 4
\&\fIresult\fR = \fIoperator\fR \fIoperand\fR ...
.RE
.RE
.RS 4
.Sp
and for those that don't return a value:
.Sp
.RS 4
\&\fIoperator\fR \fIoperand\fR
.RE
.RE
.RS 4
.Sp
where operator is any valid register machine operator, result is any
variable defined with \f(CW\*(C`var\*(C'\fR, and operands are variables, constants or
literals, or for jump operators, labels.
.Sp
The set operator can be simplified to:
.Sp
.RS 4
\&\fIresult\fR = \fIoperator\fR
.RE
.RE
.RS 4
.Sp
All operators maybe preceded by a label, which is any non-white-space
text immediately followed by a colon (':').
.RE
.SH "BUGS"
.IX Header "BUGS"
Note that the current optimizer may produce incorrect optimization for
your code, fortunately the optimizer will disable itself if you
include any jump operator in your code. A single jump to anywhere
after your final \f(CW\*(C`ret\*(C'\fR operator can be used to disable the optimizer
without slowing down your code.
.PP
There's currently no high-level code generation that can generate code
with loops or real conditions.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fBImager\fR\|(3), \fItransform.perl\fR, \fIregmach.c\fR
.SH "AUTHOR"
.IX Header "AUTHOR"
Tony Cook <tony@develop\-help.com>