Skip to content

Commit bfadf52

Browse files
committed
Switch to using the new signature objects.
1 parent 78fb2c3 commit bfadf52

File tree

2 files changed

+59
-22
lines changed

2 files changed

+59
-22
lines changed

src/NQP/Actions.pm

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ class NQP::Actions is HLL::Actions {
506506
method package_declarator:sym<stub>($/) {
507507
# Construct meta-object with specified metaclass, adding it to the
508508
# serialization context for this compilation unit.
509-
my $HOW := $*W.find_sym($<metaclass><identifier>, $/);
509+
my $HOW := $*W.find_sym($<metaclass><identifier>);
510510
my $PACKAGE := $*W.pkg_create_mo($HOW, :name(~$<name>));
511511

512512
# Install it in the current package or current lexpad as needed.
@@ -565,7 +565,7 @@ class NQP::Actions is HLL::Actions {
565565
my $parent;
566566
my $parent_found;
567567
try {
568-
$parent := $*W.find_sym(pir::clone__PP($<parent>[0]<identifier>), $/);
568+
$parent := $*W.find_sym(pir::clone__PP($<parent>[0]<identifier>));
569569
$parent_found := 1;
570570
}
571571
if $parent_found {
@@ -578,7 +578,7 @@ class NQP::Actions is HLL::Actions {
578578
elsif pir::can($how, 'set_default_parent') {
579579
my $default := $*PKGDECL eq 'grammar' ?? ['Regex', 'Cursor'] !! ['NQPMu'];
580580
$*W.pkg_add_parent_or_role($*PACKAGE, "set_default_parent",
581-
$*W.find_sym($default, $/));
581+
$*W.find_sym($default));
582582
}
583583

584584
# Add any done roles.
@@ -587,7 +587,7 @@ class NQP::Actions is HLL::Actions {
587587
my $role;
588588
my $role_found;
589589
try {
590-
$role := $*W.find_sym(pir::clone__PP($_<identifier>), $/);
590+
$role := $*W.find_sym(pir::clone__PP($_<identifier>));
591591
$role_found := 1;
592592
}
593593
if $role_found {
@@ -645,7 +645,7 @@ class NQP::Actions is HLL::Actions {
645645
my %obj_args;
646646
%lit_args<name> := $name;
647647
if $<typename> {
648-
%obj_args<type> := $*W.find_sym([~$<typename>[0]], $/);
648+
%obj_args<type> := $*W.find_sym([~$<typename>[0]]);
649649
}
650650

651651
# Add it.
@@ -885,11 +885,11 @@ class NQP::Actions is HLL::Actions {
885885
# Use set_sub_multisig op to set up a multi sig. Note that we stick
886886
# it in the same slot Parrot multis use for their multi signature,
887887
# this is just a bit more complex than what Parrot needs.
888-
my $types := PAST::Op.new( :pasttype('list') );
889-
my $definednesses := PAST::Op.new( :pasttype('list') );
888+
my $types := nqp::list();
889+
my $definednesses := nqp::list();
890890
for @($routine[0]) {
891891
if $_ ~~ PAST::Var && $_.scope eq 'parameter' {
892-
$types.push($_.multitype // PAST::Op.new( :pirop('null P') ));
892+
$types.push($_.multitype ?? ($_.multitype())<compile_time_value> !! nqp::null() );
893893
$definednesses.push($_<definedness> eq 'D' ?? 1 !!
894894
$_<definedness> eq 'U' ?? 2 !! 0);
895895
}
@@ -977,7 +977,7 @@ class NQP::Actions is HLL::Actions {
977977
my @name := HLL::Compiler.parse_name(~$/);
978978
my $found := 0;
979979
try {
980-
my $sym := $*W.find_sym(@name, $/);
980+
my $sym := $*W.find_sym(@name);
981981
make $*W.get_ref($sym);
982982
$found := 1;
983983
}

src/NQP/World.pm

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -371,19 +371,56 @@ class NQP::World is HLL::World {
371371

372372
# Associates a signature with a routine.
373373
method set_routine_signature($routine, $types, $definednesses) {
374-
# Fixup code depends on if we have the routine in the SC for
375-
# fixing up. Deserialization always goes on the blockref.
376-
my $fixup := PAST::Op.new( :pirop('set_sub_multisig vPPP'), $types, $definednesses );
377-
if pir::defined($routine<compile_time_dummy>) {
378-
$fixup.unshift(self.get_slot_past_for_object($routine<compile_time_dummy>));
374+
# Build signature object and put it in place now.
375+
my $sig_type := self.find_sym(['NQPSignature']);
376+
my $sig_obj := nqp::create($sig_type);
377+
nqp::bindattr($sig_obj, $sig_type, '$!types', $types);
378+
nqp::bindattr($sig_obj, $sig_type, '$!definednesses', $definednesses);
379+
my $slot := self.add_object($sig_obj);
380+
381+
if self.is_precompilation_mode() {
382+
unless $NEW_SER {
383+
my $types_past := PAST::Op.new( :pasttype('list') );
384+
my $definednesses_past := PAST::Op.new( :pasttype('list') );
385+
for $types {
386+
$types_past.push(pir::isa($_, 'Undef') ?? $_ !! self.get_ref($_));
387+
}
388+
for $definednesses {
389+
$definednesses_past.push($_);
390+
}
391+
self.add_fixup_task(:deserialize_past(PAST::Stmts.new(
392+
self.add_object_to_cur_sc_past($slot,
393+
PAST::Op.new( :pirop('repr_instance_of__PP'), self.get_ref($sig_type) )),
394+
PAST::Op.new( :pirop('setattribute__vPPsP'),
395+
self.get_ref($sig_obj),
396+
self.get_ref($sig_type),
397+
'$!types',
398+
$types_past),
399+
PAST::Op.new( :pirop('setattribute__vPPsP'),
400+
self.get_ref($sig_obj),
401+
self.get_ref($sig_type),
402+
'$!definednesses',
403+
$definednesses_past)
404+
)));
405+
}
406+
self.add_fixup_task(:deserialize_past(PAST::Op.new(
407+
:pirop('set_sub_multisig vPP'),
408+
PAST::Val.new( :value($routine) ),
409+
self.get_ref($sig_obj)
410+
)));
379411
}
380412
else {
381-
$fixup.unshift(PAST::Val.new( :value($routine) ));
413+
# Fixup code depends on if we have the routine in the SC for
414+
# fixing up.
415+
my $fixup := PAST::Op.new( :pirop('set_sub_multisig vPP'), self.get_ref($sig_obj) );
416+
if pir::defined($routine<compile_time_dummy>) {
417+
$fixup.unshift(self.get_slot_past_for_object($routine<compile_time_dummy>));
418+
}
419+
else {
420+
$fixup.unshift(PAST::Val.new( :value($routine) ));
421+
}
422+
self.add_fixup_task(:fixup_past($fixup));
382423
}
383-
my $des := PAST::Op.new( :pirop('set_sub_multisig vPPP'),
384-
PAST::Val.new( :value($routine) ), $types, $definednesses
385-
);
386-
self.add_fixup_task(:deserialize_past($des), :fixup_past($fixup));
387424
}
388425

389426
# This handles associating the role body with a role declaration.
@@ -575,7 +612,7 @@ class NQP::World is HLL::World {
575612
method known_sym($/, @name) {
576613
my $known := 0;
577614
try {
578-
self.find_sym(@name, $/);
615+
self.find_sym(@name);
579616
$known := 1;
580617
}
581618
$known
@@ -584,9 +621,9 @@ class NQP::World is HLL::World {
584621
# Finds a symbol that has a known value at compile time from the
585622
# perspective of the current scope. Checks for lexicals, then if
586623
# that fails tries package lookup.
587-
method find_sym(@name, $/) {
624+
method find_sym(@name) {
588625
# Make sure it's not an empty name.
589-
unless +@name { $/.CURSOR.panic("Cannot look up empty name"); }
626+
unless +@name { pir::die("Cannot look up empty name"); }
590627

591628
# If it's a single-part name, look through the lexical
592629
# scopes.

0 commit comments

Comments
 (0)