11.1 PASM Opcodes

   

For complete details on each opcode and the latest changes, read the documentation in docs/ops/ , or look at all the .ops files in the ops/ directory.

We've followed a few conventions. DEST is always the register where the result of the operation is stored. Sometimes the original value of DEST is one of the source values. VAL indicates that the actual value might be a literal integer, float, or string, or a register containing an integer, float, string, or PMC. See the .ops files for the combinations allowed with a particular operation.

abs

 abs   DEST   abs   DEST   ,   VAL   

Return the absolute value of a number. If VAL is left out, DEST gets the absolute value of itself.

Arguments: IR or NR or IR, I or IR, N or NR, I or NR, N

acos

 acos   DEST   ,   VAL   

The arc cosine of VAL in radians.

Arguments: NR, N or NR, I

add

 add   DEST   ,   VAL   add   DEST   ,   VAL   ,   VAL   

Add two values and return the sum. If only one VAL , add VAL to DEST .

Arguments: IR, I or NR, I or NR, N or P, I or P, N or P, P or IR, I, I or NR, N, I or NR, N, N or P, P, I or P, P, N or P, P, P

addattribute

 addattribute   CLASS   ,   ATTR   

Add the attribute name ATTR to class CLASS .

Arguments: P, S

addparent

 addparent   CLASS1   ,   CLASS2   

Add class CLASS2 to the list of parent classes for CLASS1 .

Arguments: P, P

and

 and   DEST   ,   VAL1   ,   VAL2   

Logical AND. Return VAL1 if it's false. Otherwise , return VAL2 .

Arguments: IR, I, I or P, P, P

asec

 asec   DEST   ,   VAL   

The arc secant of VAL in radians.

Arguments: NR, I or NR, N

asin

 asin   DEST   ,   VAL   

The arc sine of VAL in radians.

Arguments: NR, I or NR, N

assign

 assign   DEST   ,   VAL   

Assign a value to a PMC.

Arguments: SR, S or P, I or P, N or P, S or P, P

atan

 atan   DEST   ,   VAL   atan   DEST   ,   VAL1   ,   VAL2   

The arc tangent of VAL1 / VAL2 in radians (sign significant). If VAL2 is omitted, then just the arc tangent of VAL .

Arguments: NR, I or NR, N or NR, I, I or NR, I, N or NR, N, I or NR, N, N

band

 band   DEST   ,   VAL   band   DEST   ,   VAL   ,   VAL   

Bitwise AND on two values. If only one VAL , bitwise AND on DEST and VAL .

Arguments: IR, I or P, I or P, P or IR, I, I or P, P, I or P, P, P

bands

 bands   DEST   ,   VAL   bands   DEST   ,   VAL   ,   VAL   

Bitwise AND on two strings. If only one VAL , bitwise AND on DEST and VAL .

Arguments: SR, S or P, S or P, P or SR, S, S or P, P, S or P, P, P

bnot

 bnot   DEST   ,   VAL   

Bitwise NOT on VAL .

Arguments: IR, I or P, P

bnots

 bnots   DEST   ,   VAL   

Bitwise NOT on string VAL .

Arguments: SR, S or P, P

bor

 bor   DEST   ,   VAL   ,   VAL   

Bitwise OR on two values. If only one VAL , bitwise OR on DEST and VAL .

Arguments: IR, I or P, I or P, P or IR, I, I or P, P, I or P, P, P

bors

 bor   DEST   ,   VAL   ,   VAL   

Bitwise OR on two strings. If only one VAL , bitwise OR on DEST and VAL .

Arguments: SR, S or P, S or P, P or SR, S, S or P, P, S or P, P, P

bounds

 bounds   INT   

Toggle bytecode bounds checking in the interpreter (0 for off, any other value for on).

Argument: I

branch

 branch   LABEL   

Branch to a label. The label is calculated as a relative offset.

Argument: I

branch_cs

 branch_cs   FIXUP_ENTRY   

Intersegment branch to the location of the given fixup table entry.

Argument: S

bsr

 bsr   LABEL   

Branch to a label, like branch , but also push the current location onto the call stack so ret can return to it.

Argument: I

bxor

 bxor   DEST   ,   VAL   bxor   DEST   ,   VAL   ,   VAL   

Bitwise XOR on two values. If only one VAL , bitwise XOR on DEST and VAL .

Arguments: IR, I or P, I or P, P or IR, I, I or P, P, I or P, P, P

bxors

 bxors   DEST   ,   VAL   bxors   DEST   ,   VAL   ,   VAL   

Bitwise XOR on two strings. If only one VAL , bitwise XOR on DEST and VAL .

Arguments: SR, S or P, S or P, P or SR, S, S or P, P, S or P, P, P

callmethod

 callmethod callmethod   METHODNAME   

Call the method named METHODNAME on the object stored in P2 according to the Parrot-Calling Conventions. If no method name, pull the name from S0 .

Argument: S

callmethodcc

 callmethodcc callmethodcc   METHODNAME   

Call the method named METHODNAME on the object stored in P2 according to the Parrot-Calling Conventions. If no method name, pull the name from S0 . Also create a return continuation and store it in P1 .

Argument: S

can

 can   DEST   ,   OBJECT   ,   METHODNAME   

Return a true value if OBJECT can do the METHODNAME method. Otherwise, return a false value.

Arguments: IR, P, S

ceil

 ceil   DEST   ceil   DEST   ,   VAL   

Set DEST to the smallest integral value less than or equal to VAL (if present) or itself (if not).

Arguments: NR or IR, N or NR, N

checkevents

 checkevents 

Check the interpreter's task queue for unhandled events and run the associated event handlers.

chopn

 chopn   DEST   ,   VAL1   chopn   DEST   ,   VAL1   ,   VAL2   

Remove VAL2 number of characters from string VAL1 . If no VAL2 , remove VAL number of characters from string DEST .

