Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/nqpPublic

NQP

License

NotificationsYou must be signed in to change notification settings

Raku/nqp

Repository files navigation

NQP is Copyright (C) 2009-2025 by The Raku Foundation. SeeLICENSE for licensing details.

This is "Not Quite Perl" -- a lightweight Raku-like environment for virtual machines. The key feature of NQP is that it's designed to be a very small environment (as compared with, say, raku or Rakudo) and is focused on being a high-level way to create compilers and libraries for virtual machines likeMoarVM, the JVM, and others.

Unlike a full-fledged implementation of Raku, NQP strives to have as small a runtime footprint as it can, while still providing a Raku object model and regular expression engine for the virtual machine.

Building from source

To build NQP from source, you'll just need amake utility andPerl 5.8 or newer. To automatically obtain and build MoarVM you may also need agit client.

To obtainNQP directly from its repository:

$ git clone git://github.com/Raku/nqp.git

If you don't have git installed, you can get a tarball or zip of NQP from github by visitinghttp://github.com/Raku/nqp/tree/main and clicking "Download". Then unpack the tarball or zip.

NQP can run on three different backends:MoarVM, theJVM, andJavaScript. TheJVM andJavaScript backends are currently experimental. The JVM backend requiresJDK 1.9 (also known asJDK 9) or higher.

Once you have a copy of NQP, decide which backends you want to run, and configure and build it as follows:

$ cd nqp$ perl Configure.pl --with-moar=/path/to/moar --backends=moar,jvm$ make

If you don't have an installed MoarVM, you can haveConfigure.pl download and build one for you as well -- by passing the--gen-moar option to it (instead of--with-moar):

$ cd nqp$ perl Configure.pl --gen-moar --backends=moar,jvm$ make

Themake step will create anqp ornqp.exe executable in the current directory. Programs can then be run from the build directory using a command like:

$ ./nqp hello.nqp

By default, NQP searches for the MoarVM executable and installs to the directory./install. You can change that with the--prefix option to Configure.pl; this will point to the directory prefix where `moar` is installed, such as `/usr`; it needs to be the same one used when configuring MoarVM unless you use the option `--with-moar`. This optional argument should point to the installed `moar` executable; for instance, `--with-moar=/usr/local/bin/moar`.

Once built, NQP'smake install target will install NQP and its libraries into the same location as the MoarVM installation that was used to create it. Until this step is performed, thenqp executable created bymake above can only be reliably run from the root of NQP's build directory. Aftermake install is performed the executable can be run from any directory.

If theNQP compiler is invoked without an explicit script to run, it enters a small interactive mode that allows statements to be executed from the command line. Each line entered is treated as a separate compilation unit, however (which means that subroutines are preserved after they are defined, but variables are not).

Troubleshooting

OS X

On OS X, it appears that configuration fails in some configurations:

3rdparty/libuv/include/uv-darwin.h:26:11: fatal error: 'mach/mach.h' file not found

Should this happen to you, then a solution might be the following:

$ cd MoarVM/3rdparty/libuv/include$ ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/mach$ cd ../../../..$ # run the Configure again

Note that the 10.9 in the above, represents the major version of OS X being used. On Mavericks use 10.9 (like above), on Yosemite use 10.10.

JVM

If attempting to run NQP on the JVM results in NQP claiming it couldn't reserve enough memory, you may need to increase the memory limit of your shell like so:

$ ulimit -d 6144000

Using NQP

NOTE: there'sno end-user support for NQP and the behaviour can change without notice. It's a tool for writing Raku compilers, not a low-level module for Raku programmers.

Theexamples directory is a good place to start, with theloops and other files. Opcodes are listed inthe docs directory. NQP also has built-in routines listed inthe docs directory. You can use NQP from this release, it will be already installed if you have built Raku from scratch.

JavaScript backend

The best thing before playing with it/hacking on it is to contact pmurias via IRC at#raku onirc.libera.chat. We depend onnode.js at least 10.10.0

Building the JavaScript backend currently requires building the moar backend:

$ perl Configure.pl --backends=moar,js$ make

Currently it needs to be run like:

$ ./nqp-js file.nqp

If you are developingnqp-js, you may want to pass the--link option to configure to have thenqp-runtime linked instead of installed

$ cd src/vm/js/nqp-runtime; npm link .$ perl Configure --backends=moar,js

[8]ページ先頭

©2009-2025 Movatter.jp