Parrot intermediate representation

Parrot intermediate representation

The Parrot intermediate representation or PIR, previously called Intermediate code (IMC), is one of the two assembly languages for the Parrot virtual machine. The other is Parrot assembly language or PASM. Compared to PASM, PIR exists at a slightly higher level of abstraction, and provides temporary registers and named registers, simplifying code generation.

While parrot is still evolving, it is currently being used in many different capacities, and has undergone several releases.

Overview

PIR provides a set of abstractions that allow the programmer to ignore certain redundancies in the Parrot bytecode and quickly write code that adheres to the complexities of Parrot, such as the calling conventions.

Abstractions

PIR provides both type abstraction and polymorphism to some degree. For example, the "+" operator can be used with int, num or both:

.local int a .local num b a = 1 b = 1.1 .local num c c = a + b

Calling conventions

The calling conventions in Parrot are fairly complex, but all of that complexity can be hidden by using PIR directives:

.sub foo .param int a .param int b .local int tmp tmp = a + b .return (tmp) .end

Each of these directives that begins with a "." expands out to the required Parrot bytecode, but does not directly represent any fundamental Parrot operation.

Example

The hello world program in PIR is

.sub hello :main print "Hello world! ".end

If the program is saved as "hello.pir", it can be compiled and executed with this command: parrot hello.pir

External links

* [http://www.parrotcode.org/docs/art/pp001-intro.html Writing PIR]
* [http://www.parrotcode.org/examples/pir.html PIR examples at ParrotCode]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Parrot virtual machine — Developer(s) Parrot Foundation Stable release 3.10.0[1] / November 16, 2011; 7 days ago …   Wikipedia

  • Parrot — Logo Parrot ist eine in Entwicklung befindliche registerbasierte virtuelle Maschine, die vor allem auf die Bedürfnisse dynamischer Programmiersprachen wie Perl oder Python ausgerichtet ist. Parrot wurde von Dan Sugalski vor allem als Interpreter… …   Deutsch Wikipedia

  • Parrot VM — Parrot Logo Parrot ist eine in Entwicklung befindliche registerbasierte virtuelle Maschine, die vor allem auf die Bedürfnisse dynamischer Programmiersprachen wie Perl oder Python ausgerichtet ist. Parrot wurde von Dan Sugalski vor allem als… …   Deutsch Wikipedia

  • Parrot (machine virtuelle) — Pour les articles homonymes, voir Parrot. Parrot …   Wikipédia en Français

  • Parrot assembly language — The Parrot assembly language or PASM is the basic assembly language used by the Parrot virtual machine, a part of the Perl 6 project.PASM is the lowest level assembly language. The Parrot intermediate representation or PIR is PASM, extended to… …   Wikipedia

  • Máquina virtual Parrot — ? Información general Última versión estable 3.6.0 Pájaros del Caribe 19 de julio de 2011 Género Máquina virtual …   Wikipedia Español

  • Pir — may refer to:*Pir (Sufism), a Sufi teacher, spiritual leader *Pir (Zoroastrianism), a site in Persia, frequently one of the Zoroastrian faith *Pir of the Britons, legendary king of the Britons *Pir, Satu Mare, commune in Satu Mare County,… …   Wikipedia

  • South Asian arts — Literary, performing, and visual arts of India, Pakistan, Bangladesh, and Sri Lanka. Myths of the popular gods, Vishnu and Shiva, in the Puranas (ancient tales) and the Mahabharata and Ramayana epics, supply material for representational and… …   Universalium

  • Info-gap decision theory — is a non probabilistic decision theory that seeks to optimize robustness to failure – or opportuneness for windfall – under severe uncertainty,[1][2] in particular applying sensitivity analysis of the stability radius type[3] to perturbations in… …   Wikipedia

  • arts, East Asian — Introduction       music and visual and performing arts of China, Korea, and Japan. The literatures of these countries are covered in the articles Chinese literature, Korean literature, and Japanese literature.       Some studies of East Asia… …   Universalium

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”