Arguments: SR, I or SR, S, I

chr

 chr   DEST   ,   INT   

Return the character represented by the given number.

Arguments: SR, I

class

 class   CLASS   ,   OBJECT   

Return the CLASS of the given OBJECT .

Arguments: P, P

classname

 classname   NAME   ,   CLASS   

Set NAME to the classname of CLASS .

Arguments: SR, P

classoffset

 classoffset   OFFSET   ,   OBJECT   ,   CLASS   

Return the offset OFFSET of the first attribute of class CLASS in object OBJECT .

Arguments: IR, P, S

clear_eh

 clear_eh 

Clear the most recent exception handler.

See also: set_eh , throw

clearX

 cleari clearn clearp clears 

Clear all registers of the given type ("i" = integer, "n" = float, "p" = PMC, "s" = string). Integer and float registers clear to zero; string and PMC registers clear to NULL.

clone

 clone   DEST   ,   VAL   

Clone (deep copy) a string or PMC and return the result.

Arguments: SR, S or P, P

close

 close   DEST   

Close the filehandle in the given register.

Argument: P

cmod

 cmod   DEST   ,   VAL1   ,   VAL2   

C's built-in mod operator.

Arguments: IR, I, I or NR, N, N or P, P, I or P, P, N or P, P, P

See also: mod

cmp

 cmp   DEST   ,   VAL1   ,   VAL2   

Set DEST to 1 if VAL1 is greater then VAL2 , to -1 if it's less then VAL2 or to 0 if both are equal. If VAL1 and VAL2 are both PMCs, then the type of comparison depends on VAL1 .

Arguments: IR, I, I or IR, N, N or IR, S, S or IR, P, I or IR, P, N IR, P, S or IR, P, P

cmp_num

 cmp_num   DEST   ,   VAL1   ,   VAL2   

Like cmp , but forces numeric comparison.

Arguments: IR, P, P

cmp_str

 cmp_str   DEST   ,   VAL1   ,   VAL2   

Like cmp , but forces string comparison.

Arguments: IR, P, P

collect

 collect 

Trigger a garbage collection (GC) run.

collectoff

 collectoff 

Disable garbage collection runs (nestable).

collecton

 collecton 

Reenable garbage collection runs.

compile

 compile   DEST   ,   COMPILER   ,   SOURCE   

Compile a string of source code with a given compiler PMC and store the result.

Arguments: P, P, S

compreg

 compreg   DEST   ,   TYPE   

Return a compiler PMC for a particular type of source code.

Arguments: P, S compreg TYPE , SUB

Register SUB as a compiler for language TYPE .

Arguments: S, P

concat

 concat   DEST   ,   VAL   concat   DEST   ,   VAL   ,   VAL   

Concatenate two strings. If only one VAL , concatenate VAL onto DEST .

Arguments: SR, S or SR, S, S or P, P, S or P, P, P

conv_*

 conv_i1   DEST   ,   VAL   conv_i1_ovf   DEST   ,   VAL   

Convert value to integer or number of given type i1 , i2 , i4 , i8 , u1 , u2 , u4 , r4 , r8 . i corresponds to a signed integer, u to an unsigned integer, and r to a float; the number indicates the size (in bytes) of the type. The variants with _ovf throw an exception if the conversion would overflow.

cos

 cos   DEST   ,   VAL   

The cosine of VAL in radians.

Arguments: NR, I or NR, N

cosh

 cosh   DEST   ,   VAL   

The hyperbolic cosine of VAL in radians.

Arguments: NR, I or NR, N

debug

 debug   FLAG   

Toggle debugging in the interpreter (0 for off; any other value for on).

Arguments: I

dec

 dec   DEST   

Decrement a value by 1.

Arguments: I or N or P

decodelocaltime

 decodelocaltime   DEST   ,   VAL   

Set DEST to a new array which represents the decoded time of the given epoch -seconds value shifted to local time.

Arguments: P, I

decodetime

 decodetime   DEST   ,   VAL   

Set DEST to a new array which represents the decoded time of the given epoch-seconds value.

Arguments: P, I

defined

 defined   DEST   ,   PMC   defined   DEST   ,   PMC   [   KEY   ] 

Test a keyed PMC value for definedness. If no KEY , test a PMC for definedness.

Arguments: IR, P

delete

 delete   DEST   [   KEY   ] 

Delete a keyed value from an aggregate PMC.

Argument: P

delprop

 delprop   PMC   ,   NAME   

Delete a named property from a PMC.

Arguments: P, S

See also: setprop , getprop

depth

 depth   DEST   

Return the depth of the user stack.

Argument: I

deref

 deref   DEST   ,   REF   

Set DEST to the PMC that REF refers to.

Arguments: P, P

die_hard

 die_hard   LEVEL   ,   ERROR   

Die at a given level of severity, and with the given error code.

Arguments: I, I

See also: exit

div

 div   DEST   ,   VAL   div   DEST   ,   VAL1   ,   VAL2   

Divide VAL1 by VAL2 . If VAL2 is left out, divide DEST by VAL .

Arguments: IR, I or NR, I or NR, N or P, I or P, N or P, P or IR, I, I or NR, N, I or NR, N, N or P, P, I or P, P, N or P, P, P

dlfunc

 dlfunc   DEST   ,   LIBRARY   ,   SYMBOL   ,   SIGNATURE   

Look up a symbol in a dynamic link library PMC and create a subroutine PMC for that symbol with the given signature.

Arguments: P, P, S, S

dlvar

 dlvar   DEST   ,   LIBRARY   ,   SYMBOL   

Look up a symbol in a dynamic link library PMC and create a PMC for that symbol.

Arguments: P, P, S

does

 does   DEST   ,   OBJECT   ,   VAL   

