Skip to content

Commit 4acf857

Browse files
committed
Merge branch 'master' into release-2018.10
2 parents 8476ecb + 67dc472 commit 4acf857

18 files changed

+117
-42
lines changed

src/NQP/Actions.nqp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,9 @@ class NQP::Actions is HLL::Actions {
12681268
$*W.create_code($ast.ann('block_ast'), $name, 0);
12691269
};
12701270
}
1271+
elsif $<longname> eq 'box_target' {
1272+
make -> $m { $*DECLARAND_ATTR.set_box_target(1) };
1273+
}
12711274
else {
12721275
$/.panic("Trait '$<longname>' not implemented");
12731276
}

src/NQP/Grammar.nqp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ grammar NQP::Grammar is HLL::Grammar {
412412
<.newpad>
413413
[ <?{ $*PKGDECL eq 'role' }> '[' ~ ']' <role_params> ]?
414414
[ 'is' 'repr(' <repr=.quote_EXPR> ')' ]?
415+
[ 'is' 'array_type(' <array_type=.typename> ')' ]?
415416

416417
{
417418
# Construct meta-object for this package, adding it to the
@@ -421,6 +422,10 @@ grammar NQP::Grammar is HLL::Grammar {
421422
if $<repr> {
422423
%args<repr> := ~$<repr><quote_delimited><quote_atom>[0];
423424
}
425+
%args<array_type> := NQPMu;
426+
if $<array_type> {
427+
%args<array_type> := $*W.find_sym([~$<array_type><name>]);
428+
}
424429
my $how := self.how($*PKGDECL);
425430
my $INNER := $*W.cur_lexpad();
426431
my $package := $*W.pkg_create_mo($how, |%args);

src/NQP/World.nqp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,12 +369,13 @@ class NQP::World is HLL::World {
369369

370370
# Creates a meta-object for a package, adds it to the root objects and
371371
# stores an event for the action. Returns the created object.
372-
method pkg_create_mo($how, :$name, :$repr) {
372+
method pkg_create_mo($how, :$name, :$repr, :$array_type) {
373373
# Create the meta-object and add to root objects.
374374
my %args;
375375
if nqp::defined($name) { %args<name> := $name; }
376376
if nqp::defined($repr) { %args<repr> := $repr; }
377377
my $mo := $how.new_type(|%args);
378+
if !($array_type =:= NQPMu) { $mo.HOW.set_array_type($mo, $array_type) }
378379
self.add_object($mo);
379380

380381
# Result is just the object.

src/how/NQPAttribute.nqp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ knowhow NQPAttribute {
4949
$!has_default ?? $!default !! nqp::null()
5050
}
5151

52+
method set_box_target($box_target) {
53+
$!box_target := $box_target;
54+
}
55+
5256
method set_positional_delegate($value) {
5357
$!positional_delegate := $value;
5458
}

src/how/NQPClassHOW.nqp

Lines changed: 67 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ knowhow NQPClassHOW {
1919
has @!roles;
2020
has $!default_parent;
2121

22+
# Array type support.
23+
has $!is_array_type;
24+
has $!array_type;
25+
2226
# Have we been composed?
2327
has $!composed;
2428

@@ -79,7 +83,7 @@ knowhow NQPClassHOW {
7983

8084
# Create a new meta-class instance, and then a new type object
8185
# to go with it, and return that.
82-
method new_type(:$name = '<anon>', :$repr = 'P6opaque') {
86+
method new_type(:$name = '<anon>', :$repr = 'P6opaque', :$array_type) {
8387
my $metaclass := self.new(:name($name));
8488
nqp::setdebugtypename(
8589
nqp::setwho(nqp::newtype($metaclass, $repr), {}),
@@ -122,6 +126,19 @@ knowhow NQPClassHOW {
122126
nqp::push(@!attributes, $meta_attr);
123127
}
124128

129+
method is_array_type($obj) {
130+
$!is_array_type
131+
}
132+
133+
method array_type($obj) {
134+
$!array_type
135+
}
136+
137+
method set_array_type($obj, $type) {
138+
$!is_array_type := 1;
139+
$!array_type := $type;
140+
}
141+
125142
method add_parent($obj, $parent) {
126143
if $!composed {
127144
nqp::die("NQPClassHOW does not support adding parents after being composed.");
@@ -225,49 +242,59 @@ knowhow NQPClassHOW {
225242
}
226243

227244
method compose_repr($obj) {
228-
# Use any attribute information to produce attribute protocol
229-
# data. The protocol consists of an array...
230-
my @repr_info;
231-
232-
# ...which contains an array per MRO entry...
233-
for @!mro -> $type_obj {
234-
my @type_info;
235-
nqp::push(@repr_info, @type_info);
236-
237-
# ...which in turn contains the current type in the MRO...
238-
nqp::push(@type_info, $type_obj);
239-
240-
# ...then an array of hashes per attribute...
241-
my @attrs;
242-
nqp::push(@type_info, @attrs);
243-
for $type_obj.HOW.attributes($type_obj, :local) -> $attr {
244-
my %attr_info;
245-
%attr_info<name> := $attr.name;
246-
%attr_info<type> := $attr.type;
247-
if $attr.box_target {
248-
# Merely having the key serves as a "yes".
249-
%attr_info<box_target> := 1;
250-
}
251-
if nqp::can($attr, 'auto_viv_container') {
252-
%attr_info<auto_viv_container> := $attr.auto_viv_container;
253-
}
254-
if $attr.positional_delegate {
255-
%attr_info<positional_delegate> := 1;
256-
}
257-
if $attr.associative_delegate {
258-
%attr_info<associative_delegate> := 1;
245+
if self.is_array_type($obj) {
246+
if self.attributes($obj) {
247+
nqp::die("Cannot have attributes on an array representation");
248+
}
249+
nqp::composetype(nqp::decont($obj), nqp::hash('array',
250+
nqp::hash('type', nqp::decont(self.array_type($obj)))));
251+
}
252+
253+
else {
254+
# Use any attribute information to produce attribute protocol
255+
# data. The protocol consists of an array...
256+
my @repr_info;
257+
258+
# ...which contains an array per MRO entry...
259+
for @!mro -> $type_obj {
260+
my @type_info;
261+
nqp::push(@repr_info, @type_info);
262+
263+
# ...which in turn contains the current type in the MRO...
264+
nqp::push(@type_info, $type_obj);
265+
266+
# ...then an array of hashes per attribute...
267+
my @attrs;
268+
nqp::push(@type_info, @attrs);
269+
for $type_obj.HOW.attributes($type_obj, :local) -> $attr {
270+
my %attr_info;
271+
%attr_info<name> := $attr.name;
272+
%attr_info<type> := $attr.type;
273+
if $attr.box_target {
274+
# Merely having the key serves as a "yes".
275+
%attr_info<box_target> := 1;
276+
}
277+
if nqp::can($attr, 'auto_viv_container') {
278+
%attr_info<auto_viv_container> := $attr.auto_viv_container;
279+
}
280+
if $attr.positional_delegate {
281+
%attr_info<positional_delegate> := 1;
282+
}
283+
if $attr.associative_delegate {
284+
%attr_info<associative_delegate> := 1;
285+
}
286+
nqp::push(@attrs, %attr_info);
259287
}
260-
nqp::push(@attrs, %attr_info);
288+
289+
# ...followed by a list of immediate parents.
290+
nqp::push(@type_info, $type_obj.HOW.parents($type_obj, :local));
261291
}
262292

263-
# ...followed by a list of immediate parents.
264-
nqp::push(@type_info, $type_obj.HOW.parents($type_obj, :local));
293+
# Compose the representation using it.
294+
my $info := nqp::hash();
295+
$info<attribute> := @repr_info;
296+
nqp::composetype($obj, $info)
265297
}
266-
267-
# Compose the representation using it.
268-
my $info := nqp::hash();
269-
$info<attribute> := @repr_info;
270-
nqp::composetype($obj, $info)
271298
}
272299

273300
method incorporate_multi_candidates($obj) {

src/vm/moar/QAST/QASTOperationsMAST.nqp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,6 +2069,32 @@ my %const_map := nqp::hash(
20692069
'RUSAGE_NSIGNALS', 15,
20702070
'RUSAGE_NVCSW', 16,
20712071
'RUSAGE_NIVCSW', 17,
2072+
2073+
'MVM_OPERAND_LITERAL', 0,
2074+
'MVM_OPERAND_READ_REG', 1,
2075+
'MVM_OPERAND_WRITE_REG', 2,
2076+
'MVM_OPERAND_READ_LEX', 3,
2077+
'MVM_OPERAND_WRITE_LEX', 4,
2078+
'MVM_OPERAND_RW_MASK', 7,
2079+
2080+
'MVM_OPERAND_INT8', 8,
2081+
'MVM_OPERAND_INT16', 16,
2082+
'MVM_OPERAND_INT32', 24,
2083+
'MVM_OPERAND_INT64', 32,
2084+
'MVM_OPERAND_NUM32', 40,
2085+
'MVM_OPERAND_NUM64', 48,
2086+
'MVM_OPERAND_STR', 56,
2087+
'MVM_OPERAND_OBJ', 64,
2088+
'MVM_OPERAND_INS', 72,
2089+
'MVM_OPERAND_TYPE_VAR', 80,
2090+
'MVM_OPERAND_LEX_OUTER', 88,
2091+
'MVM_OPERAND_CODEREF', 96,
2092+
'MVM_OPERAND_CALLSITE', 104,
2093+
'MVM_OPERAND_TYPE_MASK', 248,
2094+
'MVM_OPERAND_UINT8', 136,
2095+
'MVM_OPERAND_UINT16', 144,
2096+
'MVM_OPERAND_UINT32', 152,
2097+
'MVM_OPERAND_UINT64', 160,
20722098
);
20732099
QAST::MASTOperations.add_core_op('const', -> $qastcomp, $op {
20742100
if nqp::existskey(%const_map, $op.name) {
@@ -2291,6 +2317,7 @@ QAST::MASTOperations.add_core_moarop_mapping('indexicim', 'indexicim_s');
22912317
QAST::MASTOperations.add_core_moarop_mapping('rindexfrom', 'rindexfrom');
22922318
QAST::MASTOperations.add_core_moarop_mapping('substr_s', 'substr_s');
22932319
QAST::MASTOperations.add_core_moarop_mapping('codepointfromname', 'getcpbyname');
2320+
QAST::MASTOperations.add_core_moarop_mapping('getcp_s', 'getcp_s');
22942321
QAST::MASTOperations.add_core_moarop_mapping('encode', 'encode');
22952322
QAST::MASTOperations.add_core_moarop_mapping('encodeconf', 'encodeconf');
22962323
QAST::MASTOperations.add_core_moarop_mapping('encoderep', 'encoderep');
@@ -2500,6 +2527,12 @@ QAST::MASTOperations.add_core_moarop_mapping('bindposnd', 'bindposnd_o', 2);
25002527
QAST::MASTOperations.add_core_moarop_mapping('bindposnd_i', 'bindposnd_i', 2);
25012528
QAST::MASTOperations.add_core_moarop_mapping('bindposnd_n', 'bindposnd_n', 2);
25022529
QAST::MASTOperations.add_core_moarop_mapping('bindposnd_s', 'bindposnd_s', 2);
2530+
QAST::MASTOperations.add_core_moarop_mapping('writeint', 'writeint');
2531+
QAST::MASTOperations.add_core_moarop_mapping('writeuint', 'writeuint');
2532+
QAST::MASTOperations.add_core_moarop_mapping('writenum', 'writenum');
2533+
QAST::MASTOperations.add_core_moarop_mapping('readint', 'readint');
2534+
QAST::MASTOperations.add_core_moarop_mapping('readuint', 'readuint');
2535+
QAST::MASTOperations.add_core_moarop_mapping('readnum', 'readnum');
25032536
QAST::MASTOperations.add_core_moarop_mapping('bindkey', 'bindkey_o', 2);
25042537
QAST::MASTOperations.add_core_moarop_mapping('bindkey_i', 'bindkey_i', 2);
25052538
QAST::MASTOperations.add_core_moarop_mapping('bindkey_n', 'bindkey_n', 2);
@@ -2876,6 +2909,7 @@ QAST::MASTOperations.add_core_moarop_mapping('bindcurhllsym', 'bindcurhllsym');
28762909
QAST::MASTOperations.add_core_moarop_mapping('sethllconfig', 'sethllconfig');
28772910
QAST::MASTOperations.add_core_moarop_mapping('loadbytecode', 'loadbytecode');
28782911
QAST::MASTOperations.add_core_moarop_mapping('loadbytecodebuffer', 'loadbytecodebuffer');
2912+
QAST::MASTOperations.add_core_moarop_mapping('buffertocu', 'buffertocu');
28792913
QAST::MASTOperations.add_core_moarop_mapping('loadbytecodefh', 'loadbytecodefh');
28802914
QAST::MASTOperations.add_core_moarop_mapping('settypehll', 'settypehll', 0);
28812915
QAST::MASTOperations.add_core_moarop_mapping('settypehllrole', 'settypehllrole', 0);
@@ -3068,6 +3102,7 @@ QAST::MASTOperations.add_core_op('speshresolve', -> $qastcomp, $op {
30683102

30693103
QAST::MASTOperations.add_core_moarop_mapping('hllbool', 'hllbool');
30703104
QAST::MASTOperations.add_core_moarop_mapping('hllboolfor', 'hllboolfor');
3105+
QAST::MASTOperations.add_core_moarop_mapping('serializetobuf', 'serializetobuf');
30713106
QAST::MASTOperations.add_core_moarop_mapping('decodelocaltime', 'decodelocaltime');
30723107
QAST::MASTOperations.add_core_moarop_mapping('fork', 'fork');
30733108

src/vm/moar/stage0/MASTNodes.moarvm

11.5 KB
Binary file not shown.

src/vm/moar/stage0/MASTOps.moarvm

19.1 KB
Binary file not shown.
360 Bytes
Binary file not shown.
6.83 KB
Binary file not shown.

0 commit comments

Comments
 (0)