Pervasives defines the objects that are defined in all programs. The following objects are defined.
Parent objects: none.
The Object object is the root object. Every class is a subclass of Object.
It provides the following fields:
o.foreach(<var1>, <var2>) <body>
For example, the following function prints all the fields of an object o.
PrintObject(o) = o.foreach(v, x) println($(v) = $(x))
The export form is valid in a foreach body. The following function collects just the field names of an object.
FieldNames(o) = names = o.foreach(v, x) names += $(v) export return $(names)
Parent objects: Object.
A Map object is a dictionary from values to values. The <key> values are restricted to simple values: integers, floating-point numbers, strings, files, directories, and arrays of simple values.
The Map object provides the following methods.
o.foreach(<var1>, <var2>) <body>
For example, the following function prints all the fields of an object o.
PrintObject(o) = o.foreach(v, x) println($(v) = $(x))
The export form is valid in a foreach body. The following function collects just the field names of the map.
FieldNames(o) = names = o.foreach(v, x) names += $(v) export return $(names)
There is also simpler syntax when the key is a string. The table can be defined using definitions with the form $|key| (the number of pipe symbols | is allowed to vary).
$|key 1| = value1 $||key1|key2|| = value2 # The key is key1|key2 X = $|key 1| # Define X to be the value of field $|key 1|
The usual modifiers are also allowed. The expression $`|key| represents lazy evaluation of the key, and $,|key| is normal evaluation.
Parent objects: Object.
The Number object is the parent object for integers and floating-point numbers.
Parent objects: Number.
The Int object represents integer values.
Parent objects: Number.
The Float object represents floating-point numbers.
Parent objects: Object.
The Sequence object represents a generic object containing sequential elements. It provides the following methods.
s.foreach(<var>) <body>
For example, the following function prints all the elements of the sequence.
PrintSequence(s) = s.foreach(x) println(Elem = $(x))
The export form is valid in a foreach body. The following function counts the number of zeros in the sequence.
Zeros(s) = count = $(int 0) s.foreach(v) if $(equal $(v), 0) count = $(add $(count), 1) export export return $(count)
Parent objects: Sequence.
The Array is a random-access sequence. It provides the following additional methods.
Parent objects: Array.
Parent objects: Object.
The Fun object provides the following methods.
Parent objects: Object.
The Rule object represents a build rule. It does not currently have any methods.
Parent object: Object.
The Target object contains information collected for a specific target file.
The object supports the following methods.
NOTE: the information for a target is constructed dynamically, so it is possible that the Target object for a node will contain different values in different contexts. The easiest way to make sure that the Target information is complete is to compute it within a rule body, where the rule depends on the target file, or the dependencies of the target file.
Parent objects: Object.
The Node object is the parent object for files and directories. It supports the following operations.
Parent objects: Node.
The file object represents the name of a file.
Parent objects: Node.
The Dir object represents the name of a directory.
Parent objects: Object.
A Channel is a generic IO channel. It provides the following methods.
Parent objects: Channel.
A InChannel is an input channel. The variable stdin is the standard input channel.
It provides the following methods.
Parent object: Channel.
A OutChannel is an output channel. The variables stdout and stderr are the standard output and error channels.
It provides the following methods.
Parent objects: Location.
The Location object represents a location in a file.
Parent objects: Position.
The Position object represents a stack trace.
Parent objects: Object.
The Exception object is used as the base object for exceptions. It has no fields.
Parent objects: Exception.
The RuntimeException object represents an exception from the runtime system. It has the following fields.
Parent objects: Object.
The Shell object contains the collection of builtin functions available as shell commands.
You can define aliases by extending this object with additional methods. All methods in this class are called with one argument: a single array containing an argument list.
The echo function prints its arguments to the standard output channel.
The jobs method prints the status of currently running commands.
The cd function changes the current directory. Note that the current directory follows the usual scoping rules. For example, the following program lists the files in the foo directory, but the current directory is not changed.
section echo Listing files in the foo directory... cd foo ls echo Listing files in the current directory... ls
The bg method places a job in the background. The job is resumed if it has been suspended.
The fg method brings a job to the foreground. The job is resumed if it has been suspended.
The stop method suspends a running job.
The wait function waits for a running job to terminate. It is not possible to wait for a suspended job.
The job is not brought to the foreground. If the wait is interrupted, the job continues to run in the background.
The kill function signal a job.
kill [signal] <pid...>.
The signals are either numeric, or symbolic. The symbolic signals are named as follows.
ABRT, ALRM, HUP, ILL, KILL, QUIT, SEGV, TERM, USR1, USR2, CHLD, STOP, TSTP, TTIN, TTOU, VTALRM, PROF.
The exit function terminates the current session.
See the documentation for the corresponding functions.
Reset the search path.
Print the current command-line history.
Win32 doesn't provide very many programs for scripting, except for the functions that are builtin to the DOS cmd.exe. The following functions are defined on Win32 and only on Win32. On other systems, it is expected that these programs already exist.
grep [-q] [-n] pattern files...
The grep function calls the omake grep function.
mkdir [-m <mode>] [-p] files
The mkdir function is used to create directories. The -verb+-m+ option can be used to specify the permission mode of the created directory. If the -p option is specified, the full path is created.
cp [-f] [-i] [-v] src dst cp [-f] [-i] [-v] files dst mv [-f] [-i] [-v] src dst mv [-f] [-i] [-v] files dst
The cp function copies a src file to a dst file, overwriting it if it already exists. If more than one source file is specified, the final file must be a directory, and the source files are copied into the directory.
rm [-f] [-i] [-v] [-r] files rmdir [-f] [-i] [-v] [-r] dirs
The rm function removes a set of files. No warnings are issued if the files do not exist, or if they cannot be removed.
Options:
chmod [-r] [-v] [-f] mode files
The chmod function changes the permissions on a set of files or directories. This function does nothing on Win32. The mode may be specified as an octal number, or in symbolic form [ugoa]*[-=][rwxXstugo]+. See the man page for chmod for details.
Options:
cat files...
The cat function prints the contents of the files to stdout
test \emph{expression} \verb+[+ \emph{expression} +]+ \verb+[ --help+ \verb+[ --version+
See the documentation for the test function.
find \emph{expression}
See the documentation for the find function.
omake(1), omake-quickstart(1), omake-options(1), omake-root(1), omake-language(1), omake-shell(1), omake-rules(1), omake-base(1), omake-system(1), omake-pervasives(1), osh(1), make(1)
Version: 0.9.6.9 of April 11, 2006.
©2003-2006, Mojave Group, Caltech
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Jason Hickey et. al.
Caltech 256-80
Pasadena, CA 91125, USA
Email: omake-devel@metaprl.org
WWW: http://www.cs.caltech.edu/~jyh