Return a true value if OBJECT does provide the interface VAL . Otherwise, return a false value.

Arguments: I, P, S

downcase

 downcase   DEST   downcase   DEST   ,   VAL   

Create a copy of the string in VAL with all characters converted to lowercase, and store it in DEST . If VAL is omitted, convert and replace the string in DEST .

Arguments: S or S, S

See also: upcase , titlecase

end

 end 

End execution within the current code segment or halt the interpreter if in the main code segment.

enternative

 enternative 

Run the run_native C function.

entrytype

 entrytype   DEST   ,   INT   

Return the type of an entry on the user stack. INT specifies the position on the stack.

Arguments: I, I

eq

 eq   VAL   ,   VAL   ,   LABEL   

Jump to a label if the two values are equal.

Arguments: I, I, IC or N, N, IC or S, S, IC or P, I, IC or P, N, IC or P, S, IC or P, P, IC

eq_addr

 eq_addr   VAL1   ,   VAL2   ,   LABEL   

Jump to a label if VAL1 and VAL2 point to the same string or PMC. Note that this op compares the addresses of the two strings or PMCs, not simply their values.

Arguments: S, S, IC or P, P, IC

eq_num

 eq_num   VAL   ,   VAL   ,   LABEL   

Jump to a label if the two values are numerically equal.

Arguments: P, P, IC

eq_str

 eq_str   VAL   ,   VAL   ,   LABEL   

Jump to a label if the two strings are equal.

Arguments: P, P, IC

err

 err   DEST   err   DEST   ,   CODE   

Return the system error code to an integer destination or the system error message to a string destination. The two-argument version returns the system error message for a given code.

Arguments: IR or SR or SR, I

errorsoff

 errorsoff   VAL   

Turn off errors of type VAL .

Argument: I

errorson

 errorson   VAL   

Turn on errors of type VAL .

Argument: I

exchange

 exchange   REG   ,   REG   

Exchange the contents of two registers.

Arguments: IR, IR or NR, NR or SR, SR or P, P

exists

 exists   DEST   ,   PMC   [   KEY   ] 

Test a PMC key for existence.

Arguments: IR, P

exit

 exit   STATUS   

Exit the interpreter with a given STATUS . (For extended exit status, throw an exception with severity EXCEPT_exit .)

Argument: I

See also: throw , die_hard

exp

 exp   DEST   ,   VAL   

Base of the natural logarithm, e , to the power of VAL .

Arguments: NR, I or NR, N

exsec

 exsec   DEST   ,   VAL   

The exsecant of VAL in radians.

Arguments: NR, N

fact

 fact   DEST   ,   INT   

Return the factorial of INT .

Arguments: IR, I or NR, I

fdopen

 fdopen   DEST   ,   INT   ,   MODE   

Get a ParrotIO object for handle INT with open mode MODE .

Arguments: P, I, S

find_chartype

 find_chartype   DEST   ,   NAME   

Find the chartype named NAME and return its number in DEST .

Arguments: IR, S

find_encoding

 find_encoding   DEST   ,   NAME   

Find the encoding named NAME and return its number in DEST .

Arguments: IR, S

find_global

 find_global   DEST   ,   NAME   

Return a global variable with the given name.

Arguments: P, S find_global DEST , NAMESPACE , NAME

Return a global variable with the given name from the given namespace.

Arguments: P, S, S or P, P, S

See also: store_global

find_lex

 find_lex   DEST   ,   NAME   find_lex   DEST   ,   DEPTH   ,   NAME   find_lex   DEST   ,   DEPTH   ,   POSITION   

Return the lexical variable of the given name from a lexical scratchpad. If DEPTH is provided, return only a variable from the scratchpad at that depth. A find by position returns the variable at a particular position in the scratchpad.

Arguments: P, S or P, I, S or P, I, I

See also: store_lex

find_method

 find_method   DEST   ,   PMC   ,   NAME   

Look up a method by name in a PMC's vtable. Return a method PMC.

Arguments: P, P, S

find_type

 find_type   DEST   ,   NAME   

Find the integer identifier for a PMC type or native Parrot datatype by name.

Arguments: IR, S

See also: typeof

findclass

 findclass   DEST   ,   NAME   

Return 1 if the class NAME exists, and 0 otherwise.

Arguments: IR, S

See also: typeof

floor

 floor   DEST   floor   DEST   ,   VAL   

Return the largest integral value less than or equal to VAL (if present) or itself (if not).

Arguments: NR or IR, N or NR, N

foldup

 foldup   DEST   foldup   DEST   ,   SKIP   

Return a new array holding all passed subroutine parameters. SKIP defines an optional offset.

Arguments: P or P, I

freeze

 freeze   DEST   ,   VAL   

Create a frozen image DEST from PMC VAL .

Arguments: SR, P

See also: thaw

gc_debug

 gc_debug   INT   

Toggle garbage collection debugging in the interpreter (0 for off, any other value for on).

Argument: I

gcd

 gcd   DEST   ,   VAL   ,   VAL   

Return the greatest common divisor of two values.

Arguments: IR, I, I or IR, N, N

ge

 ge   VAL1   ,   VAL2   ,   LABEL   

Jump to a label if VAL1 is greater than or equal to VAL2 .

Arguments: I, I, IC or N, N, IC or S, S, IC or P, I, IC or P, N, IC or P, S, IC or P, P, IC

ge_num

 ge_num   VAL1   ,   VAL2   ,   LABEL   

Jump to a label if VAL1 is numerically greater than or equal to VAL2 .

Arguments: P, P, IC

ge_str

 ge_str   VAL1   ,   VAL2   ,   LABEL   

Jump to a label if VAL1 is stringwise greater than or equal to VAL2 .

Arguments: P, P, IC

get_addr

 get_addr   DEST   ,   SUB   

Get the absolute address of a subroutine PMC.

