Skip to content

Commit 959d4c6

Browse files
committed
Add moar ops, cleanups.
Add new type _b found in a parrot opcode
1 parent f9a5c28 commit 959d4c6

File tree

1 file changed

+75
-7
lines changed

1 file changed

+75
-7
lines changed

docs/ops.markdown

Lines changed: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Opcode variants may contain a type suffix, which usually indicates:
1818
* `_i` argument is native int
1919
* `_n` argument is native float
2020
* `_s` argument is native string
21+
* `_b` argument is code blocks
2122
* `_I` argument is Big Integer
2223

2324
They may also have a numeric suffix, which typically indicates the number
@@ -36,6 +37,7 @@ correspond directly to NQP types.
3637
* Handle - an I/O Handle object
3738
* @ - this sigil indicates an array parameter
3839
* % - this sigil indicates a hash parameter
40+
* ... - indicates variable args are accepted
3941

4042
# Arithmetic Opcodes
4143

@@ -165,9 +167,12 @@ Return the value of $base raised to $exponent;
165167
and of type `$type_bigint` for positive exponents.
166168

167169
## rand
170+
* `rand_n(num $n)`
168171
* `rand_I(Int $i, Type $type)`
169172

170-
Returns a psuedo-random bigint up to the value of `$i`, of the given type.
173+
Returns a psuedo-random bigint up to the value of the
174+
given number.
175+
`_I` variant returns an object of the given type.
171176

172177
## sqrt
173178
* `sqrt_n(num $l, num $r)`
@@ -298,6 +303,17 @@ Bind $v to @arr at position $i and return $v.
298303
Joins the separate strings of `@arr` into a single string with
299304
fields separated by the value of EXPR, and returns that new string.
300305

306+
## list
307+
* `list(...)`
308+
* `list_i(...)`
309+
* `list_n(...)`
310+
* `list_s(...)`
311+
* `list_b(...)`
312+
313+
Create a list of the given parameters. If no arguments are passed,
314+
an empty list is created. If a typed variant is used, the parameters
315+
are coerced to the appropriate type.
316+
301317
## push
302318
* `push(@arr, Any $v)`
303319
* `push_i(Array int @arr, int $v)`
@@ -392,7 +408,8 @@ reverse order.
392408
Return lowercase copy of string.
393409

394410
## radix
395-
* `radix_I(int $radix, String $str, int $pos, int $flags)`
411+
* `radix(int $radix, String $str, int $pos, int $flags)`
412+
* `radix_I(int $radix, String $str, int $pos, int $flags, Type $type)`
396413

397414
Convert string $str into a number starting at offset $pos and using radix $radix.
398415
The result of the conversion returns an array with
@@ -449,6 +466,7 @@ Return an array of strings, describing the backtrace of the given exception.
449466

450467
##die
451468
* `die(str $message)`
469+
* `die_s(str $message)`
452470

453471
Create and throw an exception using the given message.
454472

@@ -602,14 +620,36 @@ Return current access position for an open handle.
602620

603621
Output the given object to the filehandle.
604622

605-
# File / Network Opcodes
623+
# File / Directory / Network Opcodes
624+
625+
##chdir
626+
* `chdir(str $path)`
627+
628+
Change the working directory to the given path.
629+
630+
##chmod
631+
* `chmod(str $path, int $mode)`
632+
633+
Change the permissions of `$path` to the posix style permissions of `$mode`.
634+
Returns 0 on success, throws an exception on failure.
635+
636+
##cwd
637+
* `cwd()`
638+
639+
Return a string containing the current working directory.
606640

607641
##fileexecutable
608642
* `fileexecutable(str $str)`
609643

610644
If the specified filename refers to an executable file, returns 1.
611645
If not, returns 0. If an error occurs, return -1.
612646

647+
##fileislink
648+
* `fileislink(str $str)`
649+
650+
If the specified filename refers to a symbolic link, returns 1.
651+
If not, returns 0. If an error occurs, return -1.
652+
613653
##filereadable
614654
* `filereadable(str $str)`
615655

@@ -622,14 +662,42 @@ If not, returns 0. If an error occurs, return -1.
622662
If the specified filename refers to a writable file, returns 1.
623663
If not, returns 0. If an error occurs, return -1.
624664

625-
##isfilelink
626-
* `isfilelink(str $str)`
665+
##link
666+
* `link(str $before, str $after)`
667+
668+
Create a link from `$after` to `$before`
669+
670+
##mkdir
671+
* `mkdir(str $name, int $mode)`
672+
673+
Create a directory of the given name. Use posix-style mode
674+
on non-windows platforms. Returns 0, or throws an exception.
675+
676+
##rmdir
677+
* `rmdir(str $path)`
678+
679+
Delete the given directory $path. Returns 0 on success, -2 if the
680+
directory didn't exist. May throw an exception.
627681

628-
If the specified filename refers to a symbolic link, returns 1.
629-
If not, returns 0. If an error occurs, return -1.
682+
683+
##symlink
684+
* `symlink(str $before, str $after)`
685+
686+
Create a symbolic link from `$after` to `$before`
687+
688+
##unlink
689+
* `unlink(str $path)`
690+
691+
Delete the given file $path. Returns 0 on success, -2 if the file
692+
didn't exist. May throw an exception.
630693

631694
# Type/Conversion Opcodes
632695

696+
##bool
697+
* `bool_I(Int $val)`
698+
699+
Returns 0 if `$val` is 0, otherwise 1.
700+
633701
##box
634702
* `box_i(int $val, Type $type)`
635703
* `box_n(num $val, Type $type)`

0 commit comments

Comments
 (0)