Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Some str constraint/coercion on paths to .symbol.
For an upcoming NQP patch to add a `str` type constraint to it.
  • Loading branch information
jnthn committed Mar 9, 2016
1 parent e1071b0 commit 3ac34a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Perl6/Actions.nqp
Expand Up @@ -1820,7 +1820,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
my $*SCOPE := 'my';

while !((my $arg := $p6_argiter.pull-one) =:= $IterationEnd) {
my $symbol := nqp::unbox_s($arg.Str());
my str $symbol := nqp::unbox_s($arg.Str());
$*W.throw($/, ['X', 'Redeclaration'], :$symbol)
if $lexpad.symbol($symbol);
declare_variable($/, $past,
Expand Down
23 changes: 12 additions & 11 deletions src/Perl6/World.nqp
Expand Up @@ -456,7 +456,7 @@ class Perl6::World is HLL::World {

# Finds the nearest signatured block and checks if it declares
# a certain symbol.
method nearest_signatured_block_declares($symbol) {
method nearest_signatured_block_declares(str $symbol) {
my $i := +@!BLOCKS;
while $i > 0 {
$i := $i - 1;
Expand Down Expand Up @@ -1178,7 +1178,7 @@ class Perl6::World is HLL::World {
# the object to install. Does an immediate installation in the
# compile-time block symbol table, and ensures that the installation
# gets fixed up at runtime too.
method install_lexical_symbol($block, $name, $obj, :$clone) {
method install_lexical_symbol($block, str $name, $obj, :$clone) {
# Install the object directly as a block symbol.
if nqp::isnull(nqp::getobjsc($obj)) {
self.add_object($obj);
Expand Down Expand Up @@ -1215,7 +1215,7 @@ class Perl6::World is HLL::World {

# Installs a lexical symbol. Takes a QAST::Block object, name and
# the type of container to install.
method install_lexical_container($block, $name, %cont_info, $descriptor, :$scope, :$package) {
method install_lexical_container($block, str $name, %cont_info, $descriptor, :$scope, :$package) {
# Add to block, if needed. Note that it doesn't really have
# a compile time value.
my $var;
Expand Down Expand Up @@ -1522,7 +1522,7 @@ class Perl6::World is HLL::World {
}

# Hunts through scopes to find the type of a lexical.
method find_lexical_container_type($name) {
method find_lexical_container_type(str $name) {
my int $i := +@!BLOCKS;
while $i > 0 {
$i := $i - 1;
Expand All @@ -1541,7 +1541,7 @@ class Perl6::World is HLL::World {

# Hunts through scopes to find a lexical and returns if it is
# known to be read-only.
method is_lexical_marked_ro($name) {
method is_lexical_marked_ro(str $name) {
my int $i := +@!BLOCKS;
while $i > 0 {
$i := $i - 1;
Expand Down Expand Up @@ -3533,7 +3533,7 @@ class Perl6::World is HLL::World {
# If it's a single-part name, look through the lexical
# scopes.
if +@name == 1 {
my $final_name := @name[0];
my str $final_name := ~@name[0];
if $*WANTEDOUTERBLOCK {
my $scope := $*WANTEDOUTERBLOCK;
while $scope {
Expand Down Expand Up @@ -3561,7 +3561,7 @@ class Perl6::World is HLL::World {
# in GLOBALish.
my $result := $*GLOBALish;
if +@name >= 2 {
my $first := @name[0];
my str $first := ~@name[0];
my int $i := $start_scope;
while $i > 0 {
$i := $i - 1;
Expand Down Expand Up @@ -3627,11 +3627,12 @@ class Perl6::World is HLL::World {
# block stack.
if +@name == 1 && !$package_only {
my int $i := +@!BLOCKS;
my str $first_name := ~@name[0];
while $i > 0 {
$i := $i - 1;
my %sym := @!BLOCKS[$i].symbol(@name[0]);
my %sym := @!BLOCKS[$i].symbol($first_name);
if +%sym {
return QAST::Var.new( :name(@name[0]), :scope(%sym<scope>) );
return QAST::Var.new( :name($first_name), :scope(%sym<scope>) );
}
}
}
Expand Down Expand Up @@ -3685,7 +3686,7 @@ class Perl6::World is HLL::World {

# Checks if the given name is known anywhere in the lexpad
# and with lexical scope.
method is_lexical($name) {
method is_lexical(str $name) {
my int $i := +@!BLOCKS;
while $i > 0 {
$i := $i - 1;
Expand Down Expand Up @@ -3756,7 +3757,7 @@ class Perl6::World is HLL::World {


# Checks if the symbol is really an alias to an attribute.
method is_attr_alias($name) {
method is_attr_alias(str $name) {
my int $i := +@!BLOCKS;
while $i > 0 {
$i := $i - 1;
Expand Down

0 comments on commit 3ac34a4

Please sign in to comment.