Arguments: IR, P

See also: set_addr

getattribute

 getattribute   DEST   ,   OBJECT   ,   OFFS   

Get a reference to attribute number OFFS from object OBJECT .

Arguments: P, P, I

See also: setattribute , classoffset

getclass

 getclass   DEST   ,   NAME   

Return the class PMC of the given name.

Arguments: P, S

getfd

 getfd   DEST   ,   PIO   

Return the file descriptor for the given ParrotIO object.

Arguments: IR, P

getfile

 getfile   DEST   

Return the name of the current file.

Argument: SR

getinterp

 getinterp   DEST   

Get a PMC representing the current interpreter.

Argument: P

getline

 getline   DEST   

Return the current line number.

Argument: IR

getpackage

 getpackage   DEST   

Return the current package name.

Argument: SR

getprop

 getprop   DEST   ,   NAME   ,   PMC   

Return the value of a named property on a PMC.

Arguments: P, S, P

See also: setprop , prophash

getstd*

 getstderr   DEST   getstdin   DEST   getstdout   DEST   

Get a ParrotIO object for the given standard handle.

Argument: P

gmtime

 gmtime   DEST   ,   VAL   

Take the integer, which represents GMT epoch-seconds, and turn it into a formatted string.

Arguments: SR, I

See also: localtime

gt

 gt   VAL1   ,   VAL2   ,   LABEL   

Jump to a label if VAL1 is greater than VAL2 .

Arguments: I, I, IC or N, N, IC or S, S, IC or P, I, IC or P, N, IC or P, S, IC or P, P, IC

gt_num

 gt_num   VAL1   ,   VAL2   ,   LABEL   

Jump to a label if VAL1 is numerically greater than VAL2 .

Arguments: P, P, IC

gt_str

 gt_str   VAL1   ,   VAL2   ,   LABEL   

Jump to a label if VAL1 is stringwise greater than VAL2 .

Arguments: P, P, IC

hav

 hav   DEST   ,   VAL   

The haversine of VAL in radians.

Arguments: NR, N

if

 if   CONDITION   ,   LABEL   

Jump to a label if the condition is a true value.

Arguments: I, IC or N, IC or S, IC or P, IC

inc

 inc   DEST   

Increment a value by one.

Arguments: IR or NR or P

index

 index   DEST   ,   STRING   ,   SEARCH   index   DEST   ,   STRING   ,   SEARCH   ,   POS   

Return the position of the first occurrence of the string SEARCH in the string STRING , starting at the position POS . If the starting position is unspecified, start at the beginning of the string.

Arguments: IR, S, S or IR, S, S, I

interpinfo

 interpinfo   DEST   ,   FLAG   

Return information about the interpreter. An integer flag selects which information to return, as listed in Table 11-1.

Arguments: IR, I

Table 11-1. Interpinfo flags

Flag

Returns

1

Allocated memory, in bytes

2

Number of DOD sweeps performed

3

Number of GC runs performed

4

Number of active PMCs

5

Number of active buffers

6

Number of allocated PMCs

7

Number of allocated buffers

8

Number of new PMC or buffer headers allocated since last DOD run

9

Number of memory blocks allocated since last GC run

10

Amount of memory copied during GC runs, in bytes


invoke

 invoke invoke   SUB   

Call a subroutine, coroutine, or continuation stored in a PMC. If no PMC register is specified, it calls the subroutine in P0 and uses the standard calling conventions. Otherwise, no calling convention is defined. Also yield from a coroutine.

Argument: P

invokecc

 invokecc invokecc   SUB   

Call a subroutine like invoke , but also generate a return continuation in P1 .

Argument: P

See also: updatecc

isa

 isa   DEST   ,   OBJECT   ,   CLASS   

Return a true value if OBJECT is a member of class CLASS , or of one of its subclasses. Otherwise, return a false value.

Arguments: IR, P, S

isnull

 isnull   VAL   ,   LABEL   

Jump to LABEL if the given PMC is a NULL PMC.

Arguments: P, IC

join

 join   DEST   ,   DELIM   ,   ARRAY   

Create a new string by joining all elements from array with the given delimiter .

Arguments: SR, S, P

jsr

 jsr   ADDRESS   

Jump to an address, like jump , but also push the current location onto the call stack so ret can return to it.

Argument: I

jump

 jump   ADDRESS   

Jump to a specified absolute address.

Argument: I

See also: set_addr

lcm

 lcm   DEST   ,   VAL   ,   VAL   

Return the least common multiple of two values.

Arguments: IR, I, I or NR, I, I

le

 le   VAL1   ,   VAL2   ,   LABEL   

Jump to a label if VAL1 is less than or equal to VAL2 .

Arguments: I, I, IC or N, N, IC or S, S, IC or P, I, IC or P, N, IC or P, S, IC or P, P, IC

le_num

 le_num   VAL1   ,   VAL2   ,   LABEL   

Jump to a label if VAL1 is numerically less than or equal to VAL2 .

Arguments: P, P, IC

le_str

 le_str   VAL1   ,   VAL2   ,   LABEL   

Jump to a label if VAL1 is stringwise less than or equal to VAL2 .

Arguments: P, P, IC

length

 length   DEST   ,   STRING   

Return the character length of a string.

Arguments: IR, S

ln

 ln   DEST   ,   VAL   

The natural logarithm of VAL .

Arguments: NR, I or NR, N

load_bytecode

 load_bytecode   FILE   

Load Parrot bytecode from a file.

Argument: S

loadlib

 loadlib   DEST   ,   LIBRARY   

Load a dynamic link library by name and store it in a PMC.

Arguments: P, S

See also: dlfunc

localtime

 localtime   DEST   ,   VAL   

Take the integer, which represents GMT epoch-seconds, and turn it into a formatted string after adjusting to localtime.

Arguments: SR, I

See also: gmtime

