Skip to content

Commit 1189dd6

Browse files
committed
Merge pull request #132 from Mouq/master
Add Array opcodes to ops.markdown
2 parents 165d8e5 + 677b1f1 commit 1189dd6

File tree

2 files changed

+68
-23
lines changed

2 files changed

+68
-23
lines changed

docs/nqp-opcode.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,7 @@ General notes:
8585
nqp::list_s(str0, str1, ...) create a low-level string list
8686
nqp::hash(key0, val0, ...) create a low-level hash
8787

88-
nqp::pop pir::pop__PP
89-
nqp::push pir::push__0PP
90-
nqp::push_s pir::push__0Ps
91-
nqp::shift pir::shift__PP
92-
nqp::unshift pir::unshift__0PP
9388
nqp::splice pir::splice__0PPii
94-
nqp::bindpos pir::set__1QiP
95-
nqp::bindkey pir::set__1QsP
96-
nqp::atpos pir::set__PQi
97-
nqp::atkey pir::set__PQs
98-
nqp::existspos pir::exists__IQi
99-
nqp::existskey pir::exists__IQs
100-
nqp::deletekey pir::delete__0Qs
10189
nqp::elems pir::elements__IP
10290

10391
object:

docs/ops.markdown

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -225,31 +225,88 @@ Return non-zero if the two parameters are not equal.
225225

226226
# Array opcodes
227227

228+
## atpos
229+
* `atpos(Any @arr, int $i)`
230+
* `atpos_i(int @arr, int $i)`
231+
* `atpos_n(num @arr, int $i)`
232+
* `atpos_s(str @arr, int $i)`
233+
234+
Return whatever is bound to @arr at position $i.
235+
236+
## bindpos
237+
* `bindpos(Any @arr, int $i, Any $v)`
238+
* `bindpos_i(int @arr, int $i, int $v)`
239+
* `bindpos_n(num @arr, int $i, num $v)`
240+
* `bindpos_s(str @arr, int $i, str $v)`
241+
242+
Bind $v to @arr at position $i and return $v.
243+
244+
## push
245+
* `push(Any @arr, Any $v)`
246+
* `push_i(int @arr, int $v)`
247+
* `push_n(num @arr, num $v)`
248+
* `push_s(str @arr, str $v)`
249+
250+
"Push $v onto the end of @arr."
251+
Bind $v to @arr at the position at the end of @arr, i.e., the position that is just after the last position of @arr that has been bound to.
252+
Return the number of elements of @arr on Parrot, $v on JVM.
253+
254+
## pop
255+
* `pop(Any @arr)`
256+
* `pop_i(int @arr)`
257+
* `pop_n(num @arr)`
258+
* `pop_s(str @arr)`
259+
260+
"Pop the last value off the end of @arr."
261+
Return the value of @arr at it's last bound position, and unbind @arr at that position.
262+
263+
## unshift
264+
* `unshift(Any @arr, Any $v)`
265+
* `unshift_i(int @arr, int $v)`
266+
* `unshift_n(num @arr, num $v)`
267+
* `unshift_s(str @arr, str $v)`
268+
269+
"Shift $v into the beginning of @arr."
270+
Bind $v to @arr at index 0, move all other bindings of @arr to the index one above what they were previously bound to.
271+
Return the number of elements of @arr on Parrot, $v on JVM.
272+
273+
## shift
274+
* `shift(Any @arr)`
275+
* `shift_i(int @arr)`
276+
* `shift_n(num @arr)`
277+
* `shift_s(str @arr)`
278+
279+
"Shift the last value from the beginning of @arr."
280+
Return the value of @arr at index 0, unbind @arr at index 0, and move all other binding of @arr to the index one below what they were previously bound to.
281+
282+
## splice
283+
* `splice(Any @arr, Any $from, int $offset, int $count)`
284+
228285
# Hash opcodes
229286

230287
## atkey
231-
* `atkey(Any %hash, String $key)`
232-
* `atkey_i(int %hash, String $key)`
233-
* `atkey_n(num %hash, String $key)`
234-
* `atkey_s(str %hash, String $key)`
288+
* `atkey(%hash, String $key)`
289+
* `atkey_i(%hash, String $key)`
290+
* `atkey_n(%hash, String $key)`
291+
* `atkey_s(%hash, String $key)`
235292

236293
Return the value of %hash at key $key.
237294

238295
## bindkey
239-
* `bindkey(Any %hash, String $key, Any $b)`
240-
* `bindkey_i(int %hash, String $key, int $b)`
241-
* `bindkey_n(num %hash, String $key, num $b)`
242-
* `bindkey_s(str %hash, String $key, str $b)`
296+
* `bindkey(%hash, String $key, Any $v)`
297+
* `bindkey_i(%hash, String $key, int $v)`
298+
* `bindkey_n(%hash, String $key, num $v)`
299+
* `bindkey_s(%hash, String $key, str $v)`
243300

244-
Bind key $key of %hash to $b and return $b.
301+
Bind key $key of %hash to $v and return $v.
245302

246303
## existskey
247-
* `existskey(Any %hash, String $key)`
304+
* `existskey(%hash, String $key)`
248305

249306
Return non-zero if %hash has key $key bound to something.
250307

251308
## deletekey
252-
* `deletekey(Any %hash, String $key)`
309+
* `deletekey(%hash, String $key)`
253310

254311
Delete the given key from %hash.
255312

0 commit comments

Comments
 (0)