.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" 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 "JE::Code 3pm" .TH JE::Code 3pm "2023-08-25" "perl v5.36.0" "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" JE::Code \- ECMAScript parser and code executor for JE .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use JE; \& \& $j = new JE; \& \& $code = $j\->compile(\*(Aq1+1\*(Aq); # returns a JE::Code object \& \& $code\->execute; .Ve .SH "METHODS" .IX Header "METHODS" .ie n .IP "$code\->execute($this, $scope, $code_type);" 4 .el .IP "\f(CW$code\fR\->execute($this, \f(CW$scope\fR, \f(CW$code_type\fR);" 4 .IX Item "$code->execute($this, $scope, $code_type);" The \f(CW\*(C`execute\*(C'\fR method of a parse tree executes it. All the arguments are optional. .Sp The first argument will be the 'this' value of the execution context. The global object will be used if it is omitted or undef. .Sp The second argument is the scope chain. A scope chain containing just the global object will be used if it is omitted or undef. .Sp The third arg indicates the type of code. \fB0\fR or \fBundef\fR indicates global code. \&\fB1\fR means eval code (code called by \fIJavaScript's\fR \f(CW\*(C`eval\*(C'\fR function, which has nothing to do with \s-1JE\s0's \f(CW\*(C`eval\*(C'\fR method, which runs global code). Variables created with \f(CW\*(C`var\*(C'\fR and function declarations inside eval code can be deleted, whereas such variables in global or function code cannot. A value of \fB2\fR means function code, which requires an explicit \f(CW\*(C`return\*(C'\fR statement for a value to be returned. .Sp If an error occurs, \f(CW\*(C`undef\*(C'\fR will be returned and \f(CW$@\fR will contain the error message. If no error occurs, \f(CW$@\fR will be a null string. .ie n .IP "$code\->set_global( $thing )" 4 .el .IP "\f(CW$code\fR\->set_global( \f(CW$thing\fR )" 4 .IX Item "$code->set_global( $thing )" You can transfer a JE::Code object to another JavaScript environment by setting the global object this way. You can also set it to \f(CW\*(C`undef\*(C'\fR, if, for instance, you want to serialise the compiled code without serialising the entire \s-1JS\s0 environment. If you do that, you'll need to set the global object again before you can use the code object. .SH "FUNCTIONS" .IX Header "FUNCTIONS" .ie n .IP "JE::Code::add_line_number($message, $code_object, $position)" 4 .el .IP "JE::Code::add_line_number($message, \f(CW$code_object\fR, \f(CW$position\fR)" 4 .IX Item "JE::Code::add_line_number($message, $code_object, $position)" \&\fB\s-1WARNING:\s0\fR The parameter list is still subject to change. .Sp This routine append a string such as 'at file, line 76.' to the error message passed to it, unless it ends with a line break already. .Sp \&\f(CW$code_object\fR is a code object as returned by \s-1JE\s0's or JE::Parser's \&\f(CW\*(C`parse\*(C'\fR method. If it is omitted, the current value of \f(CW$JE::Code::code\fR will be used (this is set while \s-1JS\s0 code is running). If \f(CW$JE::Code::code\fR turns out to be undefined, then \f(CW$message\fR will be returned unchanged (\fBthis is subject to change\fR; later I might make it use Carp to add a Perl file and line number). .Sp \&\f(CW$position\fR is the position within the source code, which will be used to determine the line number. If this is omitted, \f(CW$JE::Code::pos\fR will be used. .SH "EXPORTS" .IX Header "EXPORTS" \&\f(CW\*(C`add_line_number\*(C'\fR can optionally be exported. .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "\s-1JE\s0" 4 .IX Item "JE"