log10

 log10   DEST   ,   VAL   

The base-10 logarithm of VAL .

Arguments: NR, I or NR, N

log2

 log2   DEST   ,   VAL   

The base-2 logarithm of VAL .

Arguments: NR, I or NR, N

lookback

 lookback   DEST   ,   OFFSET   

Retrieve an entry from the user stack by position. A positive offset counts from the top of the stack; a negative offset counts from the bottom.

Arguments: IR, I or NR, I or SR, I or P, I

lsr

 lsr   DEST   ,   BITS   lsr   DEST   ,   VAL   ,   BITS   

Logically shift a value right by a given number of bits.

Arguments: IR, I or IR, I, I

lt

 lt   VAL1   ,   VAL2   ,   LABEL   

Jump to a label if VAL1 is less than VAL2 .

Arguments: I, I, IC or N, N, IC or S, S, IC or P, I, IC or P, N, IC or P, S, IC or P, P, IC

lt_num

 lt_num   VAL1   ,   VAL2   ,   LABEL   

Jump to a label if VAL1 is numerically less than VAL2 .

Arguments: P, P, IC

lt_str

 lt_str   VAL1   ,   VAL2   ,   LABEL   

Jump to a label if VAL1 is stringwise less than VAL2 .

Arguments: P, P, IC

mmdvtfind

 mmdvtfind   DEST   ,   FUNC   ,   LEFT   ,   RIGHT   

Get the subroutine PMC for the multimethod vtable function FUNC for the two given PMC types.

Arguments: P, I, I, I

mmdvtregister

 mmdvtregister   FUNC   ,   LEFT   ,   RIGHT   ,   SUB   

Register the subroutine SUB as the multimethod vtable function FUNC for the two given PMC types.

Arguments: I, I, I, P

mod

 mod   DEST   ,   VAL   mod   DEST   ,   VAL1   ,   VAL2   

Divide VAL1 by VAL2 and return the remainder. If VAL2 is omitted, divide DEST by VAL . The operation is defined as:

 x mod y = x - y * floor(x / y) 

Arguments: P, I or IR, I, I or NR, N, N or P, P, I or P, P, N

See also: cmod

mul

 mul   DEST   ,   VAL   mul   DEST   ,   VAL   ,   VAL   

Multiply two values and return the result. If only one VAL , multiply DEST by VAL .

Arguments: IR, I or NR, I or NR, N or P, I or P, N or P, P or IR, I, I or NR, N, I or NR, N, N or P, P, I or P, P, N or P, P, P

ne

 ne   VAL   ,   VAL   ,   LABEL   

Jump to a label if the two values are not equal.

Arguments: I, I, IC or N, N, IC or S, S, IC or P, I, IC or P, N, IC or P, S, IC or P, P, IC

ne_addr

 ne_addr   VAL   ,   VAL   ,   LABEL   

Jump to a label if VAL1 and VAL2 do not point to the same string or PMC.

Arguments: S, S, IC or P, P, IC

ne_num

 ne_num   VAL   ,   VAL   ,   LABEL   

Jump to a label if the two values are numerically different.

Arguments: P, P, IC

ne_str

 ne_str   VAL   ,   VAL   ,   LABEL   

Jump to a label if the two strings are not equal.

Arguments: P, P, IC

needs_destroy

 needs_destroy   PMC   

Mark the PMC as requiring timely destruction.

Argument: P

See also: sweep

neg

 neg   DEST   neg   DEST   ,   VAL   

Return the negative of a number. If there is no VAL , DEST is the negative of itself.

Arguments: IR or NR or P or IR, I or NR, N or P, P

new

 new   DEST   ,   TYPE   new   DEST   ,   TYPE   ,   INITIALIZE   new   DEST   ,   TYPE   ,   INITIALIZE   ,   PROPS   

Create a new PMC of type TYPE . INITIALIZE is an array PMC containing initialization data for the new PMC. PROPS is a propety hash.

Arguments: P, I or P, I, P or P, I, P, P

 new   DEST   new   DEST   ,   LENGTH   new   DEST   ,   LENGTH   ,   ENCODING   new   DEST   ,   LENGTH   ,   ENCODING   ,   TYPE   

Allocate a new empty string with a given LENGTH , ENCODING , and TYPE .

Arguments: SR or SR, I or SR, I, I or SR, I, I, I

new_callback

 new_callback   DEST   ,   SUB   ,   DATA   ,   SIG   

Create a callback stub DEST for a PASM subroutine SUB with user data DATA and function signature SIG .

Arguments: P, P, P, S

new_pad

 new_pad   DEPTH   new_pad   DEST   ,   DEPTH   

Create a new lexical scratchpad. If a destination PMC is provided, store the pad in the PMC. Otherwise, push it onto the pad stack. DEPTH specifies the static nesting depth for the pad (lower static depths are copied from the current static nesting).

Arguments: I or P, I

newclass

 newclass   DEST   ,   NAME   

Create a new class with the given name.

Arguments: P, S

newsub

 newsub   DEST   ,   CLASS   ,   LABEL   

Generate a new subroutine object of the given CLASS , located at the given LABEL , and store the object in the destination PMC.

Arguments: P, I, IC

 newsub   CLASS   ,   RETCLASS   ,   LABEL   ,   RETADDR   

Generate a new subroutine object of the given CLASS , located at the given LABEL , and store the object in P0 . Also generate a return continuation of class RETCLASS with the return address RETADDR and store it in P1 .

Arguments: I, I, IC, IC

noop

 noop 

Do nothing.

not

 not   DEST   ,   VAL   

Logical NOT. True if VAL is false.

Arguments: IR, I or P, P

null

 null   DEST   

Set DEST (which must be a register) to 0, 0.0, or a NULL pointer, depending on its type.

Arguments: IR or NR or SR or P

