Skip to content

Commit e9604b5

Browse files
committed
add coercion opcodes
1 parent b768938 commit e9604b5

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

docs/ops.markdown

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ For generating an abstract tree that includes opcodes, see [docs/qast.markdown](
8686
* [hash](#hash)
8787
* [iterkey](#iterkey)
8888
* [iterval](#iterval)
89+
- [Coercion Opcodes](#-coercion-opcodes)
90+
* [coerce_in](#coerce_in)
91+
* [coerce_ni](#coerce_ni)
92+
* [coerce_is](#coerce_is)
93+
* [coerce_ns](#coerce_ns)
94+
* [coerce_sn](#coerce_sb)
95+
* [coerce_si](#coerce_si)
96+
* [smrt_intify](#smrt_intify)
97+
* [smrt_numify](#smrt_numify)
98+
* [smrt_strify](#smrt_strify)
8999
- [String Opcodes](#-string-opcodes)
90100
* [chars](#chars)
91101
* [chr](#chr)
@@ -430,6 +440,7 @@ The opcodes are grouped into the following categories:
430440
* [Relational / Logic Opcodes](#logic)
431441
* [Array Opcodes](#array)
432442
* [Hash Opcodes](#hash)
443+
* [Corcion Opcodes](#coercion)
433444
* [String Opcodes](#string)
434445
* [Unicode Property Opcodes](#unicode)
435446
* [Conditional Opcodes](#conditional)
@@ -932,6 +943,39 @@ while $iter {
932943

933944
Returns the value associated with the given key-value pair.
934945

946+
# <a id="coercion"</a> Coercion opcodes
947+
948+
coerce_* opcodes do lower level conversion between int, num and str.
949+
smrt_intify, smrt_numify, smrt_strify respectively try to use the .Int, .Num or .Str method.
950+
If absent rely on lower level conversions.
951+
952+
## coerce_in
953+
* `coerce_in(int --> num)`
954+
955+
## coerce_ni
956+
* `coerce_in(num --> int)`
957+
958+
## coerce_is
959+
* `coerce_is(int --> str)`
960+
961+
## coerce_ns
962+
* `coerce_ns(num --> str)`
963+
964+
## coerce_sn
965+
* `coerce_sn(str --> num)`
966+
967+
## coerce_si
968+
* `coerce_si(str --> int)`
969+
970+
## smrt_intify
971+
* `smrt_intify($o --> int)`
972+
973+
## smrt_numify
974+
* `smrt_numify($o --> num)`
975+
976+
## smrt_strify
977+
* `smrt_strify($o --> str)`
978+
935979
# <a id="string"></a> String Opcodes
936980

937981
## chars

0 commit comments

Comments
 (0)