@@ -415,8 +415,16 @@ method package_def($/) {
415
415
# Get the body code.
416
416
my $ past := $ < block > ?? $ < block > . ast !! $ < comp_unit > . ast;
417
417
418
- # Prefix the class initialization with initial setup. Also install it
419
- # in the symbol table right away.
418
+ # Install it in the package or lexpad as needed.
419
+ if $ * SCOPE eq ' our' || $ * SCOPE eq ' ' {
420
+ $ past . namespace( $ < name >< identifier > );
421
+ $ * SC . install_package_symbol($ < name >< identifier > , $ * PKGMETA );
422
+ }
423
+ else {
424
+ $/ . CURSOR. panic(" $ * SCOPE scoped packages are not supported" );
425
+ }
426
+
427
+ # Prefix the class initialization with initial setup.
420
428
$ * PACKAGE-SETUP . unshift (PAST::Stmts. new (
421
429
PAST::Op. new ( : pasttype(' bind' ),
422
430
PAST::Var. new ( : name(' type_obj' ), : scope(' register' ), : isdecl(1 ) ),
@@ -427,18 +435,6 @@ method package_def($/) {
427
435
PAST::Var. new ( : name(' type_obj' ), : scope(' register' ) )
428
436
)
429
437
));
430
-
431
- # Install it in the package or lexpad as needed.
432
- if $ * SCOPE eq ' our' || $ * SCOPE eq ' ' {
433
- $ past . namespace( $ < name >< identifier > );
434
- $ * PACKAGE-SETUP [0 ]. push (PAST::Op. new ( : pasttype(' bind' ),
435
- PAST::Var. new ( : name($ name ), : namespace(@ ns ), : scope(' package' ) ),
436
- PAST::Var. new ( : name(' type_obj' ), : scope(' register' ) )
437
- ));
438
- }
439
- else {
440
- $/ . CURSOR. panic(" $ * SCOPE scoped packages are not supported" );
441
- }
442
438
443
439
# Evaluate everything in the package in-line unless this is a generic
444
440
# type in which case it needs delayed evaluation. Normally, $?CLASS is
@@ -523,9 +519,6 @@ method package_def($/) {
523
519
),
524
520
PAST::Var. new ( : name(' type_obj' ), : scope(' register' ) )
525
521
));
526
-
527
- # Set up slot for the type object to live in.
528
- @ BLOCK [0 ][0 ]. unshift (PAST::Var. new ( : name($ name ), : namespace(@ ns ), : scope(' package' ), : isdecl(1 ) ));
529
522
530
523
# Attach the class code to run at loadinit time.
531
524
$ past . loadinit. push (PAST::Block. new ( : blocktype(' immediate' ), $ * PACKAGE-SETUP ));
0 commit comments