open

 open   DEST   ,   FILENAME   open   DEST   ,   FILENAME   ,   MODE   

Open a file in the specified mode ("<", ">", etc.) and return a filehandle. Without the mode it defaults to read/write.

Arguments: P, S, S or P, S

or

 or   DEST   ,   VAL1   ,   VAL2   

Logical OR. Return VAL1 if it's true. Otherwise, return VAL2 .

Arguments: IR, I, I or P, P, P

ord

 ord   DEST   ,   STRING   ord   DEST   ,   STRING   ,   POS   

Return the character at position POS in STRING . If POS isn't specified, return the 0th character.

Arguments: IR, S or IR, S, I

peek

 peek   DEST   peek   DEST   ,   PIO   

Read the next byte from the given ParrotIO object or from stdin but don't remove it.

Arguments: SR or SR, P

peek_pad

 peek_pad   DEST   

Store the current lexical scope pad in a PMC.

Argument: P

pin

 pin   DEST   

Make the string in DEST immobile. This prevents the garbage collector from moving it to a different location in memory (which it otherwise may choose to do).

Argument: SR

See also: unpin

pioctl

 pioctl   DEST   ,   PIO   ,   VAL   ,   VAL   

Perform an operation on an I/O object. This is a general purpose hook for setting various flags, modes, etc.

Arguments: IR, P, I, I

pop

 pop   DEST   ,   PMC   

Pop the last entry off an aggregate PMC and return it.

Arguments: IR, P or NR, P or SR, P or P, P

pop_pad

 pop_pad 

Pop the current lexical scope pad off the lexical scope stack.

See also: peek_pad

popX

 popi popn popp pops 

Restore all the registers of one type from the stack ("i" = integer, "n" = float, "p" = PMC, "s" = string).

 popbottomi popbottomn popbottomp popbottoms 

Restore registers in the range 0..15.

 poptopi poptopn poptopp poptops 

Restore registers in the range 16..31.

See also: push X

pow

 pow   DEST   ,   VAL1   ,   VAL2   

Return VAL1 raised to the power of VAL2 .

Arguments: NR, I, I or NR, I, N or NR, N, I or NR, N, N

print

 print   VAL   print   IO   ,   VAL   

Print a value to an I/O object or file descriptor. If no IO is given, print the value to standard output.

Arguments: I or N or S or P or P, I or P, N or P, S or P, P

printerr

 printerr   VAL   

Print a value to stderr .

Arguments: I or N or S or P

profile

 profile   INT   

Toggle profiling in the interpreter (0 for off, any other value for on).

Argument: I

prophash

 prophash   DEST   ,   PMC   

Return a hash containing all the properties from a PMC.

Arguments: P, P

See also: getprop

push

 push   PMC   ,   VAL   

Push a value onto the end of an aggregate PMC.

Arguments: P, I or P, N or P, S or P, P

push_pad

 push_pad   PAD   

Push a scratchpad stored in a PMC onto the lexical scope stack.

Argument: P

pushX

 pushi pushn pushp pushs 

Save all the registers of one type to the stack ("i" = integer, "n" = float, "p" = PMC, "s" = string). Restore with pop X .

 pushbottomi pushbottomn pushbottomp pushbottoms 

Push registers 0..15.

 pushtopi pushtopn pushtopp pushtops 

Push registers 16..31.

read

 read   DEST   ,   BYTES   read   DEST   ,   IO   ,   BYTES   

Read the specified number of bytes from a ParrotIO object. Read from stdin if no IO is provided.

Arguments: SR, I or SR, P, I

readline

 readline   DEST   ,   IO   

Read a line from a ParrotIO object.

Arguments: SR, P

register

 register   PMC   

Register the given PMC in the interpreter's root set, so that it's visible during DOD.

Argument: P

See also: unregister

removeparent

 removeparent   CLASS1   ,   CLASS2   

Remove CLASS2 from class CLASS1 's list of parents.

Arguments: P, P

repeat

 repeat   DEST   ,   VAL   ,   REPEAT   

Repeat a string REPEAT number of times.

Arguments: SR, S, I or P, P, I or P, P, P

restore

 restore   DEST   

Restore a register from the user stack.

Arguments: IR or NR or SR or P

restoreall

 restoreall 

Restore all the registers. Does a pop X for every type.

restoretop

 restoretop 

Restore registers 16..31. Does a pop X for every type.

See also: savetop

ret

 ret 

Pop a location off the top of the call stack, and go there. Often used with bsr and jsr .

rethrow

 rethrow   EXCEPTION   

Rethrow an exception. Only valid inside an exception handler.

Argument: P

See also: throw

rotate_up

 rotate_up   COUNT   

Rotate the top COUNT entries on the user stack. A positive number rotates up: the top entry becomes the COUNT th entry, and the others move up one (the second entry becomes first, the third becomes the second, etc.). A negative number rotates down: the COUNT th entry becomes the top, and the others move down (the first becomes second, etc.).

Argument: I

runinterp

 runinterp   INTERPRETER   ,   OFFSET   

Use an interpreter stored in PMC to run code starting at a given offset.

Arguments: P, I

See also: newinterp

save

 save   VAL   

Save a value onto the user stack.

Arguments: I or N or S or P

saveall

 saveall 

Save all the registers. Does a push X for every type.

savec

 savec   VAL   

Save a clone of a value onto the user stack.

Arguments: S or P

savetop

 savetop 

Save registers 16..31. Does a push X for every type.

sec

 sec   DEST   ,   VAL   

The secant of VAL in radians.

Arguments: NR, I or NR, N

sech

 sech   DEST   ,   VAL   

The hyperbolic secant of VAL in radians.

Arguments: NR, I or NR, N

seek

 seek   DEST   ,   IO   ,   OFFSET   ,   STARTFLAG   seek   DEST   ,   IO   ,   UPPER32   ,   LOWER32   ,   STARTFLAG   

