Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[common] Add .defined methods to the various built-in types.
  • Loading branch information
jnthn committed Oct 29, 2010
1 parent c8d35ab commit ac08da5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions common/NQP/NQPSetting.pm
Expand Up @@ -21,6 +21,9 @@ knowhow NQPStr is repr('P6str') {
method Stringy() {
self
}
method defined() {
nqp::repr_defined(self)
}
}

knowhow NQPInt is repr('P6int') {
Expand All @@ -45,6 +48,9 @@ knowhow NQPInt is repr('P6int') {
method Stringy() {
nqp::coerce_int_to_str(self, NQPStr)
}
method defined() {
nqp::repr_defined(self)
}
}

knowhow NQPNum is repr('P6num') {
Expand All @@ -69,6 +75,9 @@ knowhow NQPNum is repr('P6num') {
method Stringy() {
nqp::coerce_num_to_str(self, NQPStr)
}
method defined() {
nqp::repr_defined(self)
}
}

knowhow NQPList is repr('P6list') {
Expand All @@ -84,6 +93,9 @@ knowhow NQPList is repr('P6list') {
method at_pos($idx) {
nqp::lllist_get_at_pos(self, $idx.Int)
}
method defined() {
nqp::repr_defined(self)
}
}

knowhow NQPArray is repr('P6list') {
Expand All @@ -102,6 +114,9 @@ knowhow NQPArray is repr('P6list') {
method bind_pos($idx, $value) {
nqp::lllist_bind_at_pos(self, $idx.Int, $value)
}
method defined() {
nqp::repr_defined(self)
}
}

knowhow NQPHash is repr('P6mapping') {
Expand All @@ -120,12 +135,18 @@ knowhow NQPHash is repr('P6mapping') {
method bind_key($key, $value) {
nqp::llmapping_bind_at_key(self, $key.Str, $value)
}
method defined() {
nqp::repr_defined(self)
}
}

knowhow NQPCode is repr('RakudoCodeRef') {
method leave($with) {
nqp::leave_block(self, $with)
}
method defined() {
nqp::repr_defined(self)
}
}

## XXX Need coercive Any fallbacks too.
Expand Down Expand Up @@ -232,6 +253,10 @@ knowhow NQPException {
self;
}

method defined() {
nqp::repr_defined(self)
}

method resumable() {
$!resumable
}
Expand Down Expand Up @@ -351,6 +376,10 @@ knowhow NQPClassHOW {
%!methods
}

method defined() {
nqp::repr_defined(self)
}

##
## Dispatchy
##
Expand Down

0 comments on commit ac08da5

Please sign in to comment.