Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Sync class attributes comments between BOOTSTRAP and P6 modules for c…
…onvenience
  • Loading branch information
lizmat committed Sep 24, 2013
1 parent b78da4e commit 367963a
Show file tree
Hide file tree
Showing 20 changed files with 130 additions and 148 deletions.
177 changes: 72 additions & 105 deletions src/Perl6/Metamodel/BOOTSTRAP.nqp
Expand Up @@ -115,15 +115,13 @@ BEGIN {
# has str $!name;
# has int $!rw;
# has int $!has_accessor;
# has $!type;
# has $!container_descriptor;
# has $!auto_viv_container;
# has $!build_closure;
# has $!package;
# has Mu $!type;
# has Mu $!container_descriptor;
# has Mu $!auto_viv_container;
# has Mu $!build_closure;
# has Mu $!package;
# has int $!positional_delegate;
# has int $!associative_delegate;
# ... # Uncomposed
# }
Attribute.HOW.add_parent(Attribute, Any);
Attribute.HOW.add_attribute(Attribute, BOOTSTRAPATTR.new(:name<$!name>, :type(str), :package(Attribute)));
Attribute.HOW.add_attribute(Attribute, BOOTSTRAPATTR.new(:name<$!rw>, :type(int), :package(Attribute)));
Expand Down Expand Up @@ -274,10 +272,9 @@ BEGIN {
Attribute.HOW.compose_repr(Attribute);

# class Scalar is Any {
# has $!descriptor;
# has $!value;
# ...
# }
# has Mu $!descriptor;
# has Mu $!value;
# has Mu $!whence;
Scalar.HOW.add_parent(Scalar, Any);
Scalar.HOW.add_attribute(Scalar, BOOTSTRAPATTR.new(:name<$!descriptor>, :type(Mu), :package(Scalar)));
Scalar.HOW.add_attribute(Scalar, BOOTSTRAPATTR.new(:name<$!value>, :type(Mu), :package(Scalar)));
Expand All @@ -304,11 +301,8 @@ BEGIN {
nqp::setcontspec(Scalar, 'rakudo_scalar', nqp::null());

# class Proxy is Any {
# has &!FETCH;
# has &!STORE;
# method FETCH() { ... }
# method STORE(\$v) { ... }
# }
# has Mu &!FETCH;
# has Mu &!STORE;
my $PROXY_FETCH;
my $PROXY_STORE;
Proxy.HOW.add_parent(Proxy, Any);
Expand Down Expand Up @@ -349,13 +343,11 @@ BEGIN {
}

# class Signature is Any{
# has $!params;
# has $!returns;
# has $!arity;
# has $!count;
# has $!code;
# ... # Uncomposed
# }
# has Mu $!params;
# has Mu $!returns;
# has Mu $!arity;
# has Mu $!count;
# has Mu $!code;
Signature.HOW.add_parent(Signature, Any);
Signature.HOW.add_attribute(Signature, BOOTSTRAPATTR.new(:name<$!params>, :type(Mu), :package(Signature)));
Signature.HOW.add_attribute(Signature, BOOTSTRAPATTR.new(:name<$!returns>, :type(Mu), :package(Signature)));
Expand Down Expand Up @@ -407,19 +399,17 @@ BEGIN {

# class Parameter is Any {
# has str $!variable_name
# has $!named_names
# has $!type_captures
# has Mu $!named_names
# has Mu $!type_captures
# has int $!flags
# has $!nominal_type
# has $!post_constraints
# has $!coerce_type
# has Mu $!nominal_type
# has Mu $!post_constraints
# has Mu $!coerce_type
# has str $!coerce_method
# has $!sub_signature
# has $!default_value
# has $!container_descriptor;
# has $!attr_package;
# ... # Uncomposed
# }
# has Mu $!sub_signature
# has Mu $!default_value
# has Mu $!container_descriptor;
# has Mu $!attr_package;
Parameter.HOW.add_parent(Parameter, Any);
Parameter.HOW.add_attribute(Parameter, BOOTSTRAPATTR.new(:name<$!variable_name>, :type(str), :package(Parameter)));
Parameter.HOW.add_attribute(Parameter, BOOTSTRAPATTR.new(:name<$!named_names>, :type(Mu), :package(Parameter)));
Expand Down Expand Up @@ -519,11 +509,9 @@ BEGIN {
Parameter.HOW.compose_repr(Parameter);

# class Code {
# has $!do; # Low level code object
# has $!signature; # Signature object
# has $!compstuff; # Place for the compiler to hang stuff
# ... # Uncomposed
# }
# has Mu $!do; # Low level code object
# has Mu $!signature; # Signature object
# has Mu $!compstuff; # Place for the compiler to hang stuff
Code.HOW.add_parent(Code, Any);
Code.HOW.add_attribute(Code, BOOTSTRAPATTR.new(:name<$!do>, :type(Mu), :package(Code)));
Code.HOW.add_attribute(Code, BOOTSTRAPATTR.new(:name<$!signature>, :type(Mu), :package(Code)));
Expand Down Expand Up @@ -582,7 +570,8 @@ BEGIN {
Code.HOW.set_invocation_attr(Code, Code, '$!do');
Code.HOW.compose_invocation(Code);

# class Block is Code { ... }
# class Block is Code {
# has Mu $!phasers; # phasers for this block
Block.HOW.add_parent(Block, Code);
Block.HOW.add_attribute(Block, BOOTSTRAPATTR.new(:name<$!phasers>, :type(Mu), :package(Block)));
Block.HOW.add_method(Block, 'clone', nqp::getstaticcode(sub ($self) {
Expand All @@ -601,7 +590,17 @@ BEGIN {
Block.HOW.compose_repr(Block);
Block.HOW.compose_invocation(Block);

# class Routine is Block { ... }
# class Routine is Block {
# has Mu $!dispatchees;
# has Mu $!dispatcher_cache;
# has Mu $!dispatcher;
# has int $!rw;
# has Mu $!inline_info;
# has int $!yada;
# has Mu $!package;
# has int $!onlystar;
# has Mu $!dispatch_order;
# has Mu $!dispatch_cache;
Routine.HOW.add_parent(Routine, Block);
Routine.HOW.add_attribute(Routine, BOOTSTRAPATTR.new(:name<$!dispatchees>, :type(Mu), :package(Routine)));
Routine.HOW.add_attribute(Routine, BOOTSTRAPATTR.new(:name<$!dispatcher_cache>, :type(Mu), :package(Routine)));
Expand Down Expand Up @@ -677,11 +676,11 @@ BEGIN {
my int $SIG_ELEM_NATIVE_NUM_VALUE := 4194304;
my int $SIG_ELEM_NATIVE_STR_VALUE := 8388608;

# Takes two candidates and determines if the first one is narrower than the
# second. Returns a true value if they are.
# Takes two candidates and determines if the first one is narrower
# than the second. Returns a true value if they are.
sub is_narrower(%a, %b) {
# Work out how many parameters to compare, factoring in slurpiness
# and optionals.
# Work out how many parameters to compare, factoring in
# slurpiness and optionals.
my int $types_to_check;
if %a<num_types> == %b<num_types> {
$types_to_check := %a<num_types>;
Expand Down Expand Up @@ -871,8 +870,8 @@ BEGIN {
));
}

# Now analyze type narrowness of the candidates relative to each other
# and create the edges.
# Now analyze type narrowness of the candidates relative to each
# other and create the edges.
my int $i := 0;
my int $j;
my int $n := nqp::elems(@candidates);
Expand Down Expand Up @@ -1450,22 +1449,25 @@ BEGIN {
Routine.HOW.compose_repr(Routine);
Routine.HOW.compose_invocation(Routine);

# class Sub is Routine { ... }
# class Sub is Routine {
Sub.HOW.add_parent(Sub, Routine);
Sub.HOW.compose_repr(Sub);
Sub.HOW.compose_invocation(Sub);

# class Method is Routine { ... }
# class Method is Routine {
Method.HOW.add_parent(Method, Routine);
Method.HOW.compose_repr(Method);
Method.HOW.compose_invocation(Method);

# class Submethod is Routine { ... }
# class Submethod is Routine {
Submethod.HOW.add_parent(Submethod, Routine);
Submethod.HOW.compose_repr(Submethod);
Submethod.HOW.compose_invocation(Submethod);

# class Regex is Method { ... }
# class Regex is Method {
# has Mu $!caps;
# has Mu $!nfa;
# has Mu $!alt_nfas
Regex.HOW.add_parent(Regex, Method);
Regex.HOW.add_attribute(Regex, scalar_attr('$!caps', Mu, Regex));
Regex.HOW.add_attribute(Regex, scalar_attr('$!nfa', Mu, Regex));
Expand Down Expand Up @@ -1500,8 +1502,6 @@ BEGIN {

# class Str is Cool {
# has str $!value is box_target;
# ...
# }
Str.HOW.add_parent(Str, Cool);
Str.HOW.add_attribute(Str, BOOTSTRAPATTR.new(:name<$!value>, :type(str), :box_target(1), :package(Str)));
Str.HOW.set_boolification_mode(Str, 4);
Expand All @@ -1515,9 +1515,7 @@ BEGIN {
Str.HOW.compose_repr(Str);

# class Int is Cool {
# has int $!value is box_target;
# ...
# }
# has bigint $!value is box_target;
Int.HOW.add_parent(Int, Cool);
Int.HOW.add_attribute(Int, BOOTSTRAPATTR.new(:name<$!value>, :type(bigint), :box_target(1), :package(Int)));
Int.HOW.set_boolification_mode(Int, 6);
Expand All @@ -1526,46 +1524,35 @@ BEGIN {

# class Num is Cool {
# has num $!value is box_target;
# ...
# }
Num.HOW.add_parent(Num, Cool);
Num.HOW.add_attribute(Num, BOOTSTRAPATTR.new(:name<$!value>, :type(num), :box_target(1), :package(Num)));
Num.HOW.set_boolification_mode(Num, 2);
Num.HOW.publish_boolification_spec(Num);
Num.HOW.compose_repr(Num);

# class Parcel is Cool {
# ...
# }
# has Mu $!storage; # VM's array of Parcel's elements
Parcel.HOW.add_parent(Parcel, Cool);
Parcel.HOW.add_attribute(Parcel, scalar_attr('$!storage', Mu, Parcel));
Parcel.HOW.compose_repr(Parcel);

# class Iterable is Any {
# ...
# }
Iterable.HOW.add_parent(Iterable, Any);
Iterable.HOW.compose_repr(Iterable);

# class Iterator is Iterable {
# ...
# }
Iterator.HOW.add_parent(Iterator, Iterable);
Iterator.HOW.compose_repr(Iterator);

# class Nil is Iterator
# ...
# }
# class Nil is Iterator {
Nil.HOW.add_parent(Nil, Iterator);
Nil.HOW.compose_repr(Nil);

# class ListIter is Iterator {
# has $!reified;
# has $!nextiter;
# has $!rest;
# has $!list;
# ...
# }
# has Mu $!reified;
# has Mu $!nextiter;
# has Mu $!rest;
# has Mu $!list;
ListIter.HOW.add_parent(ListIter, Iterator);
ListIter.HOW.add_attribute(ListIter, scalar_attr('$!reified', Mu, ListIter));
ListIter.HOW.add_attribute(ListIter, scalar_attr('$!nextiter', Mu, ListIter));
Expand All @@ -1574,11 +1561,9 @@ BEGIN {
ListIter.HOW.compose_repr(ListIter);

# class List is Iterable is Cool {
# has $!items;
# has $!flattens;
# has $!nextiter;
# ...
# }
# has Mu $!items;
# has Mu $!flattens;
# has Mu $!nextiter;
List.HOW.add_parent(List, Iterable);
List.HOW.add_parent(List, Cool);
List.HOW.add_attribute(List, scalar_attr('$!items', Mu, List));
Expand All @@ -1587,62 +1572,48 @@ BEGIN {
List.HOW.compose_repr(List);

# class Array is List {
# has $!descriptor;
# ...
# }
# has Mu $!descriptor;
Array.HOW.add_parent(Array, List);
Array.HOW.add_attribute(Array, BOOTSTRAPATTR.new(:name<$!descriptor>, :type(Mu), :package(Array)));
Array.HOW.compose_repr(Array);

# class LoL is List {
# has $!descriptor;
# ...
# }
# has Mu $!descriptor;
LoL.HOW.add_parent(LoL, List);
LoL.HOW.add_attribute(LoL, BOOTSTRAPATTR.new(:name<$!descriptor>, :type(Mu), :package(LoL)));
LoL.HOW.compose_repr(LoL);

# my class EnumMap is Iterable is Cool {
# has $!storage;
# ...
# }
# has Mu $!storage;
EnumMap.HOW.add_parent(EnumMap, Iterable);
EnumMap.HOW.add_parent(EnumMap, Cool);
EnumMap.HOW.add_attribute(EnumMap, scalar_attr('$!storage', Mu, EnumMap, :associative_delegate));
EnumMap.HOW.compose_repr(EnumMap);

# my class Hash is EnumMap {
# has $!descriptor;
# ...
# }
# has Mu $!descriptor;
Hash.HOW.add_parent(Hash, EnumMap);
Hash.HOW.add_attribute(Hash, BOOTSTRAPATTR.new(:name<$!descriptor>, :type(Mu), :package(Hash)));
Hash.HOW.compose_repr(Hash);

# class Capture is Any {
# has $!list;
# has $!hash;
# ...
# }
# has Mu $!list;
# has Mu $!hash;
Capture.HOW.add_parent(Capture, Any);
Capture.HOW.add_attribute(Capture, BOOTSTRAPATTR.new(:name<$!list>, :type(Mu), :package(Capture)));
Capture.HOW.add_attribute(Capture, BOOTSTRAPATTR.new(:name<$!hash>, :type(Mu), :package(Capture)));
Capture.HOW.compose_repr(Capture);

# class Junction is Mu {
# has $!storage;
# has $!type;
# ...
# }
# has Mu $!storage;
# has Mu $!type;
Junction.HOW.add_parent(Junction, Mu);
Junction.HOW.add_attribute(Junction, scalar_attr('$!storage', Mu, Junction));
Junction.HOW.add_attribute(Junction, scalar_attr('$!type', Mu, Junction));
Junction.HOW.compose_repr(Junction);

# class Bool is Cool {
# has int $!value;
# ...
# }
Bool.HOW.add_parent(Bool, Cool);
Bool.HOW.add_attribute(Bool, BOOTSTRAPATTR.new(:name<$!value>, :type(int), :box_target(1), :package(Bool)));
Bool.HOW.set_boolification_mode(Bool, 1);
Expand All @@ -1651,15 +1622,12 @@ BEGIN {

# class ObjAt is Any {
# has str $!value;
# }
ObjAt.HOW.add_parent(ObjAt, Any);
ObjAt.HOW.add_attribute(ObjAt, BOOTSTRAPATTR.new(:name<$!value>, :type(str), :box_target(1), :package(ObjAt)));
ObjAt.HOW.compose_repr(ObjAt);

# class ForeignCode {
# has $!do; # Code object we delegate to
# ... # Uncomposed
# }
# has Mu $!do; # Code object we delegate to
ForeignCode.HOW.add_parent(ForeignCode, Any);
ForeignCode.HOW.add_attribute(ForeignCode, BOOTSTRAPATTR.new(:name<$!do>, :type(Mu), :package(ForeignCode)));
ForeignCode.HOW.compose_repr(ForeignCode);
Expand All @@ -1668,7 +1636,6 @@ BEGIN {

# Set up Stash type, which is really just a hash.
# class Stash is Hash {
# }
Stash.HOW.add_parent(Stash, Hash);
Stash.HOW.compose_repr(Stash);

Expand Down
2 changes: 1 addition & 1 deletion src/core/Array.pm
Expand Up @@ -2,7 +2,7 @@ my class X::Item { ... };

class Array { # declared in BOOTSTRAP
# class Array is List {
# has $!descriptor;
# has Mu $!descriptor;

method new(|) {
my Mu $args := nqp::p6argvmarray();
Expand Down

0 comments on commit 367963a

Please sign in to comment.