Set the file position of a ParrotIO object to a given offset from a starting position (STARTFLAG: 0 is the beginning of the file, 1 is current the position, 2 is the end of the file). DEST is the success or failure of the seek.

64-bit seek combines UPPER32 and LOWER32 to get one 64-bit OFFSET .

Arguments: P, I, I or P, I, I, I

set

 set   DEST   ,   VAL   

Set a register to a value.

Arguments: IR, I or IR, N or IR, S or IR, P or NR, I or NR, N or NR, S or NR, P or SR, I or SR, N or SR, S or SR, P or P, I or P, N or P, S or P, P


set DEST[KEY] , VAL

A keyed set operation on a PMC.

Arguments: P, I or P, N or P, S or P, P


set DEST , PMC[KEY]

A keyed get operation on a PMC.

Arguments: I, P or N, P or S, P or P, P

setX_ind

 seti_ind   REG   ,   VAL   setn_ind   REG   ,   VAL   sets_ind   REG   ,   VAL   setp_ind   REG   ,   VAL   

Set register number REG of the specified type to VAL . Bypasses the register allocator, so use with care.

Arguments: I, I or I, S or I, N or I, P

set_addr

 set_addr   DEST   ,   LABEL   

Return the current address plus the offset to LABEL . Often used to calculate absolute addresses for jump or jsr .

Arguments: IR, IC

 set_addr   SUB   ,   LABEL   

Set the subroutine address pointing to the given label.

Arguments: P, I

set_chartype

 set_chartype   STRING   ,   CHARTYPE   

Set the chartype of a string.

Arguments: S, I

set_eh

 set_eh   HANDLER   

Push an exception handler on the control stack.

Argument: P

See also: clear_eh , throw

set_encoding

 set_encoding   STRING   ,   ENCODING   

Set the encoding of a string.

Arguments: S, I

setattribute

 setattribute   OBJECT   ,   OFFSET   ,   ATTRIBUTE   

Set the given attribute at OFFSET for object OBJECT .

Arguments: P, I, P

See also: getattribute , classoffset

setprop

 setprop   PMC   ,   NAME   ,   VALUE   

Set the value of a named property on a PMC.

Arguments: P, S, P

See also: getprop and delprop

shift

 shift   DEST   ,   PMC   

Shift a value off the front of an aggregate PMC.

Arguments: IR, P or NR, P or SR, P or P, P

shl

 shl   DEST   ,   VAL   ,   BITS   

Bitwise shift a value left by a given number of bits.

Arguments: IR, I or P, I or P, P or IR, I, I or P, P, I or P, P, P

shr

 shr   DEST   ,   VAL   ,   BITS   

Bitwise shift a value right by a given number of bits.

Arguments: IR, I or P, I or P, P or IR, I, I or P, P, I or P, P, P

sin

 sin   DEST   ,   VAL   

The sine of VAL in radians.

Arguments: NR, I or NR, N

singleton

 singleton   DEST   

Take the given object and put it into its own singleton class.

Argument: P

sinh

 sinh   DEST   ,   VAL   

The hyperbolic sine of VAL in radians.

Arguments: NR, I or NR, N

sizeof

 sizeof   DEST   ,   TYPE   

Set DEST to the size in bytes of the given natural type.

Arguments: IR, I

sleep

 sleep   SECONDS   

Sleep for the given number of seconds.

Arguments: I or N

spanw

 spawnw   DEST   ,   COMMAND   

Spawn a subprocess to run the given COMMAND , wait for it to finish, and return the result.

Arguments: IR, S

splice

 splice   DEST   ,   REPLACE   ,   OFFSET   ,   COUNT   

Starting at OFFSET , replace COUNT number of values in the destination PMC with values provided in the REPLACE PMC.

Arguments: P, P, I, I

sprintf

 sprintf   DEST   ,   FORMAT   ,   ARGS   

Format arguments in an aggregate PMC, using format string FORMAT .

Arguments: SR, S, P or P, P, P

store_global

 store_global   NAME   ,   OBJECT   store_global   NAME   ,   NAMESPACE   ,   OBJECT   

Store a global variable as a named symbol.

Arguments: S, P or S, S, P or P, S, P

See also: find_global

store_lex

 store_lex   NAME   ,   OBJECT   store_lex   DEPTH   ,   NAME   ,   OBJECT   store_lex   DEPTH   ,   POSITION   ,   OBJECT   

Store an object as a lexical variable with a given name. If the symbol doesn't exist, it will be created in the lexical scratchpad at the specified depth (a negative depth counts back from the current scope). If DEPTH isn't provided, the symbol must already exist. If a position is provided instead of a name, the symbol will be stored at the given position in the scratchpad.

Arguments: S, P or I, I, P or I, S, P

See also: find_lex

string_chartype

 string_chartype   DEST   ,   STRING   

Return the chartype of the string.

Arguments: IR, S

string_encoding

 string_encoding   DEST   ,   STRING   

Return the encoding of the string.

Arguments: IR, S

stringinfo

 stringinfo   DEST   ,   STRING   ,   FLAG   

Return information about a string. An integer flag selects which information to return, as listed in Table 11-2.

Arguments: IR, S, I

Table 11-2. stringinfo arguments

Flag

Returns

1

Location of string buffer header

2

Location of start of string memory

3

Allocated length, in bytes

4

String flags

5

Length of string buffer currently used, in bytes

6

String length, in characters


sub

 sub   DEST   ,   VAL   sub   DEST   ,   VAL1   ,   VAL2   

Subtract VAL2 from VAL1 . If no VAL2 , subtract VAL from DEST .

Arguments: IR, I or NR, I or NR, N or P, I or P, N or P, P or IR, I, I or NR, N, I or NR, N, N or P, P, I or P, P, N or P, P, P

