Permalink
Browse files

Preparations for positional/associative delegate.

This work will eliminate some of the v-table use that is in the way of
certain bits of porting work, but should also provide some other wins.
  • Loading branch information...
jnthn committed Feb 9, 2013
1 parent f7eb701 commit 7133fa1bbb98169d5d6343c9d152c30c98dce4ff
Showing with 33 additions and 1 deletion.
  1. +8 −1 src/NQP/Actions.pm
  2. +1 −0 src/NQP/World.pm
  3. +18 −0 src/how/NQPAttribute.pm
  4. +6 −0 src/how/NQPClassHOW.pm
View
@@ -709,6 +709,7 @@ class NQP::Actions is HLL::Actions {
my $sigil := $<variable><sigil>;
my $name := $past.name;
my $BLOCK := $*W.cur_lexpad();
+ my $*DECLARAND_ATTR;
if $name && $BLOCK.symbol($name) {
$/.CURSOR.panic("Redeclaration of symbol ", $name);
}
@@ -735,7 +736,7 @@ class NQP::Actions is HLL::Actions {
}
# Add it.
- $*W.pkg_add_attribute($*PACKAGE, %*HOW{$*PKGDECL ~ '-attr'},
+ $*DECLARAND_ATTR := $*W.pkg_add_attribute($*PACKAGE, %*HOW{$*PKGDECL ~ '-attr'},
%lit_args, %obj_args);
$past := QAST::Stmts.new();
@@ -1179,6 +1180,12 @@ class NQP::Actions is HLL::Actions {
$*W.pkg_add_parrot_vtable_handler_mapping($package, $name, ~$match<variable>);
};
}
+ elsif $<longname> eq 'positional_delegate' {
+ $*DECLARAND_ATTR.positional_delegate(1);
+ }
+ elsif $<longname> eq 'associative_delegate' {
+ $*DECLARAND_ATTR.associative_delegate(1);
+ }
elsif $<longname> eq 'export' {
make -> $match {
my $ast := $match.ast;
View
@@ -409,6 +409,7 @@ class NQP::World is HLL::World {
method pkg_add_attribute($obj, $meta_attr, %lit_args, %obj_args) {
my $attr := $meta_attr.new(|%lit_args, |%obj_args);
$obj.HOW.add_attribute($obj, $attr);
+ $attr
}
# Adds a method to the meta-object.
View
@@ -5,6 +5,8 @@ knowhow NQPAttribute {
has $!box_target;
has $!default;
has $!has_default;
+ has $!positional_delegate;
+ has $!associative_delegate;
method new(:$name!, :$box_target, *%extra) {
my $attr := nqp::create(self);
@@ -46,6 +48,22 @@ knowhow NQPAttribute {
method auto_viv_container() {
$!has_default ?? $!default !! nqp::null()
}
+
+ method set_positional_delegate($value) {
+ $!positional_delegate := $value;
+ }
+
+ method set_associative_delegate($value) {
+ $!associative_delegate := $value;
+ }
+
+ method positional_delegate() {
+ !nqp::isnull($!positional_delegate) && $!positional_delegate ?? 1 !! 0
+ }
+
+ method associative_delegate() {
+ !nqp::isnull($!associative_delegate) && $!associative_delegate ?? 1 !! 0
+ }
method compose($obj) {
$obj
View
@@ -277,6 +277,12 @@ knowhow NQPClassHOW {
if nqp::can($attr, 'auto_viv_container') {
%attr_info<auto_viv_container> := $attr.auto_viv_container;
}
+ if $attr.positional_delegate {
+ %attr_info<positional_delegate> := 1;
+ }
+ if $attr.associative_delegate {
+ %attr_info<associative_delegate> := 1;
+ }
nqp::push(@attrs, %attr_info);
}

0 comments on commit 7133fa1

Please sign in to comment.