subclass

 subclass   DEST   ,   CLASS   subclass   DEST   ,   CLASS   ,   NAME   

Create a sublass of CLASS . Without NAME an anonymous subclass is created.

Arguments: P, S or P, P or P, S, S or P, P, S

substr

 substr   DEST   ,   STRING   ,   OFFSET   substr   DEST   ,   STRING   ,   OFFSET   ,   LENGTH   

Return a substring of STRING , beginning at OFFSET and with length LENGTH .

Arguments: SR, S, I or SR, S, I, I or SR, P, I, I


substr DEST , STRING , OFFSET , LENGTH , REPLACE

If REPLACE is given, use it to replace the returned substring in STRING .

Arguments: SR, S, I, I, S


substr DEST , OFFSET , LENGTH , REPLACE

If STRING is omitted, operate on the string in DEST .

Arguments: SR, I, I, S

substr_r

 substr_r   DEST   ,   STRING   ,   OFFSET   ,   LENGTH   

Acts like substr , but reuses the destination string instead of creating a new string.

Arguments: SR, S, I, I

sweep

 sweep   LAZY   

Trigger a dead object detection (DOD) sweep. If LAZY is set to 1, only objects that need timely destruction may be destroyed .

Argument: IC

sweepoff

 sweepoff 

Disable DOD sweeps (nestable).

sweepon

 sweepon 

Reenable DOD sweeps.

sysinfo

 sysinfo   DEST   ,   ITEM   

Return operating-system-specific details given by ITEM .

Arguments: IR, I or SR, I

tan

 tan   DEST   ,   VAL   

The tangent of VAL in radians.

Arguments: NR, I or NR, N

tanh

 tanh   DEST   ,   VAL   

The hyperbolic tangent of VAL in radians.

Arguments: NR, I or NR, N

tell

 tell   DEST   ,   PIO   tell   UPPER32   ,   LOWER32   ,   PIO   

Return the file position of the given ParrotIO object.

Arguments: IR, P or IR, I, P

See also: seek

thaw

 thaw   DEST   ,   STR   

Create a new PMC representing the frozen image.

Arguments: P, S

See also: freeze

throw

 throw   EXCEPTION   

Throw an exception.

Argument: P

See also: rethrow , set_eh , clear_eh

time

 time   DEST   

Return the current system time.

Arguments: IR or NR

titlecase

 titlecase   DEST   titlecase   DEST   ,   VAL   

Create a copy of the string in VAL with all characters converted to title case, and store it in DEST . If VAL is omitted, convert and replace the string in DEST .

Arguments: SR or SR, S

See also: upcase , downcase

trace

 trace   INT   

Toggle tracing in the interpreter (0 for off, any other value for on).

Argument: I

transcode

 transcode   DEST   ,   ENCODING   transcode   DEST   ,   SOURCE   ,   ENCODING   transcode   DEST   ,   SOURCE   ,   ENCODING   ,   CHARTYPE   

Transcode a string to the given CHARTYPE and ENCODING . If CHARTYPE is omitted, it is assumed to be the same as the original.

Arguments: SR, I or SR, S, I or SR, S, I, I

typeof

 typeof   DEST   ,   VAL   typeof   DEST   ,   PMC[KEY]   

Return the type of a PMC or Parrot data type, either its class name (to a string destination) or integer identifier (to an integer destination).

Arguments: IR, P or SR, I or SR, P

unless

 unless   CONDITION   ,   LABEL   

Jump to a label unless the condition is a true value.

Arguments: I, IC or N, IC or S, IC or P, IC

unpin

 unpin   DEST   

Make the string in DEST movable again. This is the default, so unpin is a no-op unless the string has been pinned with pin .

Argument: SR

See also: pin

unregister

 unregister   PMC   

Remove one reference to PMC from the root set registry.

Argument: P

See also: register

unshift

 unshift   DEST   ,   VAL   

Unshift a value onto the front of an aggregate PMC.

Arguments: P, I or P, N or P, S or P, P

upcase

 upcase   DEST   upcase   DEST   ,   VAL   

Create a copy of the string in VAL with all characters converted to uppercase, and store it in DEST . If VAL is omitted, convert and replace the string in DEST .

Arguments: SR or SR, S

See also: downcase , titlecase

updatecc

 updatecc 

Update the state of a return continuation stored in P1 . Used when context information changes after the return continuation is created but before it's invoked.

See also: invokecc

valid_type

 valid_type   DEST   ,   TYPE   

Check whether a PMC type or native Parrot datatype is a valid one.

Arguments: IR, I

vers

 vers   DEST   ,   VAL   

The versine of VAL in radians.

Arguments: NR, N

warningsoff

 warningsoff   CATEGORY   

Turn off a particular category of warnings by category number. Turning off one category will not affect the status of other warnings categories. See warningson for the list of categories.

Argument: I

warningson

 warningson   CATEGORY   

Turn on a particular category of warnings by category number. The default is all warnings off. Turning on one category will not turn off other categories. Combine category numbers with a bitwise OR to turn on more than one at a time. If you include warnings.pasm , the category numbers are available by name as:

 .PARROT_WARNINGS_ALL_FLAG .PARROT_WARNINGS_UNDEF_FLAG .PARROT_WARNINGS_IO_FLAG .PARROT_WARNINGS_PLATFORM_FLAG 

Argument: I

xor

 xor   DEST   ,   VAL1   ,   VAL2   

Logical XOR. If VAL1 is true and VAL2 is false, return VAL1 . If VAL1 is false and VAL2 is true, return VAL2 . Otherwise, return a false value.

Arguments: IR, I, I or P, P, P



Perl 6 and Parrot Essentials
Perl 6 and Parrot Essentials, Second Edition
ISBN: 059600737X
EAN: 2147483647
Year: 2003
Pages: 116

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net